コード例 #1
0
        /// <summary>
        /// Raises the ParentChanged event.
        /// </summary>
        /// <param name="e">An EventArgs that contains the event data.</param>
        protected override void OnParentChanged(EventArgs e)
        {
#if !DESIGN
            this.handle = ControlEx.GetHandle(this);
#endif
            base.OnParentChanged(e);
        }
コード例 #2
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (treeView1.Nodes.Count <= 0)
                {
                    return;
                }

                //清除模板关联检查项目
                _rtm.ClearTemplateReleationExamItem(_templateId);

                List <TreeNode> checkNodes = ControlEx.GetCheckedTreeNode(treeView1.Nodes[0]);

                foreach (TreeNode tn in checkNodes)
                {
                    if (tn.Tag is ExamClassData)
                    {
                        continue;
                    }

                    ExamItemData itemData = tn.Tag as ExamItemData;

                    _rtm.NewTemplateExamItemReleation(_templateId, itemData.项目ID);
                }

                IsModify = false;
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
コード例 #3
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();
        }
コード例 #4
0
ファイル: ControlEx.cs プロジェクト: scryed001/gpstranslator
            //creates a new messagewindow associated with the specific control.
            internal ControlMessageWindow(ControlEx parent)
            {
                //set parent
                m_parent = parent;

                //make this window a child of parent control
                Win32Window.SetParent(this.Hwnd, m_parent.Handle);

                //set window style - make visible
                Win32Window.SetWindowLong(this.Hwnd, (int)GWL.STYLE, 0x46000000);
                //set ex style top-most
                Win32Window.SetWindowLong(this.Hwnd, (int)GWL.EXSTYLE, 0x00000008);

                //set visible style full size of parent
                Win32Window.SetWindowPos(this.Hwnd, 0, 0, 0, m_parent.Width, m_parent.Height, SWP.SHOWWINDOW | SWP.NOSIZE | SWP.NOZORDER);
            }
コード例 #5
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;
        }
コード例 #6
0
 protected override void OnParentChanged(EventArgs e)
 {
     base.OnParentChanged(e);
     _hwnd = ControlEx.GetHandle(this);
 }
コード例 #7
0
        private void MenuViewForm_Load(object sender, EventArgs e)
        {
            BackColor = Color.FromArgb(byte.MaxValue, Main.Colors.Base.R, Main.Colors.Base.G, Main.Colors.Base.B);
            if (Main.ScreenDpi > 96)
            {
                Font = SystemFonts.CaptionFont;
            }
            Icon        = Resources.PortableApps_blue;
            MaximumSize = Screen.FromHandle(Handle).WorkingArea.Size;
            Lang.SetControlLang(this);
            for (var i = 0; i < appMenu.Items.Count; i++)
            {
                appMenu.Items[i].Text = Lang.GetText(appMenu.Items[i].Name);
            }
            if (Main.SetFont(this))
            {
                layoutPanel.Size = new Size(Width - 2, Height - 2);
            }
            Main.SetFont(appMenu);

            layoutPanel.BackgroundImage       = Main.BackgroundImage;
            layoutPanel.BackgroundImageLayout = Main.BackgroundImageLayout;
            layoutPanel.BackColor             = Main.Colors.Base;
            layoutPanel.SetControlStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer);
            ControlEx.DrawSizeGrip(layoutPanel, Main.Colors.Base,
                                   (o, args) =>
            {
                Point point;
                switch (TaskBar.GetLocation(Handle))
                {
                case TaskBar.Location.Right:
                    point = new Point(1, Height - 1);
                    break;

                case TaskBar.Location.Bottom:
                    point = new Point(Width - 1, 1);
                    break;

                default:
                    point = new Point(Width - 1, Height - 1);
                    break;
                }
                WinApi.NativeHelper.ClientToScreen(Handle, ref point);
                WinApi.NativeHelper.SetCursorPos((uint)point.X, (uint)point.Y);
                var inputMouseDown = new WinApi.DeviceInput();
                inputMouseDown.Data.Mouse.Flags = 0x2;
                inputMouseDown.Type             = 0;
                var inputMouseUp = new WinApi.DeviceInput();
                inputMouseUp.Data.Mouse.Flags = 0x4;
                inputMouseUp.Type             = 0;
                WinApi.DeviceInput[] inputs   =
                {
                    inputMouseUp,
                    inputMouseDown
                };
                WinApi.NativeHelper.SendInput((uint)inputs.Length, inputs, Marshal.SizeOf(typeof(WinApi.DeviceInput)));
            },
                                   (o, args) =>
            {
                var p = o as PictureBox;
                if (p == null)
                {
                    return;
                }
                switch (TaskBar.GetLocation(Handle))
                {
                case TaskBar.Location.Right:
                case TaskBar.Location.Bottom:
                    p.Cursor = Cursors.SizeNESW;
                    break;

                default:
                    p.Cursor = Cursors.SizeNWSE;
                    break;
                }
            });

            _hideHScrollBar = Ini.Read("Settings", "Window.HideHScrollBar", false);
            if (Main.ScreenDpi > 96)
            {
                appsListViewPanel.Font = SystemFonts.SmallCaptionFont;
            }
            appsListViewPanel.BackColor = Main.Colors.Control;
            appsListViewPanel.ForeColor = Main.Colors.ControlText;
            appsListView.BackColor      = appsListViewPanel.BackColor;
            appsListView.ForeColor      = appsListViewPanel.ForeColor;
            appsListView.SetDoubleBuffer();
            appsListView.SetMouseOverCursor();

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

            title.ForeColor     = Main.BackgroundImage.GetAverageColor().InvertRgb().ToGrayScale();
            logoBox.Image       = Resources.PortableApps_Logo_gray.Redraw(logoBox.Height, logoBox.Height);
            appsCount.ForeColor = title.ForeColor;

            aboutBtn.BackgroundImage = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Help, Main.SystemResourcePath)?.ToBitmap();
            aboutBtn.BackgroundImage = aboutBtn.BackgroundImage.SwitchGrayScale($"{aboutBtn.Name}BackgroundImage");

            profileBtn.BackgroundImage = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.UserDir, true, Main.SystemResourcePath)?.ToBitmap();
            downloadBtn.Image          = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Network, Main.SystemResourcePath)?.ToBitmap();
            settingsBtn.Image          = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.SystemControl, Main.SystemResourcePath)?.ToBitmap();
            foreach (var btn in new[] { downloadBtn, settingsBtn })
            {
                btn.BackColor = Main.Colors.Button;
                btn.ForeColor = Main.Colors.ButtonText;
                btn.FlatAppearance.MouseDownBackColor = Main.Colors.Button;
                btn.FlatAppearance.MouseOverBackColor = Main.Colors.ButtonHover;
            }

            appMenuItem2.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Uac, Main.SystemResourcePath)?.ToBitmap();
            appMenuItem3.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Directory, Main.SystemResourcePath)?.ToBitmap();
            appMenuItem5.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Pin, Main.SystemResourcePath)?.ToBitmap();
            appMenuItem7.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.RecycleBinEmpty, Main.SystemResourcePath)?.ToBitmap();
            appMenu.CloseOnMouseLeave(32);
            appMenu.EnableAnimation();
            appMenu.SetFixedSingle();

            var docDir = PathEx.Combine(PathEx.LocalDir, "Documents");

            if (Directory.Exists(docDir) && Data.DirIsLink(docDir) && !Data.MatchAttributes(docDir, FileAttributes.Hidden))
            {
                Data.SetAttributes(docDir, FileAttributes.Hidden);
            }

            _windowOpacity = Ini.Read("Settings", "Window.Opacity", 95d);
            if (_windowOpacity.IsBetween(20d, 100d))
            {
                _windowOpacity /= 100d;
            }
            else
            {
                _windowOpacity = .95d;
            }

            var windowFadeInEffect = Ini.Read("Settings", "Window.FadeInEffect", 0);

            _windowFadeInDuration = Ini.Read("Settings", "Window.FadeInDuration", 100);
            if (_windowFadeInDuration < 25)
            {
                _windowFadeInDuration = 25;
            }
            if (_windowFadeInDuration > 750)
            {
                _windowFadeInDuration = 750;
            }

            var windowWidth = Ini.Read("Settings", "Window.Size.Width", MinimumSize.Width);

            if (windowWidth > MinimumSize.Width && windowWidth < MaximumSize.Width)
            {
                Width = windowWidth;
            }
            if (windowWidth > MaximumSize.Width)
            {
                Width = MaximumSize.Width;
            }

            var windowHeight = Ini.Read("Settings", "Window.Size.Height", MinimumSize.Height);

            if (windowHeight > MinimumSize.Height && windowHeight < MaximumSize.Height)
            {
                Height = windowHeight;
            }
            if (windowHeight > MaximumSize.Height)
            {
                Height = MaximumSize.Height;
            }

            MenuViewForm_Update();

            var windowAnimation = windowFadeInEffect == 0 ? WinApi.AnimateWindowFlags.Blend : WinApi.AnimateWindowFlags.Slide;

            switch (windowAnimation)
            {
            case WinApi.AnimateWindowFlags.Blend:
                return;

            case WinApi.AnimateWindowFlags.Slide:
                var windowPosition = Ini.Read("Settings", "Window.DefaultPosition", 0);
                if (windowPosition == 1)
                {
                    windowAnimation = WinApi.AnimateWindowFlags.Center;
                    break;
                }
                switch (TaskBar.GetLocation(Handle))
                {
                case TaskBar.Location.Left:
                    windowAnimation |= WinApi.AnimateWindowFlags.HorPositive;
                    break;

                case TaskBar.Location.Top:
                    windowAnimation |= WinApi.AnimateWindowFlags.VerPositive;
                    break;

                case TaskBar.Location.Right:
                    windowAnimation |= WinApi.AnimateWindowFlags.HorNegative;
                    break;

                case TaskBar.Location.Bottom:
                    windowAnimation |= WinApi.AnimateWindowFlags.VerNegative;
                    break;

                default:
                    windowAnimation = WinApi.AnimateWindowFlags.Center;
                    break;
                }
                break;
            }
            Opacity = _windowOpacity;
            WinApi.NativeHelper.AnimateWindow(Handle, _windowFadeInDuration, windowAnimation);
        }