コード例 #1
0
        private void UpdateImages(Image image)
        {
            if (image == null)
            {
                return;
            }

            var draw   = image;
            var size   = image.Width;
            var sizes  = IconFactory.GetSizes(Extended.Checked ? IconFactorySizeOption.Additional : IconFactorySizeOption.Application);
            var images = sizes.Where(x => size >= x).Select(x => draw.Redraw(x, x));

            SuspendLayout();
            ImgPanel.SuspendLayout();
            ImgPanel.Controls.Clear();
            var color = Color.DodgerBlue;

            foreach (var img in images)
            {
                var bgImg  = img;
                var bgSize = bgImg.Width;
                var label  = new Label
                {
                    BackgroundImage       = bgImg,
                    BackgroundImageLayout = ImageLayout.Stretch,
                    ForeColor             = color,
                    Font      = new Font("Calibri", 5.75f, FontStyle.Bold, GraphicsUnit.Point, 0),
                    Margin    = new Padding(2, 2, 2, 2),
                    Size      = img.Size,
                    Text      = bgSize.ToString(),
                    TextAlign = ContentAlignment.TopRight
                };
                label.MouseEnter += delegate { label.Cursor = Cursors.Hand; };
                label.MouseLeave += delegate { label.Cursor = Cursors.Default; };
                label.Click      += delegate
                {
                    var newBgImg = OpenImageFileDialog();
                    if (newBgImg == null)
                    {
                        return;
                    }
                    label.BackgroundImage = !newBgImg.Size.Equals(label.Size) ? newBgImg.Redraw(label.Width, label.Height) : newBgImg;
                };
                ControlEx.DrawBorder(label, color, ControlExBorderStyle.Dashed);
                ImgPanel.Controls.Add(label);
            }
            ImgPanel.ResumeLayout();
            ResumeLayout();

            Icon = image.ToIcon();
        }
コード例 #2
0
        public MenuViewForm()
        {
            InitializeComponent();

            SuspendLayout();

            Language.SetControlLang(this);
            Text = Resources.GlobalTitle;

            BackColor = Settings.Window.Colors.BaseDark;
            if (Settings.Window.BackgroundImage != default)
            {
                BackgroundImage       = Settings.Window.BackgroundImage;
                BackgroundImageLayout = Settings.Window.BackgroundImageLayout;
            }
            Icon = Resources.Logo;

            ControlEx.DrawSizeGrip(this, Settings.Window.Colors.Base);
            ControlEx.DrawBorder(this, Settings.Window.Colors.Base);

            appsListViewPanel.BackColor = Settings.Window.Colors.Control;
            appsListViewPanel.ForeColor = Settings.Window.Colors.ControlText;
            appsListView.BackColor      = Settings.Window.Colors.Control;
            appsListView.ForeColor      = Settings.Window.Colors.ControlText;
            appsListView.SetDoubleBuffer();
            appsListView.SetMouseOverCursor();

            searchBox.BackColor = Settings.Window.Colors.Control;
            searchBox.ForeColor = Settings.Window.Colors.ControlText;
            searchBox.DrawSearchSymbol(Settings.Window.Colors.ControlText);
            SearchBox_Leave(searchBox, EventArgs.Empty);

            title.ForeColor     = Settings.Window.Colors.BaseText;
            logoBox.Image       = Resources.Logo64px;
            appsCount.ForeColor = Settings.Window.Colors.BaseText;

            aboutBtn.BackgroundImage = CacheData.GetSystemImage(ImageResourceSymbol.Help);
            aboutBtn.BackgroundImage = aboutBtn.BackgroundImage.SwitchGrayScale($"{aboutBtn.Name}BackgroundImage");

            profileBtn.BackgroundImage = CacheData.GetSystemImage(ImageResourceSymbol.UserDirectory, true);

            downloadBtn.Image = CacheData.GetSystemImage(ImageResourceSymbol.Network);
            settingsBtn.Image = CacheData.GetSystemImage(ImageResourceSymbol.SystemControl);
            foreach (var btn in new[] { downloadBtn, settingsBtn })
            {
                btn.BackColor = Settings.Window.Colors.Button;
                btn.ForeColor = Settings.Window.Colors.ButtonText;
                btn.FlatAppearance.MouseDownBackColor = Settings.Window.Colors.Button;
                btn.FlatAppearance.MouseOverBackColor = Settings.Window.Colors.ButtonHover;
            }

            appMenuItem2.Image = CacheData.GetSystemImage(ImageResourceSymbol.Uac);
            appMenuItem3.Image = CacheData.GetSystemImage(ImageResourceSymbol.Directory);
            appMenuItem7.Image = CacheData.GetSystemImage(ImageResourceSymbol.RecycleBinEmpty);
            appMenuItem8.Image = CacheData.GetSystemImage(ImageResourceSymbol.SystemControl);
            for (var i = 0; i < appMenu.Items.Count; i++)
            {
                appMenu.Items[i].Text = Language.GetText(appMenu.Items[i].Name);
            }
            appMenu.CloseOnMouseLeave(32);
            appMenu.EnableAnimation();
            appMenu.SetFixedSingle();

#if !DEBUG
            SetResizingBorders(TaskBar.GetLocation(Handle));
#endif

            ResumeLayout(false);

            SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged;
        }