Example #1
0
            private void ChangeFormShape(FormShapeTypes FormShapeType, PaintEventArgs e)
            {
                //전체를 투명하게 될 색으로 먼저 설정.
                e.Graphics.FillRectangle(new SolidBrush(this.ColorToTrans), 0, 0, this.Width, this.Height);

                //다음에 원래 폼의 배경색을 채움.
                switch (FormShapeType)
                {
                case FormShapeTypes.Ellipse:
                    e.Graphics.FillEllipse(new SolidBrush(this.BackColor), 0, 0, this.Width, this.Height);

                    break;

                case FormShapeTypes.RoundedRectangle:
                    GraphicsPath gp = DrawRoundedRectangle(20);

                    Region rgn = new Region(gp);
                    e.Graphics.FillRegion(new SolidBrush(this.BackColor), rgn);

                    break;
                }
            }
Example #2
0
            /// <summary>
            /// 폼의 모양을 지정.
            /// </summary>
            /// <param name="f">Form 개체</param>
            /// <param name="fst">Forrm의 변경될 모양</param>
            public FormShape(Form f, FormShapeTypes fst)
            {
                if (f.FormBorderStyle != FormBorderStyle.None)
                {
                    f.FormBorderStyle = FormBorderStyle.None;
                }

                BackColor = f.BackColor;
                Width     = f.ClientSize.Width;
                Height    = f.ClientSize.Height;

                //폼의 배경색이 숨겨질 색과 같은 빨간색이라면 숨겨질 색을 노란색으로
                //설정해서 폼의 배경색을 보이게 함.
                ColorToTrans      = (BackColor == Color.Red) ? Color.Yellow : Color.Red;
                f.TransparencyKey = ColorToTrans;

                f.Paint       += new System.Windows.Forms.PaintEventHandler(this.FormShape_Paint);
                f.SizeChanged += new System.EventHandler(this.FormShape_SizeChanged);

                this.fst = fst;
                this.f   = f;
            }