Ejemplo n.º 1
0
        /// <summary>
        /// Finds a running Windows Explorer instance and causes it restart.
        /// </summary>
        public static void RestartExplorer()
        {
            if (OperatingSystemVersions.IsSupported(OperatingSystemVersion.WindowsVista))
            {
                using (var rm = new RestartManagerSession())
                {
                    rm.RegisterProcess(Process.GetProcessesByName("explorer"));
                    rm.Shutdown(RestartManagerSession.ShutdownType.Normal);
                    rm.Restart();
                }
            }
            else
            {
                Process[] processes = Process.GetProcessesByName("explorer");

                foreach (Process process in processes)
                {
                    process.Kill();
                }

                foreach (Process process in processes)
                {
                    process.Start();
                }
            }
        }
        public CommandControl()
        {
            this.Cursor      = Cursors.Hand;
            this.MouseLeave += (s, e) => this.SetState(0);
            this.MouseHover += (s, e) => this.SetState(1);
            this.MouseUp    += (s, e) => this.SetState(1);
            this.MouseDown  += (s, e) => this.SetState(2);

            //bitmap = NativeHelpers.ExtractImage(@"%SystemRoot%\Resources\Themes\aero\aero.msstyles", 516);
            if (OperatingSystemVersions.IsSupported(OperatingSystemVersion.Windows10))
            {
                bitmap = Properties.Resources.go10;
            }
            else if (OperatingSystemVersions.IsSupported(OperatingSystemVersion.WindowsVista))
            {
                bitmap = Properties.Resources.go7;
            }
            else
            {
                bitmap = Icons.Go.ToBitmap();
            }

            if (underlinedFont == null && !OperatingSystemVersions.IsSupported(OperatingSystemVersion.WindowsVista))
            {
                underlinedFont = new Font(this.Font, FontStyle.Underline);
            }
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            int frame = this.Enabled ? currentState : 3;

            Image icon = this.GetIcon(frame);

            e.Graphics.DrawImageUnscaled(icon, this.Padding.Left, this.Padding.Top + (this.Height / 2) - (icon.Height / 2));

            Font font = this.Font;

            if (currentState != 0 && !OperatingSystemVersions.IsSupported(OperatingSystemVersion.WindowsVista))
            {
                font = underlinedFont;
            }

            var rect = new RectangleF(
                this.Padding.Left + icon.Width + Spacing,
                this.Padding.Top + 4,
                this.Width - this.Padding.Right,
                this.Height - this.Padding.Bottom - 4);

            e.Graphics.DrawString(this.Text, font, SystemBrushes.ControlText, rect, Constants.NearCenterStringFormat);
        }
Ejemplo n.º 4
0
 internal CustomizationPage() : base("Customization", new ColorsPage())
 {
     if (OperatingSystemVersions.IsSupported(OperatingSystemVersion.WindowsVista))
     {
         this.Icon = NativeHelpers.ExtractIcon(@"%SystemRoot%\system32\imageres.dll", -197);
     }
     else
     {
         this.Icon = NativeHelpers.ExtractIcon(@"%SystemRoot%\system32\shell32.dll", -250);
     }
 }
        private void SoftwarePageView_Load(object sender, EventArgs e)
        {
            if (OperatingSystemVersions.IsSupported(OperatingSystemVersion.Windows10))
            {
                foreach (var application in getUwpApplications())
                {
                    var item = new ListViewItem()
                    {
                        Tag      = application.Item1,
                        ImageKey = application.Item1,
                        Text     = application.Item1,
                    };

                    if (application.Item3.ChildNodes.Count != 0)
                    {
                        item.Text = application.Item3["Package"]["Properties"]["DisplayName"].Value;
                    }

                    if (GetIcon(application.Item2, application.Item3) is Image icon)
                    {
                        smallImageList.Images.Add(application.Item1, icon);
                    }

                    listView.Items.Add(item);
                }
            }

            foreach (UninstallInfo info in this.getDesktopApplications())
            {
                if (info.Hide)
                {
                    continue;
                }

                var item = new ListViewItem()
                {
                    Tag      = info,
                    ImageKey = info.IconPath,
                    Text     = info.DisplayName,
                };

                var icon = info.Icon;
                if (icon != null)
                {
                    smallImageList.Images.Add(info.IconPath, icon);
                    largeImageList.Images.Add(info.IconPath, icon);
                }

                listView.Items.Add(item);
            }
        }