Exemplo n.º 1
0
        /// <summary>
        /// [イベント]ロード時
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e)
        {
            // フォームの境界線、タイトルバーを無しに設定
            this.FormBorderStyle = FormBorderStyle.None;
            // フォームの不透明度を60%に設定(半透明化)
            this.Opacity = 1;

            int radius   = 20;
            int diameter = radius * 2;

            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

            // 左上
            gp.AddPie(0, 0, diameter, diameter, 180, 90);
            // 右上
            gp.AddPie(this.Width - diameter, 0, diameter, diameter, 270, 90);
            // 左下
            gp.AddPie(0, this.Height - diameter, diameter, diameter, 90, 90);
            // 右下
            gp.AddPie(this.Width - diameter, this.Height - diameter, diameter, diameter, 0, 90);
            // 中央
            gp.AddRectangle(new Rectangle(radius, 0, this.Width - diameter, this.Height));
            // 左
            gp.AddRectangle(new Rectangle(0, radius, radius, this.Height - diameter));
            // 右
            gp.AddRectangle(new Rectangle(this.Width - radius, radius, radius, this.Height - diameter));

            this.Region = new Region(gp);
        }
        /// <summary>
        /// Calculates the segments.
        /// </summary>
        private void CalculateSegments()
        {
            Rectangle rctFull  = new Rectangle(0, 0, this.Width, this.Height);
            Rectangle rctInner = new Rectangle(((this.Width * 7) / 30),
                                               ((this.Height * 7) / 30),
                                               (this.Width - ((this.Width * 14) / 30)),
                                               (this.Height - ((this.Height * 14) / 30)));


            System.Drawing.Drawing2D.GraphicsPath pthInnerBackground = null;


            // Create 12 segment pieces
            for (int intCount = 0; intCount < 12; intCount++)
            {
                segmentPaths[intCount] = new System.Drawing.Drawing2D.GraphicsPath();

                // We subtract 90 so that the starting segment is at 12 o'clock
                segmentPaths[intCount].AddPie(rctFull, (intCount * 30) - 90, 25);
            }

            // Create the center circle cut-out
            pthInnerBackground = new System.Drawing.Drawing2D.GraphicsPath();
            pthInnerBackground.AddPie(rctInner, 0, 360);

            innerBackgroundRegion = new Region(pthInnerBackground);

            //graph.FillRegion(new SolidBrush(BackColor), innerBackgroundRegion);
        }
 private void button2_Click(object sender, System.EventArgs e)
 {
     System.Drawing.Drawing2D.GraphicsPath p = new System.Drawing.Drawing2D.GraphicsPath( );
     //根据要实现的扇形形状来填写AddPie方法中的相应参数
     p.AddPie(10, 10, 250, 250, 5, 150);
     Region = new Region(p);
 }
Exemplo n.º 4
0
    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        var rect = e.ClipRectangle;

        System.Drawing.Drawing2D.GraphicsPath grPath = new System.Drawing.Drawing2D.GraphicsPath();
        //grPath.AddPie(new Rectangle(1, 1, 10, 10), 180, 18);
        grPath.AddPie(rect, 0, 360);
        this.Region = new System.Drawing.Region(grPath);
        base.OnPaint(e);
    }
Exemplo n.º 5
0
        public void DrawHover(Graphics graphics, Rectangle bounds, double hoverDone)
        {
            using (Bitmap b = new Bitmap(mBackgroundImage, bounds.Size))
                graphics.DrawImage(b, bounds.Location);

            var path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddPie(bounds.X, bounds.Y, bounds.Width, bounds.Height, -90f, (float) (360 * hoverDone));
            graphics.SetClip(path);
            using (Bitmap b = new Bitmap(mImage, bounds.Size))
                graphics.DrawImage(b, bounds.Location);
            graphics.ResetClip();
        }
Exemplo n.º 6
0
        public void DrawHover(Graphics graphics, Rectangle bounds, double hoverDone)
        {
            using (Bitmap b = new Bitmap(mBackgroundImage, bounds.Size))
                graphics.DrawImage(b, bounds.Location);

            var path = new System.Drawing.Drawing2D.GraphicsPath();

            path.AddPie(bounds.X, bounds.Y, bounds.Width, bounds.Height, -90f, (float)(360 * hoverDone));
            graphics.SetClip(path);
            using (Bitmap b = new Bitmap(mImage, bounds.Size))
                graphics.DrawImage(b, bounds.Location);
            graphics.ResetClip();
        }
Exemplo n.º 7
0
        private void CalculateSegments()
        {
            bool flag = true;

            System.Drawing.Rectangle rectangle1 = new System.Drawing.Rectangle(0, 0, Width, Height);
            System.Drawing.Rectangle rectangle2 = new System.Drawing.Rectangle(Width * 7 / 30, Height * 7 / 30, Width - (Width * 14 / 30), Height - (Height * 14 / 30));
            System.Drawing.Drawing2D.GraphicsPath graphicsPath = null;
            int i = 0;

            while (flag)
            {
                segmentPaths[i] = new System.Drawing.Drawing2D.GraphicsPath();
                segmentPaths[i].AddPie(rectangle1, (float)((i * 30) - 90), 25.0F);
                i++;
                flag = i < 12;
            }
            graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
            graphicsPath.AddPie(rectangle2, 0.0F, 360.0F);
            innerBackgroundRegion = new System.Drawing.Region(graphicsPath);
        }
Exemplo n.º 8
0
        private void BuildMe(EDIR BodyDir)
        {
            try
            {
                SzChInternaly = true;
                System.Drawing.Drawing2D.GraphicsPath gr = new System.Drawing.Drawing2D.GraphicsPath();
                switch (BodyDir)
                {
                case EDIR.Horizontal:
                    this.Size = new Size(this.Width, _BorderWidth + 10);
                    gr.AddRectangle(new Rectangle(0, (-_BorderWidth + this.Height) / 2, this.Width, _BorderWidth));
                    break;

                case EDIR.Vertical:
                    this.Size = new Size(_BorderWidth + 10, this.Height);
                    gr.AddRectangle(new Rectangle((-_BorderWidth + this.Width) / 2, 0, _BorderWidth, this.Height));
                    break;

                case EDIR.Slash:
                    try
                    {
                        // CType(_BorderWidth * Height / Width, Integer)
                        for (int i = 0; i <= Convert.ToInt32(Math.Pow(Math.Pow(Width, 2) + Math.Pow(Height, 2), 0.5)); i += _BorderWidth)
                        {
                            switch (_DrawStyle)
                            {
                            case eStyle.circ:
                                gr.AddPie(i, Convert.ToInt32(Height * i / Width), _BorderWidth, _BorderWidth, 0, 360);
                                break;

                            case eStyle.rect:
                                gr.AddRectangle(new Rectangle(i, Convert.ToInt32(Height * i / Width), _BorderWidth, _BorderWidth));
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                    break;

                case EDIR.BKSlash:
                    try
                    {
                        // CType(_BorderWidth * Height / Width, Integer)
                        for (int i = 0; i <= Convert.ToInt32(Math.Pow(Math.Pow(this.Height, 2) + Math.Pow(this.Width, 2), 0.5)); i += _BorderWidth)
                        {
                            switch (_DrawStyle)
                            {
                            case eStyle.circ:
                                gr.AddPie(Width - 1 - i, Convert.ToInt32(Height * i / Width), _BorderWidth, _BorderWidth, 0, 360);
                                break;

                            case eStyle.rect:
                                gr.AddRectangle(new Rectangle(Width - 1 - i, Convert.ToInt32(Height * i / Width), _BorderWidth, _BorderWidth));
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                    break;
                }
                this.Region   = new Region(gr);
                SzChInternaly = false;
            }
            catch
            {
            }
        }
Exemplo n.º 9
0
        private void updateBorder()
        {
            var imeInfo = _monitor.IMEStatus;
            _lastImeStatus = imeInfo;

            if (imeInfo.WindowHandle == this.Handle || !imeInfo.WindowVisible || imeInfo.Ignored) {
                this.Opacity = 0f;
                setTopMost(false);
            }
            else {
                var borderWidth = imeInfo.IMEEnabled ?
                    _settings.ImeOnBorderStyle.Width :
                    _settings.ImeOffBorderStyle.Width;

                Rectangle windowRect = imeInfo.ClientBounds;
                windowRect.Inflate(borderWidth, borderWidth);

                // スクリーン外にはみ出た部分を押し込む
                Rectangle screenRect = Screen.FromHandle(imeInfo.ClientHandle).Bounds;
                {
                    int left = windowRect.X;
                    int top = windowRect.Y;
                    int right = windowRect.Right;
                    int bottom = windowRect.Bottom;
                    if (left < screenRect.X) left = screenRect.X;
                    if (top < screenRect.Y) top = screenRect.Y;
                    if (right > screenRect.Right) right = screenRect.Right;
                    if (bottom > screenRect.Bottom) bottom = screenRect.Bottom;
                    windowRect = Rectangle.FromLTRB(left, top, right, bottom);
                }

                if (this.Size == windowRect.Size) {
                    this.Location = windowRect.Location;
                }
                else {
                    var path = new System.Drawing.Drawing2D.GraphicsPath();
                    var w = windowRect.Width;
                    var h = windowRect.Height;
                    var border2x = borderWidth * 2;
                    path.AddPie(0, 0, border2x, border2x, 180, 90);
                    path.AddPie(w - border2x, 0, border2x, border2x, 270, 90);
                    path.AddPie(0, h - border2x, border2x, border2x, 90, 90);
                    path.AddPie(w - border2x, h - border2x, border2x, border2x, 0, 90);
                    path.AddRectangle(new Rectangle(0, borderWidth, borderWidth, h - border2x));
                    path.AddRectangle(new Rectangle(borderWidth, 0, w - border2x, borderWidth));
                    path.AddRectangle(new Rectangle(w - borderWidth, borderWidth, borderWidth, h - border2x));
                    path.AddRectangle(new Rectangle(borderWidth, h - borderWidth, w - border2x, borderWidth));
                    this.Region = new Region(path);
                    this.Bounds = windowRect;
                }

                this.BackColor = imeInfo.IMEEnabled ?
                    _settings.ImeOnBorderStyle.GetColor() :
                    _settings.ImeOffBorderStyle.GetColor();
                this.Opacity = imeInfo.IMEEnabled ?
                    _settings.ImeOnBorderStyle.Opacity :
                    _settings.ImeOffBorderStyle.Opacity;
                setTopMost(true);
            }
        }
Exemplo n.º 10
0
            /// <summary>
            /// Creates a GraphicsPath object and adds an arc to it with the specified arc values and closure type.
            /// </summary>
            /// <param name="ellipseBounds">A RectangleF structure that represents the rectangular bounds of the ellipse from which the arc is taken.</param>
            /// <param name="start">The starting angle of the arc measured in degrees.</param>
            /// <param name="extent">The angular extent of the arc measured in degrees.</param>
            /// <param name="arcType">The closure type for the arc.</param>
            /// <returns>Returns a new GraphicsPath object that contains the arc path.</returns>
            public static System.Drawing.Drawing2D.GraphicsPath CreateArc2D(System.Drawing.RectangleF ellipseBounds, float start, float extent, int arcType)
            {
                System.Drawing.Drawing2D.GraphicsPath arc2DPath = new System.Drawing.Drawing2D.GraphicsPath();
                switch (arcType)
                {
                    case OPEN:
                        arc2DPath.AddArc(ellipseBounds, start * -1, extent * -1);
                        break;
                    case CLOSED:
                        arc2DPath.AddArc(ellipseBounds, start * -1, extent * -1);
                        arc2DPath.CloseFigure();
                        break;
                    case PIE:
                        arc2DPath.AddPie(ellipseBounds.X, ellipseBounds.Y, ellipseBounds.Width, ellipseBounds.Height, start * -1, extent * -1);
                        break;
                    default:
                        break;
                }

                return arc2DPath;
            }
Exemplo n.º 11
0
 /// <summary>
 /// Creates a GraphicsPath object and adds an arc to it with the specified arc values and closure type.
 /// </summary>
 /// <param name="x">The x coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.</param>
 /// <param name="y">The y coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.</param>
 /// <param name="height">The height of the rectangular region that defines the ellipse from which the arc is drawn.</param>
 /// <param name="width">The width of the rectangular region that defines the ellipse from which the arc is drawn.</param>
 /// <param name="start">The starting angle of the arc measured in degrees.</param>
 /// <param name="extent">The angular extent of the arc measured in degrees.</param>
 /// <param name="arcType">The closure type for the arc.</param>
 /// <returns>Returns a new GraphicsPath object that contains the arc path.</returns>
 public static System.Drawing.Drawing2D.GraphicsPath CreateArc2D(float x, float y, float height, float width, float start, float extent, int arcType)
 {
     System.Drawing.Drawing2D.GraphicsPath arc2DPath = new System.Drawing.Drawing2D.GraphicsPath();
     switch (arcType)
     {
         case OPEN:
             arc2DPath.AddArc(x, y, height, width, start * -1, extent * -1);
             break;
         case CLOSED:
             arc2DPath.AddArc(x, y, height, width, start * -1, extent * -1);
             arc2DPath.CloseFigure();
             break;
         case PIE:
             arc2DPath.AddPie(x, y, height, width, start * -1, extent * -1);
             break;
         default:
             break;
     }
     return arc2DPath;
 }
Exemplo n.º 12
0
        private void CalculateSegments()
        {
            Rectangle rctFull = new Rectangle( 0, 0, Width, Height );
            Rectangle rctInner = new Rectangle( ((Width *  7) / 30),
                                                ((Height *  7) / 30),
                                                (Width -  ((Width *  14 ) / 30 )),
                                                (Height - ((Height * 14) / 30 )));

            System.Drawing.Drawing2D.GraphicsPath pthInnerBackground;

            // Create 12 segment pieces
            for ( int intCount=0; intCount < 12; intCount++ )
            {
                segmentPaths[ intCount ] = new System.Drawing.Drawing2D.GraphicsPath();

                // We subtract 90 so that the starting segment is at 12 o'clock
                segmentPaths[ intCount ].AddPie( rctFull, ( intCount * 30 ) - 90, 25 );
            }

            // Create the center circle cut-out
            pthInnerBackground = new System.Drawing.Drawing2D.GraphicsPath();
            pthInnerBackground.AddPie( rctInner, 0, 360 );
            innerBackgroundRegion = new Region( pthInnerBackground );
        }
Exemplo n.º 13
0
        public static Panel createMessage(MESSAGE message, int PanelWidth, bool isMine)
        {
            var MesView = new MessageView(PanelWidth * 9 / 10);

            var image = new Button();

            image.Text   = "";
            image.Width  = MesView.ImageWidth;
            image.Height = MesView.ImageHeight;
            image.Top    = MesView.ImageTop;
            image.Region = MesView.ImageRegion;
            image.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
            image.BackgroundImage       = View.getAvatar(message.Creator.avatarNumber);


            if (!isMine)
            {
                image.Left = MesView.ImageLeft;
            }

            var text = new Label();

            text.Text        = message.text;
            text.Font        = new Font(text.Font.Name, 8.0f, text.Font.Style);
            text.AutoSize    = true;
            text.MaximumSize = new Size(PanelWidth * 7 / 10, 0);
            text.MinimumSize = new Size(MesView.TextWidth, MesView.TextHeight);
            text.Height      = text.PreferredHeight;
            text.Width       = text.PreferredWidth;
            text.Top         = MesView.TextTop;

            if (!isMine)
            {
                text.Left = MesView.TextLeft + 2 * MesView.ImageLeft + MesView.ImageWidth;
            }
            else
            {
                text.Left  = MesView.TextLeft;
                image.Left = MesView.ImageLeft + 2 * MesView.TextLeft + text.Width;
            }


            var name = new Label();

            name.Text   = message.Creator.Name + "#" + message.Creator.HostName;
            name.Width  = MesView.NameWidth;
            name.Left   = text.Left;
            name.Top    = text.Height + MesView.TextTop + MesView.NameTop;
            name.Height = MesView.NameHeight;

            var date = new Label();

            date.Text   = message.time.ToString();
            date.Width  = MesView.DateWidth;
            date.Left   = name.Left + name.Width + MesView.DateLeft;
            date.Top    = name.Top;
            date.Height = name.Height;


            var fullMessage = new Panel();

            fullMessage.Width       = image.Width + text.Width + 2 * MesView.ImageLeft + 2 * MesView.TextLeft;
            fullMessage.Text        = "";
            fullMessage.Height      = Math.Max(MesView.ImageHeight + 2 * MesView.ImageTop, text.Height + MesView.TextTop + MesView.NameTop + name.Height);
            fullMessage.BorderStyle = BorderStyle.None;
            fullMessage.BackColor   = Color.LightGray;

            fullMessage.Controls.Add(image);
            fullMessage.Controls.Add(text);
            fullMessage.Controls.Add(name);
            fullMessage.Controls.Add(date);

            if (!isMine)
            {
                fullMessage.Left = MesView.MessageLeft;
            }
            else
            {
                fullMessage.Left = PanelWidth - MesView.MessageLeft - fullMessage.Width;
            }

            System.Drawing.Drawing2D.GraphicsPath Mess_Path = new System.Drawing.Drawing2D.GraphicsPath();
            int r = 30;

            Mess_Path.AddPie(0, 0, 2 * r, 2 * r, 180, 90);
            Mess_Path.AddPie(0, fullMessage.Height - 2 * r, 2 * r, 2 * r, 90, 90);
            Mess_Path.AddPie(fullMessage.Width - 2 * r, 0, 2 * r, 2 * r, 270, 90);
            Mess_Path.AddPie(fullMessage.Width - 2 * r, fullMessage.Height - 2 * r, 2 * r, 2 * r, 0, 90);

            Mess_Path.AddRectangle(new Rectangle(r, 0, fullMessage.Width - 2 * r, fullMessage.Height));
            Mess_Path.AddRectangle(new Rectangle(0, r, r, fullMessage.Height - 2 * r));
            Mess_Path.AddRectangle(new Rectangle(fullMessage.Width - r, r, r, fullMessage.Height - 2 * r));

            fullMessage.Region = new Region(Mess_Path);
            fullMessage.Top    = MesView.MessageTop;

            return(fullMessage);
        }
Exemplo n.º 14
0
        public static Panel createFileMessage(AddFile message, int PanelWidth, downloadClick click, bool isMine)
        {
            var MesView = new MessageView(PanelWidth * 9 / 10);

            var image = new Button();

            image.Text   = "";
            image.Width  = MesView.ImageWidth;
            image.Height = MesView.ImageHeight;
            image.Top    = MesView.ImageTop;
            image.Region = MesView.ImageRegion;
            image.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
            image.BackgroundImage       = View.getAvatar(message.getCreator().avatarNumber);


            if (!isMine)
            {
                image.Left = MesView.ImageLeft;
            }

            var fileName = new Label();

            fileName.Text        = message.getName() + "\nsize: " + Convert.ToString(message.getSize()) + "\n" + message.getNewName();
            fileName.Font        = new Font(fileName.Font.Name, 8.0f, FontStyle.Bold | FontStyle.Underline);
            fileName.ForeColor   = Color.White;
            fileName.AutoSize    = true;
            fileName.MaximumSize = new Size(PanelWidth * 7 / 10, 0);
            fileName.MinimumSize = new Size(MesView.TextWidth, MesView.TextHeight);
            fileName.Height      = fileName.PreferredHeight;
            fileName.Width       = fileName.PreferredWidth;
            fileName.Top         = MesView.TextTop;
            fileName.Click      += new EventHandler(click);
            fileName.Cursor      = Cursors.Hand;

            if (!isMine)
            {
                fileName.Left = MesView.TextLeft + 2 * MesView.ImageLeft + MesView.ImageWidth;
            }
            else
            {
                fileName.Left = MesView.TextLeft;
                image.Left    = MesView.ImageLeft + 2 * MesView.TextLeft + fileName.Width;
            }


            var name = new Label();

            name.Text   = message.getCreator().Name + "#" + message.getCreator().HostName;
            name.Width  = MesView.NameWidth;
            name.Left   = fileName.Left;
            name.Top    = fileName.Height + MesView.TextTop + MesView.NameTop;
            name.Height = MesView.NameHeight;

            var date = new Label();

            date.Text   = message.getTime().ToString();
            date.Width  = MesView.DateWidth;
            date.Left   = name.Left + name.Width + MesView.DateLeft;
            date.Top    = name.Top;
            date.Height = name.Height;


            var fullMessage = new Panel();

            fullMessage.Width       = image.Width + fileName.Width + 2 * MesView.ImageLeft + 2 * MesView.TextLeft;
            fullMessage.Text        = "";
            fullMessage.Height      = Math.Max(MesView.ImageHeight + 2 * MesView.ImageTop, fileName.Height + MesView.TextTop + MesView.NameTop + name.Height);
            fullMessage.BorderStyle = BorderStyle.None;
            fullMessage.BackColor   = Color.LightBlue;

            fullMessage.Controls.Add(image);
            fullMessage.Controls.Add(fileName);
            fullMessage.Controls.Add(name);
            fullMessage.Controls.Add(date);

            if (!isMine)
            {
                fullMessage.Left = MesView.MessageLeft;
            }
            else
            {
                fullMessage.Left = PanelWidth - MesView.MessageLeft - fullMessage.Width;
            }

            System.Drawing.Drawing2D.GraphicsPath Mess_Path = new System.Drawing.Drawing2D.GraphicsPath();
            int r = 30;

            Mess_Path.AddPie(0, 0, 2 * r, 2 * r, 180, 90);
            Mess_Path.AddPie(0, fullMessage.Height - 2 * r, 2 * r, 2 * r, 90, 90);
            Mess_Path.AddPie(fullMessage.Width - 2 * r, 0, 2 * r, 2 * r, 270, 90);
            Mess_Path.AddPie(fullMessage.Width - 2 * r, fullMessage.Height - 2 * r, 2 * r, 2 * r, 0, 90);

            Mess_Path.AddRectangle(new Rectangle(r, 0, fullMessage.Width - 2 * r, fullMessage.Height));
            Mess_Path.AddRectangle(new Rectangle(0, r, r, fullMessage.Height - 2 * r));
            Mess_Path.AddRectangle(new Rectangle(fullMessage.Width - r, r, r, fullMessage.Height - 2 * r));

            fullMessage.Region = new Region(Mess_Path);
            fullMessage.Top    = MesView.MessageTop;

            return(fullMessage);
        }