public OutputModeEditor() { this.Content = new StackLayout { Padding = 5, Spacing = 5, HorizontalContentAlignment = HorizontalAlignment.Stretch, Items = { new StackLayoutItem(editorContainer, true), new StackLayoutItem(outputModeSelector, HorizontalAlignment.Left) } }; absoluteModeEditor.SettingsBinding.Bind(ProfileBinding.Child(p => p.AbsoluteModeSettings)); relativeModeEditor.SettingsBinding.Bind(ProfileBinding.Child(p => p.RelativeModeSettings)); outputModeSelector.SelectedItemBinding.Convert <PluginSettingStore>( c => PluginSettingStore.FromPath(c?.FullName), v => v?.GetTypeInfo() ).Bind(ProfileBinding.Child(c => c.OutputMode)); outputModeSelector.SelectedValueChanged += (sender, e) => UpdateOutputMode(Profile?.OutputMode); App.Driver.AddConnectionHook(i => i.TabletsChanged += (sender, e) => UpdateTablet(e)); UpdateTablet(); }
public OutputModeEditor() { this.Content = new StackLayout { Padding = 5, Spacing = 5, HorizontalContentAlignment = HorizontalAlignment.Stretch, Items = { new StackLayoutItem(editorContainer, true), new StackLayoutItem(outputModeSelector, HorizontalAlignment.Left) } }; outputModeSelector.SelectedValueChanged += (sender, args) => { if (outputModeSelector.SelectedType is TypeInfo type) { this.Store = new PluginSettingStore(type); } }; outputModeSelector.SelectedTypeBinding.Bind( StoreBinding.Convert <TypeInfo>( c => c?.GetPluginReference().GetTypeReference(), t => PluginSettingStore.FromPath(t.FullName) ) ); }
private void UpdateOutputMode(PluginSettingStore store) { bool showNull = true; bool showAbsolute = false; bool showRelative = false; if (store != null) { App.Settings.OutputMode = store; var outputMode = store.GetPluginReference().GetTypeReference <IOutputMode>(); showAbsolute = outputMode.IsSubclassOf(typeof(AbsoluteOutputMode)); showRelative = outputMode.IsSubclassOf(typeof(RelativeOutputMode)); showNull = !(showAbsolute | showRelative); } switch (DesktopInterop.CurrentPlatform) { case PluginPlatform.Linux: noModeEditor.Visible = showNull; absoluteModeEditor.Visible = showAbsolute; relativeModeEditor.Visible = showRelative; break; default: SetVisibilityWorkaround(absoluteModeEditor, showAbsolute, 0); SetVisibilityWorkaround(relativeModeEditor, showRelative, 1); SetVisibilityWorkaround(noModeEditor, showNull, 2); break; } }
public BindingDisplay(PluginSettingStore store) { var bindingCommand = new Command(); bindingCommand.Executed += async(sender, e) => { var dialog = new BindingEditorDialog(Binding); this.Binding = await dialog.ShowModalAsync(this); }; var advancedBindingCommand = new Command(); advancedBindingCommand.Executed += async(sender, e) => { var dialog = new AdvancedBindingEditorDialog(Binding); this.Binding = await dialog.ShowModalAsync(this); }; mainButton = new Button { Command = bindingCommand }; advancedButton = new Button { Command = advancedBindingCommand, Text = "...", Width = 25 }; Spacing = 5; Orientation = Orientation.Horizontal; Items.Add(new StackLayoutItem(mainButton, true)); Items.Add(advancedButton); this.Binding = store; }
public static Control GetControlForProperty(PluginSettingStore store, PropertyInfo property) { var attr = property.GetCustomAttribute <PropertyAttribute>(); PluginSetting setting = store[property]; if (setting == null) { setting = new PluginSetting(property, null); store.Settings.Add(setting); } var settingBinding = new DelegateBinding <PluginSetting>( () => store[property], (v) => store[property] = v ); var control = GetControlForSetting(property, settingBinding); if (control != null) { // Apply all visual modifier attributes foreach (ModifierAttribute modifierAttr in property.GetCustomAttributes <ModifierAttribute>()) { control = ApplyModifierAttribute(control, modifierAttr); } control.Width = 400; return(new Group(attr.DisplayName ?? property.Name, control, Orientation.Horizontal, false)); } else { throw new NullReferenceException($"{nameof(control)} is null. This is likely due to {property.PropertyType.Name} being an unsupported type."); } }
public static void MigrateNamespace(PluginSettingStore store) { if (store != null) { store.Path = MigrateNamespace(store.Path); } }
private Control GetControlForProperty(PluginSettingStore store, PropertyInfo property) { var attr = property.GetCustomAttribute <PropertyAttribute>(); PluginSetting setting = store[property]; if (setting == null) { setting = new PluginSetting(property, null); store.Settings.Add(setting); } var control = GetControlForSetting(property, setting); if (control != null) { // Apply all visual modifier attributes foreach (ModifierAttribute modifierAttr in property.GetCustomAttributes <ModifierAttribute>()) { control = ApplyModifierAttribute(control, modifierAttr); } return(new GroupBoxBase( attr.DisplayName ?? property.Name, control )); } else { throw new NullReferenceException($"{nameof(control)} is null. This is likely due to {property.PropertyType.Name} being an unsupported type."); } }
public static string GetFormattedBinding(PluginSettingStore store) { var pluginRef = store.GetPluginReference(); var binding = pluginRef.Construct <IBinding>(); return($"{pluginRef.Name}: {binding.Property}"); }
public OutputModeEditor() { UpdateOutputMode(App.Settings?.OutputMode); App.SettingsChanged += (settings) => UpdateOutputMode(settings?.OutputMode); outputModeSelector.SelectedModeChanged += (sender, pluginRef) => { App.Settings.OutputMode = PluginSettingStore.FromPath(pluginRef.Path); UpdateOutputMode(App.Settings.OutputMode); }; this.Content = outputPanel = new StackLayout { Padding = 5, Spacing = 5, HorizontalContentAlignment = HorizontalAlignment.Stretch, Items = { new StackLayoutItem(absoluteModeEditor, true), new StackLayoutItem(relativeModeEditor, true), new StackLayoutItem(noModeEditor, true), new StackLayoutItem(outputModeSelector, HorizontalAlignment.Left, false) } }; }
private static PluginSettingStore SafeMigrateNamespace(PluginSettingStore store, PluginSettingStore defaultStore = null) { MigrateNamespace(store); if ((store == null || PluginSettingStore.FromPath(store?.Path) == null) && defaultStore != null) { Log.Write("Settings", $"Invalid plugin path '{store?.Path ?? "null"}' has been changed to '{defaultStore.Path}'", LogLevel.Warning); store = defaultStore; } return(store); }
protected override IEnumerable <Control> GetHeaderControlsForStore(PluginSettingStore store) { var enableButton = new CheckBox { Text = $"Enable {store.GetPluginReference().Name ?? store.Path}", Checked = store.Enable }; enableButton.CheckedChanged += (sender, e) => store.Enable = enableButton.Checked ?? false; yield return(enableButton); }
private string GetFriendlyDisplayString(PluginSettingStore store) { if (store == null || store["Property"] == null) { return(null); } var property = store["Property"].GetValue <string>(); var name = store.GetPluginReference().Name; return($"{name}: {property}"); }
private IEnumerable <Control> GetControlsForType(PluginSettingStore store, Type type) { var properties = from property in type.GetProperties() let attrs = property.GetCustomAttributes(true) where attrs.Any(a => a is PropertyAttribute) select property; foreach (var property in properties) { yield return(GetControlForProperty(store, property)); } }
private IEnumerable <Control> GetControlsForStore(PluginSettingStore store) { if (store != null) { var type = store.GetPluginReference().GetTypeReference <TSource>(); return(GetControlsForType(store, type)); } else { return(Array.Empty <Control>()); } }
private string GetFriendlyDisplayString(PluginSettingStore store) { if (store == null) { return(null); } var name = store.GetPluginReference().Name; string settings = string.Join(", ", store.Settings.Select(s => $"({s.Property}: {s.Value})")); return($"{name}: {settings}"); }
public virtual void Refresh(PluginSettingStore store) { this.Items.Clear(); foreach (var control in GetHeaderControlsForStore(store)) { AddControl(control); } foreach (var control in GetControlsForStore(store)) { this.Items.Add(control); } Store = store; }
private void UpdateSelectedStore(PluginReference reference) { if (CollectionReference.TryGetTarget(out PluginSettingStoreCollection storeCollection)) { if (storeCollection.FirstOrDefault(store => store.Path == reference.Path) is PluginSettingStore store) { settingStoreEditor.Refresh(store); } else { var newStore = new PluginSettingStore(reference.GetTypeReference <TSource>(), false); storeCollection.Add(newStore); settingStoreEditor.Refresh(newStore); } } }
public void Refresh(PluginSettingStore store) { this.Items.Clear(); var enableButton = new CheckBox { Text = $"Enable {store.GetPluginReference().Name ?? store.Path}", Checked = store.Enable }; enableButton.CheckedChanged += (sender, e) => store.Enable = enableButton.Checked ?? false; AddControl(enableButton); foreach (var control in GetControlsForStore(store)) { this.Items.Add(control); } }
public static string Format(this PluginSettingStore store) { if (store == null || !store.Enable) { return(null); } IList <string> storeSettings = new List <string>(); foreach (var setting in store.Settings) { storeSettings.Add(setting.Format()); } string prefix = store.Name ?? store.Path; string suffix = storeSettings.Count == 0 ? null : string.Join(", ", storeSettings); return(string.IsNullOrEmpty(suffix) ? $"'{prefix}'" : $"'{prefix}: {suffix}'"); }
private Control ConstructOutputModeSelector() { var control = new OutputModeSelector { Width = 300 }; control.SelectedModeChanged += (sender, mode) => { App.Settings.OutputMode = PluginSettingStore.FromPath(mode.Path); UpdateOutputMode(mode); }; App.SettingsChanged += (settings) => { var mode = control.OutputModes.FirstOrDefault(t => t.Path == App.Settings.OutputMode?.Path) ?? AppInfo.PluginManager.GetPluginReference(typeof(AbsoluteMode)); if (mode != null) { control.SelectedIndex = control.OutputModes.IndexOf(mode); } }; return(control); }
public BindingDisplay(PluginSettingStore store) { this.Binding = store; var bindingCommand = new Command(); bindingCommand.Executed += async(sender, e) => { var dialog = new BindingEditorDialog(Binding); this.Binding = await dialog.ShowModalAsync(this); }; this.Command = bindingCommand; this.MouseDown += async(s, e) => { if (e.Buttons.HasFlag(MouseButtons.Alternate)) { var dialog = new AdvancedBindingEditorDialog(Binding); this.Binding = await dialog.ShowModalAsync(this); } }; }
private void UpdateOutputMode(PluginSettingStore store) { bool showAbsolute = false; bool showRelative = false; if (store != null) { App.Settings.OutputMode = store; var outputMode = store.GetPluginReference().GetTypeReference <IOutputMode>(); showAbsolute = outputMode.IsSubclassOf(typeof(AbsoluteOutputMode)); showRelative = outputMode.IsSubclassOf(typeof(RelativeOutputMode)); } if (showAbsolute) { outputModeEditor.Content = absoluteModeEditor; } else if (showRelative) { outputModeEditor.Content = relativeModeEditor; } }
protected virtual IEnumerable <Control> GetHeaderControlsForStore(PluginSettingStore store) { return(Array.Empty <Control>()); }
private IEnumerable <Control> GetControlsForStore(PluginSettingStore store) { var type = store.GetPluginReference().GetTypeReference <TSource>(); return(GetControlsForType(store, type)); }
public void UpdateSelectedMode(PluginSettingStore store) { var typeReference = store?.GetPluginReference().GetTypeReference(); this.SelectedValue = typeReference; }
public StoredPluginReference(PluginManager pluginManager, PluginSettingStore store) : base(pluginManager, store.Path) { PluginSettings = store; }
public DemoBindingDisplay() : base(PluginSettingStore.FromPath(typeof(OpenTabletDriver.Plugin.IBinding).FullName)) { Width = 256; }