|
The first thing you need to do is look at the interface provided by the sensor, and how it communicates with a computer. It's most unlikely that this would be via a COM port.
Veni, vidi, abiit domum
|
|
|
|
|
DateTime[] start = new DateTime[] { new DateTime(1990, 1, 1), new DateTime(1995, 1, 1), new DateTime(1995, 1, 1),new DateTime(2003, 1, 1) };
DateTime[] end = new DateTime[] { new DateTime(2000, 1, 1), new DateTime(2005, 1, 1), new DateTime(2005, 1, 1), new DateTime(2007, 1, 1)};
i cannot explain what i what to do in earlier question so i have array that contain start days and another array contain end day. and i should calculate lenght of days i dont need calculate overlap days
|-------------------|
|-----------------------|
|-----------------------|
|---------------------|
|
|
|
|
|
You can do this very easily using LINQ and TimeSpan.
First, get the minimum DateTime from the array(Min() ).
Then get the maxumim DateTime from the array (Max( )).
Using TimeSpan get the difference.
|
|
|
|
|
sorry but i did not understand you
|
|
|
|
|
Something like
accepted
If you want to find the earliest or latest Date:
DateTime earliest = arr.Min(record => record.Date);
DateTime latest = arr.Max(record => record.Date);
TimeSpan examples to calculate datetime difference - http://www.dotnetperls.com/timespan[^].
|
|
|
|
|
Try this:
List<TimeSpan> dateIntervals = endDates.Select((eDate, ndx) => eDate - startDates[ndx]).ToList(); The Linq 'Select function overload that supplies an index is available as of .NET FrameWork 3.5.
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|
Try this:
for (int i = start.Length - 2; i > -1; --i)
{
if (start[i+1] >= start[i] && start[i+1] <= end[i])
{
start[i + 1] = end[i];
}
}
for (int i = 0; i < start.Length; ++i)
{
timespan = end[i] - start[i];
timeDifference += timespan.Days;
}
Veni, vidi, abiit domum
|
|
|
|
|
yes but it is not remove overlap for the next time i mean for this one it is good |-----------|
|-------------|
but here |--------1-----|
}-----------2---------|
}==========3==========} here it should not add 3 because value od 3 contains in 2 one
|
|
|
|
|
I tried my suggested code with your original data and it produced the correct answer.
Veni, vidi, abiit domum
|
|
|
|
|
how can make the telerik radTreeListView only allow selection of items under the same rootItem/ParentItem?
UK
-london
-london 1
-london --
-london 100
-Newcastle
-Newcastle 1
-Newcastle 2
-Newcastle 3
-liverpool
USA
-New york
-califonia
China
-one
-two
From above sample menu of a radTreeListView, user should be allowed to select only
UK, USA or China. OR London, Newcastle, Liverpool, OR Newcastle 1, Newcastle 2, Newcastle 3 BUT NOT Newcastle 1, London 1, UK ALSO NOT UK, Newcastle, Newcastle 1.
User should only select things/items at the same hierarchy. Basically, they should not select a parent and a child, THEY either select from parents or children or sub-children.
This is the control am using : http://www.telerik.com/help/silverlight/radtreelistview-overview.html
|
|
|
|
|
Presumably you have a TreeNode object that you stuff your objects into (you are displaying Country and City here). I would put a Nodelevel property on the TreeNode object and manage your SelectedItems collection using that property.
We use the HeirarchyID concept in our TreeNode that automatically knows it's level.
Take a read through some of Mr Smiths articles[^] I have quite a few bits of his code in my apps.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Mycroft,
I use a TreeView (the excellent IntegralUI TreeView from Lidor Systems) that also has a "Level" property for every Node; it's very useful.
However, in this case, knowing the Level would not be adequate to determine which are "acceptable" selected nodes: "-california" and "-liverpool," for example, are at the same level; while that may have some "historic poetic truth" in terms of the music scene ... that would not work for the OP.
Bill
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|
Ok now I see where you are coming from, however I would bet the OP (coming from Uganda) may have considered california a city rather than a state. Certainly I did not pick it up until you pointed it out
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I don't use the Telerik Treeview (I use one from Lidor Systems), so I don't know exactly what special features ... compared to any other Control ... it offers, or the exact syntax of Events it exposes, but this is pretty simple to do.
The Microsoft TreeView does not, of course, offer multiple selection, but the following code for the MS TreeView will demonstrate a general solution:
TreeNode firstSelectedNode;
TreeNode firstSelectedNodeParent;
private void treeView1_BeforeSelect(object sender, TreeViewCancelEventArgs e)
{
if (firstSelectedNode == null)
{
firstSelectedNode = e.Node;
firstSelectedNodeParent = firstSelectedNode.Parent;
}
else
{
if (e.Node.Parent != firstSelectedNodeParent) e.Cancel = true;
}
}
This code will confine selection to the sibling nodes of the first selected TreeNode. Obviously, in real-world use, you will need to reset the variable 'firstSelectedNode to null after you have "handled" the current selection.
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
DateTime[] start = new DateTime[] { new DateTime(2000, 1, 1), new DateTime(2004, 1, 1),
new DateTime(2004, 1, 1), new DateTime(2008, 1, 1) };
DateTime[] end = new DateTime[] { new DateTime(2002, 1, 1), new DateTime(2006, 1, 1),
new DateTime(2006, 1, 1), new DateTime(2010, 1, 1) };
int timeDifference = 0;
TimeSpan timespan;
private void button1_Click(object sender, EventArgs e)
{
for (int i=0; i<end.Length-2; i++)
{
if (end[i] < end[i + 1] && start[i] <start[i +="" 1]="" &&="" start[i="" 1]<="end[i])
" {
="" timespan="(end[i]" -="" start[i])="" (end[i="" end[i]);
="" }
="" if="" (end[i]="">= end[i + 1] && start[i] <= start[i + 1])
{
timespan = (end[i] - start[i]);
}
if (end[i] > end[i + 1] && start[i] > start[i + 1] && start[i] <= end[i + 1])
{
timespan = (end[i] - start[i]) + (end[i + 1] - end[i]);
}
if (end[i] <= end[i + 1] && start[i] >= start[i + 1])
{ timespan = (end[i + 1] - start[i + 1]);
}
timeDifference = timespan.Days + timeDifference;
}
MessageBox.Show(timeDifference.ToString());
}
}
}
|
|
|
|
|
What is the question?
Veni, vidi, abiit domum
|
|
|
|
|
i should find the length of days in the array but in my code |--- Date 1 ---|
|--- Date 2 ---| dont calculate in right way
|--- Date 1 ---|
| --- Date 2 --- |
| --- Date 1 --- |
| --- Date 2 ---- |
| -------- Date 1 -------- |
| --- Date 2 --- |
| --- Date 1 --- |
| -------- Date 2 -------- |
|--- Date 1 ---|
|--- Date 2 ---|
| --- Date 2 --- |
| --- Date 1 ----|
| --- Date 1 --- |
| -------- Date 2 -------- |
| --- Date 1 --- |
| --- Date 2 --- |
|
|
|
|
|
i should find the length of days in the array but in my code |--- Date 1 ---|
|--- Date 2 ---| dont calculate in right way
|
|
|
|
|
I have no idea what all these pictures are supposed to mean, please try explaining your problem in better detail.
Veni, vidi, abiit domum
|
|
|
|
|
ok i will explain in this way you worked from
DateTime[] start = new DateTime[] { new DateTime(2000, 1, 1), new DateTime(2004, 1, 1), new DateTime(2004, 1, 1), new DateTime(2008, 1, 1) };
to
DateTime[] end = new DateTime[] { new DateTime(2002, 1, 1), new DateTime(2006, 1, 1), new DateTime(2006, 1, 1), new DateTime(2010, 1, 1) };
and find how long you worked from 200years to 2010? as you see here i have overlap datetime and when i calculate in my program the lenght of working days i found it is not true
did you understand now?
|
|
|
|
|
if (end[i] < end[i + 1] && start[i] = end[i + 1] && start[i] <= start[i + 1])
should be
if (end[i] < end[i + 1] && start[i] == end[i + 1] && start[i] <= start[i + 1])
Veni, vidi, abiit domum
|
|
|
|
|
|
[twitchy left eye typing mode]
if (end[i] < end[i + 1] && start[i] == end[i + 1] && start[i] <= start[i + 1])
There is a difference between = and == in C#...
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
hi Guys....
i have a programm and its about Human Resource managment...(c# and linq)
My Problem is :
i have 2 form ...: frmPersonals.cs and frmRPersonals.cs
the first one( frmPersonals) is for input data and save it to DB. and as you will see there is an image box in it(image of person will be save and retrieve on it)
the second form(frmRPersonals) is for search the DB (filter by user request).and it search Db and use "report Viewer" to show it.
my request is here:
i want to add the same image box (like first form) and put it in my Second form(frmRPersonals)so when it find the proper person it show his-her picture in this form...(in other word i want code that do the same things in my first form means:retreive the image of filtered personT in image box that will be put in frmRPersonals)...
how can i do that...plz do this for me in my source code....god bless u!
i will upload my whole source code ....plz help me i need it.
<a href="http://www.mediafire.com/download/7q00kqzg794mp9h/Personals-Info.zip">http://www.mediafire.com/download/7q00kqzg794mp9h/Personals-Info.zip</a>[<a
href="http://www.mediafire.com/download/7q00kqzg794mp9h/Personals-Info.zip" target="_blank" title="New Window">^</a>]
|
|
|
|
|
I suggest you read the guidelines on how to ask a question. Good luck with your homework.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|