 |
|
 |
I've added 3 methods, a serializer to store data into a string, a deserializer and the cleaner:
public static string SerializeTimeFrames(TimeSpan[][][] TimeFrames)
{
string result = "";
int Counter = 0;
foreach (TimeSpan[][] tsa in TimeFrames)
{
result += Counter;
foreach (TimeSpan[] ts in tsa)
{
result += "," + ts[0].ToString() + " " + ts[1].ToString();
}
result += "#";
++Counter;
}
return result;
}
public static TimeSpan[][][] DeSerializeTimeFrames(string SerializedTimeFrames)
{
TimeSpan[][][] tss = new TimeSpan[8][][];
for (int i = 0; i < tss.Length; i++)
{
tss[i] = new TimeSpan[48][];
for (int j = 0; j < tss[i].Length; j++)
{
tss[i][j] = new TimeSpan[2];
}
}
int DayCounter = 0;
string[] Days = Microsoft.VisualBasic.Strings.Split(SerializedTimeFrames, "#", -1, Microsoft.VisualBasic.CompareMethod.Text);
for (DayCounter = 0; DayCounter < Days.Length - 1; DayCounter++)
{
int IntCounter = 0;
string[] Intervals = Microsoft.VisualBasic.Strings.Split(Days[DayCounter], ",", -1, Microsoft.VisualBasic.CompareMethod.Text);
for (IntCounter = 1; IntCounter < Intervals.Length; IntCounter++)
{
int SpanCounter = 0;
String[] Span = Microsoft.VisualBasic.Strings.Split(Intervals[IntCounter], " ", -1, Microsoft.VisualBasic.CompareMethod.Text);
for (SpanCounter = 0; SpanCounter < 2; SpanCounter++)
{
try
{
tss[DayCounter][IntCounter][SpanCounter] = TimeSpan.Parse(Span[SpanCounter]);
}
catch (Exception ex)
{
}
}
}
}
return tss;
}
public static void ClearContent()
{
for (int r = 0; r < c_NumDays; r++)
{
for (int c = 0; c < c_NumTimeIntervals; c++)
{
CellMatrix[r, c].Selected = false;
}
}
}
you can check a derived control here:
http://www.componentfactory.com/forums/viewtopic.php?f=7&t=2328[^]
Hope this helps
Angel
|
|
|
|
 |
|
 |
hello,
is it possible to add a vertical or horizontal scrollbars in the controls in such case where your time labels are from 12:00AM to 11:59PM with only 1 hour interval and maintaining the size of the form?
|
|
|
|
 |
|
 |
This is great.
I've been looking for this everywhere.
Anyone have sample code for implementing this in VB.NET?
I use free MS VB 2005 Express and don't have access to C#.
Thanks!
pclady
|
|
|
|
 |
|
 |
I am using trying usercontrol but necessary to take off one it doubts? I obtained to record the periodos in Bank SQL, but it would like to know as I make to place the information deals of the SQL in the graphical frame?
|
|
|
|
 |
|
 |
public bool[] GetValue()
{
try
{
bool[] data = new bool[NumDays * NumTimeIntervals];
for (int i = 0; i < NumDays; i++)
{
for (int j = 0; j < NumTimeIntervals; j++)
{
data[i * NumDays + j] = this[i, j];
}
}
return data;
}
catch (Exception ex)
{
Trace.WriteLine(ex.StackTrace);
return null;
}
}
public void SetValue(bool[] data)
{
try
{
for (int i = 0; i < NumDays; i++)
{
for (int j = 0; j < NumTimeIntervals; j++)
{
this[i, j] = data[i * NumDays + j];
}
}
}
catch (Exception ex)
{
Trace.WriteLine(ex.StackTrace);
}
}
private bool this[int i, int j]
{
get
{
return CellMatrix[i, j].Selected;
}
set
{
CellMatrix[i, j].Selected = value;
}
}
|
|
|
|
 |
|
 |
I added this code to the public TimeSpan[][][] TimeFrames Property. It allows me to load a saved array of TimeSpan objects into the control.
set
{
int day=0;
foreach(TimeSpan[][] tss in value)
{
foreach(TimeSpan[] ts in tss)
{
long t_inc = c_ts.Ticks / (long)NumTimeIntervals;
TimeSpan tsi = new TimeSpan( t_inc );
long start = ts[0].Ticks / tsi.Ticks;
long end = ts[1].Ticks / tsi.Ticks;
for(long time = start;time
|
|
|
|
 |
|
 |
Hi; your control it's very usefull, and I need something similar for use in the web.
How can I migrate this control to WebForms?
Thanks
|
|
|
|
 |
|
 |
Just wanted to say THANKS!! It's great. the interface, the code, etc. Wow! And it;s totally free! Thanks again.
|
|
|
|
 |
|
 |
How can create two timeframe in the same form?
One is 7 days, the other is 1 day.
Thanks
|
|
|
|
 |
|
 |
Well, I can create two TimeFrame in one form, however, when I work on the first one, the same thing happened to the second one.
It is very good control, we use it for many places, thanks for your help.
|
|
|
|
 |
|
 |
I must say that I agree with the original poster. How can the start and end times of the period *not* be DateTimes?
|
|
|
|
 |
|
 |
The reason for this is that the CellMatrix[,] member is static. So all objects of TimeFrame class uses the same data structure to store data.
|
|
|
|
 |
|
 |
And how would i go about adding another column of weeks of the year.
i.e
Monday ] 22/01/2004
Tuesday ] 23/01/2004
cheers
chris
|
|
|
|
 |
|
 |
Hi,
I've been looking for something like this for two uses:
setting appointment start/end time
and
floor schedule
so what I need is:
(meaning how do I do this...
1 - can I change times displayed. start at a reasonable time say 8am?
2 - how do I retrieve the start/end time/day
3 - I figure I'll add some kind of datepicker up top for the date.
4 -
thanks
|
|
|
|
 |
|
 |
hi did u manage to find a solution to this?
TIA
Andrew
|
|
|
|
 |
|
 |
Why did you use TimeSpans? For instance, your third dimension is the start and end *times*. Your first dimension is the *day*. The only place that makes sense to use a TimeSpan is your second dimension, but you can obtain this easily by subtracting the start DateTime from the end DateTime.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
 |
|
 |
"The DateTime and TimeSpan value types differ in that a DateTime represents an instant in time, whereas a TimeSpan represents a time interval." The control specifies time intervals which is why TimeSpan was used.
-- "If you're object doesn't encapsulate complexity, then why would I use it?"
|
|
|
|
 |
|
 |
Exactly what I was looking for.
|
|
|
|
 |
|
 |
Hi , any idea how i can do things like loading of data into the control ?
for example how do we go about getting it done with a datatable of data ?
And any chance besides having the Day of the Week by the side , any idea how to extend it to be displaying maybe the a person's name ? [so it will be like timetable of different people for a single day]
Thanks
its an awesome control !
|
|
|
|
 |
|
 |
I picked the simplest way to get the data out of the control because I new that once anyone wanted to use it, they might want it differently than what I originally coded. Another idea for importing/exporting would be a (typed) dataset. If anyone/everyone likes this idea, then I can add it. Any other ideas?
Changing the rows to people's names instead of weekdays would chnage the logic of the control. In essence, it would be a different control but would look very much like the original one.
-- "If you're object doesn't encapsulate complexity, then why would I use it?"
|
|
|
|
 |
|
 |
Importing / exporting via a typed dataset will be a great addition to it.
I am still struggling to create the triple timespan array needed to get it to display some information
but the time picking interface still rocks =);)
|
|
|
|
 |
|
 |
Yes I'm having the same problem...
Does anyone can give me ANY example of how to import data into the control?
thnks,
Martin
|
|
|
|
 |
|
 |
Hallo,
Ich changed the code as follows. I added one small function:
public bool SetTime(int intDay,int intColumn)
{
CellMatrix[ intDay, intColumn ].Selected = true ;
return true;
}
Hope this helps
Chris
Vietiane, Laos (PDR)
|
|
|
|
 |
|
 |
Does anyone have an example how to do this yet?
In my case the data is saved in the registry so I can set each day's info directly however I just can't seem to get it working.
|
|
|
|
 |