|
Doncal wrote: Thanks a lot Sascha, That works. You're welcome!
Doncal wrote: I'll keep your suggestions in mind when I start knowing what Im doing. ;o) Hehe, alright
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Good answer, Sascha, both your and Pete's answers got my vote.Sascha Lefévre wrote: but instead as an interface that only allows reading (e.g. IEnumerable or ReadOnlyCollection) and have the allowed manipulations as methods of ClsContacts. I'd be curious to see how you implement that: read-only from an interface. Saying this, I am aware I may not fully understand what you mean by this.
thanks, Bill
«To kill an error's as good a service, sometimes better than, establishing new truth or fact.» Charles Darwin in "Prospero's Precepts"
|
|
|
|
|
Thank you, Bill!
Probably I just managed to express my idea in an obfuscated way
This is what I meant:
class ListEncapsulation
{
public ReadOnlyCollection<int> Example1 { get { return EncapsulatedList.AsReadOnly(); } }
public IEnumerable<int> Example2 { get { return EncapsulatedList.AsReadOnly(); } }
public IReadOnlyList<int> Example3 { get { return EncapsulatedList.AsReadOnly(); } }
private List<int> EncapsulatedList = new List<int>();
}
This answer on Stackoverflow shows the idea in some more detail:
http://stackoverflow.com/a/7445676/4320056[^]
And a short article on the readonly-collection-interfaces new in .NET 4.5:
http://visualstudiomagazine.com/articles/2012/08/07/new-read-only-collection-interfaces-for-net.aspx[^]
cheers, Sascha
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
I have just uploaded a windows remote decktop client server application but it needs a client program to be instaled to work and is basicly a program that does a screen grab on the server and it then sends the image across the network to the client. These images are big and slow to send.
Well call me stupid but i think it could all be done in HTML so that it works in any browser and it should not be too hard to do if anyone wants to give me a hand.
Pulling the current desctop background image from windows is easy and looking in the destop folder to pull the shortcut text and then pulling the icon images should be easy too.
The start menu again is just text and icons that could be sent back as a upside down menu in HTML.
OK the task bar might need a bit more thinking about but if the worse comes to the worse then a long sideways image and a javascript polling timer would just about fit the bill.
floating divs with z-index's would do for application windows and could use a bit of JSON to keep an eye on the X,Y positions.
This just leaves the active window to deal with which would need to be sent back over the wire every second but since we know the scaled size of the window then sending it as a smaller .png and resizing it back by streching it to full size or better still doing something with a HTML5 Canvus.
It's all just text and images so does anyone want to get involved and work as a team on this one ?
|
|
|
|
|
I use below code to create chart in Excel with C#:
Excel._Workbook oWB;
Excel.Range oRange;
Excel._Chart oChart;
oWB = (Excel._Workbook)oWS.Parent;
oChart = (Excel._Chart)oWB.Charts.Add(Missing.Value, Missing.Value,
Missing.Value, Missing.Value);
oChart.HasTitle = true;
oChart.ChartTitle.Text = "IDcsacsa\t" + "TIMEfsafafas\t" + "FASvsdvfsd";
oRange = oWS.get_Range("B2", "B6");
oChart.SetSourceData(oRange, Missing.Value);
oChart.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlLine;
this code is working but there is a problem.
with this line:
oRange = oWS.get_Range("B2", "C6");
I specify the columns that must create chart from its date.
for example in above code we create chart of B2 to B6 and C2 to C6 and working well.
but now in excel worksheet I have data in 3 columns B,C and D.
so I want design Chart only from B and D columns and I don't want design chart from C columns.
so how I use get_Reang?
|
|
|
|
|
oRange = oWS.get_Range("B2:B6,D2:D6")
Should do the trick.
Replace the numbers with the ones you need.
See here for more info.[^]
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Mathematics is not my strong point!
I'm coding against a protocol (OSC) that connects to an external device that takes a float between 0.0 and 1.0 to represent a frequency between 20Hz and 400Hz. The frequency scale is an inverse log curve so for example 0.5 represents approximately 89Hz.
How on earth do I convert from the float to the frequency - and back again too?
|
|
|
|
|
Though math is also not my strong point, I would like to give it a shot.. Can you give two more "sample points" ?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Sure...
.25 = approx. 42Hz and .75 = approx. 189Hz
I've found a little more information. The displayed values on the end device are arranged into 101 steps so the mid value is actually 0.49 which displays 87Hz (this will be rounded though)
|
|
|
|
|
Are you sure that your given values (for .25, .5, .75) take into account that the range starts at 20Hz ? Because they all seem to be off by roughly 20 Hz here:
x a b f tgt xrev
-----------------------------------
0,00 10,00 1,00 20,0 20 0,00
0,25 7,75 0,89 62,1 42 0,25
0,50 5,50 0,74 118,7 89 0,50
0,75 3,25 0,51 205,5 189 0,75
1,00 1,00 0,00 400,0 400 1,00
x : input
a = 10 - x * 9
b = log(a)
f = 400 - b * 380
tgt : target
xrev = (10-10^((400-f)/380))/9
But maybe I'm missing something.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
modified 17-Apr-15 20:03pm.
|
|
|
|
|
I've double checked the displayed results for those values and they are correct.
All the spec says is:
logf [20.000, 400.000, 101] Hz
which means: log float with a range of 20-400Hz, 101 valid steps
|
|
|
|
|
I'll give it another thought tomorrow. Maybe someone who's more talented in math will solve it in the meantime
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Thanks for your help Sascha - I've got a solution, see my response to Kenneth below
|
|
|
|
|
DaveyM69 wrote: Thanks for your help Sascha Let's call it an attempt
Good to see you got a solution - I'll take a look at it myself, might come in handy some time.
cheers, Sascha
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Frame the problem as a puzzle and drop it into the Lounge, I've seen a number of them get some detailed responses as long as they don't consider it a coding question you might get away with it
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Ha ha! I don't think I'd be that brave
Nearly there now thanks to Kenneth's find.
|
|
|
|
|
|
Brilliant find Kenneth!
I have tweaked the C# method on that page to:
float[] logValues = CreateLogValues(20, 400, 101);
public static float[] CreateLogValues(float minimum, float maximum, int valuesCount)
{
double logarithmicBase = Math.E;
double logMinimum = Math.Log(minimum);
double logMaximum = Math.Log(maximum);
double delta = (logMaximum - logMinimum) / (valuesCount - 1);
double accumulatedDelta = 0;
float[] values = new float[valuesCount];
for (int i = 0; i < valuesCount; ++i)
{
values[i] = (float)Math.Pow(logarithmicBase, logMinimum + accumulatedDelta);
accumulatedDelta += delta;
}
return values;
}
which is a good start. I should be able to sort the rest from here
Thanks
|
|
|
|
|
I have education in acoustics, were this comes up quite frequent
|
|
|
|
|
Ah, you should be careful though, LogE and Log10 gives you quite different results! And log10 is the one that is used in acoustics. I would know, I have a Masters degree in it
|
|
|
|
|
I'll keep my eye on it for other parameters that use the logf type. For the 20-400HZ one Math.E is giving the correct result.
Thanks for the heads up.
|
|
|
|
|
What I am trying to accomplish is that I am making the datatable to interpret large data. I only wanted to print out the header, then the data. Also only to show "Variable" and "Value" columns.
I'm not sure how to weed out the "Hex Value" column. Also to list the rows that are (Hidden = false).
I'm not sure how to accomplish this.
On the bottom code (with variable "res" does show all of the rows with all of the columns, but no header...
DataTable dataTable = new DataTable();
dataTable.Columns.Add("Variable", typeof(string));
dataTable.Columns.Add("Hex Value", typeof(Int64));
dataTable.Columns.Add("Value", typeof(string));
dataTable.Columns.Add("Hidden", typeof(bool));
dataTable.Rows.Add("Ronald", 0x0, "Value = 0", false);
dataTable.Rows.Add("Ronald", 0x1, "Value = 1", false);
dataTable.Rows.Add("Ronald", 0x2, "Value = 2", true);
dataTable.Rows.Add("Ronald", 0x4, "Value = 4", true);
dataTable.Rows.Add("Ronald", 0x8, "Value = 8", false);
dataTable.Rows.Add("Ronald", 0x16, "Value = 16", true);
dataTable.Rows.Add("Ronald", 0x32, "Value = 32", false);
dataTable.Rows.Add("Ronald", 0x64, "Value = 64", false);
dataTable.Rows.Add("Ronald", 0x128, "Value = 128", false);
dataTable.Rows.Add("Ronald", 0xFF, "Value = 255", true);
try
{
DataRow selectedRow = dataTable.Select("").FirstOrDefault(x => (Int64)x["Hex Value"] == Convert.ToInt64(tb_Input.Text, 16));
lbl_Result.Text = selectedRow["Value"].ToString();
}
catch
{
lbl_Result.Text = "Unknown";
}
string res = String.Join(Environment.NewLine, dataTable.Rows.OfType<DataRow>().Select(x => String.Join(" ; ", x.ItemArray)));
MessageBox.Show(res);
|
|
|
|
|
If dataTable is a System.Data.DataTable, then look into the DefaultView property.
|
|
|
|
|
I've got it...
Now one question hasn't been answered. How do I generate output showing only the "Variable" and "Value" columns?
|
|
|
|
|
Updated code... Seems to be working... Any suggestion for a better approach?
DataTable dataTable = new DataTable();
dataTable.Columns.Add("Variable", typeof(string));
dataTable.Columns.Add("Hex Value", typeof(Int64));
dataTable.Columns.Add("Value", typeof(string));
dataTable.Columns.Add("Hide", typeof(bool));
dataTable.Rows.Add("Ronald", 0x0, "Value = 0", false);
dataTable.Rows.Add("Ronald", 0x1, "Value = 1", true);
dataTable.Rows.Add("Ronald", 0x2, "Value = 2", false);
dataTable.Rows.Add("Ronald", 0x4, "Value = 4", true);
dataTable.Rows.Add("Ronald", 0x8, "Value = 8", false);
dataTable.Rows.Add("Ronald", 0x16, "Value = 16", false);
dataTable.Rows.Add("Ronald", 0x32, "Value = 32", false);
dataTable.Rows.Add("Ronald", 0x64, "Value = 64", true);
dataTable.Rows.Add("Ronald", 0x128, "Value = 128", false);
dataTable.Rows.Add("Ronald", 0xFF, "Value = 255", true);
try
{
DataRow selectedRow = dataTable.Select("").FirstOrDefault(x => (Int64)x["Hex Value"] == Convert.ToInt64(tb_Input.Text, 16));
lbl_Result.Text = selectedRow["Value"].ToString();
}
catch
{
lbl_Result.Text = "Unknown";
}
DataRow[] drArrRow = dataTable.Select("Hide = False");
DataTable filteredDataTable = new DataTable();
filteredDataTable.Columns.Add("Variable", typeof(string));
filteredDataTable.Columns.Add("Value", typeof(string));
foreach (DataRow dr in drArrRow)
{
filteredDataTable.Rows.Add(dr["Variable"], dr["Value"]);
}
string res = String.Join(Environment.NewLine, filteredDataTable.Rows.OfType<DataRow>().Select(x => String.Join(" ; ", x.ItemArray)));
MessageBox.Show(res);
|
|
|
|
|