コード例 #1
0
 /// <summary>
 /// Initializes the visualization of the grid feature.
 /// </summary>
 protected virtual void InitializeGrid()
 {
     grid = new GridVisualCreator(gridInfo);
     GraphControl.BackgroundGroup.AddChild(grid, CanvasObjectDescriptors.AlwaysDirtyInstance);
     // disable the grid by default
     grid.Visible = false;
 }
コード例 #2
0
        public DragAndDropForm()
        {
            InitializeComponent();

            description.LoadFile(new MemoryStream(Resources.description), RichTextBoxStreamType.RichText);

            InitializeStylesList();

            // add the visual grid
            const int gridWidth = 80;
            GridInfo  gridInfo  = new GridInfo(gridWidth);

            var grid = new GridVisualCreator(gridInfo);

            graphControl.BackgroundGroup.AddChild(grid, CanvasObjectDescriptors.AlwaysDirtyInstance);

            // Create and configure a GraphSnapContext to enable snapping
            var context = new GraphSnapContext
            {
                NodeToNodeDistance         = 30,
                NodeToEdgeDistance         = 20,
                SnapOrthogonalMovement     = false,
                SnapDistance               = 10,
                SnapSegmentsToSnapLines    = true,
                NodeGridConstraintProvider = new GridConstraintProvider <INode>(gridInfo),
                BendGridConstraintProvider = new GridConstraintProvider <IBend>(gridInfo),
                SnapBendsToSnapLines       = true,
                GridSnapType               = GridSnapTypes.All
            };

            // Create and register a graph editor input mode for editing the graph
            // in the canvas.
            var editorInputMode = new GraphEditorInputMode();

            editorInputMode.SnapContext             = context;
            editorInputMode.AllowGroupingOperations = true;

            ConfigureNodeDropInputMode(editorInputMode);

            // use the mode in our control
            graphControl.InputMode = editorInputMode;


            // Set the default node style to the style of the first item in the list of nodes
            if (styleListBox.Items.Count > 0)
            {
                INode node = styleListBox.Items[0] as INode;
                if (node != null)
                {
                    graphControl.Graph.NodeDefaults.Style = node.Style;
                }
            }
            graphControl.Graph.SetUndoEngineEnabled(true);

            // populate the control with some nodes
            CreateSampleGraph();

            featuresComboBox.Items.AddRange(functionOptions);
            featuresComboBox.SelectedIndex = 0;
        }
コード例 #3
0
        private void InitializeGrid()
        {
            gridSnapTypeComboBox.Items.AddRange(new object[]
            {
                GridSnapTypes.None,
                GridSnapTypes.HorizontalLines,
                GridSnapTypes.VerticalLines,
                GridSnapTypes.Lines,
                GridSnapTypes.GridPoints,
                GridSnapTypes.All,
            });
            gridSnapTypeComboBox.SelectedIndex = 4;

            // initialize grid
            gridInfo = new GridInfo {
                HorizontalSpacing = 50, VerticalSpacing = 50
            };
            grid = new GridVisualCreator(gridInfo);
            graphControl.BackgroundGroup.AddChild(grid);

            snapContext.NodeGridConstraintProvider = new GridConstraintProvider <INode>(gridInfo);
            snapContext.BendGridConstraintProvider = new GridConstraintProvider <IBend>(gridInfo);

            GridVisible  = gridButton.Checked;
            GridSnapType = (GridSnapTypes)gridSnapTypeComboBox.SelectedItem;
        }
        /// <summary>
        /// Initializes the visualization of the grid feature.
        /// </summary>
        private void InitializeGridVisual()
        {
            var grid = new GridVisualCreator(new GridInfo())
            {
                GridStyle           = GridStyle.Lines,
                Pen                 = new Pen(Color.FromArgb(255, 210, 210, 210), 0.1f),
                VisibilityThreshold = 10,
            };

            graphControl.BackgroundGroup.AddChild(grid, CanvasObjectDescriptors.AlwaysDirtyInstance);
        }
コード例 #5
0
        public DragAndDropWindow()
        {
            InitializeComponent();

            InitializeStylesList();

            // add the visual grid
            const int gridWidth = 80;
            GridInfo  gridInfo  = new GridInfo(gridWidth);

            var grid = new GridVisualCreator(gridInfo);

            graphControl.BackgroundGroup.AddChild(grid);

            // Create and configure a GraphSnapContext to enable snapping
            var context = new GraphSnapContext
            {
                NodeToNodeDistance         = 30,
                NodeToEdgeDistance         = 20,
                SnapOrthogonalMovement     = false,
                SnapDistance               = 10,
                SnapSegmentsToSnapLines    = true,
                NodeGridConstraintProvider = new GridConstraintProvider <INode>(gridInfo),
                BendGridConstraintProvider = new GridConstraintProvider <IBend>(gridInfo),
                SnapBendsToSnapLines       = true,
                GridSnapType               = GridSnapTypes.All
            };

            // Create and register a graph editor input mode for editing the graph
            // in the canvas.
            var editorInputMode = new GraphEditorInputMode {
                AllowGroupingOperations = true
            };

            editorInputMode.SnapContext = context;
            editorInputMode.OrthogonalEdgeEditingContext = new OrthogonalEdgeEditingContext();
            // use the style, size and labels of the currently selected palette node for newly created nodes
            editorInputMode.NodeCreator = GetNodeCreator(editorInputMode.NodeCreator);

            ConfigureNodeDropInputMode(editorInputMode);

            // use the mode in our control
            graphControl.InputMode = editorInputMode;

            // Enable undo
            graphControl.Graph.SetUndoEngineEnabled(true);

            // populate the control with some nodes
            CreateSampleGraph();

            featuresComboBox.ItemsSource   = functionOptions;
            featuresComboBox.SelectedIndex = 0;
        }
コード例 #6
0
        // Adds grid to the GraphControl and grid constraint provider to the snap context
        protected virtual void InitializeGrid(GraphSnapContext context)
        {
            GridInfo gridInfo = new GridInfo {
                HorizontalSpacing = 200, VerticalSpacing = 200
            };

            grid = new GridVisualCreator(gridInfo);
            GraphControl.BackgroundGroup.AddChild(grid, CanvasObjectDescriptors.AlwaysDirtyInstance);

            GraphControl.Invalidate();
            GraphControl.ZoomChanged     += delegate { GraphControl.Invalidate(); };
            GraphControl.ViewportChanged += delegate { GraphControl.Invalidate(); };

            context.NodeGridConstraintProvider = new GridConstraintProvider <INode>(gridInfo);
            context.BendGridConstraintProvider = new GridConstraintProvider <IBend>(gridInfo);
        }
コード例 #7
0
        public SnapLinesForm()
        {
            InitializeComponent();

            description.LoadFile(new MemoryStream(Resources.description), RichTextBoxStreamType.RichText);

            SetupOptions();

            snapContext = new GraphSnapContext();

            // intialize input mode
            graphEditorInputMode = new GraphEditorInputMode()
            {
                AllowGroupingOperations      = true,
                OrthogonalEdgeEditingContext = new OrthogonalEdgeEditingContext(),
                SnapContext = snapContext
            };
            GraphControl.InputMode = graphEditorInputMode;

            GraphControl.Graph.GetDecorator().EdgeDecorator.EdgeReconnectionPortCandidateProviderDecorator.SetImplementation(
                edge => true, EdgeReconnectionPortCandidateProviders.AllNodeCandidates);

            // initialize grid
            this.gridInfo = new GridInfo {
                HorizontalSpacing = 30, VerticalSpacing = 30
            };
            grid = new GridVisualCreator(gridInfo);
            GraphControl.BackgroundGroup.AddChild(grid);

            snapContext.NodeGridConstraintProvider = new GridConstraintProvider <INode>(gridInfo);
            snapContext.BendGridConstraintProvider = new GridConstraintProvider <IBend>(gridInfo);

            // initialize current values
            OnSnappingChanged(this, null);
            OnGridHorizontalWidthChanged(this, null);
            OnGridVerticalWidthChanged(this, null);

            GraphControl.Invalidate();
            GraphControl.ZoomChanged     += delegate { UpdateGrid(); };
            GraphControl.ViewportChanged += delegate { UpdateGrid(); };

            InitializeGraph();
        }
コード例 #8
0
        private void InitializeGrid()
        {
            // Initializes gridInfo which holds the basic information about the grid
            // Sets horizontal and vertical space between grid lines
            gridInfo = new GridInfo {
                HorizontalSpacing = 50, VerticalSpacing = 50, Origin = new PointD(12.5, 37)
            };
            // Creates grid visualization and adds it to GraphControl
            grid = new GridVisualCreator(gridInfo)
            {
                GridStyle = GridStyle.Lines, Pen = Pens.Red
            };
            graphControl.BackgroundGroup.AddChild(grid);

            // Sets constraint provider to make nodes and bends snap to grid
            graphSnapContext.NodeGridConstraintProvider = new GridConstraintProvider <INode>(gridInfo);
            graphSnapContext.BendGridConstraintProvider = new GridConstraintProvider <IBend>(gridInfo);

            GridVisible  = gridButton.Checked;
            GridSnapType = (GridSnapTypes)gridSnapTypeComboBox.SelectedItem;
        }
コード例 #9
0
        private void OnLoaded(object source, EventArgs args)
        {
            snapContext = new GraphSnapContext();

            // intialize input mode
            graphEditorInputMode = new GraphEditorInputMode()
            {
                AllowGroupingOperations      = true,
                OrthogonalEdgeEditingContext = new OrthogonalEdgeEditingContext(),
                SnapContext = snapContext
            };
            GraphControl.InputMode = graphEditorInputMode;

            GraphControl.Graph.GetDecorator().EdgeDecorator.EdgeReconnectionPortCandidateProviderDecorator.SetImplementation(
                edge => true, EdgeReconnectionPortCandidateProviders.AllNodeCandidates);

            // initialize grid
            this.gridInfo = new GridInfo {
                HorizontalSpacing = 30, VerticalSpacing = 30
            };
            grid = new GridVisualCreator(gridInfo);
            GraphControl.BackgroundGroup.AddChild(grid);

            snapContext.NodeGridConstraintProvider = new GridConstraintProvider <INode>(gridInfo);
            snapContext.BendGridConstraintProvider = new GridConstraintProvider <IBend>(gridInfo);

            // initialize current values
            OnSnappingChanged(this, null);
            OnGridHorizontalWidthChanged(this, null);
            OnGridVerticalWidthChanged(this, null);

            GraphControl.Invalidate();
            GraphControl.ZoomChanged     += delegate { UpdateGrid(); };
            GraphControl.ViewportChanged += delegate { UpdateGrid(); };

            InitializeGraph();
        }