internal static (bool isFull, string key) BuildKey(WidgetDescription description) { bool isFull = !string.IsNullOrEmpty(description.Position); string name = description.Variant?.MediatorType.Name ?? "UNKNOWN"; return(isFull ? (true, $"{name}|{description.Position}") : (false, name)); }
void ExampleOfTypedCustomisationChange() { // Example of typed customisation which can be partly updated var description = new WidgetDescription <TypedPartialExampleCustomisation>() { VariantName = "MyWidgetVariant" }; description.Customisation.Text = "new value"; description.Customisation.Number = 7; }
private Window CreateWidget(WidgetDescription widgetDescription) { Window widgedWindow; if (widgetDescription.ResizeToContent) { widgedWindow = new AutoSizableWidgetWindow { Title = widgetDescription.Description, Left = widgetDescription.Left, Top = widgetDescription.Top, Content = widgetDescription.Control, Tag = widgetDescription, }; } else { widgedWindow = new WidgetWindow { Height = widgetDescription.Height, Width = widgetDescription.Width, Title = widgetDescription.Description, Left = widgetDescription.Left, Top = widgetDescription.Top, Content = widgetDescription.Control, Tag = widgetDescription, }; } widgedWindow.Owner = this; var menuItem = new MenuItem() { Header = widgetDescription.Description, Tag = widgedWindow, }; var visibleBinding = new Binding("IsVisible") { Source = widgedWindow, Mode = BindingMode.OneWay, }; menuItem.SetBinding(MenuItem.IsCheckedProperty, visibleBinding); menuItem.Click += HandleHideShowWidget; _viewMenuItem.Items.Add(menuItem); widgedWindow.Show(); return(widgedWindow); }
/// <summary> /// /// </summary> public OutputToAdditionalWindowPlugin() { var viewModel = new AdditionalOutputWindowsViewModel(); var additionalOutputWindowControl = new AdditionalOutputWindow(viewModel); _manager = new AdditionalOutputWindowManager(viewModel); _widget = new WidgetDescription("AdditionalOutputWindow", "Additional output", additionalOutputWindowControl) { Left = (int)SystemParameters.PrimaryScreenWidth - 400, Height = 300, Width = 400, ResizeToContent = false }; }
void ExampleOfDynamicCustomisationChange() { var changes = new Dictionary <string, object>() { { nameof(ExampleCustomisation.Text), "new value" }, { nameof(ExampleCustomisation.Number), 7 } }; // Partial customisation change can be defined by dynamic type Customisation<TCustomisation> // Dynamic types require two packages: Microsoft.CSharp and System.Dynamic.Runtime // dynamic changes = new DynamicCustomisation<IExampleCustomisation>(); // changes.Text = "new value"; // changes.Number = 7; WidgetDescription description = new WidgetDescription() { VariantName = "MyWidgetVariant", Customisation = changes }; }