public UIElement MakeTransformElement(string name, ATransformation value, object CurrentObject, bool canBeChanged, int?fixNameWidth) { var g = MakeDefaultGrid(fixNameWidth); g.Children.Add(MakeDefaultTextBlock(name)); g.Children.Add(SetCP(2, AddToSP(new StackPanel(), VisualizeObject(value, null, true)))); if (canBeChanged) { g.RowDefinitions.Add(new RowDefinition()); g.RowDefinitions.Add(new RowDefinition()); var bt = SetCP(2, new Button() { Style = BTStyle, Content = "Change", HorizontalAlignment = HorizontalAlignment.Center }); bt.Click += (_, __) => { var diag = new TransformSelector(sbr as Renderer.TransformableRenderer); diag.Init(); if (diag.ShowDialog() == true) { value = diag.result; UpdateCurrentObject(name, value, CurrentObject); (g.Children[1] as StackPanel).Children.Clear(); SetCP(2, AddToSP(g.Children[1] as StackPanel, VisualizeObject(value, null, true))); OnChanges(); } }; bt.SetValue(Grid.RowProperty, 1); //bt.SetValue(Grid.ColumnSpanProperty, 2); g.Children.Add(bt); } return(g); }
public UIElement MakeTransformListElement(string name, List <ATransformation> value, object CurrentObject, int?fixNameWidth) { var root = new FieldSet() { Header = name, Background = BGBrush, Foreground = white, BorderBrush = LRBrush }; var g = new Grid() { Margin = new Thickness(5) }; var content = new StackPanel() { VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Thickness(0, 0, 0, 30), MinHeight = 50, }; var btAddTransform = new Button() { Style = BTStyle, Content = "Add Transform", VerticalAlignment = VerticalAlignment.Bottom, Height = 30 }; void showTransform(ATransformation t) { var ng = new Grid(); ng.ColumnDefinitions.Add(new ColumnDefinition()); ng.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20) }); var b = SetCP(2, new Button() { Content = "x", Style = BTStyle, VerticalAlignment = VerticalAlignment.Center, Height = 20, }); b.Resources.Add("Rounder", MakeStyle(typeof(Border), new List <Setter>() { new Setter(Border.CornerRadiusProperty, 10) })); b.Click += (_, __) => { content.Children.Remove(ng); value.Remove(t); OnChanges(); }; string[] names = { "T", "R", "S", "C" }; ng.Children.Add(MakeRecursiveObject(names[t.TYPEID()] + value.Count, t, fixNameWidth ?? 30)); ng.Children.Add(b); content.Children.Add(ng); } void addTransform(ATransformation t) { showTransform(t); value.Add(t); } foreach (var t in value) { showTransform(t); } btAddTransform.Click += (_, __) => { var selecta = new TransformSelector(sbr as Renderer.TransformableRenderer); selecta.Init(); if (selecta.ShowDialog() == true) { addTransform(selecta.result); } }; g.Children.Add(content); g.Children.Add(btAddTransform); root.Content = g; return(root); }