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) }); }
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); }
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) }); }
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 }); }
protected override UIElement GetPaintTitle(XsdVisualizer.PaintOptions po, int fontSize) { return(new TextBlock { Text = ToString(), Foreground = Brushes.Gray, FontSize = fontSize, FontStyle = FontStyles.Italic, }); }
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 }); }
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; }
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) }); }
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; }; }
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); }
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); }