Exemplo n.º 1
0
        /// <summary>
        /// Create a new instance of this class.
        /// </summary>
        public GraphUndoForm()
        {
            InitializeComponent();
            graphControl.FileOperationsEnabled = true;
            ZoomInButton.SetCommand(Commands.IncreaseZoom, graphControl);
            ZoomOutButton.SetCommand(Commands.DecreaseZoom, graphControl);
            FitContentButton.SetCommand(Commands.FitContent, graphControl);

            undoButton.SetCommand(Commands.Undo, graphControl);
            redoButton.SetCommand(Commands.Redo, graphControl);

            // File menu
            openToolStripMenuItem.SetCommand(Commands.Open, graphControl);
            saveAsToolStripMenuItem.SetCommand(Commands.Save, graphControl);
            // Edit menu
            undoToolStripMenuItem.SetCommand(Commands.Undo, graphControl);
            redoToolStripMenuItem.SetCommand(Commands.Redo, graphControl);
            cutToolStripMenuItem.SetCommand(Commands.Cut, graphControl);
            copyToolStripMenuItem.SetCommand(Commands.Copy, graphControl);
            pasteToolStripMenuItem.SetCommand(Commands.Paste, graphControl);
            deleteToolStripMenuItem.SetCommand(Commands.Delete, graphControl);

            // View menu
            zoomInToolStripMenuItem.SetCommand(Commands.IncreaseZoom, graphControl);
            zoomOutToolStripMenuItem.SetCommand(Commands.DecreaseZoom, graphControl);
            fitToSizeToolStripMenuItem.SetCommand(Commands.FitGraphBounds, graphControl);

            openButton.SetCommand(Commands.Open, graphControl);
            saveButton.SetCommand(Commands.Save, graphControl);
            cutButton.SetCommand(Commands.Cut, graphControl);
            copyButton.SetCommand(Commands.Copy, graphControl);
            pasteButton.SetCommand(Commands.Paste, graphControl);
        }
Exemplo n.º 2
0
        public void ZoomOut()
        {
            var currentZoom = ZoomText.Text;

            ZoomOutButton.Invoke();
            WaitUntilZoomTextChanged(currentZoom);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new instance of this class.
 /// </summary>
 public GraphCollapseForm()
 {
     InitializeComponent();
     // assign zoom commands
     ZoomInButton.SetCommand(Commands.IncreaseZoom, graphControl);
     ZoomOutButton.SetCommand((Commands.DecreaseZoom), graphControl);
     FitContentButton.SetCommand(Commands.FitContent, graphControl);
     // load description
     descriptionTextBox.LoadFile(new MemoryStream(Resources.description), RichTextBoxStreamType.RichText);
 }
 /// <summary>
 /// Automatically generated by Visual Studio.
 /// Wires up the UI components and adds a
 /// <see cref="GraphControl"/> to the form.
 /// </summary>
 public InteractiveOrganicForm()
 {
     InitializeComponent();
     // enable load and save
     graphControl.FileOperationsEnabled = true;
     // register zoom commands on buttons
     ZoomInButton.SetCommand(Commands.IncreaseZoom, graphControl);
     ZoomOutButton.SetCommand(Commands.DecreaseZoom, graphControl);
     FitContentButton.SetCommand(Commands.FitGraphBounds, graphControl);
 }
 private void ConfigureComponents()
 {
     // load description
     description.LoadFile(new MemoryStream(Resources.description), RichTextBoxStreamType.RichText);
     // set commands for buttons
     OpenButton.SetCommand(Commands.Open, graphControl);
     PrintButton.SetCommand(Commands.Print, graphControl);
     ZoomInButton.SetCommand(Commands.IncreaseZoom, graphControl);
     ZoomOutButton.SetCommand(Commands.DecreaseZoom, graphControl);
     FitContentButton.SetCommand(Commands.FitGraphBounds, graphControl.FitContentViewMargins, graphControl);
 }
Exemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void GLTileControl_MouseWheel(object sender, MouseEventArgs e)
 {
     if (e.Delta > 0)
     {
         ZoomInButton.PerformClick();
     }
     else if (e.Delta < 0)
     {
         ZoomOutButton.PerformClick();
     }
 }
Exemplo n.º 7
0
        protected override Size ArrangeContentOverride(Rect arrangeRect)
        {
            CalculateScrollBarValues();

            double legendHeight = Math.Max(0, arrangeRect.Size.Height - ScrollBarHeight);
            double legendY      = 0;

            if (IsSizingHeightToExpandableContent())
            {
                //use all the width, but only the height needed
                legendHeight = Math.Min(legendHeight, Legend.DesiredSize.Height);
            }
            double scrollbarY = legendHeight;

            if (!double.IsNaN(Height) || VerticalAlignment == VerticalAlignment.Stretch)
            {
                //VerticalContentAlignment matters only if space available is different from the needed space, which is only possible if
                //LegendX is stretched or its height is defined
                switch (VerticalContentAlignment)
                {
                case VerticalAlignment.Top:
                case VerticalAlignment.Stretch:
                    break;

                case VerticalAlignment.Center:
                    legendY    = (arrangeRect.Size.Height - legendHeight - ScrollBarHeight) / 2;
                    scrollbarY = (arrangeRect.Size.Height - legendHeight + ScrollBarHeight) / 2;
                    break;

                case VerticalAlignment.Bottom:
                    legendY    = arrangeRect.Size.Height - legendHeight - ScrollBarHeight;
                    scrollbarY = arrangeRect.Size.Height - ScrollBarHeight;
                    break;

                default:
                    throw new NotSupportedException();
                }
            }

            Legend.ArrangeBorderPadding(arrangeRect, 0, legendY, arrangeRect.Size.Width, legendHeight);
            ZoomOutButton.ArrangeBorderPadding(arrangeRect, 0, scrollbarY, ScrollBarHeight, ScrollBarHeight);
            ScrollBar.ArrangeBorderPadding(arrangeRect, ScrollBarHeight, scrollbarY, Math.Max(0, arrangeRect.Size.Width - 2 * ScrollBarHeight), ScrollBarHeight);
            ZoomInButton.ArrangeBorderPadding(arrangeRect, arrangeRect.Width - ScrollBarHeight, scrollbarY, ScrollBarHeight, ScrollBarHeight);


            //if (IsSizingHeightToExpandableContent()) {
            //  return new Size(arrangeRect.Size.Width, legendHeight + scrollHeight);
            //} else {
            return(arrangeRect.Size);
            //}
        }
Exemplo n.º 8
0
        protected override Size ArrangeContentOverride(Rect arrangeRect)
        {
            CalculateScrollBarValues();

            double legendWidth = arrangeRect.Size.Width - ScrollBarWidth;
            double legendX     = 0;

            if (IsSizingWidthToExpandableContent())
            {
                //use all the height, but only the width needed
                legendWidth = Math.Min(legendWidth, Legend.DesiredSize.Width);
            }
            double scrollbarX = legendWidth;

            if (!double.IsNaN(Width) || HorizontalAlignment == HorizontalAlignment.Stretch)
            {
                //HorizontalContentAlignment matters only if space available is different from the needed space, which is only possible if
                //LegendY is stretched or its width is defined
                switch (HorizontalContentAlignment)
                {
                case HorizontalAlignment.Left:
                case HorizontalAlignment.Stretch:
                    break;

                case HorizontalAlignment.Center:
                    legendX    = (arrangeRect.Size.Width - legendWidth - ScrollBarWidth) / 2;
                    scrollbarX = (arrangeRect.Size.Width + legendWidth - ScrollBarWidth) / 2;
                    break;

                case HorizontalAlignment.Right:
                    legendX    = arrangeRect.Size.Width - legendWidth - ScrollBarWidth;
                    scrollbarX = arrangeRect.Size.Width - ScrollBarWidth;
                    break;

                default:
                    throw new NotSupportedException();
                }
            }

            Legend.ArrangeBorderPadding(arrangeRect, legendX, 0, legendWidth, arrangeRect.Size.Height);
            ZoomInButton.ArrangeBorderPadding(arrangeRect, scrollbarX, 0, ScrollBarWidth, ScrollBarWidth);
            ScrollBar.ArrangeBorderPadding(arrangeRect, scrollbarX, ScrollBarWidth, ScrollBarWidth, Math.Max(0, arrangeRect.Size.Height - 2 * ScrollBarWidth));
            ZoomOutButton.ArrangeBorderPadding(arrangeRect, scrollbarX, arrangeRect.Height - ScrollBarWidth, ScrollBarWidth, ScrollBarWidth);


            //if (IsSizingHeightToExpandableContent()) {
            //  return new Size(arrangeRect.Size.Width, legendHeight + scrollHeight);
            //} else {
            return(arrangeRect.Size);
            //}
        }
Exemplo n.º 9
0
        /// <summary>
        /// Called upon loading of the form.
        /// This method initializes the graph and the input mode.
        /// </summary>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            description.LoadFile(new MemoryStream(Resources.description), RichTextBoxStreamType.RichText);
            // initialize the graph
            Graph.SetUndoEngineEnabled(true);
            graphControl.FileOperationsEnabled = true;
            ZoomInButton.SetCommand(Commands.IncreaseZoom, graphControl);
            ZoomOutButton.SetCommand(Commands.DecreaseZoom, graphControl);
            FitContentButton.SetCommand(Commands.FitContent, graphControl);

            SaveMenuItem.SetCommand(Commands.SaveAs, graphControl);
            OpenMenuItem.SetCommand(Commands.Open, graphControl);
            sampleFilesComboBox.SelectedIndex = 0;
        }
        /// <summary>
        /// Automatically generated by Visual Studio.
        /// Wires up the UI components and adds a
        /// <see cref="GraphControl"/> to the window.
        /// </summary>
        public NodeLabelingForm()
        {
            InitializeComponent();

            ZoomInButton.SetCommand(Commands.IncreaseZoom, graphControl);
            ZoomOutButton.SetCommand(Commands.DecreaseZoom, graphControl);
            FitContentButton.SetCommand(Commands.FitContent, graphControl);

            // View menu
            zoomInToolStripMenuItem.SetCommand(Commands.IncreaseZoom, graphControl);
            zoomOutToolStripMenuItem.SetCommand(Commands.DecreaseZoom, graphControl);
            fitGraphBoundsToolStripMenuItem.SetCommand(Commands.FitContent, graphControl);

            deleteButton.SetCommand(Commands.Delete, graphControl);
        }
Exemplo n.º 11
0
        //      ----------------

        protected override Size MeasureContentOverride(Size availableSize)
        {
            ScrollBar.Measure(availableSize);
            ScrollBarHeight = ScrollBar.DesiredSize.Height;
            Size buttonSize = new Size(ScrollBarHeight, ScrollBarHeight);

            ZoomInButton.Measure(buttonSize);
            ZoomOutButton.Measure(buttonSize);

            var availableLegendHeight = Math.Max(0, availableSize.Height - ScrollBarHeight);

            Legend.Measure(new Size(availableSize.Width, availableLegendHeight));

            //use scrollbar and Legend to deal with infinite space.
            return(new Size(Legend.DesiredSize.Width, ScrollBarHeight + Legend.DesiredSize.Height));
        }
Exemplo n.º 12
0
        //      ----------------

        protected override Size MeasureContentOverride(Size availableSize)
        {
            CalculateScrollBarValues();

            ScrollBar.Measure(availableSize);
            ScrollBarWidth = ScrollBar.DesiredSize.Width;
            Size buttonSize = new Size(ScrollBarWidth, ScrollBarWidth);

            ZoomInButton.Measure(buttonSize);
            ZoomOutButton.Measure(buttonSize);

            double availableLegendWidth = Math.Max(0, availableSize.Width - ScrollBarWidth);

            Legend.Measure(new Size(availableLegendWidth, availableSize.Height));

            //use scrollbarDockPanel or Legend to deal with infinite space.
            return(new Size(Legend.DesiredSize.Width + ScrollBarWidth, Legend.DesiredSize.Height));
        }
Exemplo n.º 13
0
        protected override void OnResize(EventArgs e)
        {
            var preferredSize = ScrollBar.GetPreferredSize(ClientSize);
            var buttonSize    = preferredSize.Height;

            ScrollBar.SmallChange = ClientSize.Width / 8;
            ScrollBar.LargeChange = ClientSize.Width / 2;
            ScrollBar.SetBounds(
                0, ClientSize.Height - preferredSize.Height,
                ClientSize.Width - (buttonSize * 2), preferredSize.Height
                );

            ZoomInButton.SetBounds(
                ScrollBar.Width, ScrollBar.Top, buttonSize, buttonSize
                );
            ZoomOutButton.SetBounds(
                ZoomInButton.Width + ZoomInButton.Left, ScrollBar.Top, buttonSize, buttonSize
                );

            base.OnResize(e);
        }
        /// <summary>
        /// Automatically generated by Visual Studio.
        /// Wires up the UI components and adds a
        /// <see cref="GraphControl"/> to the form.
        /// </summary>
        public IncrementalHierarchicLayoutForm()
        {
            InitializeComponent();

            // Configure the GraphMLIOHandler so that a layout runs automatically after loading a graph
            graphControl.GraphMLIOHandler.Parsed += delegate {
                if (!this.updateLayout)
                {
                    // after the file has been loaded - create an initial layout
                    graphControl.Graph.ApplyLayout(CreateLayout(), new HierarchicLayoutData {
                        LayerIndices = layerIndices
                    });

                    // update the layers
                    layerVisualCreator.UpdateLayers(graphControl.Graph, layerIndices);
                }
            };

            ZoomInButton.SetCommand(Commands.IncreaseZoom, graphControl);
            ZoomOutButton.SetCommand(Commands.DecreaseZoom, graphControl);

            FitContentButton.SetCommand(Commands.FitGraphBounds, graphControl);
        }
Exemplo n.º 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void GLTextureControl_MouseWheel(object sender, MouseEventArgs e)
        {
            if (e.Delta > 0)
            {
                ZoomInButton.PerformClick();
            }
            else if (e.Delta < 0)
            {
                ZoomOutButton.PerformClick();
            }



            Point loc       = e.Location;
            int   zoomvalue = int.Parse((string)ZoomBox.SelectedItem);
            Point point     = new Point(((e.Location.X - TextureOffset.X) / zoomvalue) - loc.X,
                                        (int)((e.Location.Y - TextureOffset.Y) / zoomvalue) - loc.Y);

            Point point2 = new Point(((e.Location.X - TextureOffset.X) / zoomvalue),
                                     (int)((e.Location.Y - TextureOffset.Y) / zoomvalue));

            //			TextureOffset.Offset(point);
        }
Exemplo n.º 16
0
 private void RegisterToolStripCommands()
 {
     ZoomInButton.SetCommand(Commands.IncreaseZoom, graphControl);
     ZoomOutButton.SetCommand(Commands.DecreaseZoom, graphControl);
     FitContentButton.SetCommand(Commands.FitContent, graphControl);
 }
Exemplo n.º 17
0
        /// <summary>
        /// Keys on the keyboard had been pressed.
        /// </summary>
        /// <param name="Sender">The sender of the event.</param>
        /// <param name="KeyEventArgs">The key arguments.</param>
        public void ProcessKeyboardEvents(Object Sender, KeyEventArgs KeyEventArgs)
        {
            switch (KeyEventArgs.Key)
            {
                #region Process arrow keys for moving the map

            case Key.Left:

                if (InvertedKeyBoard)
                {
                    MoveTo(this.ScreenOffset.X - KeyboardStepping, this.ScreenOffset.Y);
                }
                else
                {
                    MoveTo(this.ScreenOffset.X + KeyboardStepping, this.ScreenOffset.Y);
                }

                KeyEventArgs.Handled = true;
                break;

            case Key.Up:

                if (InvertedKeyBoard)
                {
                    MoveTo(this.ScreenOffset.X, this.ScreenOffset.Y + KeyboardStepping);
                }
                else
                {
                    MoveTo(this.ScreenOffset.X, this.ScreenOffset.Y - KeyboardStepping);
                }

                KeyEventArgs.Handled = true;
                break;

            case Key.Right:

                if (InvertedKeyBoard)
                {
                    MoveTo(this.ScreenOffset.X + KeyboardStepping, this.ScreenOffset.Y);
                }
                else
                {
                    MoveTo(this.ScreenOffset.X - KeyboardStepping, this.ScreenOffset.Y);
                }

                KeyEventArgs.Handled = true;
                break;

            case Key.Down:

                if (InvertedKeyBoard)
                {
                    MoveTo(this.ScreenOffset.X, this.ScreenOffset.Y - KeyboardStepping);
                }
                else
                {
                    MoveTo(this.ScreenOffset.X, this.ScreenOffset.Y + KeyboardStepping);
                }

                KeyEventArgs.Handled = true;
                break;

                #endregion

                #region Process + and - keys for zooming the map

            case Key.Add:
            case Key.OemPlus:

                ZoomInButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));

                KeyEventArgs.Handled = true;
                break;

            case Key.Subtract:
            case Key.OemMinus:

                ZoomOutButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));

                KeyEventArgs.Handled = true;
                break;

                #endregion

                #region Process other keys...

            case Key.I:

                InvertedKeyBoard = !InvertedKeyBoard;

                KeyEventArgs.Handled = true;
                break;

            case Key.M:

                LayerPanel1.IsExpaned = !LayerPanel1.IsExpaned;

                KeyEventArgs.Handled = true;
                break;

                #endregion
            }
        }