Exemple #1
0
        protected virtual void HideDesignerOverlay(UIComponentContainer container)
        {
            Container = null;
            var layer = AdornerLayer.GetAdornerLayer(container);

            if (layer == null)
            {
                return;
            }
            var adorners = layer.GetAdorners(container);

            if (adorners == null)
            {
                return;
            }
            foreach (var adorner in adorners)
            {
                layer.Remove(adorner);
                if (adorner is UIComponentDesignerAdorner designerAdorner)
                {
                    designerAdorner.Closed -= this.OnClosed;
                    designerAdorner.Dispose();
                }
            }
        }
Exemple #2
0
        protected virtual void AddContainer(HorizontalAlignment alignment, GridLength width, UIComponentConfiguration component)
        {
            var margin = default(Thickness);

            if (this.Grid.ColumnDefinitions.Count > 0)
            {
                margin = new Thickness(2, 0, 0, 0);
            }
            this.Grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = width
            });
            var container = new UIComponentContainer()
            {
                Component           = component,
                Margin              = margin,
                HorizontalAlignment = alignment,
            };

            //TODO: Don't like anonymous event handlers, they can't be unsubscribed.
            container.ComponentChanged += (sender, e) =>
            {
                this.UpdateComponent(component, container.Component);
            };
            Grid.SetColumn(container, this.Grid.ColumnDefinitions.Count - 1);
            this.Grid.Children.Add(container);
        }
Exemple #3
0
 public Task SetAlignment(UIComponentContainer container, string alignment)
 {
     return(Windows.Invoke(() =>
     {
         if (container.Component == null)
         {
             container.Component = new UIComponentConfiguration();
         }
         container.Component.MetaData.AddOrUpdate(Alignment, alignment);
         this.UpdateChildren();
     }));
 }
 public Task SetFill(UIComponentContainer container)
 {
     return(Windows.Invoke(() =>
     {
         if (container.Component == null)
         {
             container.Component = new UIComponentConfiguration();
         }
         container.Component.MetaData.AddOrUpdate(HorizontalAlignment, Fill);
         container.Component.MetaData.AddOrUpdate(VerticalAlignment, Fill);
         this.UpdateChildren();
     }));
 }
Exemple #5
0
        protected virtual void ShowDesignerOverlay(UIComponentContainer container)
        {
            Container = container;
            var layer = AdornerLayer.GetAdornerLayer(container);

            if (layer == null)
            {
                return;
            }
            var adorner = new UIComponentDesignerAdorner(container);

            adorner.Closed += this.OnClosed;
            layer.Add(adorner);
        }
Exemple #6
0
 public Task Add(UIComponentContainer container)
 {
     return(Windows.Invoke(() =>
     {
         var component = new UIComponentConfiguration();
         var index = this.Component.Children.IndexOf(container.Component);
         var alignment = default(string);
         if (container.Component.MetaData.TryGetValue(Alignment, out alignment))
         {
             component.MetaData.TryAdd(Alignment, alignment);
         }
         this.Component.Children.Insert(index + 1, component);
         this.UpdateChildren();
     }));
 }
        protected virtual void AddComponent(UIComponentConfiguration component, string horizontalAlignment, string verticalAlignment)
        {
            var container = new UIComponentContainer()
            {
                Component           = component,
                HorizontalAlignment = (HorizontalAlignment)Enum.Parse(typeof(HorizontalAlignment), horizontalAlignment),
                VerticalAlignment   = (VerticalAlignment)Enum.Parse(typeof(VerticalAlignment), verticalAlignment),
            };

            //TODO: Don't like anonymous event handlers, they can't be unsubscribed.
            container.ComponentChanged += (sender, e) =>
            {
                this.UpdateComponent(component, container.Component);
            };
            this.Grid.Children.Add(container);
        }
Exemple #8
0
 public Task Remove(UIComponentContainer container)
 {
     return(Windows.Invoke(() =>
     {
         for (var a = 0; a < this.Component.Children.Count; a++)
         {
             if (!object.ReferenceEquals(this.Component.Children[a], container.Component))
             {
                 continue;
             }
             this.Component.Children.RemoveAt(a);
             this.UpdateChildren();
             return;
         }
         //TODO: Component was not found.
         throw new NotImplementedException();
     }));
 }
        public UIComponentRoot()
        {
            var container = new UIComponentContainer();

            //TODO: Should we create this binding now or on Loaded?
            container.SetBinding(
                UIComponentContainer.ComponentProperty,
                new Binding()
            {
                Source = this,
                Path   = new PropertyPath(nameof(this.Component))
            }
                );
            this.Content = container;
            lock (Instances)
            {
                Instances.Add(new WeakReference <UIComponentRoot>(this));
            }
            OnActiveChanged(this);
        }
Exemple #10
0
 protected virtual Task Move(UIComponentContainer container, Func <int, int> step)
 {
     return(Windows.Invoke(() =>
     {
         var containerAlignment = default(string);
         if (!container.Component.MetaData.TryGetValue(Alignment, out containerAlignment))
         {
             //Align left by default.
             containerAlignment = AlignLeft;
         }
         for (var a = 0; a < this.Component.Children.Count; a++)
         {
             if (!object.ReferenceEquals(this.Component.Children[a], container.Component))
             {
                 continue;
             }
             for (var b = step(a); b >= 0 && b < this.Component.Children.Count; b = step(b))
             {
                 var childAlignment = default(string);
                 if (!this.Component.Children[b].MetaData.TryGetValue(Alignment, out childAlignment))
                 {
                     //Align left by default.
                     childAlignment = AlignLeft;
                 }
                 if (!string.Equals(containerAlignment, childAlignment, StringComparison.OrdinalIgnoreCase))
                 {
                     //Alignment differs.
                     continue;
                 }
                 this.Component.Children[a] = this.Component.Children[b];
                 this.Component.Children[b] = container.Component;
                 this.UpdateChildren();
                 return;
             }
             //TODO: Move is invalid.
             return;
         }
     }));
 }
Exemple #11
0
 public static void SetContent(UIComponentContainer source, UIComponentBase value)
 {
     source.SetValue(ContentProperty, value);
 }
Exemple #12
0
 public static UIComponentBase GetContent(UIComponentContainer source)
 {
     return((UIComponentBase)source.GetValue(ContentProperty));
 }
Exemple #13
0
 public static UIComponentConfiguration GetComponent(UIComponentContainer source)
 {
     return((UIComponentConfiguration)source.GetValue(ComponentProperty));
 }
Exemple #14
0
 public Task MoveRight(UIComponentContainer container)
 {
     return(this.Move(container, index => index + 1));
 }
Exemple #15
0
 public Task MoveLeft(UIComponentContainer container)
 {
     return(this.Move(container, index => index - 1));
 }
Exemple #16
0
 public UIComponentDesignerAdorner(UIComponentContainer container) : base(container)
 {
     this.Container = container;
     this.InitializeComponent();
 }