예제 #1
0
 private void DevBasicMessageBoxButton_OnClick(object sender, RoutedEventArgs e)
 {
     ModernMessageBox.Show("This is a Message Box",
                           "Testing the default, and rather generic, message box. Le wumbalo. More text, need to fill up screen to test text wrapping. And to look important, ofcourse.");
 }
예제 #2
0
        public void InitPluginCore(
            TabPage pluginScreenSpace,
            Label pluginStatusText)
        {
            this.PluginStatusLabel = pluginStatusText;

            AppLog.LoadConfiguration(AppLog.HojoringConfig);
            this.AppLogger.Trace(Assembly.GetExecutingAssembly().GetName().ToString() + " start.");

            try
            {
                Logger.Init();
                Logger.Write("Plugin Start.");

                // 設定ファイルを読み込む
                Settings.Default.Load();
                Settings.Default.ApplyRenderMode();

                pluginScreenSpace.Text = "SPESPE";

                // HojoringのSplashを表示する
                WPFHelper.Start();
                UpdateChecker.ShowSplash();

                // アップデートを確認する
                Task.Run(() =>
                {
                    this.Update();
                });

                // 自身の場所を格納しておく
                var plugin = ActGlobals.oFormActMain.PluginGetSelfData(this.PluginRoot);
                if (plugin != null)
                {
                    this.Location = plugin.pluginFile.DirectoryName;
                }

                // 設定ファイルを読み込む
                SpellPanelTable.Instance.Load();
                SpellTable.Instance.Load();
                TickerTable.Instance.Load();
                TagTable.Instance.Load();

                // 設定ファイルのバックアップを作成する
                SpellPanelTable.Instance.Backup();
                SpellTable.Instance.Backup();
                TickerTable.Instance.Backup();
                TagTable.Instance.Backup();

                // TTS辞書を読み込む
                TTSDictionary.Instance.Load();

                // 設定Panelを追加する
                var baseView = new BaseView(pluginScreenSpace.Font);
                pluginScreenSpace.Controls.Add(new ElementHost()
                {
                    Child = baseView,
                    Dock  = DockStyle.Fill,
                    Font  = pluginScreenSpace.Font,
                });

                // 本体を開始する
                PluginMainWorker.Instance.Begin();
                TimelineController.Init();

                // LPSViewを表示する
                LPSView.ShowLPS();

                this.SetSwitchVisibleButton();
                this.PluginStatusLabel.Text = "Plugin Started";

                Logger.Write("Plugin Started.");
            }
            catch (Exception ex)
            {
                ActGlobals.oFormActMain.WriteExceptionLog(
                    ex,
                    "Plugin init error.");

                Logger.Write("Plugin init error.", ex);

                if (this.PluginStatusLabel != null)
                {
                    this.PluginStatusLabel.Text = "Plugin Initialize Error";
                }

                ModernMessageBox.ShowDialog(
                    "Plugin init error !",
                    "ACT.SpecialSpellTimer",
                    System.Windows.MessageBoxButton.OK,
                    ex);
            }
        }
예제 #3
0
        public void InitPlugin(
            IActPluginV1 plugin,
            TabPage pluginScreenSpace,
            Label pluginStatusText)
        {
            // タイトルをセットする
            pluginScreenSpace.Text = "YUKKURI";

            WPFHelper.Start();
            WPFHelper.BeginInvoke(async() =>
            {
                // FFXIV_MemoryReaderを先にロードさせる
                await FFXIVReader.Instance.WaitForReaderToStartedAsync();

                AppLog.LoadConfiguration(AppLog.HojoringConfig);
                this.Logger.Trace(Assembly.GetExecutingAssembly().GetName().ToString() + " start.");

                try
                {
                    EnvironmentHelper.GarbageLogs();
                    this.Logger.Trace("[YUKKURI] Start InitPlugin");

                    this.PluginStatusLabel = pluginStatusText;

                    var pluginInfo = ActGlobals.oFormActMain.PluginGetSelfData(plugin);
                    if (pluginInfo != null)
                    {
                        this.PluginDirectory = pluginInfo.pluginFile.DirectoryName;
                    }

                    // .NET FrameworkとOSのバージョンを確認する
                    if (!UpdateChecker.IsAvailableDotNet() ||
                        !UpdateChecker.IsAvailableWindows())
                    {
                        NotSupportedView.AddAndShow(pluginScreenSpace);
                        return;
                    }

                    // 設定ファイルを読み込む
                    Settings.Default.Load();

                    // 漢字変換を初期化する
                    KanjiTranslator.Default.Initialize();

                    // TTSキャッシュの移行とGarbageを行う
                    await Task.Run(() =>
                    {
                        this.MigrateTTSCache();
                        this.GarbageTTSCache();
                    });

                    // HojoringのSplashを表示する
                    WPFHelper.Start();
                    UpdateChecker.ShowSplash();

                    await Task.Run(() =>
                    {
                        // TTSサーバを開始する
                        TTSServerController.Start();

                        // TTSを初期化する
                        SpeechController.Default.Initialize();

                        // FF14監視スレッドを初期化する
                        FFXIVWatcher.Initialize();
                    });

                    // 設定Panelを追加する
                    pluginScreenSpace.Controls.Add(new ElementHost()
                    {
                        Child = new ConfigBaseView(),
                        Dock  = DockStyle.Fill,
                    });

                    // TTSメソッドを置き換える
                    this.StartReplaceTTSMethodTimer();

                    await Task.Run(() =>
                    {
                        // DISCORD BOT クライアントを初期化する
                        DiscordClientModel.Model.Initialize();

                        // AutoJoinがONならば接続する
                        if (Settings.Default.DiscordSettings.AutoJoin)
                        {
                            DiscordClientModel.Model.Connect(true);
                        }
                    });

                    await Task.Run(() =>
                    {
                        // VOICEROIDを起動する
                        if (SpeechController.Default is VoiceroidSpeechController ctrl)
                        {
                            ctrl.Start();
                        }
                    });

                    // Bridgeにメソッドを登録する
                    PlayBridge.Instance.SetBothDelegate((message, isSync, volume) => this.Speak(message, PlayDevices.Both, isSync, volume));
                    PlayBridge.Instance.SetMainDeviceDelegate((message, isSync, volume) => this.Speak(message, PlayDevices.Main, isSync, volume));
                    PlayBridge.Instance.SetSubDeviceDelegate((message, isSync, volume) => this.Speak(message, PlayDevices.Sub, isSync, volume));
                    PlayBridge.Instance.SetSyncStatusDelegate(() => Settings.Default.Player == WavePlayerTypes.WASAPIBuffered);

                    // サウンドデバイスを初期化する
                    SoundPlayerWrapper.Init();

                    PluginStatusLabel.Text = "Plugin Started";

                    this.Logger.Trace("[YUKKURI] End InitPlugin");

                    // アップデートを確認する
                    await Task.Run(() => this.Update());
                }
                catch (Exception ex)
                {
                    this.Logger.Error(ex, "InitPlugin error.");

                    ModernMessageBox.ShowDialog(
                        "Plugin init error !",
                        "ACT.TTSYukkuri",
                        System.Windows.MessageBoxButton.OK,
                        ex);

                    // TTSをゆっくりに戻す
                    Settings.Default.TTS = TTSType.Yukkuri;
                    Settings.Default.Save();
                }
            });
        }
예제 #4
0
        public async void InitPluginCore(
            TabPage pluginScreenSpace,
            Label pluginStatusText)
        {
            // タイトルをセットする
            pluginScreenSpace.Text = "SPESPE";

            EnvironmentMigrater.Migrate();
            MasterFilePublisher.Publish();
            WPFHelper.Start();

            AppLog.LoadConfiguration(AppLog.HojoringConfig);
            this.AppLogger?.Trace(Assembly.GetExecutingAssembly().GetName().ToString() + " start.");

            try
            {
                this.PluginStatusLabel = pluginStatusText;

                if (!EnvironmentHelper.IsValidPluginLoadOrder())
                {
                    if (pluginStatusText != null)
                    {
                        pluginStatusText.Text = "Plugin Initialize Error";
                    }

                    return;
                }

                EnvironmentHelper.GarbageLogs();
                EnvironmentHelper.StartActivator(() =>
                {
                    BaseView.Instance.SetActivationStatus(false);
                    this.DeInitPluginCore();
                });

                Logger.Init();
                Logger.Write("[SPESPE] Start InitPlugin");

                // .NET FrameworkとOSのバージョンを確認する
                if (!UpdateChecker.IsAvailableDotNet() ||
                    !UpdateChecker.IsAvailableWindows())
                {
                    NotSupportedView.AddAndShow(pluginScreenSpace);
                    return;
                }

                // FFXIV.Framework.config を読み込ませる
                lock (FFXIV.Framework.Config.ConfigBlocker)
                {
                    _ = FFXIV.Framework.Config.Instance;
                }

                // HojoringのSplashを表示する
                UpdateChecker.ShowSplash();

                // 外部リソースをダウンロードする
                if (await ResourcesDownloader.Instance.DownloadAsync())
                {
                    await ResourcesDownloader.Instance.WaitDownloadingAsync();
                }

                // メイン設定ファイルを読み込む
                Settings.Default.Load();
                Settings.Default.ApplyRenderMode();
                Settings.Default.StartAutoSave();

                // 最小化する?
                if (Settings.Default.IsMinimizeOnStart)
                {
                    ActGlobals.oFormActMain.WindowState = FormWindowState.Minimized;
                }

                // 自身の場所を格納しておく
                var plugin = ActGlobals.oFormActMain.PluginGetSelfData(this.PluginRoot);
                if (plugin != null)
                {
                    this.Location = plugin.pluginFile.DirectoryName;
                }

                // 設定ファイルを読み込む
                SpellPanelTable.Instance.Load();
                SpellTable.Instance.Load();
                TickerTable.Instance.Load();
                TagTable.Instance.Load();
                _ = TimelineSettings.Instance;

                // 設定ファイルをバックアップする
                await EnvironmentHelper.BackupFilesAsync(
                    Settings.Default.FileName,
                    SpellPanelTable.Instance.DefaultFile,
                    SpellTable.Instance.DefaultFile,
                    TickerTable.Instance.DefaultFile,
                    TagTable.Instance.DefaultFile,
                    TimelineSettings.FileName,
                    FFXIV.Framework.Config.FileName);

                TTSDictionary.Instance.Load();

                // 設定Panelを追加する
                var baseView = new BaseView(pluginScreenSpace.Font);
                pluginScreenSpace.Controls.Add(new ElementHost()
                {
                    Child = baseView,
                    Dock  = DockStyle.Fill,
                    Font  = pluginScreenSpace.Font,
                });

                await EnvironmentHelper.WaitInitActDoneAsync();

                // ACTのメインウィンドウの表示まで待つ
                await Task.Run(async() =>
                {
                    while (!ActGlobals.oFormActMain.CanFocus)
                    {
                        await Task.Delay(200);
                    }
                });

                // 本体を開始する
                PluginMainWorker.Instance.Begin();
                TimelineController.Init();

                // 付加情報オーバーレイを表示する
                LPSView.ShowLPS();
                POSView.ShowPOS();

                this.SetSwitchVisibleButton();

                if (this.PluginStatusLabel != null)
                {
                    this.PluginStatusLabel.Text = "Plugin Started";
                }

                Logger.Write("[SPESPE] End InitPlugin");

                // 共通ビューを追加する
                CommonViewHelper.Instance.AddCommonView(
                    pluginScreenSpace.Parent as TabControl);

                this.isLoaded = true;

                // アップデートを確認する
                await Task.Run(() => this.Update());
            }
            catch (Exception ex)
            {
                Logger.Write("InitPlugin error.", ex);

                if (this.PluginStatusLabel != null)
                {
                    this.PluginStatusLabel.Text = "Plugin Initialize Error";
                }

                ModernMessageBox.ShowDialog(
                    "Plugin init error !",
                    "ACT.SpecialSpellTimer",
                    System.Windows.MessageBoxButton.OK,
                    ex);
            }
        }
예제 #5
0
        public void InitPluginCore(
            TabPage pluginScreenSpace,
            Label pluginStatusText)
        {
            // タイトルをセットする
            pluginScreenSpace.Text = "SPESPE";

            WPFHelper.Start();
            WPFHelper.BeginInvoke(async() =>
            {
                // FFXIV_MemoryReaderを先にロードさせる
                await FFXIVReader.Instance.WaitForReaderToStartedAsync();

                this.PluginStatusLabel = pluginStatusText;

                AppLog.LoadConfiguration(AppLog.HojoringConfig);
                this.AppLogger.Trace(Assembly.GetExecutingAssembly().GetName().ToString() + " start.");

                try
                {
                    EnvironmentHelper.GarbageLogs();
                    Logger.Init();
                    Logger.Write("[SPESPE] Start InitPlugin");

                    // .NET FrameworkとOSのバージョンを確認する
                    if (!UpdateChecker.IsAvailableDotNet() ||
                        !UpdateChecker.IsAvailableWindows())
                    {
                        NotSupportedView.AddAndShow(pluginScreenSpace);
                        return;
                    }

                    // メイン設定ファイルを読み込む
                    Settings.Default.Load();
                    Settings.Default.ApplyRenderMode();

                    // 最小化する?
                    if (Settings.Default.IsMinimizeOnStart)
                    {
                        ActGlobals.oFormActMain.WindowState = FormWindowState.Minimized;
                    }

                    // HojoringのSplashを表示する
                    UpdateChecker.ShowSplash();

                    // 自身の場所を格納しておく
                    var plugin = ActGlobals.oFormActMain.PluginGetSelfData(this.PluginRoot);
                    if (plugin != null)
                    {
                        this.Location = plugin.pluginFile.DirectoryName;
                    }

                    // 設定ファイルを読み込む
                    SpellPanelTable.Instance.Load();
                    SpellTable.Instance.Load();
                    TickerTable.Instance.Load();
                    TagTable.Instance.Load();

                    await Task.Run(() =>
                    {
                        SpellPanelTable.Instance.Backup();
                        SpellTable.Instance.Backup();
                        TickerTable.Instance.Backup();
                        TagTable.Instance.Backup();
                    });

                    TTSDictionary.Instance.Load();

                    // 設定Panelを追加する
                    var baseView = new BaseView(pluginScreenSpace.Font);
                    pluginScreenSpace.Controls.Add(new ElementHost()
                    {
                        Child = baseView,
                        Dock  = DockStyle.Fill,
                        Font  = pluginScreenSpace.Font,
                    });

                    // 本体を開始する
                    PluginMainWorker.Instance.Begin();
                    TimelineController.Init();

                    // 付加情報オーバーレイを表示する
                    LPSView.ShowLPS();
                    POSView.ShowPOS();

                    this.SetSwitchVisibleButton();
                    this.PluginStatusLabel.Text = "Plugin Started";

                    Logger.Write("[SPESPE] End InitPlugin");

                    // アップデートを確認する
                    await Task.Run(() => this.Update());
                }
                catch (Exception ex)
                {
                    Logger.Write("InitPlugin error.", ex);

                    if (this.PluginStatusLabel != null)
                    {
                        this.PluginStatusLabel.Text = "Plugin Initialize Error";
                    }

                    ModernMessageBox.ShowDialog(
                        "Plugin init error !",
                        "ACT.SpecialSpellTimer",
                        System.Windows.MessageBoxButton.OK,
                        ex);
                }
            });
        }
예제 #6
0
        public void InitPlugin(
            IActPluginV1 plugin,
            TabPage pluginScreenSpace,
            Label pluginStatusText)
        {
            // タイトルをセットする
            pluginScreenSpace.Text = "YUKKURI";

            EnvironmentMigrater.Migrate();
            MasterFilePublisher.Publish();
            WPFHelper.Start();
            WPFHelper.BeginInvoke(async() =>
            {
                AppLog.LoadConfiguration(AppLog.HojoringConfig);
                this.Logger?.Trace(Assembly.GetExecutingAssembly().GetName().ToString() + " start.");

                try
                {
                    this.PluginStatusLabel = pluginStatusText;

                    if (!EnvironmentHelper.IsValidPluginLoadOrder())
                    {
                        if (pluginStatusText != null)
                        {
                            pluginStatusText.Text = "Plugin Initialize Error";
                        }

                        return;
                    }

                    EnvironmentHelper.GarbageLogs();
                    EnvironmentHelper.StartActivator(() =>
                    {
                        ConfigBaseView.Instance.SetActivationStatus(false);
                        this.DeInitPlugin();
                    });

                    this.Logger.Trace("[YUKKURI] Start InitPlugin");

                    var pluginInfo = ActGlobals.oFormActMain.PluginGetSelfData(plugin);
                    if (pluginInfo != null)
                    {
                        this.PluginDirectory = pluginInfo.pluginFile.DirectoryName;
                    }

                    // .NET FrameworkとOSのバージョンを確認する
                    if (!UpdateChecker.IsAvailableDotNet() ||
                        !UpdateChecker.IsAvailableWindows())
                    {
                        NotSupportedView.AddAndShow(pluginScreenSpace);
                        return;
                    }

                    // FFXIV.Framework.config を読み込ませる
                    lock (FFXIV.Framework.Config.ConfigBlocker)
                    {
                        _ = FFXIV.Framework.Config.Instance;
                    }

                    // HojoringのSplashを表示する
                    UpdateChecker.ShowSplash();

                    // 外部リソースをダウンロードする
                    await ResourcesDownloader.Instance.DownloadAsync();

                    // 設定ファイルを読み込む
                    Settings.Default.Load();
                    Settings.Default.StatusAlertSettings.EnabledTPAlert = false;

                    // 設定ファイルをバックアップする
                    await EnvironmentHelper.BackupFilesAsync(
                        Settings.FilePath);

                    // 漢字変換を初期化する
                    KanjiTranslator.Default.Initialize();

                    // TTSキャッシュの移行とGarbageを行う
                    await Task.Run(() =>
                    {
                        this.MigrateTTSCache();
                        this.GarbageTTSCache();
                    });

                    EnvironmentHelper.WaitInitActDone();

                    await Task.Run(() =>
                    {
                        // TTSを初期化する
                        SpeechController.Default.Initialize();

                        // FF14監視スレッドを初期化する
                        FFXIVWatcher.Initialize();
                    });

                    // 設定Panelを追加する
                    pluginScreenSpace.Controls.Add(new ElementHost()
                    {
                        Child = new ConfigBaseView(),
                        Dock  = DockStyle.Fill,
                    });

                    // TTSメソッドを置き換える
                    this.StartReplaceTTSMethodTimer();

                    await Task.Run(() =>
                    {
                        // DISCORD BOT クライアントを初期化する
                        DiscordClientModel.Model.Initialize();

                        // AutoJoinがONならば接続する
                        if (Settings.Default.DiscordSettings.AutoJoin)
                        {
                            DiscordClientModel.Model.Connect(true);
                        }
                    });

                    await Task.Run(() =>
                    {
                        // VOICEROIDを起動する
                        if (SpeechController.Default is VoiceroidSpeechController ctrl)
                        {
                            ctrl.Start();
                        }
                    });

                    // Bridgeにメソッドを登録する
                    PlayBridge.Instance.SetBothDelegate((message, voicePalette, isSync, volume) => this.Speak(message, PlayDevices.Both, voicePalette, isSync, volume));
                    PlayBridge.Instance.SetMainDeviceDelegate((message, voicePalette, isSync, volume) => this.Speak(message, PlayDevices.Main, voicePalette, isSync, volume));
                    PlayBridge.Instance.SetSubDeviceDelegate((message, voicePalette, isSync, volume) => this.Speak(message, PlayDevices.Sub, voicePalette, isSync, volume));
                    PlayBridge.Instance.SetSyncStatusDelegate(() => Settings.Default.Player == WavePlayerTypes.WASAPIBuffered);

                    // テキストコマンドの購読を登録する
                    this.SubscribeTextCommands();

                    // サウンドデバイスを初期化する
                    SoundPlayerWrapper.Init();
                    SoundPlayerWrapper.LoadTTSCache();

                    // CeVIOをアイコン化する
                    if (Settings.Default.TTS == TTSType.Sasara)
                    {
                        CevioTrayManager.Start();
                        CevioTrayManager.ToIcon();
                    }

                    if (this.PluginStatusLabel != null)
                    {
                        this.PluginStatusLabel.Text = "Plugin Started";
                    }

                    this.Logger.Trace("[YUKKURI] End InitPlugin");

                    // 共通ビューを追加する
                    CommonViewHelper.Instance.AddCommonView(
                        pluginScreenSpace.Parent as TabControl);

                    this.isLoaded = true;

                    // アップデートを確認する
                    await Task.Run(() => this.Update());
                }
                catch (Exception ex)
                {
                    this.Logger.Error(ex, "InitPlugin error.");

                    ModernMessageBox.ShowDialog(
                        "Plugin init error !",
                        "ACT.TTSYukkuri",
                        System.Windows.MessageBoxButton.OK,
                        ex);

                    // TTSをゆっくりに戻す
                    Settings.Default.TTS = TTSType.Yukkuri;
                    Settings.Default.Save();
                }
            });
        }
예제 #7
0
        private async void ExecuteGetVoicesCommand()
        {
            if (string.IsNullOrEmpty(this.Config.AccessKey) ||
                string.IsNullOrEmpty(this.Config.SecretKey))
            {
                ModernMessageBox.ShowDialog(
                    "Enter your access key and secret key.",
                    "ACT.Hojoring");

                return;
            }

            var endpoint = this.Config.Endpoint;
            var chain    = new CredentialProfileStoreChain();

            var hash        = (this.Config.Region + this.Config.AccessKey + this.Config.SecretKey).GetHashCode().ToString("X4");
            var profileName = $"polly_profile_{hash}";

            AWSCredentials awsCredentials;

            if (!chain.TryGetAWSCredentials(
                    profileName,
                    out awsCredentials))
            {
                var options = new CredentialProfileOptions
                {
                    AccessKey = this.Config.AccessKey,
                    SecretKey = this.Config.SecretKey,
                };

                var profile = new CredentialProfile(profileName, options);
                profile.Region = endpoint;

                chain.RegisterProfile(profile);

                chain.TryGetAWSCredentials(
                    profileName,
                    out awsCredentials);
            }

            if (awsCredentials == null)
            {
                return;
            }

            var voice = this.Config.Voice;

            using (var pc = new AmazonPollyClient(
                       awsCredentials,
                       endpoint))
            {
                var res = await pc.DescribeVoicesAsync(new DescribeVoicesRequest());

                if (res == null ||
                    res.HttpStatusCode != HttpStatusCode.OK)
                {
                    ModernMessageBox.ShowDialog(
                        "Voices update is failed.",
                        "ACT.Hojoring");

                    return;
                }

                this.Voices.Clear();
                this.Config.Voice = string.Empty;

                foreach (var v in
                         from x in res.Voices
                         orderby
                         x.LanguageCode.ToString(),
                         x.Gender.ToString(),
                         x.Name
                         select
                         x)
                {
                    this.Voices.Add(
                        new PollyConfigs.PollyVoice {
                        Name = $"{v.Id.Value} ({v.LanguageCode}, {v.Gender})", Value = v.Id
                    });
                }
            }

            if (this.Voices.Any(x => x.Value == voice))
            {
                this.Config.Voice = voice;
            }

            Settings.Default.Save();

            ModernMessageBox.ShowDialog(
                "Voices update is completed.",
                "ACT.Hojoring");
        }
예제 #8
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text.Length > 0)
            {
                Server.Name = txtName.Text;
                Title       = Server.DisplayName;
            }
            else
            {
                txtName.Text = Server.Name;
            }
            int port;

            if (int.TryParse(txtPort.Text, out port))
            {
                Server.Port = port;
            }
            else
            {
                txtPort.Text = Server.Port.ToString();
            }
            if (txtWorld.Text.Length > 0)
            {
                Server.World = txtWorld.Text;
            }
            else
            {
                txtWorld.Text = Server.World;
            }
            if (txtPassword.Text.Length == 0)
            {
                LogMessage("Warning: Servers must have passwords unless modded to remove that requirement.");
            }
            else if (txtPassword.Text.Length >= 5)
            {
                if (!Server.World.Contains(txtPassword.Text))
                {
                    Server.Password = txtPassword.Text;
                }
                else
                {
                    var mmb = new ModernMessageBox(this);
                    mmb.Show("Passwords must be at least 5 characters, and cannot be contained in your world name.", "Invalid Password", MessageBoxButton.OK, MessageBoxImage.Warning);
                    txtPassword.Text = Server.Password;
                }
            }
            else
            {
                var mmb = new ModernMessageBox(this);
                mmb.Show("Passwords must be at least 5 characters, and cannot be contained in your world name.", "Invalid Password", MessageBoxButton.OK, MessageBoxImage.Warning);
                txtPassword.Text = Server.Password;
            }
            Server.Password      = txtPassword.Text;
            Server.SaveDir       = txtSaveDir.Text;
            Server.Public        = chkPublic.IsChecked.GetValueOrDefault();
            Server.InstallPath   = txtServerDir.Text;
            Server.InstallMethod = (ValheimServer.ServerInstallMethod)cmbServerType.SelectedIndex;

            Server.Autostart       = chkAutostart.IsChecked.GetValueOrDefault();
            Server.RawLog          = chkRawLog.IsChecked.GetValueOrDefault();
            Server.ProcessPriority = (ProcessPriorityClass)cmbPriority.SelectedItem;
            int restartHours = Server.RestartHours;

            if (chkAutoRestart.IsChecked.GetValueOrDefault())
            {
                int.TryParse(txtRestartInterval.Text, out restartHours);
            }
            else
            {
                restartHours = 0;
            }
            if (restartHours > -1)
            {
                Server.RestartHours = restartHours;
            }
            if (restartHours == 0)
            {
                txtRestartInterval.Text  = "";
                chkAutoRestart.IsChecked = false;
            }
            Server.UpdateOnRestart = chkUpdateOnRestart.IsChecked.GetValueOrDefault();
            int updateCheckMinutes = Server.UpdateCheckMinutes;

            if (chkAutoUpdate.IsChecked.GetValueOrDefault())
            {
                int.TryParse(txtUpdateCheckInterval.Text, out updateCheckMinutes);
            }
            else
            {
                updateCheckMinutes = 0;
            }
            if (updateCheckMinutes > -1)
            {
                Server.UpdateCheckMinutes = updateCheckMinutes;
            }
            if (updateCheckMinutes == 0)
            {
                txtUpdateCheckInterval.Text = "";
                chkAutoUpdate.IsChecked     = false;
            }
            OnEditedServer(new ServerEventArgs(this.Server));
            RefreshControls();
            if (Server.Running)
            {
                var mmb = new ModernMessageBox(this);
                mmb.Show("You must restart the server for the server name, port, world, password, save folder, or public status to change.", "Server Restart", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            LoadLists();
        }
예제 #9
0
 private void modernButton1_Click(object sender, EventArgs e)
 {
     ModernMessageBox.Show(this, "This is some not-so crazy, however, odd content.", "This is a test caption.", MessageBoxButtons.YesNoCancel, MessageBoxIcon.None);
 }