コード例 #1
0
        private void GeneratePW_Click(object sender, RoutedEventArgs e)
        {
            int    zeichen = Int32.Parse(Anzahl_Zeichen.Text);
            string finish  = "";

            if (ascii_check.IsChecked == true)
            {
                finish = RandomString(zeichen, false, true);
            }
            else if (Chinese_check.IsChecked == false)
            {
                finish = RandomString(zeichen, false, false);
            }
            else if (Chinese_check.IsChecked == true)
            {
                finish = RandomString(zeichen, true, false);
            }
            Clipboard.SetText(finish);
            var msg = new ModernMessageBox("Your generated password is in your clipboard", "Application Info", ModernMessageboxIcons.Info, "Ok")
            {
                Button1Key = Key.D1,
            };

            msg.Show();
        }
コード例 #2
0
        private void modernButton4_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;

            Thread.Sleep(3000);

            ModernMessageBox.Show("Test", "Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk);
        }
コード例 #3
0
 private void btnMsgBox_Click(object sender, RoutedEventArgs e)
 {
     //ModernMessageBox.Show(this, "howdy");
     ModernMessageBox.Show(this,
                           "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras faucibus venenatis felis a luctus. Cras cursus est sed interdum consectetur. Fusce vestibulum cursus interdum. Praesent ultricies egestas dolor at elementum. Quisque et pellentesque magna, ac mattis purus. Ut pretium laoreet ullamcorper. Morbi venenatis accumsan varius. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vivamus sit amet laoreet leo. Vestibulum sodales tempus libero vitae tincidunt. Nulla facilisi. Donec posuere sapien ut interdum condimentum. Vivamus nec velit suscipit, dignissim odio a, ullamcorper arcu. Proin ac tellus enim. Quisque in cursus dolor. Curabitur adipiscing vitae sem in ornare.\n\n" +
                           "Duis in lacus volutpat, laoreet felis eget, tristique mauris. Maecenas dictum porta purus, id fringilla diam suscipit eu. Sed vitae vulputate erat. Praesent sit amet volutpat urna. Aenean id eros tincidunt, tempor nisl ut, malesuada augue. Nullam ullamcorper, sem sed consequat placerat, velit lacus porttitor velit, et suscipit ipsum nisi id lorem. Vivamus eleifend congue erat, ut rhoncus magna lacinia et.\n\n" +
                           "Maecenas in sapien vitae ligula interdum vestibulum ac ut odio. Praesent id posuere ligula. In a neque magna. Cras vestibulum fringilla urna, nec aliquam ante. Proin consectetur a enim eget varius. Aliquam vitae nulla mattis, imperdiet sapien eu, hendrerit nulla. In vel lorem mauris. Vestibulum rutrum, lorem suscipit sagittis euismod, justo nulla pharetra augue, cursus semper ante ante mollis ipsum. Phasellus volutpat augue eget consequat pretium. Vivamus sed ante vel purus hendrerit sollicitudin. Aliquam dignissim leo eu enim interdum auctor. Nam augue tortor, scelerisque facilisis turpis at, venenatis imperdiet dui. Nulla facilisi.", "Caption", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning, MessageBoxResult.No);
     ModernMessageBox.Show(this, "Test Message", "Caption", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes);
     ModernMessageBox.Show(this, "Test Message", "Caption", MessageBoxButton.OKCancel, MessageBoxImage.Information, MessageBoxResult.Cancel);
     ModernMessageBox.Show(this, "Test Message", "Caption", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
 }
コード例 #4
0
 private void menuSteamCmdUpdate_Click(object sender, RoutedEventArgs e)
 {
     if (!Server.Running)
     {
         Server.Update();
     }
     else
     {
         var mmb = new ModernMessageBox(this);
         mmb.Show("Please stop the server before updating.", "Stop Server to Update", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
     }
 }
コード例 #5
0
        private void btnServerDir_Click(object sender, RoutedEventArgs e)
        {
            var openFolderDialog = new System.Windows.Forms.FolderBrowserDialog();

            if (txtServerDir.Text != "")
            {
                var serverpath = new FileInfo(txtServerDir.Text).Directory.FullName;
                if (Directory.Exists(serverpath))
                {
                    openFolderDialog.SelectedPath = serverpath;
                }
            }
            openFolderDialog.UseDescriptionForTitle = true;
            openFolderDialog.Description            = "Server installation folder";
            var result = openFolderDialog.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                var folderName = openFolderDialog.SelectedPath;

                /*if (folderName.Equals(serverpath))
                 * {
                 *  return;
                 * }*/
                if (!File.Exists($@"{folderName}\{ValheimServer.ExecutableName}") && cmbServerType.SelectedIndex == (int)ValheimServer.ServerInstallMethod.SteamCMD && File.Exists(Properties.Settings.Default.SteamCMDPath))
                {
                    var mmb     = new ModernMessageBox(this);
                    var install = mmb.Show($"{ValheimServer.ExecutableName} was not found in this folder, do you want to install it via SteamCMD?",
                                           "Install Valheim dedicated server?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
                    if (install == MessageBoxResult.Yes)
                    {
                        try
                        {
                            var process = new Process();
                            process.StartInfo.FileName  = Properties.Settings.Default.SteamCMDPath;
                            process.StartInfo.Arguments = $"+login anonymous +force_install_dir \"{folderName}\" +app_update {ValheimServer.SteamID} +quit";
                            //process.EnableRaisingEvents = true;
                            //process.Exited += SteamCmdProcess_Exited;
                            process.Start();
                            process.WaitForExit();
                        }
                        catch (Exception ex)
                        {
                            LogMessage($"Error installing dedicated server: {ex.Message}", LogEntryType.Error);
                        }
                    }
                }
                folderName       += $@"\{ValheimServer.ExecutableName}";
                txtServerDir.Text = folderName;
            }
            RefreshControls();
        }
コード例 #6
0
        private void checkForUpdate()
        {
            new Thread(() =>
            {
                Thread.CurrentThread.IsBackground = true;

                try
                {
                    WebClient client = new WebClient();
                    client.Headers.Add("User-Agent", "TarkovPriceCheck");
                    string source = client.DownloadString("https://api.github.com/repos/Razzmatazzz/TarkovPriceCheck/releases/latest");
                    client.Dispose();
                    var release           = JsonSerializer.Deserialize <GitHubRelease>(source);
                    Version remoteVersion = new Version(release.tag_name);
                    Version localVersion  = typeof(MainWindow).Assembly.GetName().Version;
                    this.Dispatcher.Invoke(() =>
                    {
                        try
                        {
                            if (localVersion.CompareTo(remoteVersion) == -1)
                            {
                                var mmb           = new ModernMessageBox(this);
                                var confirmResult = mmb.Show("There is a new version available. Would you like to visit the download page?",
                                                             "Update Available", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
                                if (confirmResult == MessageBoxResult.Yes)
                                {
                                    Process.Start("cmd", $"/C start {release.html_url}");
                                }
                            }
                            else
                            {
                                //logMessage("No new version found.");
                            }
                        }
                        catch (Exception ex)
                        {
                            logMessage($"Error navigating to new version web page: {ex.Message}", LogEntryType.Error);
                        }
                    });
                }
                catch (Exception ex)
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        logMessage($"Error checking for new version: {ex.Message}", LogEntryType.Error);
                    });
                }
            }).Start();
            //lastUpdateCheck = DateTime.Now;
        }
コード例 #7
0
        private void Copy_EmailPass_Click(object sender, RoutedEventArgs e)
        {
            Clipboard.Clear();
            string username = SaveSpace.CryptUsername;

            Clipboard.SetText(username);
            username = "";
            var msg = new ModernMessageBox("Deine Email/Username befindet sich in deiner Zwischenablage", "Application Info", ModernMessageboxIcons.Info, "Ok")
            {
                Button1Key = Key.D1,
            };

            msg.Show();
        }
コード例 #8
0
        private async void modernButton3_Click(object sender, EventArgs e)
        {
            modernButton1.Enabled = false;
            modernButton2.Enabled = false;
            modernButton3.Enabled = false;
            await Task.Run((() =>
            {
                string t = null;
                this.Invoke(new Action((() =>
                {
                    t = title;
                })));

                StringBuilder rBuilder = new StringBuilder(t);
                foreach (char rInvalidChar in Path.GetInvalidFileNameChars())
                {
                    rBuilder.Replace(rInvalidChar.ToString(), string.Empty);
                }

                string outpath = modernTextBox2.Text + "\\" + rBuilder + "\\";
                Directory.CreateDirectory(outpath);
                foreach (Item item in items)
                {
                    this.Invoke(new Action((() =>
                    {
                        var currentrow = modernDataGridView1.Rows[items.IndexOf(item)];
                        modernDataGridView1.ClearSelection();
                        currentrow.Selected = true;
                        modernDataGridView1.CurrentCell = currentrow.Cells[0];
                        item.状态 = "下载中";
                    })));
                    RestClient rc = new RestClient(new Uri(item.Url));
                    RestRequest req = new RestRequest();
                    req.Method = Method.GET;
                    IRestResponse res = rc.Execute(req);
                    File.WriteAllBytes(outpath + item.Title.Replace(" ", "") + ".jpg", res.RawBytes);
                    this.Invoke(new Action((() =>
                    {
                        item.状态 = "下载完成";
                    })));
                }
            }));

            modernDataGridView1.Refresh();
            ModernMessageBox.Show("OK", "Message");
            modernButton1.Enabled = true;
            modernButton2.Enabled = true;
        }
コード例 #9
0
        private void Copy_Pass_Click(object sender, RoutedEventArgs e)
        {
            Clipboard.Clear();

            string password = SaveSpace.CryptPW;

            Clipboard.SetText(password);
            password = "";

            var msg = new ModernMessageBox("Dein Passwort befindet sich in deiner Zwischenablage", "Application Info", ModernMessageboxIcons.Info, "Ok")
            {
                Button1Key = Key.D1,
            };

            msg.Show();
        }
コード例 #10
0
 private void Umod_InstallEnded(object sender, uMod.ProcessEndedEventArgs e)
 {
     this.Dispatcher.Invoke(() =>
     {
         btnuModInstall.IsEnabled = true;
         if (e.ExitCode == 0)
         {
             var mmb = new ModernMessageBox(this);
             mmb.Show("uMod installation compelete.", "uMod Installed", MessageBoxButton.OK, MessageBoxImage.Information);
         }
         else
         {
             var mmb = new ModernMessageBox(this);
             mmb.Show($"uMod terminated with code {e.ExitCode}, which indicates an error.", "uMod Installation Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     });
 }
コード例 #11
0
        private void modernButton1_Click(object sender, EventArgs e)
        {
            switch (ModernMessageBox.Show("Start a ModernTaskWindow?", "Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk))
            {
            case DialogResult.Abort:
            case DialogResult.Cancel:
            case DialogResult.Ignore:
            case DialogResult.No:
            case DialogResult.None:
                break;

            case DialogResult.OK:
            case DialogResult.Retry:
            case DialogResult.Yes:
                ModernTaskWindow.Show("SubControl in TaskWindow", long.Parse(modernTextBox1.Text) * 1000);
                break;

            default:
                break;
            }
        }
コード例 #12
0
 private void Umod_UpdateEnded(object sender, uMod.ProcessEndedEventArgs e)
 {
     this.Dispatcher.Invoke(() =>
     {
         btnuModUpdate.IsEnabled = true;
         if (e.ExitCode == 0)
         {
             var mmb = new ModernMessageBox(this);
             mmb.Show("uMod update compelete.", "uMod Updated", MessageBoxButton.OK, MessageBoxImage.Information);
         }
         else if (e.ExitCode == 2)
         {
             var mmb = new ModernMessageBox(this);
             mmb.Show($"uMod did not need to install any updates.", "No Update Needed", MessageBoxButton.OK, MessageBoxImage.Information);
         }
         else
         {
             var mmb = new ModernMessageBox(this);
             mmb.Show($"uMod terminated with code {e.ExitCode}; unable to update uMod core or uMod apps.", "uMod Update Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     });
 }
コード例 #13
0
 private void btnuModInstall_Click(object sender, RoutedEventArgs e)
 {
     if (Server.Status == ValheimServer.ServerStatus.Stopped)
     {
         this.Dispatcher.Invoke(() =>
         {
             btnuModInstall.IsEnabled = false;
         });
         var umod = new uMod(Server.InstallPath, "valheim");
         umod.InstallEnded  += Umod_InstallEnded;
         umod.LoggedMessage += (object sender, LoggedMessageEventArgs args) =>
         {
             LogMessage("uMod: " + args.LogEntry.Message, args.LogEntry.Type);
         };
         umod.Install("umod");
     }
     else
     {
         var mmb = new ModernMessageBox(this);
         mmb.Show("Stop server before updating.", "Server Running", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
コード例 #14
0
        /// <summary>
        /// Handles a basic <see cref="MessageBoxMessage" /> on a flyout container by showing a <see cref="ModernMessageBox" />
        /// and invokes the callback.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="owner">The owner.</param>
        /// <exception cref="System.ArgumentNullException">owner</exception>
        public static void HandleWithModern(this MessageBoxMessage message, FlyoutContainer owner)
        {
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }

            var d = owner.FindDispatcher();

            if (d != null && !d.CheckAccess())
            {
                d.BeginInvoke(new Action <Window>(win =>
                {
                    HandleWithModern(message, win);
                }), owner);
                return;
            }

            var res = ModernMessageBox.Show(owner, message.Content, message.Caption, message.Button, message.Icon, message.DefaultResult);

            message.DoCallback(res);
        }
コード例 #15
0
ファイル: MainWindow.xaml.cs プロジェクト: lukaszmn/ntwain
        private void CapDetailList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var capVM = CapList.SelectedItem as CapVM;

            if (capVM != null)
            {
                if (capVM.Supports.HasFlag(QuerySupports.Set))
                {
                    try
                    {
                        capVM.Set(CapDetailList.SelectedItem);
                    }
                    catch (Exception ex)
                    {
                        if (ex is TargetInvocationException)
                        {
                            ex = ex.InnerException;
                        }
                        ModernMessageBox.Show(this, ex.Message, "Cannot Set", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }
コード例 #16
0
        /// <summary>
        /// Handles a basic <see cref="MessageBoxMessage" /> on a window by showing a <see cref="ModernMessageBox" />
        /// and invokes the callback.
        /// </summary>
        /// <param name="owner">The owner.</param>
        public void HandleWithModern(Window owner)
        {
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }

            var res = ModernMessageBox.Show(owner, Content, Caption, Button, Icon, DefaultResult);

            if (Callback != null)
            {
                if (owner == null || owner.CheckAccess())
                {
                    Callback(res);
                }
                else
                {
                    owner.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        Callback(res);
                    }));
                }
            }
        }
コード例 #17
0
ファイル: Home.xaml.cs プロジェクト: MegaMech/nitrogen
 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.");
 }
コード例 #18
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();
        }
コード例 #19
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);
 }