public void Reset(Option option) { var provider = option.DefaultValue as IEncoderViewModel; if(provider == null) return; provider.Reset(); }
public bool Serialize(IRadioEnvironment store, Option option) { store.Settings.EncoderProfiles.SetDefault(CurrentEncoder.Value as string); var returnVal = _old == CurrentEncoder.Value as string; _old = CurrentEncoder.Value as string; return returnVal; }
public void Deserialize(IRadioEnvironment store, Option option, object defaultValue) { var provider = defaultValue as IEncoderViewModel; if(provider == null) return; option.SettingValue = defaultValue; provider.Deserialize(); }
public virtual void Deserialize(IRadioEnvironment store, Option option, object defaultValue) { string currentValue = store.Settings.PropertyStore.GetValue(option.SettingKey, defaultValue?.ToString()); _oldValue = currentValue; SetValue(_oldValue); option.SettingValue = currentValue; }
public override FrameworkElement LoadUI(Option option) { if (_checkBox != null) return _checkBox; _checkBox = new CheckBox { DataContext = this, Content = _content ?? option.DisplayName }; _checkBox.SetBinding(ToggleButton.IsCheckedProperty, "CurrentValue"); return _checkBox; }
public bool Serialize(IRadioEnvironment store, Option option) { var provider = option.SettingValue as IEncoderViewModel; if (provider == null) return false; provider.Serialize(); return true; }
public void Deserialize(IRadioEnvironment store, Option option, object defaultValue) { var encoder = store.Settings.EncoderProfiles.Default; _old = encoder.Item2 != null ? encoder.Item1 : null; Profiles = store.Settings.EncoderProfiles.Profiles.Select(s => new CommonComboBoxItem(s, s)).ToList(); _nullItem = new CommonComboBoxItem(RadioStreamerResources.NoneString, null); Reset(option); Profiles?.Add(_nullItem); }
public virtual bool Serialize(IRadioEnvironment store, Option option) { var newValue = GetCurrentValue(); if(newValue == _oldValue) return false; store.Settings.PropertyStore.SetValue(option.SettingKey, newValue); _oldValue = newValue; option.SettingValue = newValue; return true; }
public FrameworkElement LoadUI(Option option) { var box = new ComboBox { MinWidth = 100, DataContext = this, ItemsSource = Profiles }; box.SetBinding(Selector.SelectedItemProperty, new Binding("CurrentEncoder")); return box; }
public override FrameworkElement LoadUI(Option option) { var box = new ComboBox { MinWidth = 100, DataContext = this, ItemsSource = Items }; box.SetBinding(Selector.SelectedItemProperty, new Binding(nameof(CurrentItem))); return box; }
public void Reset(Option option) { var currentEncoder = Profiles.Find(i => i.Value as string == _old) ?? _nullItem; CurrentEncoder = currentEncoder; }
public override bool Serialize(IRadioEnvironment store, Option option) { var temp = base.Serialize(store, option); _saveAction?.Invoke(CurrentValue ?? false); return temp; }
public override FrameworkElement LoadUI(Option option) { if (_textBox != null) return _textBox; var textBox = new TextBox { MinWidth = 100}; textBox.SetBinding(TextBox.TextProperty, new Binding(nameof(TextContent)) { Delay = 100, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged}); if (_optionalPathButton) { var panel = new StackPanel { DataContext = this, Orientation = Orientation.Horizontal }; var button = new Button {Content = "...", Margin = new Thickness(10, 0, 0, 0)}; button.Click += ButtonOnClick; panel.Children.Add(textBox); panel.Children.Add(button); _textBox = panel; } else { textBox.DataContext = this; _textBox = textBox; } return _textBox; }
public virtual void Reset(Option option) { SetValue(_oldValue); }
public abstract FrameworkElement LoadUI(Option option);
public void RegisterOption(string path, Option option) { if (path == null) throw new ArgumentNullException(nameof(path)); if (option == null) throw new ArgumentNullException(nameof(option)); string[] segemnts = path.Split('\\'); bool isNew = false; OptionPath root = null; OptionPath current = null; foreach (string name in segemnts) { if (root == null) { string name1 = name; root = _options.FirstOrDefault(op => op.DisplayName == name1); if (root == null) { root = new OptionPath {DisplayName = name}; isNew = true; } current = root; continue; } var temp = (OptionPath) current.Elements.FirstOrDefault(op => op.DisplayName == name && op is OptionPath); if (temp == null) { temp = new OptionPath {DisplayName = name}; current.Elements.Add(temp); } current = temp; } if(isNew) _options.Add(root); if (current == null) throw new InvalidOperationException(); if (string.IsNullOrEmpty(option.Group)) current.Elements.Add(option); else { var gr = (OptionGroup) current.Elements.FirstOrDefault(e => e.DisplayName == option.Group && e is OptionGroup); if (gr == null) { // ReSharper disable once AssignNullToNotNullAttribute gr = new OptionGroup { DisplayName = option.Group }; current.Elements.Add(gr); } gr.Options.Add(option); } option.Load(_radioEnvironment); }
public FrameworkElement LoadUI(Option option) { var temp = ViewManager.Manager.CreateView(AppConstants.CommonEncoderUI); new FrameworkObject(temp, false).DataContext = option.SettingValue; return (Control)temp; }