private void PagesList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (PagesList.SelectedIndex != -1) { currentPage = clipPages[PagesList.SelectedIndex]; } BuildClipPage(); PagesList.SelectedIndex = -1; }
public ClipPageSettings(ClipPage clipPage) { InitializeComponent(); Name.Text = clipPage.Name; Width.Text = clipPage.Width.ToString(); Height.Text = clipPage.Height.ToString(); Hotkey.Info = clipPage.HotkeyInfo; this.clipPage = clipPage; }
private void AddClipPage_Click(object sender, RoutedEventArgs e) { var page = new ClipPage(7, 5) { Name = "Page " + clipPages.Count }; page.OnChanged += Page_OnChanged; if (PagesList.SelectedIndex == -1) { clipPages.Add(page); UpdatePagesList(); PagesList.SelectedIndex = clipPages.Count - 1; } else { clipPages.Insert(PagesList.SelectedIndex, page); UpdatePagesList(); } }
public MainWindow() { #if !DEBUG Hide(); #endif var assembly = Assembly.GetExecutingAssembly(); string resourceName = "WPF_Soundboard.Resources.icon.ico"; using Stream stream = assembly.GetManifestResourceStream(resourceName); notifyIcon.Icon = new Icon(stream); notifyIcon.Visible = true; notifyIcon.MouseClick += NotifyIcon_MouseClick; notifyIcon.ContextMenuStrip = new ContextMenuStrip(); var showItem = new ToolStripMenuItem("Show"); showItem.Click += ShowItem_Click; var exitItem = new ToolStripMenuItem("Exit"); exitItem.Click += ExitItem_Click; notifyIcon.ContextMenuStrip.Items.Add(showItem); notifyIcon.ContextMenuStrip.Items.Add(exitItem); InitializeComponent(); try { AudioHandler.Initialize(); } catch { try { MessageBoxResult result = System.Windows.MessageBox.Show("Error while initializing Audio. Do you want to reset audio settings?", "Audio error in WPF-Soundboard", MessageBoxButton.YesNo, MessageBoxImage.Error); if (result == MessageBoxResult.Yes) { AudioHandler.Config = AudioConfig.GetDefault(); AudioHandler.Initialize(); } else { throw; } } catch (Exception e) { System.Windows.MessageBox.Show(e.GetType() + ": " + e.Message + "\n--------\n" + e.StackTrace, "Audio error in WPF-Soundboard - Quitting", MessageBoxButton.OK, MessageBoxImage.Error); closing = true; notifyIcon.Visible = false; AudioHandler.Dispose(); System.Windows.Application.Current.Shutdown(); return; } } clipPages = Serializer.GetClipPages(); clipPages.GlobalHotkeyList.OnHotkeyPressed += GlobalHotkeyList_OnHotkeyPressed; clipPages.OnStopHotkeyPressed += ClipPages_OnStopHotkeyPressed; if (clipPages.Count == 0) { clipPages.Add(new ClipPage(7, 5)); } foreach (ClipPage page in clipPages) { page.OnChanged += Page_OnChanged; page.OnHotkeyPressed += Page_OnHotkeyPressed; } currentPage = clipPages[0]; BuildClipPage(); UpdatePagesList(); }
private void Page_OnHotkeyPressed(object sender, EventArgs e) { currentPage = sender as ClipPage; BuildClipPage(); }