Inheritance: System.Windows.Forms.Form
Beispiel #1
0
        private void InstallPad_Load(object sender, EventArgs e)
        {
            preferencesDialog = new PreferencesDialog();
            this.logoBox.Click += new EventHandler(logoBox_Click);
            this.errorLink.Click += new EventHandler(errorLink_Click);
            this.KeyUp += new KeyEventHandler(InstallPad_KeyUp);
            this.FormClosing += new FormClosingEventHandler(InstallPad_FormClosing);
            this.controlList = new ControlList();
            this.controlList.ListItemClicked += new MouseEventHandler(controlList_ListItemClicked);
            this.controlList.ListItemDoubleClicked += new MouseEventHandler(controlList_ListItemDoubleClicked);

            controlList.Size = this.controlListPanel.Size;
            this.controlListPanel.Controls.Add(controlList);

            controlList.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom;

            this.controlList.Resize += new EventHandler(controlList_Resize);

            BuildContextMenuEntries();

            // Restore form position etc. from the installpad config file
            // Depending upon where we bomb out, this may or may not be recoverable.
            // E.g. if the static initializer for Preferences fails because the user
            // has messed up system environment variables, then we should exit.
            try
            {
                LoadConfigFile();
            }
            catch (Exception ex)
            {
                string message = (ex is TypeInitializationException &&
                    ex.InnerException!=null) ?
                    ex.InnerException.InnerException.Message : ex.Message;
                MessageBox.Show(message);
                System.Windows.Forms.Application.Exit();
                return;
            }
            // Should be externalized
            string errorMessage = Resources.TempFileCreateError;

            // Try and create the temp folder that we'll be downloading to.
            // If we aren't successful, maybe log a warning
            if (!Directory.Exists(InstallPadApp.Preferences.DownloadTo))
            {
                try
                {
                    Directory.CreateDirectory(InstallPadApp.Preferences.DownloadTo);
                }
                catch (System.IO.IOException)
                {
                    //Debug.WriteLine("Error creating install folder: " + ex);
                    MessageBox.Show(this, errorMessage + InstallPadApp.Preferences.DownloadTo,
                        Resources.InstallFolderCreateError, MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    // Should log this TODO
                }
                catch (NotSupportedException)
                {
                    MessageBox.Show(this, errorMessage + InstallPadApp.Preferences.DownloadTo,
                        Resources.Errorcreatinginstallfolder, MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }

            // Error box used to indicate a problem loading the application list
            appListErrorBox = new AppListErrorBox();
            this.controlListPanel.Controls.Add(appListErrorBox);
            appListErrorBox.Visible = false;
            appListErrorBox.openLink.Click += new EventHandler(openLink_Click);

            BuildSearchBox();

            // Load the application list. If not successful (file not found),
            // all controls will be disabled.
            LoadApplicationList(InstallPadApp.AppListFile);
        }
Beispiel #2
0
        private void InstallPad_Load(object sender, EventArgs e)
        {
            preferencesDialog                       = new PreferencesDialog();
            this.logoBox.Click                     += new EventHandler(logoBox_Click);
            this.errorLink.Click                   += new EventHandler(errorLink_Click);
            this.KeyUp                             += new KeyEventHandler(InstallPad_KeyUp);
            this.FormClosing                       += new FormClosingEventHandler(InstallPad_FormClosing);
            this.controlList                        = new ControlList();
            this.controlList.ListItemClicked       += new MouseEventHandler(controlList_ListItemClicked);
            this.controlList.ListItemDoubleClicked += new MouseEventHandler(controlList_ListItemDoubleClicked);

            controlList.Size = this.controlListPanel.Size;
            this.controlListPanel.Controls.Add(controlList);

            controlList.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom;

            this.controlList.Resize += new EventHandler(controlList_Resize);

            BuildContextMenuEntries();

            // Restore form position etc. from the installpad config file
            // Depending upon where we bomb out, this may or may not be recoverable.
            // E.g. if the static initializer for Preferences fails because the user
            // has messed up system environment variables, then we should exit.
            try
            {
                LoadConfigFile();
            }
            catch (Exception ex)
            {
                string message = (ex is TypeInitializationException &&
                                  ex.InnerException != null) ?
                                 ex.InnerException.InnerException.Message : ex.Message;
                MessageBox.Show(message);
                System.Windows.Forms.Application.Exit();
                return;
            }
            // Should be externalized
            string errorMessage = Resources.TempFileCreateError;

            // Try and create the temp folder that we'll be downloading to.
            // If we aren't successful, maybe log a warning
            if (!Directory.Exists(InstallPadApp.Preferences.DownloadTo))
            {
                try
                {
                    Directory.CreateDirectory(InstallPadApp.Preferences.DownloadTo);
                }
                catch (System.IO.IOException)
                {
                    //Debug.WriteLine("Error creating install folder: " + ex);
                    MessageBox.Show(this, errorMessage + InstallPadApp.Preferences.DownloadTo,
                                    Resources.InstallFolderCreateError, MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    // Should log this TODO
                }
                catch (NotSupportedException)
                {
                    MessageBox.Show(this, errorMessage + InstallPadApp.Preferences.DownloadTo,
                                    Resources.Errorcreatinginstallfolder, MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }

            // Error box used to indicate a problem loading the application list
            appListErrorBox = new AppListErrorBox();
            this.controlListPanel.Controls.Add(appListErrorBox);
            appListErrorBox.Visible         = false;
            appListErrorBox.openLink.Click += new EventHandler(openLink_Click);

            BuildSearchBox();


            // Load the application list. If not successful (file not found),
            // all controls will be disabled.
            LoadApplicationList(InstallPadApp.AppListFile);
        }