public FrameworkElement CreateControl(UIComponentConfiguration configuration, out UIComponentBase component) { var type = this.GetComponentType(configuration.Component); if (type == null || type == LayoutManager.PLACEHOLDER) { //A plugin was uninstalled. component = null; return(null); } component = ComponentActivator.Instance.Activate <UIComponentBase>(type); if (component is IUIComponentPanel panel) { panel.Component = configuration; } //Some components expect to be hosted in a Grid (Artwork..) //We might as well add a Rectangle to make the entire thing hit testable. var grid = new Grid(); grid.Children.Add(new Rectangle() { Fill = Brushes.Transparent }); grid.Children.Add(component); return(grid); }
protected virtual void UpdateChildren() { this.Grid.Children.Clear(); this.Grid.ColumnDefinitions.Clear(); if (this.Component.Children != null && this.Component.Children.Count > 0) { foreach (var component in this.Component.Children) { var horizontalAlignment = default(string); var verticalAlignment = default(string); if (component == null || !component.MetaData.TryGetValue(HorizontalAlignment, out horizontalAlignment)) { horizontalAlignment = Fill; } if (component == null || !component.MetaData.TryGetValue(VerticalAlignment, out verticalAlignment)) { verticalAlignment = Fill; } this.AddComponent(component, horizontalAlignment, verticalAlignment); } } else { var component = new UIComponentConfiguration(); this.AddComponent(component, Fill, Fill); this.Component.Children = new ObservableCollection <UIComponentConfiguration>() { component }; } }
public static void Save(Stream stream, UIComponentConfiguration config) { using (var writer = new XmlTextWriter(stream, Encoding.Default)) { writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteStartElement(Publication.Product); SaveComponent(writer, config); writer.WriteEndElement(); writer.WriteEndDocument(); } }
public override void InitializeComponent(ICore core) { global::FoxTunes.Windows.ShuttingDown += this.OnShuttingDown; this.LayoutDesignerBehaviour = ComponentRegistry.Instance.GetComponent <LayoutDesignerBehaviour>(); this.LayoutDesignerBehaviour.IsDesigningChanged += this.OnIsDesigningChanged; this.Configuration = core.Components.Configuration; this.Main = this.Configuration.GetElement <TextConfigurationElement>( WindowsUserInterfaceConfiguration.SECTION, UIComponentLayoutProviderConfiguration.MAIN ); this.Main.ConnectValue(value => this.MainComponent = this.LoadComponent(value)); base.InitializeComponent(core); }
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 UpdateComponent(UIComponentConfiguration originalComponent, UIComponentConfiguration newComponent) { for (var a = 0; a < this.Component.Children.Count; a++) { if (!object.ReferenceEquals(this.Component.Children[a], originalComponent)) { continue; } this.Component.Children[a] = newComponent; this.UpdateChildren(); return; } //TODO: Component was not found. throw new NotImplementedException(); }
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); }
private static void SaveComponent(XmlTextWriter writer, UIComponentConfiguration config) { writer.WriteStartElement(nameof(UIComponentConfiguration)); if (config != null) { writer.WriteAttributeString(nameof(UIComponentConfiguration.Component), config.Component); foreach (var child in config.Children) { SaveComponent(writer, child); } foreach (var pair in config.MetaData) { SaveMetaData(writer, pair.Key, pair.Value); } } writer.WriteEndElement(); }
protected virtual void UpdateChildren() { this.Grid.Children.Clear(); this.Grid.ColumnDefinitions.Clear(); if (this.Component.Children != null && this.Component.Children.Count > 0) { this.AddLeft(this.GetComponents(AlignLeft)); this.AddStretch(this.GetComponents(AlignStretch)); this.AddRight(this.GetComponents(AlignRight)); } else { var component = new UIComponentConfiguration(); this.AddLeft(new[] { component }); this.Component.Children = new ObservableCollection <UIComponentConfiguration>() { component }; } }
public static void SetDockComponent(UIComponentDockContainer source, UIComponentConfiguration value) { source.SetValue(DockComponentProperty, value); }
public static void SetBottomComponent(UIComponentHorizontalSplitContainer source, UIComponentConfiguration value) { source.SetValue(BottomComponentProperty, value); }
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); }
public static void SetRightComponent(UIComponentVerticalSplitContainer source, UIComponentConfiguration value) { source.SetValue(RightComponentProperty, value); }
public void Reset() { this.MainComponent = this.LoadComponent(this.Main.Value); this.OnUpdated(); }
public static void SetComponent(UIComponentPanel source, UIComponentConfiguration value) { source.SetValue(ComponentProperty, value); }
public UIComponent CreateComponent(UIComponentConfiguration configuration) { return(LayoutManager.Instance.GetComponent(configuration.Component)); }