コード例 #1
0
 public void TryRunAction(AddIn addIn, AddInAction action)
 {
     foreach (AddInControl ctl in splitContainer.Panel1.Controls)
     {
         ctl.Selected = ctl.AddIn == addIn;
     }
     UpdateActionBox();
     if (selectedAction == action && runActionButton.Visible && runActionButton.Enabled)
     {
         runActionButton.PerformClick();
     }
 }
コード例 #2
0
        void UpdateActionBox()
        {
            ignoreFocusChange = true;
            selected = new List<AddIn>();
            foreach (AddInControl ctl in splitContainer.Panel1.Controls)
            {
                if (ctl.Selected)
                    selected.Add(ctl.AddIn);
            }
            splitContainer.Panel2Collapsed = selected.Count == 0;
            if (selected.Count > 0)
            {
                dependencyTable.Visible = false;
                runActionButton.Visible = true;
                uninstallButton.Visible = true;

                bool allHaveIdentity = true;
                bool allEnabled = true;
                bool allDisabled = true;
                bool allInstalling = true;
                bool allUninstalling = true;
                bool allUpdating = true;
                bool allUninstallable = true;
                bool hasErrors = false;
                foreach (AddIn addIn in selected)
                {
                    if (addIn.Manifest.PrimaryIdentity == null)
                    {
                        allHaveIdentity = false;
                        break;
                    }
                    allEnabled &= addIn.Action == AddInAction.Enable;
                    if (IsErrorAction(addIn.Action))
                        hasErrors = true;
                    else
                        allDisabled &= addIn.Action == AddInAction.Disable;
                    allUpdating &= addIn.Action == AddInAction.Update;
                    allInstalling &= addIn.Action == AddInAction.Install;
                    allUninstalling &= addIn.Action == AddInAction.Uninstall;
                    if (allUninstallable)
                    {
                        if (FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, addIn.FileName))
                        {
                            allUninstallable = false;
                        }
                    }
                }
                if (allEnabled == true || allHaveIdentity == false)
                {
                    selectedAction = AddInAction.Disable;
                    actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionDisable");
                    actionDescription.Text = ResourceService.GetString("AddInManager.DescriptionDisable");
                    if (allHaveIdentity)
                        runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Disable);
                    else
                        runActionButton.Enabled = false;
                    uninstallButton.Enabled = allUninstallable && runActionButton.Enabled;
                }
                else if (allDisabled)
                {
                    selectedAction = AddInAction.Enable;
                    actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionEnable");
                    actionDescription.Text = ResourceService.GetString("AddInManager.DescriptionEnable");
                    runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Enable);
                    if (hasErrors)
                        runActionButton.Enabled = false;
                    uninstallButton.Enabled = allUninstallable;
                }
                else if (allInstalling)
                {
                    selectedAction = AddInAction.Uninstall;
                    actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionCancelInstallation");
                    actionDescription.Text = ResourceService.GetString("AddInManager.DescriptionCancelInstall");
                    runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Disable);
                    uninstallButton.Visible = false;
                }
                else if (allUninstalling)
                {
                    selectedAction = AddInAction.Enable;
                    actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionCancelDeinstallation");
                    actionDescription.Text = ResourceService.GetString("AddInManager.DescriptionCancelDeinstallation");
                    runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Enable);
                    uninstallButton.Visible = false;
                }
                else if (allUpdating)
                {
                    selectedAction = AddInAction.InstalledTwice;
                    actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionCancelUpdate");
                    actionDescription.Text = ResourceService.GetString("AddInManager.DescriptionCancelUpdate");
                    runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.CancelUpdate);
                    uninstallButton.Visible = false;
                }
                else
                {
                    actionGroupBox.Text = "";
                    actionDescription.Text = ResourceService.GetString("AddInManager.DescriptionInconsistentSelection");
                    runActionButton.Visible = false;
                    uninstallButton.Visible = false;
                }
            }
            ignoreFocusChange = false;
        }
コード例 #3
0
        void ShowInstallableAddIns(IList<InstallableAddIn> addInPackages)
        {
            shownAddInPackages = addInPackages;
            ignoreFocusChange = true;
            splitContainer.Panel2Collapsed = false;
            dependencyTable.Visible = false;
            runActionButton.Visible = true;
            uninstallButton.Visible = false;

            selectedAction = AddInAction.Install;
            List<string> installAddIns = new List<string>();
            List<string> updateAddIns = new List<string>();
            foreach (InstallableAddIn addInPackage in addInPackages)
            {
                string identity = addInPackage.AddIn.Manifest.PrimaryIdentity;
                AddIn foundAddIn = null;
                foreach (AddIn addIn in AddInTree.AddIns)
                {
                    if (addIn.Action != AddInAction.Install
                        && addIn.Manifest.Identities.ContainsKey(identity))
                    {
                        foundAddIn = addIn;
                        break;
                    }
                }
                if (foundAddIn != null)
                {
                    updateAddIns.Add(addInPackage.AddIn.Name);
                }
                else
                {
                    installAddIns.Add(addInPackage.AddIn.Name);
                }
            }

            if (updateAddIns.Count == 0)
            {
                actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionInstall");
            }
            else if (installAddIns.Count == 0)
            {
                actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionUpdate");
            }
            else
            {
                actionGroupBox.Text = runActionButton.Text =
                    ResourceService.GetString("AddInManager.ActionInstall")
                    + " + " +
                    ResourceService.GetString("AddInManager.ActionUpdate");
            }
            List<AddIn> addInList = new List<AddIn>();
            StringBuilder b = new StringBuilder();
            if (installAddIns.Count == 1)
            {
                b.Append("Installs the AddIn " + installAddIns[0]);
            }
            else if (installAddIns.Count > 1)
            {
                b.Append("Installs the AddIns " + string.Join(",", installAddIns.ToArray()));
            }
            if (updateAddIns.Count > 0 && installAddIns.Count > 0)
                b.Append("; ");
            if (updateAddIns.Count == 1)
            {
                b.Append("Updates the AddIn " + updateAddIns[0]);
            }
            else if (updateAddIns.Count > 1)
            {
                b.Append("Updates the AddIns " + string.Join(",", updateAddIns.ToArray()));
            }
            actionDescription.Text = b.ToString();
            runActionButton.Enabled = ShowDependencies(addInList, ShowDependencyMode.Enable);
        }
コード例 #4
0
 static bool IsErrorAction(AddInAction action)
 {
     return action == AddInAction.DependencyError
         || action == AddInAction.InstalledTwice
         || action == AddInAction.CustomError;
 }
コード例 #5
0
 public void TryRunAction(AddIn addIn, AddInAction action)
 {
     foreach (AddInControl ctl in splitContainer.Panel1.Controls)
     {
         ctl.Selected = ctl.AddIn == addIn;
     }
     UpdateActionBox();
     if (selectedAction == action && runActionButton.Visible && runActionButton.Enabled)
         runActionButton.PerformClick();
 }
コード例 #6
0
        void ShowInstallableAddIns(IList <InstallableAddIn> addInPackages)
        {
            shownAddInPackages             = addInPackages;
            ignoreFocusChange              = true;
            splitContainer.Panel2Collapsed = false;
            dependencyTable.Visible        = false;
            runActionButton.Visible        = true;
            uninstallButton.Visible        = false;

            selectedAction = AddInAction.Install;
            List <string> installAddIns = new List <string>();
            List <string> updateAddIns  = new List <string>();

            foreach (InstallableAddIn addInPackage in addInPackages)
            {
                string identity   = addInPackage.AddIn.Manifest.PrimaryIdentity;
                AddIn  foundAddIn = null;
                foreach (AddIn addIn in AddInTree.AddIns)
                {
                    if (addIn.Action != AddInAction.Install &&
                        addIn.Manifest.Identities.ContainsKey(identity))
                    {
                        foundAddIn = addIn;
                        break;
                    }
                }
                if (foundAddIn != null)
                {
                    updateAddIns.Add(addInPackage.AddIn.Name);
                }
                else
                {
                    installAddIns.Add(addInPackage.AddIn.Name);
                }
            }

            if (updateAddIns.Count == 0)
            {
                actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionInstall");
            }
            else if (installAddIns.Count == 0)
            {
                actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionUpdate");
            }
            else
            {
                actionGroupBox.Text = runActionButton.Text =
                    ResourceService.GetString("AddInManager.ActionInstall")
                    + " + " +
                    ResourceService.GetString("AddInManager.ActionUpdate");
            }
            List <AddIn>  addInList = new List <AddIn>();
            StringBuilder b         = new StringBuilder();

            if (installAddIns.Count == 1)
            {
                b.Append("Installs the AddIn " + installAddIns[0]);
            }
            else if (installAddIns.Count > 1)
            {
                b.Append("Installs the AddIns " + string.Join(",", installAddIns.ToArray()));
            }
            if (updateAddIns.Count > 0 && installAddIns.Count > 0)
            {
                b.Append("; ");
            }
            if (updateAddIns.Count == 1)
            {
                b.Append("Updates the AddIn " + updateAddIns[0]);
            }
            else if (updateAddIns.Count > 1)
            {
                b.Append("Updates the AddIns " + string.Join(",", updateAddIns.ToArray()));
            }
            actionDescription.Text  = b.ToString();
            runActionButton.Enabled = ShowDependencies(addInList, ShowDependencyMode.Enable);
        }
コード例 #7
0
        void UpdateActionBox()
        {
            ignoreFocusChange = true;
            selected          = new List <AddIn>();
            foreach (AddInControl ctl in splitContainer.Panel1.Controls)
            {
                if (ctl.Selected)
                {
                    selected.Add(ctl.AddIn);
                }
            }
            splitContainer.Panel2Collapsed = selected.Count == 0;
            if (selected.Count > 0)
            {
                dependencyTable.Visible = false;
                runActionButton.Visible = true;
                uninstallButton.Visible = true;

                bool allEnabled       = true;
                bool allDisabled      = true;
                bool allInstalling    = true;
                bool allUninstalling  = true;
                bool allUpdating      = true;
                bool allUninstallable = true;
                bool hasErrors        = false;
                foreach (AddIn addIn in selected)
                {
                    allEnabled &= addIn.Action == AddInAction.Enable;
                    if (addIn.Action == AddInAction.DependencyError || addIn.Action == AddInAction.InstalledTwice)
                    {
                        hasErrors = true;
                    }
                    else
                    {
                        allDisabled &= addIn.Action == AddInAction.Disable;
                    }
                    allUpdating     &= addIn.Action == AddInAction.Update;
                    allInstalling   &= addIn.Action == AddInAction.Install;
                    allUninstalling &= addIn.Action == AddInAction.Uninstall;
                    if (allUninstallable)
                    {
                        if (FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, addIn.FileName))
                        {
                            allUninstallable = false;
                        }
                    }
                }
                if (allEnabled)
                {
                    selectedAction          = AddInAction.Disable;
                    actionGroupBox.Text     = runActionButton.Text = ResourceService.GetString("AddInManager.ActionDisable");
                    actionDescription.Text  = ResourceService.GetString("AddInManager.DescriptionDisable");
                    runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Disable);
                    uninstallButton.Enabled = allUninstallable && runActionButton.Enabled;
                }
                else if (allDisabled)
                {
                    selectedAction          = AddInAction.Enable;
                    actionGroupBox.Text     = runActionButton.Text = ResourceService.GetString("AddInManager.ActionEnable");
                    actionDescription.Text  = ResourceService.GetString("AddInManager.DescriptionEnable");
                    runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Enable);
                    if (hasErrors)
                    {
                        runActionButton.Enabled = false;
                    }
                    uninstallButton.Enabled = allUninstallable;
                }
                else if (allInstalling)
                {
                    selectedAction          = AddInAction.Uninstall;
                    actionGroupBox.Text     = runActionButton.Text = ResourceService.GetString("AddInManager.ActionCancelInstallation");
                    actionDescription.Text  = ResourceService.GetString("AddInManager.DescriptionCancelInstall");
                    runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Disable);
                    uninstallButton.Visible = false;
                }
                else if (allUninstalling)
                {
                    selectedAction          = AddInAction.Enable;
                    actionGroupBox.Text     = runActionButton.Text = ResourceService.GetString("AddInManager.ActionCancelDeinstallation");
                    actionDescription.Text  = ResourceService.GetString("AddInManager.DescriptionCancelDeinstallation");
                    runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Enable);
                    uninstallButton.Visible = false;
                }
                else if (allUpdating)
                {
                    selectedAction          = AddInAction.InstalledTwice;
                    actionGroupBox.Text     = runActionButton.Text = ResourceService.GetString("AddInManager.ActionCancelUpdate");
                    actionDescription.Text  = ResourceService.GetString("AddInManager.DescriptionCancelUpdate");
                    runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.CancelUpdate);
                    uninstallButton.Visible = false;
                }
                else
                {
                    actionGroupBox.Text     = "";
                    actionDescription.Text  = ResourceService.GetString("AddInManager.DescriptionInconsistentSelection");
                    runActionButton.Visible = false;
                    uninstallButton.Visible = false;
                }
            }
            ignoreFocusChange = false;
        }
コード例 #8
0
 static bool IsErrorAction(AddInAction action)
 {
     return(action == AddInAction.DependencyError ||
            action == AddInAction.InstalledTwice ||
            action == AddInAction.CustomError);
 }