public void AddActionControl(ActionImplementation actImpl) { if (actImpl.Location.X == 0 && actImpl.Location.Y == 0) { actImpl.Location = new Point(-_translateTransform.X, -_translateTransform.Y); } ActionControl ac = new ActionControl(); Canvas.SetLeft(ac, actImpl.Location.X); Canvas.SetTop(ac, actImpl.Location.Y); ac.ActionImplementation = actImpl; actImpl.UIActionControl = ac; dragCanvas.Children.Add(ac); ac.PreviewMouseRightButtonDown += UserControl_PreviewMouseRightButtonDown; DragCanvas.SetCanBeDragged(ac, false); ac.Equal.MouseDown += new MouseButtonEventHandler(Output_MouseDown); ac.Smaller.MouseDown += new MouseButtonEventHandler(Output_MouseDown); ac.SmallerEqual.MouseDown += new MouseButtonEventHandler(Output_MouseDown); ac.Larger.MouseDown += new MouseButtonEventHandler(Output_MouseDown); ac.LargerEqual.MouseDown += new MouseButtonEventHandler(Output_MouseDown); ac.NotEqual.MouseDown += new MouseButtonEventHandler(Output_MouseDown); ac.EntryPoint.MouseDown += new MouseButtonEventHandler(EntryPoint_MouseDown); ac.LayoutUpdated += new EventHandler(ac_LayoutUpdated); ac.MouseEnter += new MouseEventHandler(ac_MouseEnter); ac.MouseLeave += new MouseEventHandler(ac_MouseLeave); ac.RenderTransform = _translateTransform; if (!(actImpl is ActionStart)) { ac.ContextMenu = itemContextMenu; } }
void Output_MouseDown(object sender, MouseButtonEventArgs e) { Grid g = sender as Grid; if (e.ClickCount == 1 && g != null) { if (_currentConnectionLine == null && g.Children.Count > 0) { ConnectionInfo ci = new ConnectionInfo(); ActionControl ac = FindParent <ActionControl>(g); Line el = new Line(); el.RenderTransform = _translateTransform; Point p = g.TranslatePoint(new Point(g.ActualWidth / 2, g.ActualHeight), dragCanvas); el.X1 = p.X - _translateTransform.X; el.Y1 = p.Y - _translateTransform.Y; p = e.GetPosition(dragCanvas); el.X2 = p.X - _translateTransform.X; el.Y2 = p.Y - _translateTransform.Y; el.Stroke = (g.Children[0] as Label).Foreground; el.Cursor = Cursors.Pen; el.StrokeThickness = 2.0; _currentConnectionLine = el; dragCanvas.Children.Insert(0, el); DragCanvas.SetCanBeDragged(el, false); ci.ConnectionLine = el; ci.StartActionControl = ac; ci.StartConnector = g; _connectionInfo.Add(ci); el.MouseEnter += new MouseEventHandler(el_MouseEnter); el.MouseLeave += new MouseEventHandler(el_MouseLeave); el.ContextMenu = itemContextMenu; Label lb = new Label(); ci.Label = lb; lb.FontWeight = FontWeights.Bold; lb.Background = new SolidColorBrush(Colors.LightGray); if (_showConnectionLabels) { lb.Visibility = System.Windows.Visibility.Visible; } else { lb.Visibility = System.Windows.Visibility.Hidden; } lb.RenderTransform = _translateTransform; dragCanvas.Children.Insert(0, lb); DragCanvas.SetCanBeDragged(lb, false); el.LayoutUpdated += new EventHandler(el_LayoutUpdated); PositionConnectionLineLabel(ci); } else { dragCanvas.Children.Remove(_currentConnectionLine); ConnectionInfo ci = (from c in _connectionInfo where c.ConnectionLine == _currentConnectionLine select c).FirstOrDefault(); _connectionInfo.Remove(ci); dragCanvas.Children.Remove(ci.Label); _currentConnectionLine = null; } } }
void AddFormatOptions() { dataRecodingControl = new DataRecodingControl(dashboardHelper); dataRecodingControl.MouseEnter += new MouseEventHandler(dataRecodingControl_MouseEnter); dataRecodingControl.MouseLeave += new MouseEventHandler(dataRecodingControl_MouseLeave); dataRecodingControl.Loaded += new RoutedEventHandler(dataRecodingControl_Loaded); MapContainer.Children.Add(dataRecodingControl); DragCanvas.SetCanBeDragged(dataRecodingControl, false); }
void AddSelectionCriteria() { dataFilteringControl = new DataFilteringControl(dashboardHelper); dataFilteringControl.MouseEnter += new MouseEventHandler(selectionCriteriaControl_MouseEnter); dataFilteringControl.MouseLeave += new MouseEventHandler(selectionCriteriaControl_MouseLeave); dataFilteringControl.SelectionCriteriaChanged += new EventHandler(selectionCriteriaControl_SelectionCriteriaChanged); dataFilteringControl.Loaded += new RoutedEventHandler(dataFilteringControl_Loaded); MapContainer.Children.Add(dataFilteringControl); DragCanvas.SetCanBeDragged(dataFilteringControl, false); }
private void addConnector(ActionImplementation a, ActionImplementation c, Grid g) { ConnectionInfo ci = new ConnectionInfo(); ci.StartActionControl = a.UIActionControl; ci.StartConnector = g; ci.EndActionControl = c.UIActionControl; ci.EndConnector = c.UIActionControl.EntryPoint; Line el = new Line(); el.Cursor = Cursors.Pen; el.RenderTransform = _translateTransform; Point p = g.TranslatePoint(new Point(g.ActualWidth / 2, g.ActualHeight), dragCanvas); el.X1 = p.X; el.Y1 = p.Y; p = c.UIActionControl.EntryPoint.TranslatePoint(new Point(c.UIActionControl.EntryPoint.ActualWidth / 2, c.UIActionControl.EntryPoint.ActualHeight), dragCanvas); el.X2 = p.X; el.Y2 = p.Y; el.Stroke = (g.Children[0] as Label).Foreground; el.StrokeThickness = 2.0; dragCanvas.Children.Insert(0, el); DragCanvas.SetCanBeDragged(el, false); ci.ConnectionLine = el; _connectionInfo.Add(ci); el.MouseEnter += new MouseEventHandler(el_MouseEnter); el.MouseLeave += new MouseEventHandler(el_MouseLeave); el.ContextMenu = itemContextMenu; Label lb = new Label(); ci.Label = lb; lb.FontWeight = FontWeights.Bold; lb.Background = new SolidColorBrush(Colors.LightGray); if (_showConnectionLabels) { lb.Visibility = System.Windows.Visibility.Visible; } else { lb.Visibility = System.Windows.Visibility.Hidden; } lb.RenderTransform = _translateTransform; dragCanvas.Children.Add(lb); DragCanvas.SetCanBeDragged(lb, false); el.LayoutUpdated += new EventHandler(el_LayoutUpdated); PositionConnectionLineLabel(ci); }
private void Grid_MouseLeave_1(object sender, MouseEventArgs e) { DragCanvas.SetCanBeDragged(this, false); }
private void Grid_MouseEnter_1(object sender, MouseEventArgs e) { DragCanvas.SetCanBeDragged(this, true); }