예제 #1
0
        void Button_Click(object sender, RoutedEventArgs e)
        {
            if (buttonStateIsNew) // new
            {
                IVertex baseVertex = Vertex.Get(@"BaseEdge:\From:");
                IVertex meta       = Vertex.Get(@"BaseEdge:\Meta:");

                IVertex newVertex = VertexOperations.AddInstanceByEdgeVertex(baseVertex, meta);

                GraphUtil.CreateOrReplaceEdge(Vertex.Get(@"BaseEdge:"), MinusZero.Instance.Root.Get(@"System\Meta\ZeroTypes\Edge\To"), newVertex);

                if (newVertex != null)
                {
                    ButtonSetOpen();
                }
            }
            else // open
            {
                FormVisualiser v = (FormVisualiser)UIWpf.getParentFormVisualiser(this);

                if (v != null)
                {
                    Edge.CopyAndReplaceEdge(v.Vertex, "BaseEdge", Vertex.Get("BaseEdge:"));
                }
                else
                {
                    //BaseCommands.Open(Vertex.Get("BaseEdge:"), null); // want Form visualiser
                    BaseCommands.OpenFormVisualiser(Vertex.Get("BaseEdge:"));
                }
            }
        }
예제 #2
0
 void OnLoad(object sender, RoutedEventArgs e)
 {
     if (!UIWpf.HasParentsGotContextMenu(this))
     {
         this.ContextMenu = new m0ContextMenu(this);
     }
 }
예제 #3
0
        private void dndPreviewMouseMove(object sender, MouseEventArgs e)
        {
            Point  mousePos = e.GetPosition(this);
            Vector diff     = dndStartPoint - mousePos;

            var    headersPresenter   = UIWpf.FindVisualChild <DataGridColumnHeadersPresenter>(this);
            double headerActualHeight = headersPresenter.ActualHeight;

            if (mousePos.Y <= headerActualHeight) // if header
            {
                e.Handled = false;
                return;
            }

            if (hasButtonBeenDown && isDraggin == false &&
                !UIWpf.IsMouseOverScrollbar(sender, dndStartPoint) &&
                (e.LeftButton == MouseButtonState.Pressed) && (
                    (Math.Abs(diff.X) > Dnd.MinimumHorizontalDragDistance) ||
                    (Math.Abs(diff.Y) > Dnd.MinimumVerticalDragDistance)))
            {
                isDraggin = true;

                RestoreSelectedVertexes();

                IVertex dndVertex = MinusZero.Instance.CreateTempVertex();

                if (Vertex.Get(@"SelectedEdges:\") != null)
                {
                    foreach (IEdge ee in Vertex.GetAll(@"SelectedEdges:\"))
                    {
                        dndVertex.AddEdge(null, ee.To);
                    }
                }
                else
                {
                    IVertex v = GetEdgeByLocation(dndStartPoint);
                    if (v != null)
                    {
                        dndVertex.AddEdge(null, v);
                    }
                }

                if (dndVertex.Count() > 0)
                {
                    DataObject dragData = new DataObject("Vertex", dndVertex);
                    dragData.SetData("DragSource", this);

                    Dnd.DoDragDrop(this, dragData);

                    e.Handled = true;
                }

                isDraggin = false;
            }

            // e.Handled = true;
        }
예제 #4
0
        protected override void OnClick()
        {
            FormVisualiser v = (FormVisualiser)UIWpf.getParentFormVisualiser(this);

            if (v != null)
            {
                Edge.ReplaceEdgeEdges(v.Vertex.Get("BaseEdge:"), BaseEdge);
            }
            else
            {
                IVertex v2 = MinusZero.Instance.CreateTempVertex();
                Edge.AddEdgeEdges(v2, BaseEdge);

                //BaseCommands.Open(v2,null); // want Form Visuliser always
                BaseCommands.OpenFormVisualiser(v2);
            }
        }
예제 #5
0
        public IVertex GetEdgeByLocation(Point point)
        {
            var    headersPresenter   = UIWpf.FindVisualChild <DataGridColumnHeadersPresenter>(ThisDataGrid);
            double headerActualHeight = headersPresenter.ActualHeight;

            if (point.Y <= headerActualHeight) // if header
            {
                return(null);
            }

            foreach (var item in ThisDataGrid.Items)
            {
                var row = ThisDataGrid.ItemContainerGenerator.ContainerFromItem(item) as DataGridRow;

                if (row != null)
                {
                    DataGridRow roww = (DataGridRow)row;

                    if (VisualTreeHelper.HitTest(roww, TranslatePoint(point, roww)) != null)
                    {
                        if (point.X >= ThisDataGrid.Columns.First().ActualWidth&& roww.IsEditing)
                        {
                            return(null);
                        }

                        IVertex v = MinusZero.Instance.CreateTempVertex();
                        Edge.AddEdgeEdges(v, (IEdge)roww.Item);
                        return(v);
                    }
                }
            }

            // DO WANT THIS FEATURE ?
            //
            if (GeneralUtil.CompareStrings(MinusZero.Instance.Root.Get(@"User\CurrentUser:\Settings:\AllowBlankAreaDragAndDrop:").Value, "StartAndEnd"))
            {
                return(Vertex.Get("BaseEdge:"));
            }
            else
            {
                return(null);
            }
        }
예제 #6
0
        private void dndPreviewMouseMove(object sender, MouseEventArgs e)
        {
            Point  mousePos = e.GetPosition(this);
            Vector diff     = dndStartPoint - mousePos;

            if (hasButtonBeenDown &&
                !UIWpf.IsMouseOverScrollbar(sender, dndStartPoint) &&
                (e.LeftButton == MouseButtonState.Pressed) && (
                    (Math.Abs(diff.X) > Dnd.MinimumHorizontalDragDistance) ||
                    (Math.Abs(diff.Y) > Dnd.MinimumVerticalDragDistance)))
            {
                isDraggin = true;

                IVertex dndVertex = MinusZero.Instance.CreateTempVertex();

                if (Vertex.Get(@"SelectedEdges:\") != null)
                {
                    foreach (IEdge ee in Vertex.GetAll(@"SelectedEdges:\"))
                    {
                        dndVertex.AddEdge(null, ee.To);
                    }
                }
                else
                {
                    IVertex v = GetEdgeByLocation(dndStartPoint);
                    if (v != null)
                    {
                        dndVertex.AddEdge(null, v);
                    }
                }

                if (dndVertex.Count() > 0)
                {
                    DataObject dragData = new DataObject("Vertex", dndVertex);
                    dragData.SetData("DragSource", this);

                    Dnd.DoDragDrop(this, dragData);
                }

                isDraggin = false;
            }
        }
예제 #7
0
        } // to be called after Vertex is setted up

        public virtual void VisualiserUpdate()
        {
            double sizeX = GraphUtil.GetDoubleValue(Vertex.Get("SizeX:"));
            double sizeY = GraphUtil.GetDoubleValue(Vertex.Get("SizeY:"));

            if (sizeX != GraphUtil.NullDouble && sizeY != GraphUtil.NullDouble)
            {
                Width  = sizeX;
                Height = sizeY;
            }

            if (Vertex.Get("BackgroundColor:") != null)
            {
                BackgroundColor = UIWpf.GetBrushFromColorVertex(Vertex.Get("BackgroundColor:"));
            }
            else
            {
                BackgroundColor = (Brush)FindResource("0BackgroundBrush");
            }

            if (Vertex.Get("ForegroundColor:") != null)
            {
                ForegroundColor = UIWpf.GetBrushFromColorVertex(Vertex.Get("ForegroundColor:"));
            }
            else
            {
                ForegroundColor = (Brush)FindResource("0ForegroundBrush");
            }

            if (GraphUtil.GetDoubleValue(Vertex.Get("LineWidth:")) != GraphUtil.NullDouble)
            {
                LineWidth = GraphUtil.GetDoubleValue(Vertex.Get("LineWidth:"));
            }

            SetBackAndForeground();
        }
예제 #8
0
 void OnLoad(object sender, RoutedEventArgs e)
 {
     UIWpf.SetWindowPosition(this, _mousePosition);
 }
예제 #9
0
        public virtual void DoCreateDiagramLine(DiagramItemBase toItem)
        {
            IVertex toEdge = toItem.Vertex.Get("BaseEdge:");

            IVertex r = m0.MinusZero.Instance.Root;

            IVertex v = m0.MinusZero.Instance.CreateTempVertex();


            foreach (IEdge def in Vertex.GetAll(@"Definition:\DiagramLineDefinition:"))
            {
                bool CreateEdgeOnly = false;

                if (GraphUtil.GetValueAndCompareStrings(def.To.Get("CreateEdgeOnly:"), "True"))
                {
                    CreateEdgeOnly = true;
                }

                foreach (IEdge e in Vertex.GetAll(@"BaseEdge:\To:\" + def.To.Get("EdgeTestQuery:")))
                {
                    bool canAdd = true;

                    if (def.To.Get("ToDiagramItemTestQuery:") != null && toItem.Vertex.Get((string)def.To.Get("ToDiagramItemTestQuery:").Value) == null)
                    {
                        canAdd = false;
                    }

                    if (e.To.Get(@"$EdgeTarget:") != null &&
                        !GeneralUtil.CompareStrings(e.To.Get(@"$EdgeTarget:").Value, "Vertex") && // Vertexes do not have $Is:Vertex
                        toEdge.Get(@"To:\$Is:" + (string)e.To.Get(@"$EdgeTarget:").Value) == null)
                    {
                        canAdd = false;
                    }

                    if (CreateEdgeOnly == false &&
                        e.To.Get(@"$VertexTarget:") != null &&
                        toEdge.Get(@"To:\$Is:" + (string)e.To.Get(@"$VertexTarget:").Value) == null)
                    {
                        canAdd = false;
                    }

                    if (canAdd)
                    {
                        AddNewLineOption(v, def, e);
                    }
                }

                if (GeneralUtil.CompareStrings(def.To.Value, "Edge"))// Vertex\Edge
                {
                    foreach (IEdge e in r.Get(@"System\Meta\Base\Vertex"))
                    {
                        AddNewLineOption(v, def, e);
                    }
                }

                if (GeneralUtil.CompareStrings(def.To.Get("EdgeTestQuery:"), "$EdgeTarget")) // $EdgeTarget is not present as there is no inheritance from Vertex
                {
                    AddNewLineOption(v, def, GraphUtil.FindEdgeByToVertex(r.Get(@"System\Meta\Base\Vertex"), "$EdgeTarget"));
                }
            }

            if (v.Count() == 0)
            {
                MinusZero.Instance.DefaultShow.ShowInfo("There is no diagram line definition matching selected source and target items.");
            }

            IVertex info = m0.MinusZero.Instance.CreateTempVertex();

            info.Value = "choose diagram line:";


            Point mousePosition = UIWpf.GetMousePosition();

            IVertex a = MinusZero.Instance.DefaultShow.SelectDialog(info, v, mousePosition);

            if (a != null)
            {
                IVertex test = VertexOperations.TestIfNewEdgeValid(Vertex.Get(@"BaseEdge:\To:"), a.Get("OptionEdge:"), toEdge.Get("To:"));

                if (test == null)
                {
                    bool?ForceShowEditForm = null;      // ForceShowEditForm

                    if (a.Get(@"OptionDiagramLineDefinition:\ForceShowEditForm:") != null)
                    {
                        if (GeneralUtil.CompareStrings(a.Get(@"OptionDiagramLineDefinition:\ForceShowEditForm:"), "True"))
                        {
                            ForceShowEditForm = true;
                        }

                        if (GeneralUtil.CompareStrings(a.Get(@"OptionDiagramLineDefinition:\ForceShowEditForm:"), "False"))
                        {
                            ForceShowEditForm = false;
                        }
                    }

                    bool CreateEdgeOnly = false;     // CreateEdgeOnly

                    if (GraphUtil.GetValueAndCompareStrings(a.Get(@"OptionDiagramLineDefinition:\CreateEdgeOnly:"), "True"))
                    {
                        CreateEdgeOnly = true;
                    }


                    CanAutomaticallyAddEdges = false;     // for VertexChange
                    IEdge edge = VertexOperations.AddEdgeOrVertexByMeta(Vertex.Get(@"BaseEdge:\To:"), a.Get("OptionEdge:"), toEdge.Get("To:"), mousePosition, CreateEdgeOnly, ForceShowEditForm);
                    CanAutomaticallyAddEdges = true;

                    AddDiagramLineVertex(edge, a.Get(@"OptionDiagramLineDefinition:"), toItem);
                }
                else
                {
                    MinusZero.Instance.DefaultShow.ShowInfo("Adding new diagram line  \"" + a.Value + "\" is not possible.\n\n" + test.Value);
                }
            }
        }
예제 #10
0
        protected void CreateComposite()
        {
            Children.Clear();

            if (!GraphUtil.IsNullNumber <T>(MinValue) && !GraphUtil.IsNullNumber <T>(MaxValue))
            {
                IsRanged = true;

                ColumnDefinitions.Clear();

                ColumnDefinition col0 = new ColumnDefinition();

                T test = default(T);

                if (test is float)
                {
                    col0.Width = new GridLength(UIWpf.GetHorizontalSizeOfCharacterString((int)Math.Ceiling(2 * Math.Log10(Math.Max(GraphUtil.ToInt <T>(MinValue), GraphUtil.ToInt <T>(MaxValue))))));
                }
                else
                {
                    col0.Width = new GridLength(UIWpf.GetHorizontalSizeOfCharacterString((int)Math.Ceiling(Math.Log10(Math.Max(GraphUtil.ToInt <T>(MinValue), GraphUtil.ToInt <T>(MaxValue))))));
                }

                this.ColumnDefinitions.Add(col0);

                ColumnDefinition col1 = new ColumnDefinition();
                col1.Width = new GridLength(5);
                this.ColumnDefinitions.Add(col1);

                ColumnDefinition col2 = new ColumnDefinition();
                col2.Width = new GridLength(1, GridUnitType.Star);
                this.ColumnDefinitions.Add(col2);

                TextBox = new TextBox();
                Grid.SetColumn(TextBox, 0);
                TextBox.TextChanged += new TextChangedEventHandler(OnBoxTextChanged);
                Children.Add(TextBox);

                Slider                     = new MySlider();
                Slider.MinWidth            = 60; //////////////////////////////////////// !!!!!!!!!!!
                Slider.Minimum             = GraphUtil.ToDouble <T>(MinValue);
                Slider.Maximum             = GraphUtil.ToDouble <T>(MaxValue);
                Slider.IsSnapToTickEnabled = true;
                Slider.Foreground          = (Brush)FindResource("0GrayBrush");
                Slider.TickFrequency       = 1;
                Slider.TickPlacement       = TickPlacement.BottomRight;
                Grid.SetColumn(Slider, 2);
                Slider.ValueChanged += new RoutedPropertyChangedEventHandler <double>(OnSliderValueChanged);

                if (Vertex.Get(@"BaseEdge:\Meta:\$UpdateAfterInteractionEnd:") != null)
                {
                    Slider.FireValueChangedOnlyIfDraggingFinished = true;
                }


                Children.Add(Slider);
            }
            else
            {
                TextBox              = new TextBox();
                TextBox.TextChanged += new TextChangedEventHandler(OnBoxTextChanged);
                Children.Add(TextBox);
            }
        }
예제 #11
0
        protected virtual void UpdateLineEnds()
        {
            if (Vertex.Get("BackgroundColor:") != null)
            {
                BackgroundColor = UIWpf.GetBrushFromColorVertex(Vertex.Get("BackgroundColor:"));
            }
            else
            {
                BackgroundColor = (Brush)Line.FindResource("0BackgroundBrush");
            }

            if (Vertex.Get("ForegroundColor:") != null)
            {
                ForegroundColor = UIWpf.GetBrushFromColorVertex(Vertex.Get("ForegroundColor:"));
            }
            else
            {
                ForegroundColor = (Brush)Line.FindResource("0ForegroundBrush");
            }

            LineEndings.Stroke = ForegroundColor;
            Line.Stroke        = ForegroundColor;
            Label.Foreground   = ForegroundColor;


            string StartAnchor = (string)GraphUtil.GetValue(Vertex.Get(@"StartAnchor:"));
            string EndAnchor   = (string)GraphUtil.GetValue(Vertex.Get(@"EndAnchor:"));

            if (StartAnchor == "Straight")
            {
                LineEndings.StartEnding = LineEndEnum.Straight;
                Line.StartEnding        = LineEndEnum.Straight;
            }

            if (EndAnchor == "Straight")
            {
                LineEndings.EndEnding = LineEndEnum.Straight;
                Line.EndEnding        = LineEndEnum.Straight;
            }

            if (StartAnchor == "Arrow")
            {
                LineEndings.StartEnding = LineEndEnum.Arrow;
                Line.StartEnding        = LineEndEnum.Arrow;
            }

            if (EndAnchor == "Arrow")
            {
                LineEndings.EndEnding = LineEndEnum.Arrow;
                Line.EndEnding        = LineEndEnum.Arrow;
            }

            if (StartAnchor == "Triangle")
            {
                LineEndings.StartEnding = LineEndEnum.Triangle;
                Line.StartEnding        = LineEndEnum.Triangle;

                FillBrush          = BackgroundColor;
                HighlightFillBrush = BackgroundColor;
            }

            if (EndAnchor == "Triangle")
            {
                LineEndings.EndEnding = LineEndEnum.Triangle;
                Line.EndEnding        = LineEndEnum.Triangle;

                FillBrush          = BackgroundColor;
                HighlightFillBrush = BackgroundColor;
            }

            if (StartAnchor == "FilledTriangle")
            {
                LineEndings.StartEnding = LineEndEnum.FilledTriangle;
                Line.StartEnding        = LineEndEnum.FilledTriangle;

                FillBrush          = ForegroundColor;
                HighlightFillBrush = (Brush)LineEndings.FindResource("0LightHighlightBrush");
            }

            if (EndAnchor == "FilledTriangle")
            {
                LineEndings.EndEnding = LineEndEnum.FilledTriangle;
                Line.EndEnding        = LineEndEnum.FilledTriangle;

                FillBrush          = ForegroundColor;
                HighlightFillBrush = (Brush)LineEndings.FindResource("0LightHighlightBrush");
            }

            if (StartAnchor == "Diamond")
            {
                LineEndings.StartEnding = LineEndEnum.Diamond;
                Line.StartEnding        = LineEndEnum.Diamond;

                FillBrush          = BackgroundColor;
                HighlightFillBrush = BackgroundColor;
            }

            if (EndAnchor == "Diamond")
            {
                LineEndings.EndEnding = LineEndEnum.Diamond;
                Line.EndEnding        = LineEndEnum.Diamond;

                FillBrush          = BackgroundColor;
                HighlightFillBrush = BackgroundColor;
            }

            if (StartAnchor == "FilledDiamond")
            {
                LineEndings.StartEnding = LineEndEnum.FilledDiamond;
                Line.StartEnding        = LineEndEnum.FilledDiamond;

                FillBrush          = ForegroundColor;
                HighlightFillBrush = (Brush)LineEndings.FindResource("0LightHighlightBrush");
            }

            if (EndAnchor == "FilledDiamond")
            {
                LineEndings.EndEnding = LineEndEnum.FilledDiamond;
                Line.EndEnding        = LineEndEnum.FilledDiamond;

                FillBrush          = ForegroundColor;
                HighlightFillBrush = (Brush)LineEndings.FindResource("0LightHighlightBrush");
            }


            if (FillBrush != null)
            {
                LineEndings.Fill = FillBrush;
            }

            LineEndings.ArrowLength = 0;
            Line.ArrowLength        = 0;
            LineEndings.ArrowLength = 15;
            Line.ArrowLength        = 15;
        }