Init() public static method

public static Init ( ) : void
return void
Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            try
            {
                if ((args.Length == 1) && (args[0] == "start"))                         // Used to start application during install
                {
                    ProcessStartInfo psi = new ProcessStartInfo
                    {
                        FileName         = Application.ExecutablePath,
                        UseShellExecute  = false,
                        WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath)
                    };
                    Process.Start(psi);
                    return;
                }

                const string iniFileName = "SCM_Notifier.ini";
                if (File.Exists(iniFileName))
                {
                    Config.Init(iniFileName);
                }
                else
                {
                    Config.Init(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), iniFileName));
                }

                if (!Config.IsSettingsOK())
                {
                    if (new SettingsForm().ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                }

                MainForm form = new MainForm();

                Thread.CurrentThread.Name    = "Main";
                Application.ThreadException += OnThreadException;
                Application.Run(form);

                lock (form)
                {
                    if (statusThread != null)
                    {
                        statusThread.Abort();
                    }
                }
            }
            catch (Exception e)
            {
                FatalError(e);
            }
        }
Exemplo n.º 2
0
        private void menuItemImportConfig_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog
            {
                Filter           = "Ini files (*.ini)|*.ini|All files (*.*)|*.*",
                RestoreDirectory = true
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                if ((folders.Count > 0) && MessageBox.Show("All current settings will be lost.\n\nDo you really want to change the settings?", "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                {
                    return;
                }

                try
                {
                    File.Copy(ofd.FileName, Config.iniFileName, true);
                    Config.Init();

                    // Check for correct import configs
                    if (!Config.IsSettingsOK())
                    {
                        Hide();
                        statusUpdateTimer.Stop();
                        notifyIcon.Icon = trayIcon_Unknown;

                        if (new SettingsForm().ShowDialog() != DialogResult.OK)
                        {
                            Application.Exit();
                            return;
                        }
                        ShowInTaskbar = Config.ShowInTaskbar;
                        Show();
                    }

                    FormInit();
                }
                catch (Exception ex)
                {
                    ShowError(ex.Message);
                }
            }
        }