Пример #1
0
        private void btnTraySlider_Click(object sender, EventArgs e)
        {
            TraySlider slider = new TraySlider();

            slider.ButtonLayout   = TraySlider.ButtonLayoutEnum.OneButton;              // Defaults to "OK"
            slider.ShowDurationMs = 30000;
            slider.ShowTraySlider(rtbMessage.Text, tbTitle.Text);
        }
Пример #2
0
        public void UpdateCheck()
        {
            try
            {
                // Check new version
                Stream stream;
                if (PluginDebug.UsesDebugData)
                {
                    var assembly = Assembly.GetExecutingAssembly();
                    stream = assembly.GetManifestResourceStream("FFXIV_ACT_Helper_Plugin.Resources.DebugPluginData.xml");
                }
                else
                {
                    using (WebClient client = new WebClient())
                    {
                        var data = Encoding.Default.GetString(client.DownloadData("https://ugabugab.github.io/ffxiv-act-helper-plugin/data/plugin_data.xml"));
                        stream = new MemoryStream(Encoding.UTF8.GetBytes(data));
                    }
                }
                XmlSerializer serializer = new XmlSerializer(typeof(PluginData));
                var           pluginData = (PluginData)serializer.Deserialize(stream);

                Version currentVersion = typeof(PluginMain).Assembly.GetName().Version;
                Version latestVersion  = new Version(pluginData.Version);

                if (currentVersion < latestVersion)
                {
                    // Show update confirming message
                    ActGlobalsExtension.RunOnACTUIThread(delegate
                    {
                        TraySlider traySlider = new TraySlider
                        {
                            ButtonLayout   = TraySlider.ButtonLayoutEnum.TwoButton,
                            ButtonSW       = { Text = "Update" },
                            ButtonSE       = { Text = "Cancel" },
                            TrayTitle      = { Text = "Plugin Update" },
                            TrayText       = { Text = Properties.Resources.MessagePluginUpdate },
                            ShowDurationMs = 30000
                        };
                        traySlider.ButtonSW.Click += delegate(object sender, EventArgs eventArgs)
                        {
                            UpdatePlugin(pluginData.Url);
                        };
                        traySlider.ShowTraySlider();
                    });
                }
            }
            catch (ThreadAbortException)
            {
                // Do nothing
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }
Пример #3
0
        protected override void OnSendNotification(string title, string message, string testing)
        {
            Logger.Write("UI: Request Showing Taost received...", LogLevel.Debug);
            if (MainControl.DisableToasts.Checked)
            {
                Logger.Write("UI: Toasts are disabled!", LogLevel.Debug);
                return;
            }

            if (MainControl.EnableActToast.Checked)
            {
                Logger.Write("UI: Using ACT Toasts", LogLevel.Debug);
                var traySlider = new TraySlider();
                traySlider.ShowDurationMs   = 30000;
                traySlider.ButtonSE.Visible = false;
                traySlider.ButtonNE.Visible = false;
                traySlider.ButtonNW.Visible = false;
                traySlider.ButtonSW.Visible = true;
                traySlider.ButtonSW.Text    = LocalizationRepository.GetText("ui-close-act-toast");
                traySlider.TrayTitle.Font   = new Font(FontFamily.GenericSerif, 16, FontStyle.Bold);
                traySlider.TrayText.Font    = new Font(FontFamily.GenericSerif, 12, FontStyle.Regular);
                if (!string.IsNullOrWhiteSpace(testing))
                {
                    message += $"\nCode [{testing}]";
                }

                traySlider.ShowTraySlider(message, title);
            }
            else
            {
                Logger.Write("UI: Using Windows Toasts", LogLevel.Debug);
                try
                {
                    // clearing old toasts if needed
                    DesktopNotificationManagerCompat.History.Clear();

                    Logger.Write("UI: Creating new Toast...", LogLevel.Debug);
                    ToastManager.ShowToast(title, message, testing);
                }
                catch (Exception e)
                {
                    Logger.Write(e, "UI: Using built in notifier...", LogLevel.Error);
                    var icon = new NotifyIcon
                    {
                        Icon            = SystemIcons.WinLogo,
                        Text            = "DFAssist",
                        Visible         = true,
                        BalloonTipTitle = title,
                        BalloonTipText  = message
                    };
                    icon.ShowBalloonTip(3000);
                    icon.Dispose();
                }
            }
        }
Пример #4
0
        private void btnTraySlider2_Click(object sender, EventArgs e)
        {
            TraySlider slider = new TraySlider();

            slider.ButtonLayout    = TraySlider.ButtonLayoutEnum.TwoButton;
            slider.ButtonSW.Text   = "OK";              // Do nothing and hide
            slider.ButtonSE.Text   = "Message";
            slider.ButtonSE.Click += (sender1, eventArgs1) => { MessageBox.Show("Message"); };
            slider.TrayTitle.Text  = tbTitle.Text;
            slider.TrayText.Text   = rtbMessage.Text;
            slider.AddNotification = false;             // Don't create notification
            slider.ShowTraySlider();
        }
Пример #5
0
 internal void NotifyEmptyApiKey()
 {
     if (InvokeRequired)
     {
         this.SafeInvoke(new Action(NotifyEmptyApiKey));
     }
     else
     {
         var ts = new TraySlider
         {
             ButtonLayout = TraySlider.ButtonLayoutEnum.OneButton,
         };
         ts.ShowTraySlider(strings.msgBaiduApiKeyEmpty, strings.actPanelTitle);
     }
 }
Пример #6
0
        private void ShowUpdateResult(PublishVersion newVersion, bool forceNotify)
        {
            if (newVersion == null)
            {
                if (forceNotify)
                {
                    var ts = new TraySlider
                    {
                        ButtonLayout = TraySlider.ButtonLayoutEnum.OneButton,
                    };
                    ts.ShowTraySlider(strings.messageLatest, strings.actPanelTitle);
                }
            }
            else
            {
                // Check if ignored
                if (forceNotify ||
                    !Version.TryParse(_plugin.Settings.VersionIgnored, out var v) ||
                    v < newVersion.ParsedVersion)
                {
                    // Show notify
                    var message = string.Format(newVersion.IsPreRelease
                            ? strings.messageNewPrerelease
                            : strings.messageNewStable,
                                                newVersion.ParsedVersion);

                    var ts = new TraySlider
                    {
                        ButtonLayout = TraySlider.ButtonLayoutEnum.FourButton,
                        ButtonSW     = { Text = strings.buttonUpdateNow },
                        ButtonSE     = { Text = strings.buttonUpdateLater },
                        ButtonNE     = { Text = strings.buttonIgnoreVersion },
                    };
                    ts.ButtonNW.Hide();
                    ts.ButtonSW.Click += (sender, args) => Process.Start(newVersion.PublishPage);
                    ts.ButtonNE.Click += (sender, args) => _controller.NotifyNewVersionIgnored(true, newVersion.ParsedVersion.ToString());
                    ts.ShowTraySlider(message, strings.actPanelTitle);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Play sound with ACT's WMP wrapper API
        /// </summary>
        private void ActWmpPlay(string WavFilePath, int VolumePercent)
        {
            try
            {
                ActGlobals.oFormActMain.PlaySoundWmpApi(WavFilePath, VolumePercent);
            }
            catch (Exception e)
            {
                if (e.ToString().Contains("6BF52A52-394A-11D3-B153-00C04F79FAA6"))
                {
                    // WMP unavailable
                    Logger.Error(strings.msgErrorWMPUnavailable);
                    Logger.Debug("Detailed exception:", e);

                    ActGlobals.oFormActMain.SafeInvoke(new Action(() =>
                    {
                        // Show notification
                        var ts = new TraySlider
                        {
                            ButtonLayout = TraySlider.ButtonLayoutEnum.OneButton,
                        };
                        ts.ShowTraySlider(strings.msgErrorWMPUnavailable, strings.actPanelTitle);

                        // Automatically switch to WASAPI
                        _plugin.SettingsTab.SwitchPlaybackPlayer(SoundPlayerWrapper.PlayerWASAPI);

                        // And retry this request using WASAPI
                        _plugin.SoundPlayer.Play(WavFilePath);
                    }));
                }
                else
                {
                    throw;
                }
            }
        }
Пример #8
0
        protected override void OnSendNotification(string title, string message, string testing)
        {
            Logger.Write("UI: Request Showing Taost received...", LogLevel.Debug);
            if (MainControl.DisableToasts.Checked)
            {
                Logger.Write("UI: Toasts are disabled!", LogLevel.Debug);
                return;
            }

            if (MainControl.EnableActToast.Checked)
            {
                Logger.Write("UI: Using ACT Toasts", LogLevel.Debug);
                var traySlider = new TraySlider
                {
                    Font           = new Font(FontFamily.GenericSerif, 16, FontStyle.Bold),
                    ShowDurationMs = 30000
                };
                traySlider.ButtonSE.Visible = false;
                traySlider.ButtonNE.Visible = false;
                traySlider.ButtonNW.Visible = false;
                traySlider.ButtonSW.Visible = true;
                traySlider.ButtonSW.Text    = LocalizationRepository.GetText("ui-close-act-toast");
                traySlider.ShowTraySlider($"{message}\n{testing}", title);
            }
            else
            {
                Logger.Write("UI: Using Windows Toasts", LogLevel.Debug);
                try
                {
                    Logger.Write("UI: Creating new Toast...", LogLevel.Debug);
                    var attribution = nameof(DFAssist);

                    if (string.IsNullOrWhiteSpace(testing))
                    {
                        WinToastWrapper.CreateToast(
                            DFAssistPlugin.AppId,
                            DFAssistPlugin.AppId,
                            title,
                            message,
                            _toastEventCallback,
                            attribution,
                            true,
                            Duration.Long);
                    }
                    else
                    {
                        WinToastWrapper.CreateToast(
                            DFAssistPlugin.AppId,
                            DFAssistPlugin.AppId,
                            title,
                            message,
                            $"Code [{testing}]",
                            _toastEventCallback,
                            attribution,
                            Duration.Long);
                    }
                }
                catch (Exception e)
                {
                    Logger.Write(e, "UI: Unable to show toast notification", LogLevel.Error);
                }
            }
        }
Пример #9
0
        private void ControllerOnSettingsLoaded()
        {
            Logger.IsDebugLevelEnabled = checkBoxDebugLogging.Checked;
            if (checkBoxCheckUpdate.Checked)
            {
                _plugin.UpdateChecker.CheckUpdate(false);
            }

            comboBoxTTSEngine.SelectedItem =
                TTSEngineFactory.Engines.FirstOrDefault(it => it.Name.Equals(_plugin.Settings.TTSEngine)) ??
                TTSEngineFactory.Engines.First();

            if (_plugin.Settings.BaiduTtsSettings.WasUsingFreeKey &&
                comboBoxTTSEngine.SelectedItem == TTSEngineFactory.EngineBaidu)
            {
                // Automatically switch to default engine if user is currently using baidu tts free key
                comboBoxTTSEngine.SelectedItem = TTSEngineFactory.Default;

                var ts = new TraySlider
                {
                    ButtonLayout = TraySlider.ButtonLayoutEnum.OneButton,
                };
                ts.ShowTraySlider(strings.msgBaiduFreeApiKeyExpired, strings.actPanelTitle);
            }

            comboBoxTTSEngine.SelectedIndexChanged += comboBoxTTSEngine_SelectedIndexChanged;

            switch (_plugin.Settings.PluginIntegration)
            {
            case PluginIntegration.Act:
                radioButtonIntegrationAct.Checked = true;
                break;

            case PluginIntegration.Yukkuri:
                radioButtonIntegrationYukkuri.Checked = true;
                break;

            default:
            case PluginIntegration.Auto:
                radioButtonIntegrationAuto.Checked = true;
                break;
            }
            radioButtonIntegrationAuto.CheckedChanged    += OnPluginIntegrationValueChanged;
            radioButtonIntegrationAct.CheckedChanged     += OnPluginIntegrationValueChanged;
            radioButtonIntegrationYukkuri.CheckedChanged += OnPluginIntegrationValueChanged;

            var playbackSettings = _plugin.Settings.PlaybackSettings;

            trackBarMasterVolume.SetValue(playbackSettings.MasterVolume, 100);
            switch (playbackSettings.Method)
            {
            case PlaybackMethod.Act:
                radioButtonPlaybackACT.Checked = true;
                break;

            case PlaybackMethod.Yukkuri:
                radioButtonPlaybackYukkuri.Checked = true;
                break;

            default:
            case PlaybackMethod.BuiltIn:
                radioButtonPlaybackBuiltIn.Checked = true;
                break;
            }
            comboBoxPlaybackApi.SelectedItem = playbackSettings.Api;
            if (comboBoxPlaybackApi.SelectedIndex == -1)
            {
                comboBoxPlaybackApi.SelectedIndex = 0;
            }
            checkBoxStopPrevious.Checked               = playbackSettings.StopPrevious;
            radioButtonPlaybackACT.CheckedChanged     += OnPlayerValueChanged;
            radioButtonPlaybackYukkuri.CheckedChanged += OnPlayerValueChanged;
            radioButtonPlaybackBuiltIn.CheckedChanged += OnPlayerValueChanged;
            comboBoxPlaybackApi.SelectedIndexChanged  += OnPlayerValueChanged;

            comboBoxPlaybackDevice.SelectedIndexChanged += OnPlaybackValueChanged;
            trackBarMasterVolume.ValueChanged           += OnPlaybackValueChanged;
            checkBoxStopPrevious.CheckedChanged         += OnPlaybackValueChanged;

            // Load text processor settings
            dataGridViewRules.AutoGenerateColumns = false;
            dataGridViewRules.Columns["ColumnOrder"].DataPropertyName       = nameof(PreProcessorRuleViewModel.Order);
            dataGridViewRules.Columns["ColumnEnabled"].DataPropertyName     = nameof(PreProcessorRuleViewModel.Enabled);
            dataGridViewRules.Columns["ColumnFindPattern"].DataPropertyName = nameof(PreProcessorRuleViewModel.SourcePattern);
            dataGridViewRules.Columns["ColumnReplacement"].DataPropertyName = nameof(PreProcessorRuleViewModel.Replacement);
            dataGridViewRules.Columns["ColumnUseRegex"].DataPropertyName    = nameof(PreProcessorRuleViewModel.UseRegex);
            foreach (var vm in _plugin.Settings.PreProcessorSettings.Rules.Select(
                         (v, index) => new PreProcessorRuleViewModel(index + 1, v)
                         ))
            {
                _rules.Add(vm);
            }
            dataGridViewRules.DataSource        = _rules;
            dataGridViewRules.SelectionChanged += DataGridViewRules_SelectionChanged;
            _rules.ListChanged += Rules_ListChanged;

            comboBoxTTSEngine_SelectedIndexChanged(null, EventArgs.Empty);
            OnPluginIntegrationValueChanged(null, EventArgs.Empty);
            OnPlayerValueChanged(null, EventArgs.Empty);
            OnPlaybackValueChanged(null, EventArgs.Empty);
            DataGridViewRules_SelectionChanged(null, EventArgs.Empty);
        }