Пример #1
0
 private void ExitItem_Click(object sender, EventArgs e)
 {
     closing            = true;
     notifyIcon.Visible = false;
     AudioHandler.Dispose();
     System.Windows.Application.Current.Shutdown();
 }
Пример #2
0
 private void FrmAudio_FormClosing(object sender, FormClosingEventArgs e)
 {
     // all cleanup logic goes here
     if (_remoteAudioHandler.IsStarted)
     {
         StopStream();
     }
     UnregisterMessageHandler();
     _remoteAudioHandler.Dispose();
 }
 /// <summary>
 /// Sets the handler references to null.
 /// Where required also calls Dispose().
 /// </summary>
 private void FreeHandlersExceptLifeSpanAndFocus()
 {
     AudioHandler?.Dispose();
     AudioHandler    = null;
     DialogHandler   = null;
     FindHandler     = null;
     RequestHandler  = null;
     DisplayHandler  = null;
     LoadHandler     = null;
     KeyboardHandler = null;
     JsDialogHandler = null;
     DragHandler     = null;
     DownloadHandler = null;
     MenuHandler     = null;
     ResourceRequestHandlerFactory = null;
     RenderProcessMessageHandler   = null;
 }
Пример #4
0
        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();
        }