/// <summary> /// Runs the commanding logic /// </summary> /// <param name="parameter">N/A</param> private void _pickDirectory(object sender) { DirectoryPicker p = new DirectoryPicker(); if (p.Resolve()) { _directoryDisplayTextBox.Text = p.Directory; Property.Value = p.Directory; } }
/// <summary> /// Picks the file. /// </summary> public static void PickDirectory(this SpecialFolder startDirectory, string dialogmsg, Action <string> directorySelected_Action) { DirectoryPicker pck = new DirectoryPicker(); pck.InitialDirectory = startDirectory; string pth; if (pck.PickPath(dialogmsg, out pth) && Directory.Exists(pth)) { directorySelected_Action(pth); } }
private void CreateDisplayer() { if (directory is null) { return; } displayer?.Hide(); if (displayer is Displayer internalDisplayer) { internalDisplayer.ClearDisplayArea(); } if (UseExternalView.IsChecked.Value) { DirectoryPicker dirPicker = null; if (PhotoRadioButton.IsChecked.Value) { dirPicker = new PhotoDirectoryPicker(directory); } else if (VideoRadioButton.IsChecked.Value) { dirPicker = new MovieDirectoryPicker(directory); } displayer = new ExternalDisplayer(dirPicker); } else { if (PhotoRadioButton.IsChecked.Value) { displayer = new PhotoDisplayer(DisplayArea, directory); } else if (VideoRadioButton.IsChecked.Value) { displayer = new MovieDisplayer(DisplayArea, directory); } } foreach (var action in autoActions) { _ = action.Register(displayer); } if (displayer is RandomMediaPlayer.HistoryTracking.IHistoryTracking historyDisplayer) { TrackHistory.Visibility = Visibility.Visible; SeenTotalMedia.Visibility = Visibility.Visible; TrackHistory.IsChecked = historyDisplayer.HistoryTracker.IsTracking; } else { TrackHistory.Visibility = Visibility.Collapsed; SeenTotalMedia.Visibility = Visibility.Collapsed; } ApplyMinHeight(); SetDisplayedTest(); }
public DynamicSettingsControl() { InitializeComponent(); evaluator = new DataTable(); DefaultEditors.Add(typeof(bool), "checkbox"); DefaultEditors.Add(typeof(string), "textbox"); DefaultEditors.Add(typeof(Color), "colorpicker"); DefaultEditors.Add(typeof(Font), "fontpicker"); #region Default Control Builders // Checkbox Builder EditorBuilders.Add("checkbox", setting => { var checkBox = new CheckBox() { Text = setting.Title, Checked = GetSettingValue <bool>(setting.Name), AutoSize = true, UseVisualStyleBackColor = true }; checkBox.CheckedChanged += (s, e) => SetSettingValue(setting.Name, checkBox.Checked); return(checkBox); }); // Radio Group Builder EditorBuilders.Add("radio", setting => { var group = new GroupBox() { AutoSize = true, Text = setting.Title, Dock = DockStyle.Top }; FlowLayoutPanel panel = new FlowLayoutPanel() { AutoSize = true, FlowDirection = FlowDirection.TopDown, Dock = DockStyle.Fill }; object settingValue = GetSettingValue <object>(setting.Name); Array values = Enum.GetValues(settingValue.GetType()); foreach (var value in values) { RadioButton radio = new RadioButton() { Name = $"{setting.Name}.{value}", AutoSize = true, Checked = value.Equals(settingValue), Text = value.GetType() .GetMember(value.ToString()) .FirstOrDefault() ?.GetCustomAttribute <DescriptionAttribute>() ?.Description }; radio.CheckedChanged += (s, e) => { if (radio.Checked) { SetSettingValue(setting.Name, value); } }; panel.Controls.Add(radio); } group.Controls.Add(panel); return(group); }); // Textbox Builder EditorBuilders.Add("textbox", setting => { TextPicker picker = new TextPicker() { Title = setting.Title, SelectedValue = GetSettingValue <string>(setting.Name), Dock = DockStyle.Fill }; picker.SelectedValueChanged += (s, e) => SetSettingValue(setting.Name, picker.SelectedValue); return(picker); }); // Color Picker Builder EditorBuilders.Add("colorpicker", setting => { ColorPicker picker = new ColorPicker() { Text = setting.Title, SelectedValue = GetSettingValue <Color>(setting.Name), AutoSize = true }; picker.SelectedValueChanged += (s, e) => SetSettingValue(setting.Name, picker.SelectedValue); return(picker); }); // Font Picker Builder EditorBuilders.Add("fontpicker", setting => { Font font = GetSettingValue <Font>(setting.Name); FontPicker picker = new FontPicker() { Title = setting.Title, SelectedValue = font, Dock = DockStyle.Fill }; picker.SelectedValueChanged += (s, e) => SetSettingValue(setting.Name, picker.SelectedValue); return(picker); }); // Directory Picker Builder EditorBuilders.Add("directorypicker", setting => { string directory = GetSettingValue <string>(setting.Name); DirectoryPicker picker = new DirectoryPicker() { Title = setting.Title, SelectedValue = directory, Dock = DockStyle.Fill }; picker.SelectedValueChanged += (s, e) => SetSettingValue(setting.Name, picker.SelectedValue); return(picker); }); #endregion Default Control Builders }