public static void CreateColorPicker() { SolidColorBrush tempAccent = null; var picker = SingleOpenHelper.CreateControl <ColorPicker>(); var window = new PopupWindow { PopupElement = picker, WindowStartupLocation = WindowStartupLocation.CenterScreen, AllowsTransparency = true, WindowStyle = WindowStyle.None, MinWidth = 0, MinHeight = 0, Title = "Accent Color", FontFamily = ResourceHelper.GetResource <FontFamily>("CascadiaCode") }; Style style = new Style(typeof(Button)); style.BasedOn = ResourceHelper.GetResource <Style>("ButtonDefault"); window.Resources.Add(typeof(Button), style); if (Settings.Accent != null) { picker.SelectedBrush = new SolidColorBrush(ColorHelper.GetColorFromBrush(Settings.Accent)); tempAccent = picker.SelectedBrush; } picker.SelectedColorChanged += delegate { ((App)Application.Current).UpdateAccent(picker.SelectedBrush); }; bool isConfirmed = false; picker.Confirmed += delegate { Settings.Accent = picker.SelectedBrush; isConfirmed = true; window.Close(); }; picker.Canceled += delegate { ((App)Application.Current).UpdateAccent(tempAccent); Settings.Accent = tempAccent; isConfirmed = false; window.Close(); }; window.Closing += (s, e) => { if (!isConfirmed) { ((App)Application.Current).UpdateAccent(tempAccent); Settings.Accent = tempAccent; } }; window.Show(); }
private void Share_OnClick(object sender, RoutedEventArgs e) { ShareWindow shareWindow = SingleOpenHelper.CreateControl <ShareWindow>(); (new PopupWindow() { PopupElement = shareWindow }).ShowDialog(this.Share, false); }
private void ButtonMouseFollow_OnClick(object sender, RoutedEventArgs e) { var picker = SingleOpenHelper.CreateControl <ColorPicker>(); var window = new PopupWindow { PopupElement = picker }; picker.SelectedColorChanged += delegate { window.Close(); }; picker.Canceled += delegate { window.Close(); }; window.Show(ButtonMouseFollow, false); }
private void ButtonCustomContent_OnClick(object sender, RoutedEventArgs e) { var picker = SingleOpenHelper.CreateControl <ColorPicker>(); var window = new PopupWindow { PopupElement = picker, WindowStartupLocation = WindowStartupLocation.CenterScreen, AllowsTransparency = true, WindowStyle = WindowStyle.None, MinWidth = 0, MinHeight = 0, Title = Properties.Langs.Lang.ColorPicker }; picker.SelectedColorChanged += delegate { window.Close(); }; picker.Canceled += delegate { window.Close(); }; window.Show(); }