示例#1
0
        public static ContextMenu CreateMenu(FormBrowser form)
        {
            ContextMenu menu = new ContextMenu();

            menu.MenuItems.Add(TitleReloadBrowser, (sender, args) => form.ReloadToTweetDeck());
            menu.MenuItems.Add(TitleMuteNotifications, (sender, args) => ToggleMuteNotifications());
            menu.MenuItems.Add("-");
            menu.MenuItems.Add(TitleSettings, (sender, args) => form.OpenSettings());
            menu.MenuItems.Add(TitlePlugins, (sender, args) => form.OpenPlugins());
            menu.MenuItems.Add(TitleAboutProgram, (sender, args) => form.OpenAbout());

            menu.Popup += (sender, args) => {
                menu.MenuItems[1].Checked = Program.UserConfig.MuteNotifications;
            };

            return(menu);
        }
示例#2
0
        public static IResourceHandler CreateFileHandler(string path)
        {
            string mimeType;

            switch (Path.GetExtension(path))
            {
            case ".weba":
            case ".webm": mimeType = "audio/webm"; break;

            case ".wav": mimeType = "audio/wav"; break;

            case ".ogg": mimeType = "audio/ogg"; break;

            case ".mp3": mimeType = "audio/mp3"; break;

            case ".flac": mimeType = "audio/flac"; break;

            case ".opus": mimeType = "audio/ogg; codecs=opus"; break;

            default: mimeType = null; break;
            }

            try{
                return(ResourceHandler.FromFilePath(path, mimeType));
            }catch {
                FormBrowser browser = FormManager.TryFind <FormBrowser>();

                browser?.InvokeAsyncSafe(() => {
                    using (FormMessage form = new FormMessage("Sound Notification Error", "Could not find custom notification sound file:\n" + path, MessageBoxIcon.Error)){
                        form.AddButton(FormMessage.Ignore, ControlType.Cancel | ControlType.Focused);

                        Button btnViewOptions   = form.AddButton("View Options");
                        btnViewOptions.Width   += 16;
                        btnViewOptions.Location = new Point(btnViewOptions.Location.X - 16, btnViewOptions.Location.Y);

                        if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnViewOptions)
                        {
                            browser.OpenSettings(typeof(TabSettingsSounds));
                        }
                    }
                });

                return(null);
            }
        }
示例#3
0
        public static Func <IResourceHandler> CreateFileHandler(string path)
        {
            string mimeType = Path.GetExtension(path) switch {
                ".weba" => "audio/webm",
                ".webm" => "audio/webm",
                ".wav" => "audio/wav",
                ".ogg" => "audio/ogg",
                ".mp3" => "audio/mp3",
                ".flac" => "audio/flac",
                ".opus" => "audio/ogg; codecs=opus",
                _ => null
            };

            try{
                return(ResourceHandlers.ForBytes(File.ReadAllBytes(path), mimeType));
            }catch {
                FormBrowser browser = FormManager.TryFind <FormBrowser>();

                browser?.InvokeAsyncSafe(() => {
                    using FormMessage form = new FormMessage("Sound Notification Error", "Could not find custom notification sound file:\n" + path, MessageBoxIcon.Error);
                    form.AddButton(FormMessage.Ignore, ControlType.Cancel | ControlType.Focused);

                    Button btnViewOptions   = form.AddButton("View Options");
                    btnViewOptions.Width   += 16;
                    btnViewOptions.Location = new Point(btnViewOptions.Location.X - 16, btnViewOptions.Location.Y);

                    if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnViewOptions)
                    {
                        browser.OpenSettings(typeof(TabSettingsSounds));
                    }
                });

                return(null);
            }
        }
    }