Exemple #1
0
        /// <summary>
        /// Called when graphics resources need to be loaded.
        ///
        /// Use this for the usage of :
        /// - creation of the internal embedded controls.
        /// - setting of the variables and resources in this control
        /// - to load any game-specific graphics resources
        /// - take over the config width and height and use it into State
        /// - overriding how this item looks like , by settings its texture or theme
        ///
        /// Call base.LoadContent before you do your override code, this will cause :
        /// - State.SourceRectangle to be reset to the Config.Size
        /// </summary>
        public override void LoadContent()
        {
            base.LoadContent();

            // min button
            MinButton.ConfigText    = "<";
            MinButton.Config.Width  = Config.Height;
            MinButton.Config.Height = Config.Height;
            MinButton.LoadContent();

            // max button
            MaxButton.ConfigText       = ">";
            MaxButton.Config.Width     = Config.Height;
            MaxButton.Config.Height    = Config.Height;
            MaxButton.Config.PositionX = Config.Width - MaxButton.Config.Width;
            MaxButton.LoadContent();

            // indicator
            this.ScrollIndicator = new Button(Name + "-indicator");
            this.RedrawSize();
            this.RedrawPosition();
            this.AddControl(this.ScrollIndicator);
            ScrollIndicator.LoadContent();

            this.SetVisibility();
        }
Exemple #2
0
        private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            e.Graphics.FillRegion(Brushes.Green, TitleBar);
            e.Graphics.FillRectangle(SystemBrushes.Menu, new Rectangle(0, 26, Width, 19));

            if (FileHot)
            {
                e.Graphics.FillRectangle(SystemBrushes.Highlight, labelFile.Bounds);
            }
            if (HelpHot)
            {
                e.Graphics.FillRectangle(SystemBrushes.Highlight, labelHelp.Bounds);
            }

            Pen BorderPen = new Pen(Color.Green, 2);

            BorderPen.Alignment = PenAlignment.Inset;
            e.Graphics.DrawPath(BorderPen, FormShape);
            BorderPen.Dispose();

            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;

            StringFormat sf = new StringFormat(StringFormatFlags.NoWrap);

            sf.Trimming      = StringTrimming.EllipsisCharacter;
            sf.Alignment     = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;

            e.Graphics.DrawString(this.Text, Control.DefaultFont, Brushes.White, RectangleF.FromLTRB(84, 0, MinButton.GetBounds().X, 24), sf);

            if (ClosePress)
            {
                e.Graphics.FillPath(Brushes.Blue, CloseButton);
            }
            else
            {
                e.Graphics.FillPath(Brushes.Red, CloseButton);
            }

            if (MinPress)
            {
                e.Graphics.FillPath(Brushes.Red, MinButton);
            }
            else
            {
                e.Graphics.FillPath(Brushes.Yellow, MinButton);
            }

            Font GlyphFont = new Font("marlett", Font.SizeInPoints, FontStyle.Bold, GraphicsUnit.Point);

            e.Graphics.DrawString("0", GlyphFont, Brushes.Black, MinButton.GetBounds(), sf);
            e.Graphics.DrawString("r", GlyphFont, Brushes.Black, CloseButton.GetBounds(), sf);
            GlyphFont.Dispose();
        }
Exemple #3
0
        private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            ClosePress = CloseButton.IsVisible(e.X, e.Y) && e.Button == MouseButtons.Left;
            MinPress   = MinButton.IsVisible(e.X, e.Y) && e.Button == MouseButtons.Left;
            FormDrag   = TitleBar.IsVisible(e.X, e.Y) &&
                         e.Button == MouseButtons.Left &&
                         ClosePress == false && MinPress == false;

            if (FormDrag)
            {
                this.Capture = false;
                Message msg = Message.Create(Handle, WM_NCLBUTTONDOWN, (IntPtr)HT_CAPTION, IntPtr.Zero);
                WndProc(ref msg);
            }

            Invalidate();
        }
Exemple #4
0
        private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            bool OverClose, OverMin;

            OverClose = CloseButton.IsVisible(e.X, e.Y);
            OverMin   = MinButton.IsVisible(e.X, e.Y);

            if (OverClose && ClosePress && e.Button == MouseButtons.Left)
            {
                this.Close();
            }
            if (OverMin && MinPress && e.Button == MouseButtons.Left)
            {
                this.WindowState = FormWindowState.Minimized;
            }

            if (e.Button == MouseButtons.Right && TitleBar.IsVisible(e.X, e.Y))
            {
                if (OverClose == false && OverMin == false)
                {
                    const int WM_GETSYSMENU = 0x313;
                    if (e.Button == MouseButtons.Right)
                    {
                        Point   pos  = this.PointToScreen(new Point(e.X, e.Y));
                        IntPtr  hPos = (IntPtr)((int)((pos.Y * 0x10000) | (pos.X & 0xFFFF)));
                        Message msg  = Message.Create(this.Handle, WM_GETSYSMENU, IntPtr.Zero, hPos);
                        WndProc(ref msg);
                    }
                }
            }

            ClosePress = false;
            MinPress   = false;
            FormDrag   = false;

            Invalidate();
        }
Exemple #5
0
        private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            bool OverClose, OverMin;

            OverClose  = CloseButton.IsVisible(e.X, e.Y);
            OverMin    = MinButton.IsVisible(e.X, e.Y);
            ClosePress = OverClose && e.Button == MouseButtons.Left;
            MinPress   = OverMin && e.Button == MouseButtons.Left;

            if (OverClose && ClosePress == false)
            {
                toolTip1.SetToolTip(this, "Close");
            }
            else if (OverMin && MinPress == false)
            {
                toolTip1.SetToolTip(this, "Minimize");
            }
            else
            {
                toolTip1.SetToolTip(this, "");
            }

            Invalidate();
        }