Example #1
0
        // Cell CONTENT clicked (not just cell, the actual cell content)
        // This is used for the checkbox enabled toggles.
        private void _packageList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e?.ColumnIndex != 4)
            {
                return;
            }

            var package = GetPackageFromRow(e);

            if (package == null)
            {
                return;
            }

            //var cell = _packageList.Rows[e.RowIndex].Cells[4];

            if (!package.IsDisabled)
            {
                LocalPackageManager.TryDisablePackage(package.GUID);
            }
            else
            {
                LocalPackageManager.TryEnablePackage(package.GUID);
            }

            //RefreshRow(e.RowIndex, package);
        }
Example #2
0
        internal static void Cmd_Disable(params string[] args)
        {
            if (!Folders.IsCurrentOutwardPathValid())
            {
                Console.WriteLine("You need to set the Outward path first!");
                Execute();
                return;
            }

            foreach (var guid in args)
            {
                LocalPackageManager.TryDisablePackage(guid);
            }
        }
Example #3
0
        /// <summary>
        /// Enable all packages in this profile, and disable all other packages.
        /// </summary>
        public void EnableProfile()
        {
            if (this.packages == null || this.packages.Count == 0)
            {
                if (LocalPackageManager.s_enabledPackages.Any())
                {
                    LocalPackageManager.DisableAllPackages();
                }
                return;
            }

            // Try enable all packages (does nothing if already OK)
            // its possible our 'packages' list will change during this process, so copy it now.
            //var copy = packages.ToList();
            List <string> missing = new List <string>();

            for (int i = 0; i < packages.Count; i++)
            {
                var pkg = packages[i];
                if (LocalPackageManager.TryGetInstalledPackage(pkg) == null)
                {
                    missing.Add(pkg);
                }
                else
                {
                    if (!LocalPackageManager.TryEnablePackage(pkg))
                    {
                        LocalPackageManager.TryDisablePackage(pkg, true);
                        packages.Remove(pkg);
                    }
                }
            }

            if (missing.Any())
            {
                string miss = "";
                foreach (var entry in missing)
                {
                    miss += $"\n{entry}";
                }

                var msgResult = MessageBox.Show($"The following packages in your profile are missing and need to be re-installed:" +
                                                $"\n{miss}" +
                                                $"\n\n" +
                                                $"Do you want to re-install them?",
                                                "Missing packages!",
                                                MessageBoxButtons.YesNo);
                if (msgResult == DialogResult.Yes)
                {
                    foreach (var entry in missing)
                    {
                        LocalPackageManager.TryInstallWebPackage(entry);
                    }
                }
            }

            // Disable currently enabled packages which are not in this profile
            if (LocalPackageManager.s_enabledPackages.Any())
            {
                for (int i = LocalPackageManager.s_enabledPackages.Count - 1; i >= 0; i--)
                {
                    var pkg = LocalPackageManager.s_enabledPackages.ElementAt(i);

                    if (!packages.Any(it => it == pkg.Key))
                    {
                        LocalPackageManager.TryDisablePackage(pkg.Key, true);
                    }
                }
            }
        }