public void AddBox(Canvas canvas, double x, double y, double? parentX, string ID, string name, string title, string department, string extension, bool root, bool subNodes, bool hiddenSubNodes, string field1, string field2, string field3, string field4, string field5, string dotted) { NodeBox nb = new NodeBox(drawingScale); nb.Name = ID; nb.ID = ID; nb.EmployeeName = name; //b.Data = Data; nb.Field1 = field1; nb.Field2 = field2; nb.Field3 = field3; nb.Field4 = field4; nb.Field5 = field5; if (string.Compare(dotted,"1").Equals(0)) { DoubleCollection db = new DoubleCollection(); db.Add(10); db.Add(2); nb.recBorder.StrokeDashArray = db; } // nb.Title = title; // nb.Department = department; nb.Extension = extension; nb.Width = buttonWidth; nb.Height = buttonHeight; nb.SetValue(Canvas.LeftProperty, x - nb.Width / 2); nb.SetValue(Canvas.TopProperty, y); // handle the double click actions _doubleClickTimer = new DispatcherTimer(); _doubleClickTimer.Interval = new TimeSpan(0, 0, 0, 0, 200); _doubleClickTimer.Tick += new EventHandler(delegate { _doubleClickTimer.Stop(); }); nb.MouseLeftButtonDown += new MouseButtonEventHandler(delegate { if (_doubleClickTimer.IsEnabled) { _doubleClickTimer.Stop(); btnClicked(ID); } else { _doubleClickTimer.Start(); } }); canvas.Children.Add(nb); // The line above the box if (root) DrawLine(canvas, x, y - minVerticalSpace, x, y); // Draw the horizontal line to the parent if (parentX != null) DrawLine(canvas, x, y - minVerticalSpace, Convert.ToDouble(parentX), y - minVerticalSpace); // Draw the line under the box if (subNodes || hiddenSubNodes) DrawLine(canvas, x, y + buttonHeight, x, y + buttonHeight + minVerticalSpace); // display the small plus if (hiddenSubNodes) { Button btn = new Button(); btn.Name = "plus" + ID; btn.FontSize = fontSize / 2; btn.Click += new RoutedEventHandler(btn_Click); btn.Height = plusButtonHeight; btn.Width = plusButtonWidth; btn.Content = "+"; btn.SetValue(Canvas.LeftProperty, x - btn.Width / 2); btn.SetValue(Canvas.TopProperty, y + buttonHeight + minVerticalSpace - minVerticalSpace / 2); canvas.Children.Add(btn); } }
public void AddBox(Canvas canvas, double x, double y, double?parentX, string ID, string name, string title, string department, string extension, bool root, bool subNodes, bool hiddenSubNodes, string field1, string field2, string field3, string field4, string field5, string dotted) { NodeBox nb = new NodeBox(drawingScale); nb.Name = ID; nb.ID = ID; nb.EmployeeName = name; //b.Data = Data; nb.Field1 = field1; nb.Field2 = field2; nb.Field3 = field3; nb.Field4 = field4; nb.Field5 = field5; if (string.Compare(dotted, "1").Equals(0)) { DoubleCollection db = new DoubleCollection(); db.Add(10); db.Add(2); nb.recBorder.StrokeDashArray = db; } // nb.Title = title; // nb.Department = department; nb.Extension = extension; nb.Width = buttonWidth; nb.Height = buttonHeight; nb.SetValue(Canvas.LeftProperty, x - nb.Width / 2); nb.SetValue(Canvas.TopProperty, y); // handle the double click actions _doubleClickTimer = new DispatcherTimer(); _doubleClickTimer.Interval = new TimeSpan(0, 0, 0, 0, 200); _doubleClickTimer.Tick += new EventHandler(delegate { _doubleClickTimer.Stop(); }); nb.MouseLeftButtonDown += new MouseButtonEventHandler(delegate { if (_doubleClickTimer.IsEnabled) { _doubleClickTimer.Stop(); btnClicked(ID); } else { _doubleClickTimer.Start(); } }); canvas.Children.Add(nb); // The line above the box if (root) { DrawLine(canvas, x, y - minVerticalSpace, x, y); } // Draw the horizontal line to the parent if (parentX != null) { DrawLine(canvas, x, y - minVerticalSpace, Convert.ToDouble(parentX), y - minVerticalSpace); } // Draw the line under the box if (subNodes || hiddenSubNodes) { DrawLine(canvas, x, y + buttonHeight, x, y + buttonHeight + minVerticalSpace); } // display the small plus if (hiddenSubNodes) { Button btn = new Button(); btn.Name = "plus" + ID; btn.FontSize = fontSize / 2; btn.Click += new RoutedEventHandler(btn_Click); btn.Height = plusButtonHeight; btn.Width = plusButtonWidth; btn.Content = "+"; btn.SetValue(Canvas.LeftProperty, x - btn.Width / 2); btn.SetValue(Canvas.TopProperty, y + buttonHeight + minVerticalSpace - minVerticalSpace / 2); canvas.Children.Add(btn); } }