예제 #1
0
 private void MainFormDragDrop(object sender, DragEventArgs e)
 {
     try {
         textBox1.Text = ((string[])e.Data.GetData(DataFormats.FileDrop, false))[0];
         if (string.IsNullOrWhiteSpace(textBox3.Text) || !Directory.Exists(textBox3.Text) || textBox3.Text == workingFolderPathTemp)
         {
             textBox3.Text = Path.GetDirectoryName(textBox1.Text);
             textBox3.SelectAll();
             workingFolderPathTemp = textBox3.Text;
         }
         if (string.IsNullOrWhiteSpace(textBox4.Text) || textBox4.Text == shortcutNameTemp)
         {
             textBox4.Text = Program.GetTitle() + Constants.Space + Path.GetFileNameWithoutExtension(textBox1.Text);
             textBox4.SelectAll();
             shortcutNameTemp = textBox4.Text;
         }
         textBox1.Focus();
         textBox1.SelectAll();
     } catch (Exception exception) {
         Debug.WriteLine(exception);
         ErrorLog.WriteLine(exception);
         dialog = new MessageForm(this, exception.Message, Program.GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageForm.Buttons.OK, MessageForm.BoxIcon.Error);
         dialog.ShowDialog();
     }
 }
예제 #2
0
 private void SelectFolder(object sender, EventArgs e)
 {
     try {
         if (!string.IsNullOrEmpty(textBox3.Text))
         {
             if (Directory.Exists(textBox3.Text))
             {
                 folderBrowserDialog.SelectedPath = textBox3.Text;
             }
         }
     } catch (Exception exception) {
         Debug.WriteLine(exception);
         ErrorLog.WriteLine(exception);
     }
     try {
         if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
         {
             if (textBox3.Text != folderBrowserDialog.SelectedPath)
             {
                 textBox3.Text         = folderBrowserDialog.SelectedPath;
                 workingFolderPathTemp = textBox3.Text;
             }
         }
     } catch (Exception exception) {
         Debug.WriteLine(exception);
         ErrorLog.WriteLine(exception);
         dialog = new MessageForm(this, exception.Message, Program.GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageForm.Buttons.OK, MessageForm.BoxIcon.Error);
         dialog.ShowDialog();
     } finally {
         textBox3.Focus();
         textBox3.SelectAll();
     }
 }
예제 #3
0
 private void CopyLink(object sender, EventArgs e)
 {
     try {
         Clipboard.SetText(((LinkLabel)((MenuItem)sender).GetContextMenu().SourceControl).Text);
     } catch (Exception exception) {
         Debug.WriteLine(exception);
         ErrorLog.WriteLine(exception);
     }
 }
예제 #4
0
 private void CopyAbout(object sender, EventArgs e)
 {
     try {
         Clipboard.SetText(stringBuilder.ToString());
     } catch (Exception exception) {
         Debug.WriteLine(exception);
         ErrorLog.WriteLine(exception);
     }
 }
 private void OpenHelp(object sender, HelpEventArgs e)
 {
     try {
         Process.Start(Properties.Resources.Website.TrimEnd('/').ToLowerInvariant() + '/' + Application.ProductName.ToLowerInvariant() + '/');
     } catch (Exception exception) {
         Debug.WriteLine(exception);
         ErrorLog.WriteLine(exception);
     }
 }
예제 #6
0
 private void OpenHelp(object sender, HelpEventArgs hlpevent)
 {
     try {
         Process.Start(Properties.Resources.Website.TrimEnd('/').ToLowerInvariant() + '/' + Application.ProductName.ToLowerInvariant() + '/');
     } catch (Exception exception) {
         Debug.WriteLine(exception);
         ErrorLog.WriteLine(exception);
         dialog = new MessageForm(this, exception.Message, Program.GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageForm.Buttons.OK, MessageForm.BoxIcon.Error);
         dialog.ShowDialog();
     }
 }
        private static ContextMenu BuildLabelAndCheckBoxContextMenu()
        {
            ContextMenu contextMenu = new ContextMenu();

            contextMenu.MenuItems.Add(new MenuItem(Properties.Resources.MenuItemCopy, new EventHandler((sender, e) => {
                try {
                    Clipboard.SetText(((MenuItem)sender).GetContextMenu().SourceControl.Text);
                } catch (Exception exception) {
                    Debug.WriteLine(exception);
                    ErrorLog.WriteLine(exception);
                }
            })));
            return(contextMenu);
        }
예제 #8
0
        private bool IsDynamicDaylightTimeDisabled()
        {
            RegistryKey registryKey = null;
            int         value       = 0;

            try {
                registryKey = Registry.LocalMachine.OpenSubKey(timeZoneInformationKey);
                value       = (int)registryKey.GetValue("DynamicDaylightTimeDisabled", 0);
            } catch (Exception exception) {
                Debug.WriteLine(exception);
                ErrorLog.WriteLine(exception);
            }
            return(value != 0);
        }
예제 #9
0
        private bool IsRealTimeUniversal()
        {
            RegistryKey registryKey = null;
            int         value       = 0;

            try {
                registryKey = Registry.LocalMachine.OpenSubKey(timeZoneInformationKey);
                value       = (int)registryKey.GetValue("RealTimeIsUniversal", 0);
            } catch (Exception exception) {
                Debug.WriteLine(exception);
                ErrorLog.WriteLine(exception);
            }
            return(value != 0);
        }
예제 #10
0
 private void OnLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         try {
             Process.Start(((LinkLabel)sender).Text);
             linkLabel.LinkVisited = true;
         } catch (Exception exception) {
             Debug.WriteLine(exception);
             ErrorLog.WriteLine(exception);
             dialog = new MessageForm(this, exception.Message, Program.GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageForm.Buttons.OK, MessageForm.BoxIcon.Error);
             dialog.ShowDialog();
         }
     }
 }
예제 #11
0
 private void CreateShortcut(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(textBox4.Text))
     {
         dialog = new MessageForm(this, Properties.Resources.MessageShortcutNameNotSet, null, MessageForm.Buttons.OK, MessageForm.BoxIcon.Exclamation);
         dialog.ShowDialog();
         textBox4.Focus();
         textBox4.SelectAll();
         return;
     }
     try {
         string shortcutFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), textBox4.Text);
         if (!shortcutFilePath.EndsWith(Constants.ExtensionLnk, StringComparison.OrdinalIgnoreCase))
         {
             shortcutFilePath += Constants.ExtensionLnk;
         }
         if (File.Exists(shortcutFilePath))
         {
             dialog = new MessageForm(this, Properties.Resources.MessageShortcutAlreadyExists, null, MessageForm.Buttons.YesNo, MessageForm.BoxIcon.Warning, MessageForm.DefaultButton.Button2);
             if (dialog.ShowDialog() != DialogResult.Yes)
             {
                 textBox4.Focus();
                 textBox4.SelectAll();
                 return;
             }
         }
         List <string>   arguments       = BuildArguments();
         ProgramShortcut programShortcut = new ProgramShortcut()
         {
             ShortcutFilePath = shortcutFilePath,
             TargetPath       = Application.ExecutablePath,
             WorkingFolder    = Application.StartupPath,
             Arguments        = string.Join(Constants.Space, arguments),
             IconLocation     = textBox1.Text
         };
         programShortcut.Create();
     } catch (ApplicationException exception) {
         Debug.WriteLine(exception);
         ErrorLog.WriteLine(exception);
         dialog = new MessageForm(this, exception.Message, null, MessageForm.Buttons.OK, MessageForm.BoxIcon.Exclamation);
         dialog.ShowDialog();
     } catch (Exception exception) {
         Debug.WriteLine(exception);
         ErrorLog.WriteLine(exception);
         dialog = new MessageForm(this, exception.Message, Program.GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageForm.Buttons.OK, MessageForm.BoxIcon.Error);
         dialog.ShowDialog();
     }
 }
예제 #12
0
 private void SelectApplication(object sender, EventArgs e)
 {
     try {
         if (!string.IsNullOrEmpty(textBox1.Text))
         {
             string directoryPath = Path.GetDirectoryName(textBox1.Text);
             if (Directory.Exists(directoryPath))
             {
                 openFileDialog.InitialDirectory = directoryPath;
             }
             if (File.Exists(textBox1.Text))
             {
                 openFileDialog.FileName = Path.GetFileName(textBox1.Text);
             }
         }
     } catch (Exception exception) {
         Debug.WriteLine(exception);
         ErrorLog.WriteLine(exception);
     }
     try {
         if (openFileDialog.ShowDialog() == DialogResult.OK)
         {
             textBox1.Text = openFileDialog.FileName;
             if (string.IsNullOrWhiteSpace(textBox3.Text) || !Directory.Exists(textBox3.Text) || textBox3.Text == workingFolderPathTemp)
             {
                 textBox3.Text = Path.GetDirectoryName(textBox1.Text);
                 textBox3.SelectAll();
                 workingFolderPathTemp = textBox3.Text;
             }
             if (string.IsNullOrWhiteSpace(textBox4.Text) || textBox4.Text == shortcutNameTemp)
             {
                 textBox4.Text = Program.GetTitle() + Constants.Space + Path.GetFileNameWithoutExtension(textBox1.Text);
                 textBox4.SelectAll();
                 shortcutNameTemp = textBox4.Text;
             }
         }
     } catch (Exception exception) {
         Debug.WriteLine(exception);
         ErrorLog.WriteLine(exception);
         dialog = new MessageForm(this, exception.Message, Program.GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageForm.Buttons.OK, MessageForm.BoxIcon.Error);
         dialog.ShowDialog();
     } finally {
         textBox1.Focus();
         textBox1.SelectAll();
     }
 }
예제 #13
0
        private void Launch(object sender, EventArgs e)
        {
            try {
                administratorRegPath = Application.CommonAppDataRegistry.Name;
            } catch (Exception exception) {
                Debug.WriteLine(exception);
                ErrorLog.WriteLine(exception);
                dialog = new MessageForm(this, Properties.Resources.MessageRunAsAdministrator, null, MessageForm.Buttons.OK, MessageForm.BoxIcon.Shield);
                dialog.ShowDialog();
                return;
            }
            try {
                List <string> arguments = BuildArguments();

                if (!settings.WarningOk)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine(Properties.Resources.MessageLaunchWarning1).AppendLine().AppendLine(Properties.Resources.MessageLaunchWarning2).AppendLine().AppendLine(Properties.Resources.MessageLaunchWarning3);
                    dialog = new MessageForm(this, stringBuilder.ToString(), null, MessageForm.Buttons.YesNo, MessageForm.BoxIcon.Warning, MessageForm.DefaultButton.Button2);
                    if (dialog.ShowDialog() == DialogResult.Yes)
                    {
                        settings.WarningOk = true;
                        SaveSettings();
                    }
                }
                if (settings.WarningOk)
                {
                    process = new Process();
                    process.StartInfo.FileName         = Application.ExecutablePath;
                    process.StartInfo.Arguments        = string.Join(Constants.Space, arguments);
                    process.StartInfo.WorkingDirectory = Application.StartupPath;
                    process.Start();
                    SaveSettings();
                }
            } catch (ApplicationException exception) {
                Debug.WriteLine(exception);
                ErrorLog.WriteLine(exception);
                dialog = new MessageForm(this, exception.Message, null, MessageForm.Buttons.OK, MessageForm.BoxIcon.Exclamation);
                dialog.ShowDialog();
            } catch (Exception exception) {
                Debug.WriteLine(exception);
                ErrorLog.WriteLine(exception);
                dialog = new MessageForm(this, exception.Message, Program.GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageForm.Buttons.OK, MessageForm.BoxIcon.Error);
                dialog.ShowDialog();
            }
        }
예제 #14
0
        public static void Main(string[] args)
        {
            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
            {
                MessageBox.Show(Properties.Resources.MessageApplicationCannotRun, GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Settings settings = new Settings();

            if (!settings.DisableThemes)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                settings.RenderWithVisualStyles = Application.RenderWithVisualStyles;
            }
            ArgumentParser argumentParser = new ArgumentParser();

            try {
                argumentParser.Arguments = args;
            } catch (Exception exception) {
                Debug.WriteLine(exception);
                ErrorLog.WriteLine(exception);
                MessageBox.Show(exception.Message, GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (argumentParser.HasArguments)
            {
                if (argumentParser.IsHelp)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine1.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine2.Replace("\\t", "\t"));
                    stringBuilder.AppendLine(Properties.Resources.HelpLine3.Replace("\\t", "\t"));
                    stringBuilder.AppendLine(Properties.Resources.HelpLine4.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine5.Replace("\\t", "\t"));
                    stringBuilder.AppendLine(Properties.Resources.HelpLine6.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine7.Replace("\\t", "\t"));
                    stringBuilder.AppendLine(Properties.Resources.HelpLine8.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine9.Replace("\\t", "\t"));
                    stringBuilder.AppendLine(Properties.Resources.HelpLine10.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine11.Replace("\\t", "\t"));
                    stringBuilder.AppendLine(Properties.Resources.HelpLine12.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine13.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine14.Replace("\\t", "\t"));
                    stringBuilder.AppendLine(Properties.Resources.HelpLine15.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine16.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine17.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine18.Replace("\\t", "\t"));
                    MessageBox.Show(stringBuilder.ToString(), GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionHelp, MessageBoxButtons.OK, MessageBoxIcon.Question);
                }
                else if (argumentParser.IsTest)
                {
                    try {
                        Application.Run(new TestForm(args));
                    } catch (Exception exception) {
                        Debug.WriteLine(exception);
                        ErrorLog.WriteLine(exception);
                        MessageBox.Show(exception.Message, GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MessageBox.Show(Properties.Resources.MessageApplicationError, GetTitle(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else if (argumentParser.IsThisTest)
                {
                    try {
                        Application.Run(new ArgumentParserForm());
                    } catch (Exception exception) {
                        Debug.WriteLine(exception);
                        ErrorLog.WriteLine(exception);
                        MessageBox.Show(exception.Message, GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MessageBox.Show(Properties.Resources.MessageApplicationError, GetTitle(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    try {
                        LauncherAsDate launcherAsDate = new LauncherAsDate()
                        {
                            ApplicationFilePath   = argumentParser.ApplicationFilePath,
                            DateTime              = argumentParser.DateTime.Value,
                            Arguments             = argumentParser.ApplicationArguments,
                            WorkingFolderPath     = argumentParser.WorkingFolderPath,
                            OneInstance           = argumentParser.OneInstance,
                            Interval              = argumentParser.Interval,
                            DisableTimeCorrection = settings.DisableTimeCorrection,
                            ForceTimeCorrection   = settings.ForceTimeCorrection
                        };
                        launcherAsDate.Launch();
                    } catch (Exception exception) {
                        Debug.WriteLine(exception);
                        ErrorLog.WriteLine(exception);
                        MessageBox.Show(exception.Message, GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                try {
                    SingleMainForm.Run(new MainForm(settings));
                } catch (Exception exception) {
                    Debug.WriteLine(exception);
                    ErrorLog.WriteLine(exception);
                    MessageBox.Show(exception.Message, GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MessageBox.Show(Properties.Resources.MessageApplicationError, GetTitle(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
예제 #15
0
        public ArgumentParserForm()
        {
            Icon = Properties.Resources.Icon;

            textBoxClicks      = 0;
            textBoxClicksTimer = new Timer();

            argumentParser = new ArgumentParser();

            InitializeComponent();
            Text = Program.GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Text;

            statusBarPanel = new StatusBarPanel()
            {
                BorderStyle = StatusBarPanelBorderStyle.Sunken,
                AutoSize    = StatusBarPanelAutoSize.Spring,
                Alignment   = HorizontalAlignment.Left
            };
            statusBar.Panels.Add(statusBarPanel);

            statusBarPanelCapsLock = new StatusBarPanel()
            {
                BorderStyle = StatusBarPanelBorderStyle.Sunken,
                Alignment   = HorizontalAlignment.Center,
                Width       = 42
            };
            statusBar.Panels.Add(statusBarPanelCapsLock);

            statusBarPanelNumLock = new StatusBarPanel()
            {
                BorderStyle = StatusBarPanelBorderStyle.Sunken,
                Alignment   = HorizontalAlignment.Center,
                Width       = 42
            };
            statusBar.Panels.Add(statusBarPanelNumLock);

            statusBarPanelInsert = new StatusBarPanel()
            {
                BorderStyle = StatusBarPanelBorderStyle.Sunken,
                Alignment   = HorizontalAlignment.Center,
                Width       = 42
            };
            statusBar.Panels.Add(statusBarPanelInsert);

            statusBarPanelScrollLock = new StatusBarPanel()
            {
                BorderStyle = StatusBarPanelBorderStyle.Sunken,
                Alignment   = HorizontalAlignment.Center,
                Width       = 42
            };
            statusBar.Panels.Add(statusBarPanelScrollLock);

            statusBar.ContextMenu = new ContextMenu();
            statusBar.ContextMenu.MenuItems.Add(new MenuItem(Properties.Resources.MenuItemCopy, new EventHandler((sender, e) => {
                if (!string.IsNullOrEmpty(statusBarPanel.Text))
                {
                    try {
                        Clipboard.SetText(statusBarPanel.Text);
                    } catch (Exception exception) {
                        Debug.WriteLine(exception);
                        ErrorLog.WriteLine(exception);
                    }
                }
            })));
            statusBar.ContextMenu.Popup += new EventHandler((sender, e) => {
                ((ContextMenu)sender).MenuItems[0].Visible = !string.IsNullOrEmpty(statusBarPanel.Text);
            });

            SubscribeEvents();

            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("/i ");
            stringBuilder.Append(ArgumentParser.EscapeArgument(Constants.ExampleApplicationFilePath));
            stringBuilder.Append(" /d 2019-01-01 /a ");
            stringBuilder.Append(ArgumentParser.EscapeArgument(Constants.ExampleApplicationArguments));
            stringBuilder.Append(" /w ");
            stringBuilder.Append(ArgumentParser.EscapeArgument(Constants.ExampleWorkingFolderPath));
            stringBuilder.Append(" /o /s 5");
            textBox1.Text = stringBuilder.ToString();

            textBoxInput.Text = Constants.ExampleApplicationArguments;
        }