示例#1
0
        void addNewItem_Click(object sender, EventArgs e)
        {
            ApplicationDialog dialog = new ApplicationDialog();

            dialog.Title = "Add New Application";
            dialog.ShowDialog(this);

            if (dialog.Saved)
            {
                ApplicationListItem listItem = CreateApplicationListItem(dialog.ApplicationItem);
                int i = controlList.IndexOfListItem(highlightedControl);
                controlList.AddControl(listItem, i);

                if (i >= 0)
                {
                    InstallPadApp.AppList.ApplicationItems.Insert(i, dialog.ApplicationItem);
                }
                else
                {
                    InstallPadApp.AppList.ApplicationItems.Add(dialog.ApplicationItem);
                }

                SaveApplist();
            }
        }
示例#2
0
        void removeItem_Click(object sender, EventArgs e)
        {
            ApplicationListItem item = (ApplicationListItem)highlightedControl;
            string appTitle          = item.ApplicationItem.Name;

            if (item.State == ApplicationListItem.InstallState.Downloading)
            {
                MessageBox.Show(String.Format("{0} is currently being downloaded. Stop the download before removing the item.", appTitle));
                return;
            }
            else if (item.State == ApplicationListItem.InstallState.Installing)
            {
                MessageBox.Show(String.Format("{0} is currently being installed. Stop the download before removing the item.", appTitle));
                return;
            }


            DialogResult result = MessageBox.Show(this,
                                                  String.Format("Are you sure you want to remove '{0}' from the list of installable applications?", appTitle),
                                                  String.Format("Remove {0}?", appTitle),
                                                  MessageBoxButtons.YesNo);

            if (result.Equals(DialogResult.Yes))
            {
                controlList.RemoveControl(item);
                InstallPadApp.AppList.ApplicationItems.Remove(item.ApplicationItem);
                SaveApplist();
            }
        }
示例#3
0
        void controlList_ListItemDoubleClicked(object sender, MouseEventArgs e)
        {
            Control doubleClickedControl = controlList.ControlAtAbsolutePosition(Cursor.Position);

            //remove highlight from whatever controler may have been hightlighted.
            controlList.Unhighlight(controlList.HighlightedEntry);
            //highlight control that the user double clicked, so it shows behind the editing dialog.
            controlList.Highlight(doubleClickedControl);

            if (doubleClickedControl != null && doubleClickedControl is ApplicationListItem)
            {
                ApplicationListItem item   = (ApplicationListItem)controlList.HighlightedEntry;
                ApplicationDialog   dialog = new ApplicationDialog(item.ApplicationItem);
                dialog.Title = Resources.EditApplication;
                dialog.ShowDialog(this);

                if (dialog.Saved)
                {
                    // Update the list item
                    item.ApplicationItem = item.ApplicationItem;
                    SaveApplist();
                }

                //remove highlight from the control once editing is complete.
                controlList.Unhighlight(doubleClickedControl);
            }
        }
示例#4
0
        /// <summary>
        /// Creates a list item and listens to its events
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        private ApplicationListItem CreateApplicationListItem(ApplicationItem item)
        {
            ApplicationListItem listItem = new ApplicationListItem(item);

            listItem.FinishedDownloading  += new EventHandler(HandleFinishedDownloading);
            listItem.FinishedInstalling   += new EventHandler(HandleFinishedInstalling);
            listItem.FinishedUnInstalling += new EventHandler(HandleFinishedUnInstalling);
            return(listItem);
        }
示例#5
0
        private void LoadApplicationList(string filename)
        {
            ApplicationList appList;

            SetErrorPanelVisibility(false);
            try
            {
                appList = ApplicationList.FromFile(filename);
                InstallPadApp.AppList = appList;
            }
            catch (FileNotFoundException)
            {
                ShowErrorBox(Resources.AppFileNotFound, null);
                return;
            }
            catch (XmlException ex)
            {
                ShowErrorBox(Resources.AppFileParseError, ex.Message);
                return;
            }

            appList.FileName = filename;

            if (appList.ApplicationItems.Count <= 0)
            {
                SetControlsEnabled(false);
            }
            else
            {
                SetControlsEnabled(true);
            }

            // Show errors, if we had any in loading
            if (appList.XmlErrors.Count > 0)
            {
                errorDialog = new AppListErrorDialog();
                foreach (string error in appList.XmlErrors)
                {
                    errorDialog.ErrorText += error + System.Environment.NewLine;
                }

                // Show the "encountered errors" label
                //this.errorPanel.Show();
                SetErrorPanelVisibility(true);
            }
            List <Control> toAdd = new List <Control>();

            foreach (ApplicationItem item in appList.ApplicationItems)
            {
                ApplicationListItem listItem = CreateApplicationListItem(item);
                toAdd.Add(listItem);
            }

            // Add the controls all at once.
            this.controlList.AddAll(toAdd);
        }
示例#6
0
        void editItem_Click(object sender, EventArgs e)
        {
            ApplicationListItem item   = (ApplicationListItem)highlightedControl;
            ApplicationDialog   dialog = new ApplicationDialog(item.ApplicationItem);

            dialog.Title = "Edit Application";
            dialog.ShowDialog(this);

            if (dialog.Saved)
            {
                // Update the list item
                item.ApplicationItem = item.ApplicationItem;
                SaveApplist();
            }
        }
示例#7
0
        private void InstallNext()
        {
            // You want to calculate what's downloading and what's installing,
            // instead of keeping counters, because users can click on the
            // individual install links at any time and trigger other things installing/downloading
            int downloading = 0;
            int installing  = 0;

            // Kepe track of the first item we found that needs to be installed
            ApplicationListItem toInstall = null;

            foreach (ApplicationListItem item in this.controlList.ListItems)
            {
                if (!item.Checked)
                {
                    continue;
                }

                // Avoid trying items again that we've tried to install before
                if (item.State == ApplicationListItem.InstallState.Downloaded && !triedToInstall.Contains(item))
                {
                    if (toInstall == null)
                    {
                        toInstall = item;
                    }
                }
                else if (item.State == ApplicationListItem.InstallState.Installing)
                {
                    installing++;
                }
                else if (item.State == ApplicationListItem.InstallState.Downloading)
                {
                    downloading++;
                }
            }
            // If there's no installing or downloading happening, then we're done.
            if (installing == 0 && downloading == 0 && toInstall == null)
            {
                this.installingAll = false;
            }

            // Only install when no other installers are running - run 1 at a time.
            if (toInstall != null && installing == 0)
            {
                triedToInstall.Add(toInstall);
                toInstall.InstallApplication();
            }
        }
示例#8
0
 /// <summary>
 /// Creates a list item and listens to its events
 /// </summary>
 /// <param name="?"></param>
 /// <returns></returns>
 private ApplicationListItem CreateApplicationListItem(ApplicationItem item)
 {
     ApplicationListItem listItem = new ApplicationListItem(item);
     listItem.FinishedDownloading += new EventHandler(HandleFinishedDownloading);
     listItem.FinishedInstalling += new EventHandler(HandleFinishedInstalling);
     listItem.FinishedUnInstalling += new EventHandler(HandleFinishedUnInstalling);
     return listItem;
 }