예제 #1
0
        private void AddSettingsButton_Click(object sender, EventArgs e)
        {
            DialogResult dr = SettingsSaveFileDialog.ShowDialog();

            if (dr == DialogResult.OK)
            {
                string filename = SettingsSaveFileDialog.FileName;

                Settings newSettings = new Settings();
                newSettings.Save(filename);

                ListViewItem lvi = new ListViewItem();
                lvi.Text = newSettings.ApplicationShortName;
                IconImageList.Images.Add(this.Icon);
                lvi.ImageIndex = IconImageList.Images.Count - 1;
                lvi.Tag        = filename;

                this.primaryHost.AddLaunchHistory(
                    filename,
                    newSettings.ApplicationShortName,
                    newSettings.ApplicationDescription,
                    newSettings.WindowIconPath
                    );

                AppHistoryListView.Items.Add(lvi);

                AppHistoryListView.SelectedIndices.Clear();
                AppHistoryListView.SelectedIndices.Add(AppHistoryListView.Items.Count - 1);
                AppHistoryListView.Focus();
            }
        }
예제 #2
0
        private void HistorySelectorForm_Load(object sender, EventArgs e)
        {
            if (AppHistoryListView.Items.Count > 0)
            {
                AppHistoryListView.SelectedIndices.Clear();
                AppHistoryListView.SelectedIndices.Add(0);
            }

            AppHistoryListView.Focus();
        }
예제 #3
0
        private void AppHistoryListView_DragDrop(object sender, DragEventArgs e)
        {
            List <string> failedFiles = new List <string>();

            try
            {
                string[] settingsFilenames = (string[])e.Data.GetData(DataFormats.FileDrop);

                foreach (string settingsFilename in settingsFilenames)
                {
                    FileInfo fi = new FileInfo(settingsFilename);
                    if (!fi.Extension.ToLower().Equals(".xos") && !fi.Extension.ToLower().Equals(".xml"))
                    {
                        failedFiles.Add(fi.Name);
                    }
                    else
                    {
                        Settings settings = Settings.Load(settingsFilename, false);

                        ExoAppLaunchInfo ali = new ExoAppLaunchInfo();

                        ali.SettingsPath = settingsFilename;
                        ali.IconPath     = settings.WindowIconPath;
                        ali.ShortName    = settings.ApplicationShortName;
                        ali.Description  = settings.ApplicationDescription;

                        ListViewItem lvi = new ListViewItem();
                        lvi.Text = ali.ShortName;

                        string revisedIconPath = ali.IconPath
                                                 .Replace("{CurrentLocation}", Environment.CurrentDirectory)
                                                 .Replace("{SettingsLocation}", fi.DirectoryName);

                        if (revisedIconPath != "" && File.Exists(revisedIconPath))
                        {
                            // Haven't quite loaded the settings file so calling IPrimaryHost.ResolveExoUrlPath
                            // won't work.  For now just substitute manually.

                            Icon appIcon = new Icon(revisedIconPath);
                            IconImageList.Images.Add(appIcon);
                            lvi.ImageIndex = IconImageList.Images.Count - 1;
                            lvi.Tag        = ali.SettingsPath;
                        }
                        else
                        {
                            IconImageList.Images.Add(this.Icon);
                            lvi.ImageIndex = IconImageList.Images.Count - 1;
                            lvi.Tag        = ali.SettingsPath;
                        }

                        // We can however make sure the global settings knows about this 'history' even
                        // if we don't select it immediately.
                        this.primaryHost.AddLaunchHistory(
                            ali.SettingsPath,
                            ali.ShortName,
                            ali.Description,
                            ali.IconPath
                            );

                        AppHistoryListView.Items.Add(lvi);

                        AppHistoryListView.SelectedIndices.Clear();
                        AppHistoryListView.SelectedIndices.Add(AppHistoryListView.Items.Count - 1);
                        AppHistoryListView.Focus();
                    }
                }

                if (failedFiles.Count() > 0)
                {
                    string files = String.Join(Environment.NewLine, failedFiles.ToArray());
                    MessageBox.Show(
                        files,
                        "The following files are not .xos or .xml files",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                        );
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error processing dropped file", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #4
0
 private void HistorySelectorForm_Activated(object sender, EventArgs e)
 {
     AppHistoryListView.Focus();
 }