Thursday, April 22, 2010Marking up certain days in the datescaler, Silverlight and WPFImplement the event OnTextOutOverride, look at the code below where I mark up the 5:th of March, make Sundays red, and append “a.d” behind each year 1: void dateScalerHorizontal_OnTextOutOverride(object sender, PlexityHide.GTP.TextOutOverrideArgs e) 2: { 3: if (CBRedSundays.IsChecked==true) 4: { 5: if ((!e.IsUpperBand && e.Resolution == TimeResolution.days) && e.Time.DayOfWeek == DayOfWeek.Sunday) 6: { 7: e.TextBlock.FontWeight = FontWeights.ExtraBold; 8: e.TextBlock.Foreground = new SolidColorBrush(Colors.Red); 9: } 10: } 11: 12: if (e.Resolution == TimeResolution.years) 13: { 14: e.TextBlock.Text = e.Time.Year.ToString() + "A.D."; 15: } 16: 17: if (CBBirthday.IsChecked==true) 18: { 19: if (e.Time.Month == 3 && e.Time.Day == 5) 20: { 21: e.ReturnCanvasToUseInstead = new Canvas(); 22: Ellipse ellipse = new Ellipse(); 23: ellipse.Height = 20; 24: ellipse.Width = 20; 25: ellipse.StrokeThickness = 2; 26: ellipse.Stroke = new SolidColorBrush(Colors.Green); 27: ellipse.Fill = new SolidColorBrush(Colors.Yellow); 28: TranslateTransform trt = new TranslateTransform(); 29: trt.X = -6; 30: trt.Y = -6; 31: ellipse.RenderTransform = trt; 32: e.ReturnCanvasToUseInstead.Children.Add(ellipse); 33: e.ReturnCanvasToUseInstead.Children.Add(e.TextBlock); // Adding the original text to our canvas 34: 35: TextBlock tb = new TextBlock(); 36: tb.Text = "My birthday! Sure hope I get cake..."; 37: e.ReturnCanvasToUseInstead.Children.Add(tb); 38: TranslateTransform trt2 = new TranslateTransform(); 39: trt2.X = 10; 40: trt2.Y = -20; 41: tb.RenderTransform = trt2; 42: 43: } 44: } 45: 46: 47: } Wednesday, April 21, 2010In GTP.NET for Silverlight and WPF, how to stop a move to avoid collisionThis is one way to stop a move that will cause a collision: 1: private void GanttRow_OnTimeItemChange(object sender, OnTimeItemChangeArgs e) 2: { 3: if (e.MoveState == MoveState.move) 4: { 5: DateTime newstart=e.TimeItem.Start+e.Diff; 6: DateTime newstop=e.TimeItem.Stop+e.Diff; 7: foreach(GanttRowItem gri in e.TimeItem.GanttRow.InternalIndexOfContent) 8: { 9: if (newstart<gri.TimeItem.Stop && newstop>gri.TimeItem.Start && gri.TimeItem!=e.TimeItem) 10: { 11: // collision 12: e.Allow=false; 13: return; 14: } 15: 16: } 17: } 18: } Stealing the scrollbarIf you want to have the scrollbar to the right of the time item area, you can achieve with very little effort. In this samples I added some panels and gave them color so that they would be visible. The yellow panel to the right is were I want my scrollbar. Like this: And the code that does the trick: 1: private void button1_Click(object sender, EventArgs e) 2: { 3: // Hi jack the Scrollbar to a new owner, and position it 4: gantt1.Grid.ScrollbarNodes.Parent = panelToHoldScroller; 5: gantt1.Grid.ScrollbarNodes.Top = 0; 6: gantt1.Grid.ScrollbarNodes.Left = 0; 7: // Catch all resize of the grid ... 8: gantt1.Grid.Resize += new EventHandler(Grid_Resize); 9: } 10: 11: void Grid_Resize(object sender, EventArgs e) 12: { 13: //... and update position if we are hi-jacked that is 14: if (gantt1.Grid.ScrollbarNodes.Parent == panelToHoldScroller) 15: { 16: gantt1.Grid.ScrollbarNodes.Top = 0; 17: gantt1.Grid.ScrollbarNodes.Left = 0; 18: } 19: 20: } Filter away exceptionsIn Eco the OCL parser uses exceptions to abort operations that fails. Since the different levels in the parsing logic catch this exception, acts on it and then throws it again, you normally get not 1 but 5 halts for every error discovered (it halts on throw). I have started to mask away these messages by adding the exception to the visual studio exception dialog like this. Sunday, April 18, 2010Better Silverlight and WPF performanceI been working on performance for the GTP.NET.SL products for Silverlight and WPF. I also took the Microsoft FamilyShow sample as a base and created some new WPF samples: This sample also show skinning by the use of DynamicResources: The main performance gain was by avoiding to resize UIElements that will not currently show on screen. Monday, April 12, 2010This blog has moved
This blog is now located at http://theblog.plexityhide.com/.
You will be automatically redirected in 30 seconds, or you may click here.
For feed subscribers, please update your feed subscriptions to
http://theblog.plexityhide.com/feeds/posts/default.
Subscribe to Posts [Atom] |
|
