Beispiel #1
0
        public override UIElement GetPaintComponent(XsdVisualizer.PaintOptions po, int fontSize)
        {
            StackPanel pnl = new StackPanel();

            if (fontSize <= 0)
            {
                return(pnl);
            }

            Brush  foreground  = Brushes.Gray;
            string displayName = Name;

            if ("optional".Equals(Use))
            {
                displayName += " (opt)";
                foreground   = Brushes.DarkGray; //darkGray is lighter than gray
            }

            TextBlock tb = new TextBlock
            {
                Text       = displayName,
                Foreground = foreground,
                FontSize   = fontSize,
            };

            pnl.Children.Add(tb);
            //pnl.Children.Add(GetPaintChildren(po, fontSize - 1));

            addMouseEvents(po, tb, this);

            return(pnl);
        }
        public override UIElement GetPaintComponent(XsdVisualizer.PaintOptions po, int fontSize)
        {
            if (fontSize <= 0)
            {
                return(null);
            }

            StackPanel pnl = new StackPanel();

            pnl.Children.Add(GetPaintTitle(po, fontSize));

            string s = SchemaLocation;

            if (s.Contains("/"))
            {
                s = "..." + s.Substring(s.LastIndexOf('/'));
            }
            pnl.Children.Add(new TextBlock
            {
                Text       = s,
                Foreground = Brushes.Gray,
                FontSize   = fontSize - 1
            });

            if (po.ExpandIncludes)
            {
                pnl.Children.Add(GetPaintChildren(po, fontSize - 1));
            }

            addMouseEvents(po, pnl, this);

            return(new Border {
                BorderBrush = Brushes.Black, BorderThickness = new Thickness(1), Child = pnl, Margin = new Thickness(5)
            });
        }
Beispiel #3
0
        public override UIElement GetPaintComponent(XsdVisualizer.PaintOptions po, int fontSize)
        {
            if (fontSize <= 0)
            {
                return(null);
            }

            StackPanel pnl = new StackPanel();

            Rectangle rect = new Rectangle();

            rect.Height = 2;
            rect.Fill   = Brushes.LightGray;
            rect.HorizontalAlignment = HorizontalAlignment.Stretch;
            rect.Margin = new Thickness(2);

            pnl.Children.Add(rect);

            pnl.Children.Add(GetPaintTitle(po, fontSize));

            pnl.Children.Add(GetPaintChildren(po, fontSize - 1));

            addMouseEvents(po, pnl, this);

            return(pnl);
        }
Beispiel #4
0
        public override UIElement GetPaintComponent(XsdVisualizer.PaintOptions po, int fontSize)
        {
            StackPanel pnl = new StackPanel();

            if (fontSize <= 0)
            {
                return(pnl);
            }

            pnl.Children.Add(GetPaintTitle(po, fontSize));

            if (po.ExpandTypes)
            {
                if (BaseTarget != null)
                {
                    pnl.Children.Add(BaseTarget.GetPaintComponent(po, fontSize - 1));
                }
                else
                {
                    pnl.Children.Add(new TextBlock {
                        Text = Base, FontSize = fontSize - 1
                    });
                }
            }

            pnl.Children.Add(new TextBlock
            {
                Text      = "extends:",
                FontSize  = fontSize,
                FontStyle = FontStyles.Italic
            });

            if (_attrs.Count == 0)
            {
                pnl.Children.Add(new TextBlock
                {
                    Text       = "(no attributes)",
                    Foreground = Brushes.Gray,
                    FontSize   = fontSize
                });
            }
            else
            {
                foreach (XsdAttribute attr in _attrs)
                {
                    pnl.Children.Add(attr.GetPaintComponent(po, fontSize));
                }
            }

            pnl.Children.Add(GetPaintChildren(po, fontSize - 1));

            addMouseEvents(po, pnl, this);

            return(new Border
            {
                BorderBrush = Brushes.Black, BorderThickness = new Thickness(1), Child = pnl,
                Margin = new Thickness(5)
            });
        }
Beispiel #5
0
 protected override UIElement GetPaintTitle(XsdVisualizer.PaintOptions po, int fontSize)
 {
     return(new TextBlock
     {
         Text = ToString(),
         Background = new LinearGradientBrush(Colors.Chartreuse, Colors.Transparent, 90),
         FontSize = fontSize,
         FontWeight = FontWeights.DemiBold
     });
 }
Beispiel #6
0
 protected override UIElement GetPaintTitle(XsdVisualizer.PaintOptions po, int fontSize)
 {
     return(new TextBlock
     {
         Text = ToString(),
         Foreground = Brushes.Gray,
         FontSize = fontSize,
         FontStyle = FontStyles.Italic,
     });
 }
Beispiel #7
0
        protected override UIElement GetPaintTitle(XsdVisualizer.PaintOptions po, int fontSize)
        {
            if (!string.IsNullOrEmpty(Name))
            {
                return(base.GetPaintTitle(po, fontSize));
            }

            //Ref
            return(new TextBlock
            {
                Text = ToString(),
                Background = new LinearGradientBrush(Colors.Turquoise, Colors.Transparent, 90),
                FontSize = fontSize,
                FontWeight = FontWeights.DemiBold
            });
        }
Beispiel #8
0
        protected static void addMouseEvents(XsdVisualizer.PaintOptions po, FrameworkElement pnl, IXsdNode node)
        {
            pnl.MouseDown += (sender, args) =>
            {
                if (args.ClickCount == 2)
                {
                    IXsdNode xsdNode = node;
                    if (xsdNode is IXsdHasRef)
                    {
                        IXsdHasRef refer = (IXsdHasRef)xsdNode;
                        if (refer.RefTarget != null)
                        {
                            po.Visualizer.SetRoot(refer.RefTarget);
                            return;
                        }
                    }

                    po.Visualizer.SetRoot(xsdNode);
                }
                args.Handled = true;
            };
            pnl.MouseMove += (sender, args) =>
            {
                po.Visualizer.SetDescription(node);
                args.Handled = true;
            };

            ContextMenu mainMenu = new ContextMenu();

            mainMenu.Items.Add(new MenuItem {
                Header = node.ToString(), IsEnabled = false
            });
            MenuItem item1 = new MenuItem {
                Header = "Hide"
            };

            item1.Click += (e, args) =>
            {
                po.Visualizer.IgnoreNodes.Add(node);
                po.Visualizer.Refresh();
            };
            mainMenu.Items.Add(item1);

            pnl.ContextMenu = mainMenu;
        }
Beispiel #9
0
        public virtual UIElement GetPaintComponent(XsdVisualizer.PaintOptions po, int fontSize)
        {
            StackPanel pnl = new StackPanel();

            if (fontSize <= 0)
            {
                return(pnl);
            }

            pnl.Children.Add(GetPaintTitle(po, fontSize));
            pnl.Children.Add(GetPaintChildren(po, fontSize - 1));

            addMouseEvents(po, pnl, this);

            return(new Border {
                BorderBrush = Brushes.Black, BorderThickness = new Thickness(1), Child = pnl, Margin = new Thickness(5)
            });
        }
Beispiel #10
0
 private void addMouseEvents(XsdVisualizer.PaintOptions po, UIElement pnl, IXsdNode node)
 {
     pnl.MouseDown += (sender, args) =>
     {
         if (args.ClickCount == 2)
         {
             if (TypeTarget != null)
             {
                 po.Visualizer.SetRoot(TypeTarget);
             }
         }
         args.Handled = true;
     };
     pnl.MouseMove += (sender, args) =>
     {
         po.Visualizer.SetDescription(node);
         args.Handled = true;
     };
 }
Beispiel #11
0
        public override UIElement GetPaintComponent(XsdVisualizer.PaintOptions po, int fontSize)
        {
            if (fontSize <= 0)
            {
                return(null);
            }

            StackPanel pnl = new StackPanel {
                Margin = new Thickness(5), Background = Brushes.BlanchedAlmond
            };

            if (!string.IsNullOrEmpty(Base))
            {
                pnl.Children.Add(new TextBlock {
                    Text = Base, FontSize = fontSize
                });
            }
            if (!string.IsNullOrEmpty(Id))
            {
                pnl.Children.Add(new TextBlock {
                    Text = "Id: " + Id, FontSize = fontSize
                });
            }
            if (!string.IsNullOrEmpty(MinExclusive))
            {
                pnl.Children.Add(new TextBlock {
                    Text = "MinExclusive: " + MinExclusive, FontSize = fontSize
                });
            }
            if (!string.IsNullOrEmpty(MaxExclusive))
            {
                pnl.Children.Add(new TextBlock {
                    Text = "MaxExclusive: " + MaxExclusive, FontSize = fontSize
                });
            }
            if (!string.IsNullOrEmpty(MinInclusive))
            {
                pnl.Children.Add(new TextBlock {
                    Text = "MinInclusive: " + MinInclusive, FontSize = fontSize
                });
            }
            if (!string.IsNullOrEmpty(MaxInclusive))
            {
                pnl.Children.Add(new TextBlock {
                    Text = "MaxInclusive: " + MaxInclusive, FontSize = fontSize
                });
            }
            if (!string.IsNullOrEmpty(MaxExclusive))
            {
                pnl.Children.Add(new TextBlock {
                    Text = "MaxExclusive: " + MaxExclusive, FontSize = fontSize
                });
            }
            if (!string.IsNullOrEmpty(Length))
            {
                pnl.Children.Add(new TextBlock {
                    Text = "Length: " + Length, FontSize = fontSize
                });
            }
            if (!string.IsNullOrEmpty(MinLength))
            {
                pnl.Children.Add(new TextBlock {
                    Text = "MinLength: " + MinLength, FontSize = fontSize
                });
            }
            if (!string.IsNullOrEmpty(MaxLength))
            {
                pnl.Children.Add(new TextBlock {
                    Text = "MaxLength: " + MaxLength, FontSize = fontSize
                });
            }
            if (!string.IsNullOrEmpty(Pattern))
            {
                pnl.Children.Add(new TextBlock {
                    Text = "Pattern: " + Pattern, FontSize = fontSize
                });
            }
            foreach (string e in _enumeration)
            {
                pnl.Children.Add(new TextBlock {
                    Text = "Enum: " + e, FontSize = fontSize
                });
            }

            addMouseEvents(po, pnl, this);

            return(pnl);
        }
Beispiel #12
0
        protected UIElement GetPaintChildren(XsdVisualizer.PaintOptions po, int fontSize)
        {
            StackPanel pnlKids = new StackPanel();

            pnlKids.Orientation = Orientation.Horizontal;

            foreach (IXsdNode kid in _kids)
            {
                if (po.HideTypes && kid is IXsdIsType)
                {
                    continue;
                }
                if (po.HideImportIncludes && kid is XsdImportInclude)
                {
                    continue;
                }

                bool     referenceExpanded = false, typeExpanded = false;
                IXsdNode toPaint = kid;
                if (po.ExpandReferences && kid is IXsdHasRef && ((IXsdHasRef)kid).RefTarget != null)
                {
                    toPaint           = ((IXsdHasRef)kid).RefTarget;
                    referenceExpanded = true;
                }
                if (po.ExpandTypes && kid is IXsdHasType && ((IXsdHasType)kid).TypeTarget != null)
                {
                    toPaint      = ((IXsdHasType)kid).TypeTarget;
                    typeExpanded = true;
                }
                Debug.Assert(!(typeExpanded && referenceExpanded), "node cannot be type and ref");


                //shade expanded nodes
                if (referenceExpanded || typeExpanded)
                {
                    StackPanel pnlExpanded = new StackPanel {
                        Margin = new Thickness(3)
                    };

                    Color c = referenceExpanded ? Colors.Blue : /*typeExpanded */ Colors.Green;
                    pnlExpanded.Background = new SolidColorBrush(Color.FromArgb(32, c.R, c.G, c.G));

                    UIElement title = ((XsdNode)kid).GetPaintTitle(po, fontSize);

                    if (!po.DontPaint.Contains(toPaint))
                    {
                        var kidComp = toPaint.GetPaintComponent(po, fontSize);

                        if (title != null && kidComp != null)
                        {
                            pnlExpanded.Children.Add(title);
                            pnlExpanded.Children.Add(kidComp);
                        }

                        pnlKids.Children.Add(pnlExpanded);
                    }
                }
                else
                {
                    if (!po.DontPaint.Contains(toPaint))
                    {
                        var kidComp = toPaint.GetPaintComponent(po, fontSize);
                        if (kidComp != null)
                        {
                            pnlKids.Children.Add(kidComp);
                        }
                    }
                }
            }

            return(pnlKids);
        }