Exemplo n.º 1
0
        /// <summary>
        /// Creates a new store management window.
        /// </summary>
        /// <param name="store">The <see cref="IImplementationStore"/> to manage.</param>
        /// <param name="feedCache">Information about implementations found in the <paramref name="store"/> are extracted from here.</param>
        public StoreManageForm(IImplementationStore store, IFeedCache feedCache)
        {
            _store     = store ?? throw new ArgumentNullException(nameof(store));
            _feedCache = feedCache ?? throw new ArgumentNullException(nameof(feedCache));

            InitializeComponent();
            buttonRunAsAdmin.AddShieldIcon();

            HandleCreated += delegate
            {
                if (Locations.IsPortable || ZeroInstallInstance.IsRunningFromCache)
                {
                    WindowsTaskbar.PreventPinning(Handle);
                }
                if (Locations.IsPortable)
                {
                    Text += @" - " + Resources.PortableMode;
                }
                if (WindowsUtils.IsAdministrator)
                {
                    Text += @" (Administrator)";
                }
                else if (WindowsUtils.HasUac)
                {
                    buttonRunAsAdmin.Visible = true;
                }
            };

            Shown += async delegate { await RefreshListAsync(); };

            _treeView.SelectedEntryChanged  += OnSelectedEntryChanged;
            _treeView.CheckedEntriesChanged += OnCheckedEntriesChanged;
            splitContainer.Panel1.Controls.Add(_treeView);
        }
Exemplo n.º 2
0
        public static void ConfigureTaskbar(Form form, string name, string?subCommand = null, string?arguments = null)
        {
            #region Sanity checks
            if (form == null)
            {
                throw new ArgumentNullException(nameof(form));
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            #endregion

            if (Locations.IsPortable || ZeroInstallInstance.IsRunningFromCache)
            {
                WindowsTaskbar.PreventPinning(form.Handle);
            }

            string appUserModelID = AppUserModelID;
            if (!string.IsNullOrEmpty(subCommand))
            {
                appUserModelID += "." + subCommand;
            }
            string exePath = Path.Combine(Locations.InstallBase, ExeName + ".exe");
            WindowsTaskbar.SetWindowAppID(form.Handle, appUserModelID, exePath.EscapeArgument() + " " + arguments, exePath, name);
        }
Exemplo n.º 3
0
        public ConfigDialog(Config config)
        {
            InitializeComponent();

            if (Locations.IsPortable)
            {
                Text += @" - " + Resources.PortableMode;
            }
            HandleCreated += delegate
            {
                if (Locations.IsPortable || ZeroInstallInstance.IsRunningFromCache)
                {
                    WindowsTaskbar.PreventPinning(Handle);
                }
            };

            _config = config;
            ConfigToControls();
            LoadImplementationDirs();

            LoadCatalogSources();

            LoadTrust();
            panelTrustedKeys.Controls.Add(treeViewTrustedKeys);
            treeViewTrustedKeys.CheckedEntriesChanged += treeViewTrustedKeys_CheckedEntriesChanged;

            if (WindowsUtils.IsWindows)
            {
                LoadLanguages();
            }
            else
            {
                tabPageLanguage.Visible = false;
            }
        }
Exemplo n.º 4
0
        //--------------------//

        #region Form
        private void MainForm_HandleCreated(object sender, EventArgs e)
        {
            if (Locations.IsPortable || ZeroInstallInstance.IsRunningFromCache)
            {
                WindowsTaskbar.PreventPinning(Handle);
            }
            else
            {
                string exePath     = Path.Combine(Locations.InstallBase, "ZeroInstall.exe");
                string commandsExe = Path.Combine(Locations.InstallBase, "0install-win.exe");
                WindowsTaskbar.SetWindowAppID(Handle, "ZeroInstall", exePath.EscapeArgument(), exePath, "Zero Install");
                WindowsTaskbar.AddTaskLinks("ZeroInstall", new[]
                {
                    new WindowsTaskbar.ShellLink(buttonSync.Text.Replace("&", ""), commandsExe, SyncApps.Name),
                    new WindowsTaskbar.ShellLink(buttonUpdateAll.Text.Replace("&", ""), commandsExe, UpdateApps.Name),
                    new WindowsTaskbar.ShellLink(buttonStoreManage.Text.Replace("&", ""), commandsExe, StoreMan.Name + " manage")
                });
            }
        }
Exemplo n.º 5
0
        internal static void ConfigureTaskbar([NotNull] Form form, [NotNull] string name)
        {
            #region Sanity checks
            if (form == null)
            {
                throw new ArgumentNullException(nameof(form));
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            #endregion

            if (Locations.IsPortable || ProgramUtils.IsRunningFromCache)
            {
                WindowsTaskbar.PreventPinning(form.Handle);
            }

            string appUserModelID = AppUserModelID;
            string exePath        = Path.Combine(Locations.InstallBase, ExeName + ".exe");
            WindowsTaskbar.SetWindowAppID(form.Handle, appUserModelID, exePath.EscapeArgument(), exePath, name);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Prepares reporting an error.
        /// </summary>
        /// <param name="exception">The exception object describing the error.</param>
        /// <param name="uploadUri">The URI to upload error reports to.</param>
        private ErrorReportForm(Exception exception, Uri uploadUri)
        {
            #region Sanity checks
            if (exception == null)
            {
                throw new ArgumentNullException(nameof(exception));
            }
            if (uploadUri == null)
            {
                throw new ArgumentNullException(nameof(uploadUri));
            }
            #endregion

            InitializeComponent();
            HandleCreated += delegate { WindowsTaskbar.PreventPinning(Handle); };
            Shown         += delegate { this.SetForegroundWindow(); };

            _exception = exception;

            // A missing file as the root is more important than the secondary exceptions it causes
            if (exception.InnerException is FileNotFoundException)
            {
                exception = exception.InnerException;
            }

            // Make the message simpler for missing files
            detailsBox.Text = (exception is FileNotFoundException) ? exception.Message.Replace("\n", Environment.NewLine) : exception.ToString();

            // Append inner exceptions
            if (exception.InnerException != null)
            {
                detailsBox.Text += Environment.NewLine + Environment.NewLine + exception.InnerException;
            }

            _uploadUri = uploadUri;
        }
Exemplo n.º 7
0
 private OutputBox()
 {
     InitializeComponent();
     HandleCreated += delegate { WindowsTaskbar.PreventPinning(Handle); };
 }