Beispiel #1
0
        private void Panel0_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Middle)
            {
                //Перемещение камеры вида
                _graph.MoveCamera(new Point(_mouseRightClickPoint.X - e.X, _mouseRightClickPoint.Y - e.Y));

                _mouseRightClickPoint = e.Location;

                Panel0.Invalidate();
            }
            else if (e.Button == MouseButtons.Left)
            {
                if (_graph.SelectedTableGraph != null)
                {
                    if (_graph.GraphState == GraphStateEnum.Move)
                    {
                        //Перемещение графа
                        _graph.MoveGraph(_graph.SelectedTableGraph, e.Location);
                        Panel0.Invalidate();
                    }
                    else if (_graph.GraphState == GraphStateEnum.EditSize)
                    {
                        //Изменение размера у графа
                        _graph.ResizeGraph(_mouseLeftClickPoint, e.Location, _oldSizeGraph);
                        Panel0.Invalidate();
                    }
                }
            }
            else if (_graph.GraphState == GraphStateEnum.EditSize)
            {
                //Показать курсор изменения
                _graph.ShowCursorSizeAndAutosetEditState(e.Location);
            }
        }
Beispiel #2
0
        private void AddGraph(bool isReferenceIn)
        {
            TableGraph tableGraph = null;

            var maxItem = (from v in _graph.ListGraphs orderby v.Id descending select v).FirstOrDefault();

            if (maxItem != null)
            {
                tableGraph = new TableGraph()
                {
                    Id        = maxItem.Id + 1,
                    Rectangle = new RectangleF(
                        new PointF(maxItem.Rectangle.X + TableGraph.GraphSize.Width * 2,
                                   maxItem.Rectangle.Y + TableGraph.GraphSize.Height * 2),
                        TableGraph.GraphSize),
                    IsReference = isReferenceIn
                };
            }
            else
            {
                tableGraph = new TableGraph()
                {
                    Rectangle   = new Rectangle(Point.Empty, TableGraph.GraphSize),
                    IsReference = isReferenceIn
                };
            }

            //Получим номер графа в текущем дереве
            var idNode     = 0;
            var countNodes = TreeViewP3?.SelectedNode?.Nodes.Count;

            if (countNodes != null)
            {
                foreach (var node in TreeViewP3.SelectedNode.Nodes)
                {
                    if (node != null)
                    {
                        idNode++;
                    }
                }
            }

            tableGraph.LayerTreeNodeOwner     = AddObjectToLayer(idNode.ToString());
            tableGraph.LayerTreeNodeOwner.Tag = tableGraph.Id;

            _graph.ListGraphs.Add(tableGraph);

            //Update object for repaint
            Panel0.Invalidate();
        }
Beispiel #3
0
        private void Panel0_DoubleClick(object sender, EventArgs e)
        {
            if (_graph.SelectedPreviousTableGraph != null)
            {
                _graph.SelectedPreviousTableGraph.LayerTreeNodeOwner.BackColor = Color.White;
                _graph.SelectedPreviousTableGraph.IsDrawGraphBorderLine        = false;
                Panel0.Invalidate();
            }

            if (_graph.SelectedTableGraph != null && _graph.SelectedTableGraph.IsReference && _graph.SelectedTableGraph.ParentIds.Count > 0)
            {
                TableGraph tg = _graph.ListGraphs.Find(match => match.Id == _graph.SelectedTableGraph.ParentIds[0]);
                ShowOneAndFocusLayer(tg.LayerTreeNodeOwner.Parent);
            }
            else if (_graph.SelectedTableGraph != null)
            {
                _graph.SelectedTableGraph.LayerTreeNodeOwner.BackColor = Color.LightSeaGreen;
                _graph.SelectedTableGraph.IsDrawGraphBorderLine        = true;
                _graph.SelectedTableGraph.LayerTreeNodeOwner.EnsureVisible();
                Panel0.Invalidate();
            }
        }
Beispiel #4
0
 private void TreeViewP3_AfterCheck(object sender, TreeViewEventArgs e)
 {
     Panel0.Invalidate();
 }
Beispiel #5
0
        private void Panel0_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (_graph.EditSizeState != EditSizeStateEnum.None)
                {
                    if (_graph.SelectedTableGraph != null)
                    {
                        _mouseLeftClickPoint = e.Location;
                        _oldSizeGraph        = _graph.SelectedTableGraph.Rectangle.Size;
                    }
                }
                else if (_graph.GraphState == GraphStateEnum.SetReference)
                {
                    //Прописываем ссылку на другой слой
                    TableGraph graph = _graph.SelectGraph(e.Location);
                    if (graph != null)
                    {
                        if (graph.IsReference)
                        {
                            if (graph.ParentIds.Count > 0)
                            {
                                TableGraph tg = _graph.ListGraphs.Find(match => match.Id == graph.ParentIds[0]);
                                MessageBox.Show($"Выбранная ссылка уже содержит переход на слой '{tg.LayerTreeNodeOwner.Parent.FullPath}'");
                            }
                            else
                            {
                                _graph.SelectedTableGraph.ParentIds.Clear();
                                _graph.SelectedTableGraph.ParentIds.Add(graph.Id);
                                graph.ParentIds.Clear();
                                graph.ParentIds.Add(_graph.SelectedTableGraph.Id);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Граф должен быть ссылкой.");
                        }
                    }
                    _graph.GraphState = GraphStateEnum.None;
                }
                else
                {
                    //Выделение графа
                    var oldTableGraph = _graph.SelectedTableGraph;
                    _graph.SelectedTableGraph = _graph.SelectGraph(e.Location);
                    if (_graph.SelectedTableGraph != null && oldTableGraph != null && _graph.SelectedTableGraph.Id != oldTableGraph.Id ||
                        oldTableGraph != null && _graph.SelectedTableGraph == null)
                    {
                        _graph.SelectedPreviousTableGraph = oldTableGraph;
                    }

                    SetDataToControlsP1(_graph.SelectedTableGraph);

                    if (_graph.SelectedTableGraph != null)
                    {
                        _graph.GraphState = GraphStateEnum.Move;
                    }
                    else
                    {
                        _graph.GraphState = GraphStateEnum.None;
                    }
                }
            }
            else if (e.Button == MouseButtons.Middle)
            {
                _mouseRightClickPoint = e.Location;
            }
            else if (e.Button == MouseButtons.Right)
            {
                if (_graph.SelectedTableGraph != null)
                {
                    _graph.GraphState = GraphStateEnum.ContextMenu;

                    if (_graph.SelectedTableGraph.IsReference)
                    {
                        ContextMenu c = new ContextMenu();
                        c.MenuItems.Add("Переход на другой слой", (ob, ev) =>
                        {
                            ContextMenu contextSub = new ContextMenu();
                            List <TreeNode> list   = GetTreeNodesLayer(true);

                            foreach (var node in list)
                            {
                                if (node.Tag != null)
                                {
                                    continue;
                                }
                                MenuItem item = contextSub.MenuItems.Add(node.Text, (obSubIn, evSubIn) =>
                                {
                                    TreeNode treeNode = (TreeNode)((MenuItem)obSubIn).Tag;
                                    ShowOneAndFocusLayer(treeNode);

                                    _graph.GraphState = GraphStateEnum.SetReference;
                                });
                                item.Tag = node;
                            }
                            contextSub.Show(Panel0, e.Location);
                        });
                        c.MenuItems.Add("Изменить размер", (ob, ev) =>
                        {
                            _graph.GraphState = GraphStateEnum.EditSize;
                        });
                        c.MenuItems.Add("Удалить граф", (ob, ev) =>
                        {
                            DeleteGraph(_graph.SelectedTableGraph);
                            Panel0.Invalidate();
                        });
                        c.Show(Panel0, e.Location);
                    }
                    else
                    {
                        TableGraph selectSecondGraph = _graph.SelectGraph(e.Location);
                        if (selectSecondGraph != null && selectSecondGraph != _graph.SelectedTableGraph)
                        {
                            ContextMenu c = new ContextMenu();
                            c.MenuItems.Add("Создать линию", (ob, ev) =>
                            {
                                if (!selectSecondGraph.ParentIds.Contains(_graph.SelectedTableGraph.Id))
                                {
                                    selectSecondGraph.ParentIds.Add(_graph.SelectedTableGraph.Id); Panel0.Invalidate();
                                }
                            });
                            c.Show(Panel0, e.Location);
                        }
                        else
                        {
                            ContextMenu c = new ContextMenu();
                            c.MenuItems.Add("Изменить размер", (ob, ev) =>
                            {
                                _graph.GraphState = GraphStateEnum.EditSize;
                            });
                            c.MenuItems.Add("Удалить граф", (ob, ev) =>
                            {
                                DeleteGraph(_graph.SelectedTableGraph);
                                Panel0.Invalidate();
                            });
                            c.MenuItems.Add("Удалить линии с этим графом", (ob, ev) =>
                            {
                                foreach (TableGraph tg in _graph.ListGraphs)
                                {
                                    if (tg.ParentIds.Contains(_graph.SelectedTableGraph.Id))
                                    {
                                        tg.ParentIds.Remove(_graph.SelectedTableGraph.Id);
                                    }
                                }

                                Panel0.Invalidate();
                            });
                            c.Show(Panel0, e.Location);
                        }
                    }
                }
            }
        }
Beispiel #6
0
 private void ButtonScaleMinus_Click(object sender, EventArgs e)
 {
     _graph.ScaleIncreaseView(-Settings.ScaleFactor);
     Panel0.Invalidate();
 }