public GraphCanvas(GraphControl graphControl, string startupFile) { InitializeComponent(); this.startupFile = startupFile; this.graphControl = graphControl; this.Loaded += new RoutedEventHandler(OnGraphCanvasLoaded); }
public FeedbackMessage(string iconPath, string message, GraphControl graphControl) { InitializeComponent(); this.graphControl = graphControl; this.Width = graphControl.FeedbackMsssagePanel.ActualWidth / 2; feedbackIcon.Source = new BitmapImage(new Uri(iconPath)); feedbackMessage.Text = message; if (iconPath == ResourceNames.Confirmation) { DispatcherTimer timer = new DispatcherTimer(); timer.Tick += new EventHandler(OnFeedBackMessageTimeout); timer.Interval = TimeSpan.FromSeconds(Configurations.ConfirmTimeSpan); timer.Start(); } PreviewMouseLeftButtonDown += OnFeedbackMessageMouseLeftButtonDown; }
public LibraryView(GraphControl graphControl) { InitializeComponent(); this.graphControl = graphControl; library = new LibraryItem(NodeType.None, String.Empty); library.AddChildItem(new LibraryItem(NodeType.None, Configurations.LoadingMessage)); libraryTree = new LibraryTreeViewModel(library, this); searchList = new List <SearchItem>(); backgroundSearcher = new BackgroundWorker(); backgroundSearcher.DoWork += new DoWorkEventHandler(BackgroundSearcherDoWork); backgroundSearcher.ProgressChanged += new ProgressChangedEventHandler(BackgroundSearcherProgressChanged); backgroundSearcher.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundSearcherRunWorkerCompleted); backgroundSearcher.WorkerReportsProgress = true; backgroundSearcher.WorkerSupportsCancellation = true; base.DataContext = libraryTree; }
public ExtendedPreview(String text, double width, double height, GraphControl graphControl, GraphVisualHost visualHost) { InitializeComponent(); this.graphControl = graphControl; this.visualHost = visualHost; this.InternalTextBox.Text = text; this.Focusable = true; this.IsEnabled = true; PreviewPanel.Focusable = true; PreviewPanel.IsEnabled = true; InternalTextBox.Focusable = true; InternalTextBox.IsEnabled = true; InternalTextBox.IsReadOnly = true; InternalTextBox.FontFamily = new FontFamily(Configurations.Font); InternalTextBox.FontWeight = FontWeights.Normal; InternalTextBox.FontSize = Configurations.InfoBubbleText; FormattedText formattedText = new FormattedText(text, Configurations.culture, FlowDirection.LeftToRight, Configurations.TypeFace, Configurations.InfoBubbleText, Configurations.PreviewBubbleExtendedTextColor); double textWidth = formattedText.WidthIncludingTrailingWhitespace + 2 * Configurations.InfoBubbleMargin + Configurations.PreviewBubbleExtendedScrollBarWidth; double extendedPreviewWidth; // the minimum width should allow the first value to be shown in one line if (text.Contains(',')) { double minimumTextWidth = double.MinValue; string tempText = text.Substring(0, text.IndexOf(',')); FormattedText tempFormattedText = new FormattedText(tempText, Configurations.culture, FlowDirection.LeftToRight, Configurations.TypeFace, Configurations.InfoBubbleText, Configurations.PreviewBubbleExtendedTextColor); minimumTextWidth = tempFormattedText.WidthIncludingTrailingWhitespace + 2 * Configurations.InfoBubbleMargin + Configurations.PreviewBubbleExtendedScrollBarWidth + 3; extendedPreviewWidth = Math.Max(width, minimumTextWidth); } else // if there is only one data member, need to fit in it { extendedPreviewWidth = Math.Max(width, textWidth); } //leave space for scrollbar and radial menu this.InternalTextBox.Width = extendedPreviewWidth - Configurations.PreviewBubbleExtendedScrollBarWidth; if (height > 0) { InternalTextBox.Height = height; } if (textWidth <= InternalTextBox.Width) { InternalTextBox.TextAlignment = TextAlignment.Center; InternalTextBox.Padding = new Thickness(Configurations.PreviewBubbleExtendedScrollBarWidth, Configurations.InfoBubbleMargin, 0, Configurations.InfoBubbleMargin); } else { InternalTextBox.MaxHeight = Configurations.InfoBubbleMaxHeight; InternalTextBox.TextWrapping = TextWrapping.Wrap; InternalTextBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; InternalTextBox.Padding = new Thickness(Configurations.InfoBubbleMargin, Configurations.InfoBubbleMargin, 0, Configurations.InfoBubbleMargin); } }
//Zoom to Fit Animation public ZoomAndPanAnimationHelper(double newOffsetX, double newOffsetY, double newScale, GraphVisualHost visualHost, GraphControl graphControl, bool captureMouse) { staticGraphControl = graphControl; this.visualHost = visualHost; staticScrollViewer = staticGraphControl.canvasScrollViewer; ZoomAndPanAnimationHelper.newOffsetX = newOffsetX; ZoomAndPanAnimationHelper.newOffsetY = newOffsetY; ZoomAndPanAnimationHelper.newScale = newScale; double offsetX = staticGraphControl.canvasScrollViewer.HorizontalOffset; double offsetY = staticGraphControl.canvasScrollViewer.VerticalOffset; double scale = staticGraphControl.scaleTransform.ScaleX; double shiftX = newOffsetX - offsetX; double shiftY = newOffsetY - offsetY; double scaleChange = newScale - scale; if (captureMouse) { Point mousePositionOnScreen = GetMousePosition(); mousePosition = new Point((mousePositionOnScreen.X + offsetX) / scale, (mousePositionOnScreen.Y + offsetY) / scale); this.currentCursor = staticGraphControl.GetCursor(); //System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.None; } if (Math.Abs(shiftX) < 0.05 && Math.Abs(shiftY) < 1 && Math.Abs(scaleChange) < 1) { return; } zoomAndPanStoryboard = new Storyboard(); if (Math.Abs(shiftX) >= 0.05) { DoubleAnimation scaleAnimation = new DoubleAnimation(); scaleAnimation.From = scale; scaleAnimation.To = newScale; scaleAnimation.Duration = TimeSpan.FromMilliseconds(Configurations.ShortAnimationTime); Storyboard.SetTarget(scaleAnimation, visualHost); Storyboard.SetTargetProperty(scaleAnimation, new PropertyPath("Scale")); zoomAndPanStoryboard.Children.Add(scaleAnimation); } if (Math.Abs(shiftX) >= 1) { DoubleAnimation xOffsetAnimation = new DoubleAnimation(); xOffsetAnimation.From = offsetX; xOffsetAnimation.To = newOffsetX; xOffsetAnimation.Duration = TimeSpan.FromMilliseconds(Configurations.ShortAnimationTime); Storyboard.SetTarget(xOffsetAnimation, visualHost); Storyboard.SetTargetProperty(xOffsetAnimation, new PropertyPath("XOffset")); zoomAndPanStoryboard.Children.Add(xOffsetAnimation); } if (Math.Abs(shiftY) >= 1) { DoubleAnimation yOffsetAnimation = new DoubleAnimation(); yOffsetAnimation.From = offsetY; yOffsetAnimation.To = newOffsetY; yOffsetAnimation.Duration = TimeSpan.FromMilliseconds(Configurations.ShortAnimationTime); Storyboard.SetTarget(yOffsetAnimation, visualHost); Storyboard.SetTargetProperty(yOffsetAnimation, new PropertyPath("YOffset")); zoomAndPanStoryboard.Children.Add(yOffsetAnimation); } zoomAndPanStoryboard.Completed += new EventHandler(OnAnimationCompleted); BeginAnimation(); }
//Ctrl/Shift Pan Animation public ZoomAndPanAnimationHelper(double newOffsetX, double newOffsetY, GraphVisualHost visualHost, GraphControl graphControl) { mousePosition = graphControl.canvasScrollViewer.TranslatePoint(GetMousePosition(), graphControl.CurrentGraphCanvas); this.currentCursor = graphControl.GetCursor(); //System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.None; staticGraphControl = graphControl; this.visualHost = visualHost; staticScrollViewer = staticGraphControl.canvasScrollViewer; ZoomAndPanAnimationHelper.newOffsetX = newOffsetX; ZoomAndPanAnimationHelper.newOffsetY = newOffsetY; ZoomAndPanAnimationHelper.newScale = double.MinValue; double offsetX = staticGraphControl.canvasScrollViewer.HorizontalOffset; double offsetY = staticGraphControl.canvasScrollViewer.VerticalOffset; double shiftX = newOffsetX - offsetX; double shiftY = newOffsetY - offsetY; if (Math.Abs(shiftX) < 0.01 && Math.Abs(shiftY) < 0.01) { return; } DoubleAnimation xOffsetAnimation = new DoubleAnimation(); xOffsetAnimation.From = offsetX; xOffsetAnimation.To = newOffsetX; xOffsetAnimation.Duration = TimeSpan.FromMilliseconds(Configurations.ShortAnimationTime); Storyboard.SetTarget(xOffsetAnimation, visualHost); Storyboard.SetTargetProperty(xOffsetAnimation, new PropertyPath("XOffset")); DoubleAnimation yOffsetAnimation = new DoubleAnimation(); yOffsetAnimation.From = offsetY; yOffsetAnimation.To = newOffsetY; yOffsetAnimation.Duration = TimeSpan.FromMilliseconds(Configurations.ShortAnimationTime); Storyboard.SetTarget(yOffsetAnimation, visualHost); Storyboard.SetTargetProperty(yOffsetAnimation, new PropertyPath("YOffset")); zoomAndPanStoryboard = new Storyboard(); zoomAndPanStoryboard.Children.Add(xOffsetAnimation); zoomAndPanStoryboard.Children.Add(yOffsetAnimation); zoomAndPanStoryboard.Completed += new EventHandler(OnAnimationCompleted); BeginAnimation(); }
public GraphVisualHost(GraphCanvas graphCanvas, GraphControl graphControl, string startupFile) { this.graphCanvas = graphCanvas; this.graphControl = graphControl; if (children == null) children = new VisualCollection(this); if (string.IsNullOrEmpty(startupFile)) this.graphController = ClassFactory.CreateGraphController(this); else { try { this.graphController = ClassFactory.CreateGraphController(this, startupFile); } catch (FileNotFoundException e) { MessageBox.Show(string.Format("FileNotFoundException: {0}", e.FileName)); } catch (IOException e) { MessageBox.Show(string.Format("IOException: {0}", e.Message)); } catch (InvalidDataException e) { MessageBox.Show(string.Format("InvalidDataException: {0}", e.Message)); } catch (FileVersionException e) { string message = string.Format(UiStrings.FutureFileVersionFmt, e.RequiredAppVersion); MessageBoxResult result = MessageBoxResult.None; string caption = UiStrings.IncompatibleVersion; result = MessageBox.Show(message, caption, MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { System.Diagnostics.Process.Start(CoreStrings.DesignScriptSiteUrl); } } catch (Exception e) { this.graphController = ClassFactory.CreateGraphController(this); this.graphControl.DisplayException(e); } finally { if (null == graphController) this.graphController = ClassFactory.CreateGraphController(this); } } DrawingVisual foregroundVisual = new DrawingVisual(); edgeVisuals.Add(foregroundVisual, 0); this.children.Add(foregroundVisual); if (!string.IsNullOrEmpty(startupFile)) this.ZoomToFit(); }
public ZoomAndPanControl(GraphControl graphControl) { InitializeComponent(); this.graphControl = graphControl; }
private void OnMainWindowLoaded(object sender, RoutedEventArgs e) { HostApplication app = Application.Current as HostApplication; graphControl = new GraphControl(app.IsInRecordingMode, app as IGraphEditorHostApplication); grid.Children.Add(graphControl); }
public Splash(GraphControl graphControl) { InitializeComponent(); this.graphControl = graphControl; }
public GraphCanvas(GraphControl graphControl) { InitializeComponent(); this.graphControl = graphControl; this.Loaded += new RoutedEventHandler(OnGraphCanvasLoaded); }
public GraphTabItem(GraphTabControl graphTabControl, GraphControl graphControl) { this.graphTabControl = graphTabControl; this.graphControl = graphControl; }