示例#1
0
        void tool_deleteProgram_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(LocalStrings.SureDelete, LocalStrings.Warning, MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }

            ConfigSaver.DeleteRegistryKey();
            FileAssociation.Remove();
            Cmd($"taskkill /f /pid \"{Process.GetCurrentProcess().Id}\" &" +
                $"del /f \"{Assembly.GetExecutingAssembly().Location}\"");
        }
示例#2
0
        public MainWindow(string path)
        {
            InitializeComponent();

            ConfigSaver = new ConfigSaver();

            if (!ConfigSaver.IsAssociated || !FileAssociation.IsAssociated())
            {
                FileAssociation.Associate($"{LocalStrings.Description}", Assembly.GetExecutingAssembly().Location);
                FileAssociation.AddToContextMenuNew();
                ConfigSaver.IsAssociated = true;
            }

            this.Width       = ConfigSaver.FormSize.Width;
            this.Height      = ConfigSaver.FormSize.Height;
            richTextBox.Font = ConfigSaver.Font;

            //All events are here
            richTextBox.TextChanged += (s, e) =>
            {
                saved           = false;
                lbl_status.Text = $"{LocalStrings.TotalChars}: {richTextBox.Text.Length}";
            };
            tool_new.Click           += new System.EventHandler(tool_new_Click);
            tool_open.Click          += new EventHandler(tool_open_Click);
            tool_save.Click          += new EventHandler(tool_save_Click);
            tool_saveAs.Click        += new System.EventHandler(tool_saveAs_Click);
            tool_fontSettings.Click  += new EventHandler(tool_fontSettings_Click);
            tool_replace.Click       += new EventHandler(tool_replace_Click);
            tool_about.Click         += new EventHandler(tool_about_Click);
            tool_exit.Click          += new System.EventHandler(tool_exit_Click);
            tool_deleteProgram.Click += new System.EventHandler(tool_deleteProgram_Click);
            Shown += (s, e) =>
            {
                //update ui
                #region
                new Thread(() =>
                {
                    while (true)
                    {
                        try
                        {
                            this.Invoke(new MethodInvoker(() =>
                            {
                                string t  = (saved) ? "" : "*";
                                this.Text = Path.GetFileName(FilePath) + t;
                                try
                                {
                                    progressBar.Maximum = MaxValueProgress;
                                    progressBar.Value   = ValueProgress;
                                }
                                catch { }
                            }));
                            Thread.Sleep(250);
                        }
                        catch { }
                    }
                })
                {
                    IsBackground = true
                }.Start();
                #endregion
                if (path == "")
                {
                    return;
                }
                LoadFile(path);
            };
        }