|
I'm not sure exactly what you are trying to do, but it's simple to create a List of Lists:
List<List<IndividualSensorReading>> sensorData = new List<List<IndividualSensorReading>>()
foreach(SetOfSensorData data in MySensorData)
{
List<IndividualSensorReading> readings = new List<IndividualSensorReading>();
sensorData.add(readings);
foreach(IndividualSensorReading reading in data)
{
readings.Add(reading);
}
} If that isn't what you are trying to do, then perhaps an example would help?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
sdecorme wrote: I would to store all the acquisition in List (one by sensor). And after I
need to read them back. If it is in memory, I'd recommend a Dictionary<int, List<whatever>> ; the int would refer to the index of your sensor (or use a string to identify them for something readable), containing a List with an object to represent the measurement. If it is a singular integer, then int would be enough.
You do not declare all variables of that complex type; inherit your own type from it and use that;
class MyComplexCollection: Dictionary<string, List<MyObject>> { }
...
var mcc = new MyComplexCollection();
mcc.Add("bla", new List<MyObject>());
mcc["bla"].Add(new MyObject(42)); If you really need the data then stream it to a file and flush after every write.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello,
I am trying to implement a chart in word using Microsoft.Office.Interop.Word.Chart .
I am able to generate a 2 dimensional chart with a x-axis and a y-axis but i am not able to add one more y-axis on the right side (secondary y-axis). can we achieve this by using Microsoft.Office.Interop.Word.Chart?
If YES, Please guide me in solving that issue else it will be a great help if you can provide any alternative.
Regards,
Santosh.
|
|
|
|
|
santosh kumar dash wrote: can we achieve this by using Microsoft.Office.Interop.Word.Chart? According to the documentation[^], yes.
What have you tried?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi Eddy,
I have pasted my code please have a look.
can we draw secondary y axis with the help of ChartWizard method in word chart.
Microsoft.Office.Interop.Word.Chart wdChart = wordDoc.InlineShapes.AddChart(Microsoft.Office.Core.XlChartType.xlLine, para17.Range).Chart;
wdChart.ChartWizard(Source: missing1,
Title: "graphTitle",
CategoryTitle: "Time",
ValueTitle: "Temperature",
ExtraTitle:"check");
Microsoft.Office.Interop.Word.ChartData chartData = wdChart.ChartData;
Microsoft.Office.Interop.Excel.Workbook dataWorkbook = (Microsoft.Office.Interop.Excel.Workbook)chartData.Workbook;
Microsoft.Office.Interop.Excel.Worksheet dataSheet = (Microsoft.Office.Interop.Excel.Worksheet)dataWorkbook.Worksheets[1];
Microsoft.Office.Interop.Excel.ChartObjects ChartObjects = (Microsoft.Office.Interop.Excel.ChartObjects)dataSheet.ChartObjects();
Microsoft.Office.Interop.Excel.ChartObject chartObject = ChartObjects.Add(40, 1000, 700, 350);
Microsoft.Office.Interop.Excel.SeriesCollection seriesCollection = (Microsoft.Office.Interop.Excel.SeriesCollection)chartObject.Chart.SeriesCollection();
Microsoft.Office.Interop.Excel.Series series1 = seriesCollection.NewSeries();
series1.XValues = dataSheet.get_Range("A1", "B7");
series1.AxisGroup = Microsoft.Office.Interop.Excel.XlAxisGroup.xlSecondary;
Microsoft.Office.Interop.Excel.Series series3 = seriesCollection.NewSeries();
series3.XValues = dataSheet.get_Range("A1", "D7");
Microsoft.Office.Interop.Excel.Series series4 = seriesCollection.NewSeries();
series4.XValues = dataSheet.get_Range("A1", "E7");
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("A2", missing1)).FormulaR1C1 = "5";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("A3", missing1)).FormulaR1C1 = "10";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("A4", missing1)).FormulaR1C1 = "15";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("A5", missing1)).FormulaR1C1 = "20";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("A6", missing1)).FormulaR1C1 = "25";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("A7", missing1)).FormulaR1C1 = "30";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("B2", missing1)).FormulaR1C1 = "1000";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("B3", missing1)).FormulaR1C1 = "2500";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("B4", missing1)).FormulaR1C1 = "4000";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("B5", missing1)).FormulaR1C1 = "3000";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("B6", missing1)).FormulaR1C1 = "400";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("B7", missing1)).FormulaR1C1 = "300";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("C2", missing1)).FormulaR1C1 = "700";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("C3", missing1)).FormulaR1C1 = "500";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("C4", missing1)).FormulaR1C1 = "400";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("C5", missing1)).FormulaR1C1 = "300";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("C6", missing1)).FormulaR1C1 = "2500";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("C7", missing1)).FormulaR1C1 = "3500";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("D2", missing1)).FormulaR1C1 = "1100";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("D3", missing1)).FormulaR1C1 = "2150";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("D4", missing1)).FormulaR1C1 = "4100";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("D5", missing1)).FormulaR1C1 = "3100";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("D6", missing1)).FormulaR1C1 = "2100";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("D7", missing1)).FormulaR1C1 = "3100";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("E2", missing1)).FormulaR1C1 = "2100";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("E3", missing1)).FormulaR1C1 = "2050";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("E4", missing1)).FormulaR1C1 = "4000";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("E5", missing1)).FormulaR1C1 = "2100";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("E6", missing1)).FormulaR1C1 = "4000";
((Microsoft.Office.Interop.Excel.Range)dataSheet.Cells.get_Range("E7", missing1)).FormulaR1C1 = "2100";
wdChart.ApplyDataLabels(Microsoft.Office.Interop.Word.XlDataLabelsType.xlDataLabelsShowLabel, missing1, missing1, missing1, missing1, missing1, missing1, missing1, missing1, missing1);
dataWorkbook.Application.Quit();
Regards,
Santosh.
|
|
|
|
|
I wanted to understand how to call a type parameter's method from a generic class. So if one has a class List<T>
and the class has a sort() method, how can the nodes in the list be sorted using T's Compare() method. The List<T> class is in a library.
Since T is a user defined class the list's sort method may not know how to Compare nodes in the list.
Thanks.
binsafir.
|
|
|
|
|
If T is limited to an interface, you can cast it to that interface. Alternatively, you can mess with reflection.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
With the default approach, you would only be able to do this if T implements IComparable . Suppose that you have the following class:
public class Cmp
{
public string Name { get; set; }
} With the default List.Sort(); , you would need to ensure that the class looks something like this instead:
public class Cmp : IComparable<Cmp>
{
public string Name { get; set; }
public int CompareTo(Cmp obj)
{
if (Name == null) return -1;
return Name.CompareTo(obj.Name);
}
} Now, suppose that you cannot modify the underlying library? Well, Sort accepts classes that derive from Comparison , or that implement IComparer<T> so you can create a new comparer that might look something like this:
public class CustomCmpComparer : IComparer<Cmp>
{
public int Compare(Cmp x, Cmp y)
{
if (x.Name == null) return -1;
return x.Name.CompareTo(y.Name);
}
} Then, your Sort call would look something like this instead:
myList.Sort(new CustomCmpComparer());
|
|
|
|
|
Generics are functions that work regardless of the type they are bound to. If you need to call a method then your function is no longer generic as it can't be used with any type. In order to do this your types will need to implement an interface that has your method on it
public interface IMyInterface
{
bool Compare(object target);
}
public class MyClass : IMyInterface
{
public bool Compare(object target)
{
return true;
}
}
When defining your generic function you can now stipulate that the type used has to implement your interface
private void MyFunction<T>(T data, T data2) where T : IMyInterface
{
data.Compare(data2);
}
You can now call your generic method but it must be bound to an object that implements your interface, it is no longer 100% generic.
MyFunction<MyClass>(new MyClass(), new MyClass());
MyFunction<SqlConnection>(new SqlConnection(), new SqlConnection());
|
|
|
|
|
The zero parameter Sort method on List<T> expects that T implements IComparable<T> or IComparable interface. If it does not an InvalidOperationException will be thrown. If T does implement the interface then knowing this List<T> can cast T to IComparable<T> or IComparable and call the Compare method. No need for reflection and List<T>>otherwise doesn't understand much about T at all, other than that it either does or does not implement IComparable<T> or IComparable.
If you want your "generic" to be able to call a method on T that is not exposed via a known interface or subclass you will probably need to resort to reflection or use some other way of mapping to the target method. While List<t> does not do this, you can constrain the type parameter for your generic such that it must implement certain interfaces or derive from a certain class allowing your generic class to call the methods known to be exposed via the super class or interfaces.
|
|
|
|
|
If you define List<T> where T: Icomparable , I think the compiler will object if it doesn't.
|
|
|
|
|
User register from windows form application and then insert that data to webserver database please help me.
|
|
|
|
|
That is not a question, that is functionality. As is, the task is a bit large to explain.
Have you inserted data into a database before? If not, that is where you start.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I need to display some summary details in the RDLC report and also i need that in the form of table. I tried vertical tablix and bond values with DataSet but right now my problem is the summary details are showing vertically twice.
Eg. I need
Sum1 val1
Sum2 val2
Sum3 val3
Total val1+val2+val3
BUT right now its displaying like
Sum1 val1
Sum2 val2
Sum3 val3
Total val1+val2+val3
Sum1 val1
Sum2 val2
Sum3 val3
Total val1+val2+val3
|
|
|
|
|
That is the code? I am sure not, so the code of your application would help us understand the context and problem.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Thanks..
|
|
|
|
|
I would like to know if it is possible to develop an webcam application under WPF C# to capture webcam image and save it to disk without showing the preview (showing the content to the user)?
|
|
|
|
|
|
|
Great! Please help me with a few codes in WPF C# so I could implement this to my application.
Please note that the objective is not to aware the user of the webcam activity at all.
Thanks in advance.
|
|
|
|
|
I said it's possible, I did not say I know how to do it. You need to study the webcam interface to see what you need to do in order to capture the activity without displaying it. But personally I would never install such an application on my PC.
|
|
|
|
|
Let me clear my objectives one more time before it creates any ambiguity.
This is an application where the user puts a few input in a sequence of pages. Every time the user enters into a page the application captures the image of his/her face along with the other activities with 2 webcams. Reason to take the image is to resolve any dispute if occurs. It would be awkward to show the webcam preview on the input pages. If we had to put an image control it has to be on the main window keeping it hidden.
This is a DropBox application to be written in C# WPF where there are 2 webcams - 1 for the user face and the other at the DropBox shutter end to capture if the user actually dropped anything.
|
|
|
|
|
And how are you going to switch off the Webcam notification itself? You know, the light that appears on the camera when it's in use.
|
|
|
|
|
Since all the webcams are inside the cage the light can not be seen by the user.
|
|
|
|
|