PlexityHide

Home 

Products 

Downloads 

Our Shop 

Support 

Contact 


Saturday, October 2, 2010

Gantt for Silverlight and WPF

The GTP.NET.SL enables you to easily add time dependant stuff in the background or foreground of your TimeItemArea.

As our Gantt is flexible enough to integrate with any grid or treeview we need a generic way to help you do draw things in the area that belongs to the Grid or Tree but resides under the DateScaler:

Silverligth and WPF Gantt chart

We did this by exposing two events:

   1: /// <summary>
   2: /// Overridable for advanced use, public for technical reasons
   3: /// </summary>
   4: public virtual void UpdateBackAndForegroundContent()
   5: {
   6:     if (VerticalDayStripesUse != VerticalDayStripesUse.none)
   7:         DrawVerticalDayStripes();
   8:     if (TodayLineUse)
   9:         TodayLine();
  10:     if (OnDrawBackground != null)
  11:         OnDrawBackground(this, new GanttUserDrawArgs() { Canvas = _userBackgroundCanvas });
  12:     if (OnDrawForeground != null)
  13:         OnDrawForeground(this, new GanttUserDrawArgs() { Canvas = _userForegroundCanvas });
  14: }

You can from the internal code above see that the exact same way that we implement the TodayLine and the VerticalDayStripes we also call the OnDrawBackground and OnDrawForeground events.

This is how we implement the today line:

   1: Line l = new Line();
   2: _todayLineCanvas.Children.Clear();
   3: _todayLineCanvas.Children.Add(l);
   4: l.Fill = _todayLineStroke;
   5: l.Stroke = _todayLineStroke;
   6: l.StrokeThickness = TodayLineStrokeThickness;
   7: double pos = DateScaler.TimeToPixel(DateTime.Now);
   8: if (ScheduleMode)
   9: {
  10:     l.Y1 = pos;
  11:     l.Y2 = pos;
  12:     l.X1 = 0;
  13:     l.X2 = ActualWidth;
  14: }
  15: else
  16: {
  17:     l.X1 = pos;
  18:     l.X2 = pos;
  19:     l.Y1 = 0;
  20:     l.Y2 = ActualHeight;
  21: }

Notice that the call to DateScaler.TimeToPixel easily helps anyone to convert between time and position – this call – that is very effective and the heart of our Gantt implementation – ensures that the TodayLine is positioned on the exact spot where the user perceives NOW to be.

Also notice that we check the ScheduleMode setting to decide in what direction to draw the todayline.

This is the sample implementation of the OnDrawForeground event:

   1: void gantt1_OnDrawForeground(object sender, GanttUserDrawArgs e)
   2: {
   3:     e.Canvas.Children.Clear();
   4:     Canvas c = new Canvas();
   5:     e.Canvas.Children.Add(c);
   6:     Canvas.SetLeft(c, gantt10.DateScaler.TimeToPixel(DateTime.Now));
   7:     Canvas.SetTop(c, 440);
   8:  
   9:     Ellipse ellipse = new Ellipse();
  10:     c.Children.Add(ellipse);
  11:     ellipse.Stroke = new SolidColorBrush(Colors.Blue);
  12:     ellipse.StrokeThickness = 3;
  13:     ellipse.Width = 100;
  14:     ellipse.Height = 20;
  15:  
  16:     TextBlock text = new TextBlock();
  17:     c.Children.Add(text);
  18:     text.Text = "Easily add your own time dependant stuff\n in the foreground";
  19:  
  20: }

The difference between Foreground and Background is achieved with Canvas.ZIndex settings and enables you to get effects like this:

Gantt Time items ZIndex

Where the the blue ellipse goes above the TimeItem and the green ellipse goes below the TimeItem.


Comments:
Great tips for constructing a gantt for silverlight. I've been looking for something like this, hopefully I can get it to work on my application.
web design perth
 
A very interesting topic that you have discussed here, definitely, your tips help me out to reach my passion. I would love to see more updates. Thank you, admin.
dot net training institutes in chennai
dotnet training in chennai
 
This could be one of the most useful blogs I have ever come across on this technology. I am a newbie to this technology. Great work admin.
Selenium Course in Chennai
Selenium Courses in Chennai
 
It is exceptionally valuable data. It will enhance my insight in Selenium. Much thanks to you for sharing this marvelous site.
Selenium Training in Chennai | Selenium Training | Selenium Course in Chennai | Selenium Training Institute in Chennai
 
This comment has been removed by the author.
 
The ankle is another joint that can be injured as a result of the demanding quick-change motions found in many sports. Ankle sprains are common, and they are caused by a partially or completely torn ligament. Damaged ligaments in the ankle, similar to knee injuries, can cause increased strain on other ligaments and structures in the ankle, increasing the risk of further injury if left untreated. Your sports injury surgeon in Gurgaon can examine the extent of the damage and provide treatment or surgical intervention to reduce the risk of long-term damage if you seek prompt orthopedic care for an ankle injury.
 

Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]

Support

Support intro

Knowledgebase

FAQ phGantTimePackage

FAQ GTP.NET

FAQ general

History