Exemplo n.º 1
0
        protected void AddEdge(IVertex meta, bool isSet)
        {
            if (DisplayBaseVertex && BaseVertexEdgeAdded == false)
            {
                BaseVertexEdge      = getMetaForForm();
                BaseVertexEdgeAdded = true;
                AddEdge(BaseVertexEdge, false);
            }

            string group   = getGroup(meta);
            string section = getSection(meta);

            IVertex r = MinusZero.Instance.Root;

            TextBlock metaControl = new TextBlock();

            if (meta == null)
            {
                metaControl.Text   = "XXX";
                metaControl.Height = 0;
            }
            else
            {
                metaControl.Text = (string)meta.Value;
            }

            metaControl.FontStyle  = FontStyles.Italic;
            metaControl.FontWeight = UIWpf.MetaWeight;
            metaControl.Foreground = (Brush)FindResource("0GrayBrush");
            metaControl.FontStyle  = FontStyles.Italic;

            System.Windows.FrameworkElement dataControl = null;

            if (isSet)
            {
                TableVisualiser tv = new TableVisualiser();

                if (ExpertMode)
                {
                    GraphUtil.SetVertexValue(tv.Vertex, MinusZero.Instance.Root.Get(@"System\Meta\Visualiser\Table\ExpertMode"), "True");
                }


                // need to remove and add to have "transaction"
                GraphUtil.CreateOrReplaceEdge(tv.Vertex.Get("ToShowEdgesMeta:"), r.Get(@"System\Meta\ZeroTypes\Edge\Meta"), meta);

                IVertex v = tv.Vertex.Get("ToShowEdgesMeta:");

                GraphUtil.DeleteEdgeByMeta(tv.Vertex, "ToShowEdgesMeta");

                tv.Vertex.AddEdge(MinusZero.Instance.Root.Get(@"System\Meta\Visualiser\Table\ToShowEdgesMeta"), v);

                //GraphUtil.CreateOrReplaceEdge(tv.Vertex.Get("ToShowEdgesMeta:"), r.Get(@"System\Meta\ZeroTypes\Edge\To"), e.To); // do not need

                GraphUtil.ReplaceEdge(tv.Vertex.Get("BaseEdge:"), "To", Vertex.Get(@"BaseEdge:\To:"));

                dataControl = tv;
            }
            else
            {
                if (meta == BaseVertexEdge)
                {
                    StringVisualiser sv = new StringVisualiser();

                    Edge.ReplaceEdgeEdges(sv.Vertex.Get("BaseEdge:"), Vertex.GetAll(@"BaseEdge:\To:").FirstOrDefault());

                    dataControl = sv;
                }
                else
                {
                    VisualiserEditWrapper w = new VisualiserEditWrapper();

                    IEdge e;

                    e = Vertex.GetAll(@"BaseEdge:\To:\" + (string)meta.Value + ":").FirstOrDefault();

                    if (e == null) // no edge in data vertex
                    {
                        w.BaseEdge = new EasyEdge(Vertex.Get(@"BaseEdge:\To:"), meta, null);
                    }
                    else
                    {
                        w.BaseEdge = e;
                    }

                    dataControl = w;
                }
            }

            ControlInfo ci = new ControlInfo();

            ci.MetaControl = metaControl;
            ci.DataControl = dataControl;

            if (meta == null)
            { // BaseEdgeVertex
                TabList[group].ControlInfos.Add(MinusZero.Instance.CreateTempVertex(), ci);
            }
            else
            {
                if (TabList[group].ControlInfos.ContainsKey(meta))
                {
                    int x = 0; // same meta sub vertex two times in meta vertex
                }
                else
                {
                    TabList[group].ControlInfos.Add(meta, ci);
                }
            }

            Panel place = GetUIPlace(group, section, ci);

            if (MetaOnLeft)
            {
                metaControl.TextAlignment = TextAlignment.Right;

                StackPanel s = new StackPanel();
                s.Orientation = Orientation.Horizontal;

                ci.GapControl = new StackPanel();

                s.Children.Add(ci.GapControl);

                s.Children.Add(metaControl);

                Border b2 = new Border();

                b2.BorderThickness = new System.Windows.Thickness(metaVsDataSeparator, 0, 0, 0);

                s.Children.Add(b2);

                s.Children.Add(dataControl);

                place.Children.Add(s);
            }
            else
            {
                place.Children.Add(metaControl);

                place.Children.Add(dataControl);
            }


            Border b = new Border();

            b.BorderThickness = new System.Windows.Thickness(0, controlLineVsControlLineSeparator, 0, 0);

            place.Children.Add(b);
        }
Exemplo n.º 2
0
        protected Panel GetUIPlace(string group, string section, ControlInfo ci)
        {
            TabInfo t = TabList[group];


            int targetColumn = (int)((double)t.CurrentNumberOfControls * (double)ColumnNumber / (double)t.TotalNumberOfControls);

            if (targetColumn >= ColumnNumber)
            {
                targetColumn = ColumnNumber - 1;
            }

            t.CurrentNumberOfControls++;

            ci.Column = targetColumn;

            if (section != null)
            {
                if (t.Sections.ContainsKey(section))
                {
                    ci.Column = t.Sections[section].Column;

                    return((Panel)t.Sections[section].Panel);
                }

                Panel toAdd;

                if (HasTabs)
                {
                    toAdd = (Panel)((Grid)t.TabItem.Content).Children[targetColumn];
                }
                else
                {
                    toAdd = (Panel)((Grid)this.Content).Children[0];
                }

                GroupBox g = new GroupBox();

                //Expander g = new Expander();

                g.BorderBrush = (Brush)FindResource("0ForegroundBrush");

                TextBlock Header = new TextBlock();
                Header.FontWeight = UIWpf.BoldWeight;
                Header.Text       = section;
                g.Header          = Header;

                g.BorderThickness = new Thickness(2); // can be 1, but 2 is more separated

                toAdd.Children.Add(g);

                Border b = new Border(); // separator

                b.BorderThickness = new System.Windows.Thickness(0, controlLineVsControlLineSeparator, 0, 0);

                toAdd.Children.Add(b);

                StackPanel gp = new StackPanel();

                g.Content = gp;

                SectionInfo si = new SectionInfo();
                si.Panel  = gp;
                si.Column = targetColumn;

                t.Sections.Add(section, si);

                return(gp);
            }


            if (HasTabs)
            {
                return((Panel)((Grid)t.TabItem.Content).Children[targetColumn]);
            }
            else
            {
                return((Panel)((Grid)this.Content).Children[targetColumn]);
            }
        }