示例#1
0
        protected void RecalcLayout()
        {
            if (base.get_IsHandleCreated())
            {
                System.Drawing.Size size = base.Size;
                System.Drawing.Point[] pointArray = new System.Drawing.Point[3];
                System.Drawing.Point empty = System.Drawing.Point.Empty;
                System.Drawing.Point point2 = (System.Drawing.Point) size;
                switch (this.Quadrant)
                {
                    case BallonQuadrant.TopLeft:
                        empty.set_Y(TIPTAIL);
                        pointArray[2].set_X((int) (((size.get_Width() - TIPTAIL) / 4) + TIPTAIL));
                        pointArray[2].set_Y(TIPTAIL);
                        pointArray[0].set_X((int) (((size.get_Width() - TIPTAIL) / 4) + 1));
                        pointArray[0].set_Y(pointArray[2].get_Y());
                        pointArray[1].set_X(pointArray[0].get_X());
                        pointArray[1].set_Y(1);
                        break;

                    case BallonQuadrant.TopRight:
                        empty.set_Y(TIPTAIL);
                        pointArray[0].set_X((int) (((size.get_Width() - TIPTAIL) / 4) * 3));
                        pointArray[0].set_Y(TIPTAIL);
                        pointArray[2].set_X((int) (((((size.get_Width() - TIPTAIL) / 4) * 3) + TIPTAIL) - 1));
                        pointArray[2].set_Y(pointArray[0].get_Y());
                        pointArray[1].set_X(pointArray[2].get_X());
                        pointArray[1].set_Y(1);
                        break;

                    case BallonQuadrant.BottomLeft:
                        point2.set_Y((int) (size.get_Height() - TIPTAIL));
                        pointArray[0].set_X((int) ((((size.get_Width() - TIPTAIL) / 4) + TIPTAIL) - 1));
                        pointArray[0].set_Y((int) (size.get_Height() - TIPTAIL));
                        pointArray[2].set_X((int) ((size.get_Width() - TIPTAIL) / 4));
                        pointArray[2].set_Y(pointArray[0].get_Y());
                        pointArray[1].set_X(pointArray[2].get_X());
                        pointArray[1].set_Y((int) (size.get_Height() - 1));
                        break;

                    case BallonQuadrant.BottomRight:
                        point2.set_Y((int) (size.get_Height() - TIPTAIL));
                        pointArray[2].set_X((int) (((size.get_Width() - TIPTAIL) / 4) * 3));
                        pointArray[2].set_Y((int) (size.get_Height() - TIPTAIL));
                        pointArray[0].set_X((int) (((((size.get_Width() - TIPTAIL) / 4) * 3) + TIPTAIL) - 1));
                        pointArray[0].set_Y(pointArray[2].get_Y());
                        pointArray[1].set_X(pointArray[0].get_X());
                        pointArray[1].set_Y((int) (size.get_Height() - 1));
                        break;
                }
                if (pointArray[0].get_X() < TIPMARGIN)
                {
                    pointArray[0].set_X(TIPMARGIN);
                }
                if (pointArray[0].get_X() > (size.get_Width() - TIPMARGIN))
                {
                    pointArray[0].set_X((int) (size.get_Width() - TIPMARGIN));
                }
                if (pointArray[1].get_X() < TIPMARGIN)
                {
                    pointArray[1].set_X(TIPMARGIN);
                }
                if (pointArray[1].get_X() > (size.get_Width() - TIPMARGIN))
                {
                    pointArray[1].set_X((int) (size.get_Width() - TIPMARGIN));
                }
                if (pointArray[2].get_X() < TIPMARGIN)
                {
                    pointArray[2].set_X(TIPMARGIN);
                }
                if (pointArray[2].get_X() > (size.get_Width() - TIPMARGIN))
                {
                    pointArray[2].set_X((int) (size.get_Width() - TIPMARGIN));
                }
                if (!base.get_DesignMode())
                {
                    System.Drawing.Point point3 = new System.Drawing.Point((int) (this.anchorPoint.get_X() - pointArray[1].get_X()), (int) (this.anchorPoint.get_Y() - pointArray[1].get_Y()));
                    System.Drawing.Rectangle workingArea = System.Windows.Forms.Screen.FromPoint(this.anchorPoint).WorkingArea;
                    int num = 0;
                    int num2 = 0;
                    if (point3.get_X() < workingArea.get_X())
                    {
                        num = (int) (workingArea.get_Left() - point3.get_X());
                    }
                    else if ((point3.get_X() + size.get_Width()) >= workingArea.get_Right())
                    {
                        num = (int) (workingArea.get_Right() - (point3.get_X() + size.get_Width()));
                    }
                    if ((point3.get_Y() + TIPTAIL) < workingArea.get_Top())
                    {
                        num2 = (int) (workingArea.get_Top() - (point3.get_Y() + TIPTAIL));
                    }
                    else if (((point3.get_Y() + size.get_Height()) - TIPTAIL) >= workingArea.get_Bottom())
                    {
                        num2 = (int) (workingArea.get_Bottom() - ((point3.get_Y() + size.get_Height()) - TIPTAIL));
                    }
                    pointArray[1].set_X((int) (pointArray[1].get_X() - num));
                    point3.set_X((int) (point3.get_X() + num));
                    point3.set_Y((int) (point3.get_Y() + num2));
                    int introduced15 = point3.get_X();
                    int introduced16 = size.get_Width();
                    base.SetBounds(introduced15, point3.get_Y(), introduced16, size.get_Height());
                }
                if (this.path != null)
                {
                    this.path.Dispose();
                }
                this.path = new System.Drawing.Drawing2D.GraphicsPath(System.Drawing.Drawing2D.FillMode.Alternate);
                int num3 = (int) (TIPMARGIN * 3);
                int num4 = (int) (num3 * 2);
                int num5 = (int) (empty.get_X() + num3);
                int num6 = (int) (point2.get_X() - num3);
                int num7 = (int) (empty.get_Y() + num3);
                int num8 = (int) (point2.get_Y() - num3);
                this.path.StartFigure();
                if ((this.Quadrant == BallonQuadrant.TopLeft) || (this.Quadrant == BallonQuadrant.TopRight))
                {
                    this.path.AddArc(empty.get_X(), (int) (num8 - num3), num4, num4, 90f, 90f);
                    this.path.AddLine(empty.get_X(), num8, empty.get_X(), num7);
                    int introduced17 = empty.get_X();
                    this.path.AddArc(introduced17, empty.get_Y(), num4, num4, 180f, 90f);
                    this.path.AddLine(num5, empty.get_Y(), pointArray[0].get_X(), empty.get_Y());
                    this.path.AddLines(pointArray);
                    this.path.AddLine(pointArray[2].get_X(), empty.get_Y(), num6, empty.get_Y());
                    this.path.AddArc((int) (num6 - num3), empty.get_Y(), num4, num4, 270f, 90f);
                    this.path.AddLine(point2.get_X(), num7, point2.get_X(), num8);
                    this.path.AddArc((int) (num6 - num3), (int) (num8 - num3), num4, num4, 0f, 90f);
                    this.path.AddLine(num6, point2.get_Y(), num5, point2.get_Y());
                }
                else
                {
                    this.path.AddLine(num5, empty.get_Y(), num6, empty.get_Y());
                    this.path.AddArc((int) (num6 - num3), empty.get_Y(), num4, num4, 270f, 90f);
                    this.path.AddLine(point2.get_X(), num7, point2.get_X(), num8);
                    this.path.AddArc((int) (num6 - num3), (int) (num8 - num3), num4, num4, 0f, 90f);
                    this.path.AddLine(num6, point2.get_Y(), pointArray[0].get_X(), point2.get_Y());
                    this.path.AddLines(pointArray);
                    this.path.AddLine(pointArray[2].get_X(), point2.get_Y(), num5, point2.get_Y());
                    this.path.AddArc(empty.get_X(), (int) (num8 - num3), num4, num4, 90f, 90f);
                    this.path.AddLine(empty.get_X(), num8, empty.get_X(), num7);
                    int introduced18 = empty.get_X();
                    this.path.AddArc(introduced18, empty.get_Y(), num4, num4, 180f, 90f);
                }
                this.path.CloseFigure();
                base.set_Region(new System.Drawing.Region(this.path));
            }
        }