/// <summary> /// Delegate called when the mouse isup on the working canvas. /// </summary> /// <param name="pSender">The event sender.</param> /// <param name="pEventArgs">The event arguments.</param> private void OnWorkingCanvasMouseUp(object pSender, MouseButtonEventArgs pEventArgs) { // Release the mouse capture. this.WorkingCanvas.ReleaseMouseCapture(); this.WorkingCanvas.MouseMove -= this.OnWorkingCanvasMouseMove; this.WorkingCanvas.MouseUp -= this.OnWorkingCanvasMouseUp; this.WorkingCanvas.Visibility = Visibility.Collapsed; this.ConnectingLine.Visibility = Visibility.Collapsed; // Trying to create the final connection. if (this.mSourceConnector != null && this.mTargetConnector != null) { // Both defined means the connection can be created. Test have been made in the mouse move event handler. AGraphViewModel lGraphViewModel = this.ParentView.DataContext as AGraphViewModel; if (lGraphViewModel == null) { return; } PortViewModel lSourceViewModel = this.mSourceConnector.ParentPort.Content as PortViewModel; PortViewModel lTargetViewModel = this.mTargetConnector.ParentPort.Content as PortViewModel; // Requesting connection creation. lGraphViewModel.RequestConnectionCreation(lSourceViewModel, lTargetViewModel); } // Forget the reference on connectors. this.mSourceConnector = null; this.mTargetConnector = null; }
/// <summary> /// Delegate called when the is active button is clicked. /// </summary> /// <param name="pSender">The button sender.</param> /// <param name="pEventArgs">The event arguments.</param> private void OnIsActiveButtonClicked(object pSender, RoutedEventArgs pEventArgs) { AGraphViewModel lRootViewModel = this.GraphView.DataContext as AGraphViewModel; NodeViewModel lSelectedItem = this.GraphView.SelectedViewModels.OfType <NodeViewModel>().FirstOrDefault(); if (lSelectedItem != null) { lSelectedItem.IsActive = !lSelectedItem.IsActive; } }
/// <summary> /// Delegate called when the warning button is clicked. /// </summary> /// <param name="pSender">The button sender.</param> /// <param name="pEventArgs">The event arguments.</param> private void OnWarningsButtonClicked(object pSender, RoutedEventArgs pEventArgs) { AGraphViewModel lRootViewModel = this.GraphView.DataContext as AGraphViewModel; NodeViewModel lSelectedItem = this.GraphView.SelectedViewModels.OfType <NodeViewModel>().FirstOrDefault(); if (lSelectedItem != null) { if (lSelectedItem.Warnings == null) { string[] lWarnings = new string[] { "My first little warning.", "My second really really really really long warning." }; lSelectedItem.Warnings = lWarnings; } else { lSelectedItem.Warnings = null; } } }
/// <summary> /// Delegate called when the warning button is clicked. /// </summary> /// <param name="pSender">The button sender.</param> /// <param name="pEventArgs">The event arguments.</param> private void OnConnectionBrushButtonClicked(object pSender, RoutedEventArgs pEventArgs) { AGraphViewModel lRootViewModel = this.GraphView.DataContext as AGraphViewModel; ConnectionViewModel lSelectedItem = this.GraphView.SelectedViewModels.OfType <ConnectionViewModel>().FirstOrDefault(); if (lSelectedItem != null) { SolidColorBrush lDefaultBrush = new SolidColorBrush(Color.FromRgb(157, 157, 157)); SolidColorBrush lSelectedItemBrush = lSelectedItem.Brush as SolidColorBrush; if (lSelectedItemBrush == null || lSelectedItemBrush.Color == lDefaultBrush.Color) { lSelectedItem.Brush = new SolidColorBrush(Colors.Red); } else { lSelectedItem.Brush = lDefaultBrush; } } }