Offset() public method

Translates this by the specified amount.
public Offset ( Point p ) : void
p Point
return void
        public override void Redraw(Graphics g)
        {
            if (txt == null)
                return;

            Point position = txt.GetPositionFromCharIndex(startIndex);
            Point centerPos = new Point(position.X, (int)(position.Y + (txt.Font.Size * 0.75)));
            float thirdFontSize = txt.Font.Size / 3;

            centerPos.Offset((int)thirdFontSize, 0);
            centerPos.Offset((int)thirdFontSize, 0);
            Brush brush = new SolidBrush(BrushColor);
            Pen pen = new Pen(brush);

            //the horizontal line
            Point lineEnd = new Point((int)(centerPos.X + thirdFontSize), centerPos.Y);
            g.DrawLine(pen, centerPos, lineEnd);

            //the verical line from top
            PointF verticalLineStart = new PointF(lineEnd.X, (lineEnd.Y - thirdFontSize));
            g.DrawLine(pen, verticalLineStart, lineEnd);

            //the arrow on the left pointing left
            PointF topArrowHead = new PointF(centerPos.X, (centerPos.Y - thirdFontSize));
            PointF bottomArrowHead = new PointF(centerPos.X, (centerPos.Y + thirdFontSize));
            PointF middleArrowHead = new PointF(centerPos.X - thirdFontSize, centerPos.Y);

            g.DrawPolygon(pen, new PointF[] { topArrowHead, bottomArrowHead, middleArrowHead });
            g.FillPolygon(brush, new PointF[] { topArrowHead, bottomArrowHead, middleArrowHead });
        }
Example #2
0
        public Outline(Point center)
        {
            var sideLength = 50;
            center.Offset(-sideLength / 2, -sideLength/2);
            nodes.Add(PanAndZoom.fromLocalToGlobal(center));

            center.Offset(0, sideLength);
            nodes.Add(PanAndZoom.fromLocalToGlobal(center));

            center.Offset(sideLength, 0);
            nodes.Add(PanAndZoom.fromLocalToGlobal(center));

            center.Offset(0, -sideLength);
            nodes.Add(PanAndZoom.fromLocalToGlobal(center));

            //parent.Controls.Add(this);
            //BringToFront();

            foreach(var n in nodes){
                var marker = new VertexMarker();
                marker.setPosition(n);
                marker.MouseClick += new MouseEventHandler(deleteMarker);
                markers.Add(marker);

                marker.BringToFront();

                var c = new CreaterMarker();
                c.MouseClick += new MouseEventHandler(createMarker);
                //parent.Controls.Add(c);
                creaters.Add(c);
            }
            paintEvent = new PaintEventHandler(paint);
        }
Example #3
0
        public override void Draw(Graphics gr, Point position, Range range)
        {
            string text = range.Text;
            int iChar = range.Start.iChar;

            while (text != "")
            {
                bool replaced = false;
                foreach (var pair in ImagesByText)
                {
                    if (text.StartsWith(pair.Key))
                    {
                        float k = (float)(pair.Key.Length * range.tb.CharWidth) / pair.Value.Width;
                        if (k > 1)
                            k = 1f;
                        //
                        text = text.Substring(pair.Key.Length);
                        RectangleF rect = new RectangleF(position.X + range.tb.CharWidth * pair.Key.Length / 2 - pair.Value.Width * k / 2, position.Y, pair.Value.Width * k, pair.Value.Height * k);
                        gr.DrawImage(pair.Value, rect);
                        position.Offset(range.tb.CharWidth * pair.Key.Length, 0);
                        replaced = true;
                        iChar += pair.Key.Length;
                        break;
                    }
                }
                if (!replaced && text.Length > 0)
                {
                    Range r = new Range(range.tb, iChar, range.Start.iLine, iChar + 1, range.Start.iLine);
                    base.Draw(gr, position, r);
                    position.Offset(range.tb.CharWidth, 0);
                    text = text.Substring(1);
                }
            }
        }
Example #4
0
        public override void Process()
        {
            DrawLocation = new Point((CurrentLocation.X - User.Movement.X + MapControl.OffSetX) * MapControl.CellWidth, (CurrentLocation.Y - User.Movement.Y + MapControl.OffSetY) * MapControl.CellHeight);
            DrawLocation.Offset((MapControl.CellWidth - Size.Width) / 2, (MapControl.CellHeight - Size.Height) / 2);
            DrawLocation.Offset(User.OffSetMove);
            DrawLocation.Offset(GlobalDisplayLocationOffset);
            FinalDrawLocation = DrawLocation;

            DisplayRectangle = new Rectangle(DrawLocation, Size);
        }
 public static Point ToAbsolute(Anchor anchor, Point point, Rectangle rect)
 {
     switch (anchor)
     {
         case Anchor.TopLeft:
             point.Offset(rect.Left, rect.Top);
             break;
         case Anchor.TopCenter:
             point.Offset(rect.Left + (rect.Width / 2), rect.Top);
             break;
         case Anchor.TopRight:
             point.Offset(rect.Right, rect.Top);
             break;
         case Anchor.MiddleLeft:
             point.Offset(rect.Left, rect.Top + (rect.Height / 2));
             break;
         case Anchor.MiddleCenter:
             point.Offset(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2));
             break;
         case Anchor.MiddleRight:
             point.Offset(rect.Right, rect.Top + (rect.Height / 2));
             break;
         case Anchor.BottomLeft:
             point.Offset(rect.Left, rect.Bottom);
             break;
         case Anchor.BottomCenter:
             point.Offset(rect.Left + (rect.Width / 2), rect.Bottom);
             break;
         case Anchor.BottomRight:
             point.Offset(rect.Right, rect.Bottom);
             break;
     }
     return point;
 }
Example #6
0
File: Utils.cs Project: 0anion0/IBN
        public static Point GetAbsolute(Point point, Control sourceControl, Control rootControl)
        {
            Point tempPoint = new Point();
            for (Control iterator = sourceControl; iterator != rootControl; iterator = iterator.Parent)
            {
                tempPoint.Offset(iterator.Left, iterator.Top);
            }

            tempPoint.Offset(point.X, point.Y);
            return tempPoint;
        }
Example #7
0
		private unsafe void BlitVoxelToSurface(DrawingSurface ds, DrawingSurface vxl_ds, GameObject obj, DrawProperties props) {
			Point d = new Point(obj.Tile.Dx * TileWidth / 2, (obj.Tile.Dy - obj.Tile.Z) * TileHeight / 2);
			d.Offset(props.GetOffset(obj));
			d.Offset(-vxl_ds.BitmapData.Width / 2, -vxl_ds.BitmapData.Height / 2);

			// rows inverted!
			var w_low = (byte*)ds.BitmapData.Scan0;
			byte* w_high = w_low + ds.BitmapData.Stride * ds.BitmapData.Height;
			var zBuffer = ds.GetZBuffer();
			var shadowBufVxl = vxl_ds.GetShadows();
			var shadowBuf = ds.GetShadows();
			// int rowsTouched = 0;

			// short firstRowTouched = short.MaxValue;
			for (int y = 0; y < vxl_ds.Height; y++) {
				byte* src_row = (byte*)vxl_ds.BitmapData.Scan0 + vxl_ds.BitmapData.Stride * (vxl_ds.Height - y - 1);
				byte* dst_row = ((byte*)ds.BitmapData.Scan0 + (d.Y + y) * ds.BitmapData.Stride + d.X * 3);
				int zIdx = (d.Y + y) * ds.Width + d.X;
				if (dst_row < w_low || dst_row >= w_high) continue;

				for (int x = 0; x < vxl_ds.Width; x++) {
					// only non-transparent pixels
					if (*(src_row + x * 4 + 3) > 0) {
						*(dst_row + x * 3) = *(src_row + x * 4);
						*(dst_row + x * 3 + 1) = *(src_row + x * 4 + 1);
						*(dst_row + x * 3 + 2) = *(src_row + x * 4 + 2);

						// if (y < firstRowTouched)
						// 	firstRowTouched = (short)y;

						short zBufVal = (short)((obj.Tile.Rx + obj.Tile.Ry + obj.Tile.Z) * TileHeight / 2);
						if (zBufVal >= zBuffer[zIdx])
							zBuffer[zIdx] = zBufVal;
					}
					// or shadows
					else if (shadowBufVxl[x + y * vxl_ds.Height]) {
						int shadIdx = (d.Y + y) * ds.Width + d.X + x;
						if (!shadowBuf[shadIdx]) {
							*(dst_row + x * 3) /= 2;
							*(dst_row + x * 3 + 1) /= 2;
							*(dst_row + x * 3 + 2) /= 2;
							shadowBuf[shadIdx] = true;
						}
					}
					zIdx++;
				}
			}
		}
Example #8
0
 private void BaseTableForm_MouseWheel(object sender, MouseEventArgs e)
 {
     Point mousePoint = new Point(e.X, e.Y);
     mousePoint.Offset(this.Location.X, this.Location.Y);
     if (panelContent.RectangleToScreen(panelContent.DisplayRectangle).Contains(mousePoint))
         panelContent.AutoScrollPosition = new Point(0, panelContent.VerticalScroll.Value - e.Delta);
 }
Example #9
0
        public void DisplayAtCursor(Point position)
        {
            // [experimental]
            // a fix to stop the tooltip flickering
            // on some machines
            position.Offset(1, 1);

            Rectangle rect = this.Bounds;
            rect.X = position.X + Cursor.HotSpot.X;
            rect.Y = position.Y + Cursor.HotSpot.Y;

            if (Screen.PrimaryScreen.WorkingArea.Contains(rect) == false)
            {
                if ((rect.X + rect.Width) > Screen.PrimaryScreen.WorkingArea.Width)
                    rect.X -= Cursor.HotSpot.X + rect.Width;

                if ((rect.Y + rect.Height) > Screen.PrimaryScreen.WorkingArea.Height)
                    rect.Y -= Cursor.HotSpot.Y + rect.Height;

                if (rect.Y < 0)
                    rect.Y = Screen.PrimaryScreen.WorkingArea.Height - rect.Height;

                if (rect.X < 0)
                    rect.X = Screen.PrimaryScreen.WorkingArea.Width - rect.Width;
            }

            this.Location = rect.Location;

            if (this.Visible == false)
                this.Visible = true;
        }
        private void AddCardDiscardPile(MouseEventArgs e, Panel sourcePanel, DiscardPile discardPile, ref Point lastLocation, MouseEventHandler methodToHandle)
        {
            if (e.Button == MouseButtons.Left)
            {
            if (wPile.getCount() > 0)
            {
                Card card = wPile.getLastCardInPile();
                discardPile.AddToPile(card);
                if (discardPile.getCount() == 1)
                    sourcePanel.BackgroundImage = card.getCardImage();
                else
                {
                    Panel p = new Panel();
                    p.BackgroundImage = card.getCardImage();
                    p.Height = sourcePanel.Height;
                    p.Width = sourcePanel.Width;
                    lastLocation.Offset(0, 20);
                    p.Location = lastLocation;
                    lastLocation = p.Location;
                    p.MouseDown += new System.Windows.Forms.MouseEventHandler(methodToHandle);
                    this.Controls.Add(p);
                    p.BringToFront();
                }

                //Remove card from the waste pile
                wPile.removeCard(card);
                wastePilePicture.BackgroundImage = null;
            }
            }
        }
Example #11
0
File: Form1.cs Project: daro5g/Maze
 private void Wygrana()
 {
     nrmapy++;
     
     switch (nrmapy)
     {
         case 1:
             game_board1.Image = Game.Properties.Resources.lvl1;
             StartPoint = game_board1.Location;
             StartPoint.Offset(200, 23);
             StartMouse();
             break;
         case 2:
             game_board1.Image = Game.Properties.Resources.lvl2;
             StartPoint = game_board1.Location;
             StartPoint.Offset(472, 462);
             StartMouse();
             break;
         case 3:
             game_board1.Image = Game.Properties.Resources.lvl3;
             la.Visible = true;
             hiden.Visible = true;
             StartPoint = game_board1.Location;
             StartPoint.Offset(254, 468);
             StartMouse();
             break;
             
     }
 }
Example #12
0
        public void Draw(Point displayLocation)
        {
            long timeRemaining = ExpireTime - CMain.Time;

            if (DamageLabel == null)
            {
                DamageLabel = new MirLabel
                {
                    AutoSize = true,
                    BackColour = Color.Transparent,
                    ForeColour = Colour,
                    OutLine = true,
                    OutLineColour = Color.Black,
                    Text = Text,
                    Font = new Font(Settings.FontName, 10F, FontStyle.Bold)
                };
                DamageLabel.Disposing += label_Disposing;

                MapObject.DamageLabelList.Add(DamageLabel);
            }

            displayLocation.Offset((int)(15 - (Text.Length * 3)), (int)(((int)((double)timeRemaining / Factor)) - Distance) - 75 - Offset);

            DamageLabel.Location = displayLocation;
            DamageLabel.Draw();
        }
Example #13
0
 public static void DrawString(this Graphics g, string str, Font font, Brush brush, Point center, double angle, Point pt, StringFormat stringFormat)
 {
     Point newPt = new Point(pt.X, pt.Y);
     newPt.Offset(-center.X, -center.Y);
     g.ResetTransform();
     g.TranslateTransform(g.ClipBounds.Left + center.X, g.ClipBounds.Top + center.Y);
     g.RotateTransform((float)MathHelper.Rad2Deg(angle));
     g.DrawString(str, font, brush, newPt, stringFormat);
 }
Example #14
0
		private static void ShowContextMenu(ContextMenuStrip contextMenuStrip, ActionModelNode actionModel, Point screenPoint, int minWidth, bool alignRight)
		{
			ToolStripBuilder.Clear(contextMenuStrip.Items);
			if (actionModel != null)
			{
				ToolStripBuilder.BuildMenu(contextMenuStrip.Items, actionModel.ChildNodes);
				if (alignRight)
					screenPoint.Offset(-contextMenuStrip.Width, 0);
				contextMenuStrip.Show(screenPoint);
			}
		}
 public static void Points(out Point midTop, out Point midBottom, out Point midLeft, out Point midRight, Rectangle region)
 {
     midTop = region.Location;
     midTop.Offset(region.Width / 2, 0);
     midBottom = midTop;
     midBottom.Offset(0, region.Height);
     midRight = region.Location;
     midRight.Offset(region.Width, region.Height / 2);
     midLeft = midRight;
     midLeft.Offset(-region.Width, 0);
 }
Example #16
0
 public static void DrawLine(this Graphics g, Pen pen, Point center, double angle, Point pt1, Point pt2)
 {
     Point newPt1 = new Point(pt1.X, pt1.Y);
     Point newPt2 = new Point(pt2.X, pt2.Y);
     newPt1.Offset(-center.X, -center.Y);
     newPt2.Offset(-center.X, -center.Y);
     g.ResetTransform();
     g.TranslateTransform(g.ClipBounds.Left + center.X, g.ClipBounds.Top + center.Y);
     g.RotateTransform((float)MathHelper.Rad2Deg(angle));
     g.DrawLine(pen, newPt1, newPt2);
 }
 public void DrawEmphasized(LayoutItem layoutItem)
 {
     Font font = GetFont(layoutItem.Word.Occurrences);
     Color color = GetPresudoRandomColorFromPalette(layoutItem);
     //m_Graphics.DrawString(layoutItem.Word, font, brush, layoutItem.Rectangle);
     Point point = new Point((int)layoutItem.Rectangle.X, (int)layoutItem.Rectangle.Y);
     TextRenderer.DrawText(m_Graphics, layoutItem.Word.Text, font, point, Color.LightGray);
     int offset = (int)(5 *font.Size / MaxFontSize)+1;
     point.Offset(-offset, -offset);
     TextRenderer.DrawText(m_Graphics, layoutItem.Word.Text, font, point, color);
 }
Example #18
0
        public static Point getMitadPanelVisto(Panel panel, Size sizeObjeto)
        {
            Point mitad =
                new Point(panel.HorizontalScroll.Value + panel.Width / 2,
                panel.VerticalScroll.Value + panel.Height / 2);
            //me devuelve la posicion de la mitad del panel que esta visible

            mitad.Offset(sizeObjeto.Width / -2, sizeObjeto.Height / -2);
            //a eso le resto la mitad del tamaño para que quede realmente "centrado"

            return mitad;
        }
Example #19
0
        /// <summary>
        /// Popups a tool tip with provided text, at the given point.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="pt">The pt.</param>
        public void Show(string text, Point pt)
        {
            if (text == m_text)
                return;

            pt.Offset(0, 24);
            m_point = pt;

            Hide(m_owner);
            m_text = text;
            m_initialDelayTimer.Start();
        }
Example #20
0
		public static Rectangle GetBounds(GameObject obj, ShpFile shp, DrawProperties props) {
			shp.Initialize();
			int frameIndex = DecideFrameIndex(props.FrameDecider(obj), shp.NumImages);
			var offset = new Point(-shp.Width / 2, -shp.Height / 2);
			Size size = new Size(0, 0);
			var img = shp.GetImage(frameIndex);
			if (img != null) {
				offset.Offset(img.X, img.Y);
				size = new Size(img.Width, img.Height);
			}
			return new Rectangle(offset, size);
		}
Example #21
0
        /// <summary>
        /// Inflates balloon body and target point
        /// </summary>
        public static void InflateBalloon(ref Rectangle body, ref Point target, int deltaBody, int deltaTarget)
        {
            Point center = new Point(body.Left + body.Width / 2, body.Top + body.Height / 2);
              PolarPoint pp = new PolarPoint(center, target);

              body.Inflate(deltaBody, deltaBody);

              pp.R += deltaTarget;

              target = pp.Point;
              target.Offset(center.X, center.Y);
        }
Example #22
0
 private void AdjustLocation()
 {
     // Adjust the position relative to main form
     int dx = (mainForm.Width - this.Width) / 2;
     int dy = (mainForm.Height - this.Height) / 2;
     Point loc = new Point(mainForm.Location.X, mainForm.Location.Y);
     loc.Offset(dx, dy);
     this.Location = loc;
     if (!IsClosed)
     {
         this.Visible = true;
     }
 }
 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     Graphics G = e.Graphics;                    //获取绘图对象
     Point point1 = new Point(10, 10);           //实例化点1
     Point point2 = new Point(30, 10);           //实例化点2
     G.DrawLine(Pens.Black, point1, point2);     //绘制水平直线
     point1.Offset(0, 10);                       //点1向下移动10个像素
     point2.Offset(0, 20);                       //点2向下移动20个像素
     G.DrawLine(Pens.Black, point1, point2);     //绘制斜直线
     Point point3 = new Point(50, 10);           //实例化点3
     Size size1 = new Size(10, 10);              //实例化大小1
     Rectangle rect1 = new Rectangle(point3, size1);//实例化矩形
     G.DrawRectangle(Pens.Black, rect1);         //绘制矩形边框
     G.SmoothingMode = SmoothingMode.AntiAlias;  //开启抗锯齿功能
     point1.Offset(0, 10);                       //点1向下移动10个像素
     point2.Offset(0, 10);                       //点1向下移动10个像素
     G.DrawLine(Pens.Black, point1, point2);     //绘制斜直线
     rect1.Offset(0, 50);                        //矩形向下移动50个像素
     rect1.Inflate(20, 20);                      //放大矩形
     Color color1 = Color.FromArgb(100, Color.Yellow);//获取ARGB颜色
     G.DrawRectangle(Pens.Black, rect1);         //绘制矩形
     rect1.Offset(50, 0);                        //矩形向右移动50个像素
     Color color2 = Color.FromArgb(255, 0, 255); //获取RGB颜色
     G.DrawPie(Pens.Black, rect1, 45, 270);      //绘制扇形
     rect1.Offset(50, 0);                        //矩形向右移动50个像素
     rect1.Inflate(10, 0);                       //矩形向左右方向各扩大10个像素
     G.DrawEllipse(Pens.Black, rect1);           //绘制椭圆
     rect1.Offset(0, 100);                        //矩形向下移动50个像素
     SolidBrush brush1 = new SolidBrush(Color.Lime);//创建画刷
     G.FillEllipse(brush1, rect1);               //填充椭圆
     rect1.Inflate(-10, 0);                       //矩形向左右方向各缩小10个像素
     rect1.Offset(-30, 0);                       //矩形向左移动50个像素
     SolidBrush brush2 = new SolidBrush(Color.FromArgb(100, 0, 0, 255));
     G.FillPie(brush2, rect1, 45, 270);          //填充扇形
     rect1.Offset(-30, 0);                       //矩形向左移动50个像素
     SolidBrush brush3 = new SolidBrush(Color.FromArgb(100, 255, 0, 0));
     G.FillRectangle(brush3, rect1);             //填充矩形
 }
Example #24
0
        public override void OnRender(Graphics g)
        {
            System.Drawing.Point p1 = new System.Drawing.Point(LocalPosition.X, LocalPosition.Y);
             p1.Offset(0, -10);
             System.Drawing.Point p2 = new System.Drawing.Point(LocalPosition.X, LocalPosition.Y);
             p2.Offset(0, 10);

             System.Drawing.Point p3 = new System.Drawing.Point(LocalPosition.X, LocalPosition.Y);
             p3.Offset(-10, 0);
             System.Drawing.Point p4 = new System.Drawing.Point(LocalPosition.X, LocalPosition.Y);
             p4.Offset(10, 0);

             g.DrawLine(Pen, p1.X, p1.Y, p2.X, p2.Y);
             g.DrawLine(Pen, p3.X, p3.Y, p4.X, p4.Y);
        }
Example #25
0
 private void CollectTracePanel(Control host, Point offset, ref List<TracePanel> tracePanels)
 {
     if (host == null)
         return;
     if (tracePanels == null)
         tracePanels = new List<TracePanel>();
     foreach (Control child in host.Controls.Cast<Control>().Where(child => child.GetType() == typeof (TracePanel)))
         AddTracePanel((TracePanel)child, offset);
     foreach (Control child in host.Controls.Cast<Control>().Where(child => child.GetType() != typeof (TracePanel)))
     {
         Point newOffset = new Point(offset.X,offset.Y);
         newOffset.Offset(child.Location);
         CollectTracePanel(child, newOffset, ref tracePanels);
     }
 }
Example #26
0
        public void DrawCurrentMeasure(Map map, Point location)
        {
            HatchBrush brushMeasure = new HatchBrush(HatchStyle.LightDownwardDiagonal, Color.Silver, Color.Transparent);
            HatchBrush brushPlayedTime = new HatchBrush(HatchStyle.Weave, Color.Purple, Color.Transparent);

            location.Offset(new Point(0, (map.Size+2)*sampleSize));
            for (int layer = 0; layer < map.LayerCells.Keys.Count; layer++)
            {
                //--- Nombre de cases sur la couche
                int numberOfCellOnLayer = layer * 8;

                if (numberOfCellOnLayer == 0)
                    numberOfCellOnLayer = 1;
                //---

                //--- Beat  de la couche
                int layerBeat = r.Beat % numberOfCellOnLayer;
                //---

                //---
                int minPlayedCell = (layerBeat / 4) * 4;
                //---

                for (int i = 0; i < map.LayerCells[layer].Count; i++)
                {
                    Cell cell = map.LayerCells[layer][i];

                    if (cell.IsInPlayedTime)
                    {
                        if (!cell.IsEmpty)
                        {
                            gImgMap.FillRectangle(new SolidBrush(cell.Sample.SampleModel.Color),
                                location.X + (cell.NumberOnLayer - minPlayedCell) * sampleSize,
                                location.Y + layer * sampleSize,
                                sampleSize, sampleSize);
                        }

                        if (cell.IsOnMeasure)
                            gImgMap.FillRectangle(brushMeasure, location.X + (cell.NumberOnLayer - minPlayedCell) * sampleSize, location.Y + layer * sampleSize, sampleSize, sampleSize);

                        gImgMap.FillRectangle(brushPlayedTime, location.X + (cell.NumberOnLayer - minPlayedCell) * sampleSize, location.Y + layer * sampleSize, sampleSize, sampleSize);

                        if (cell.IsEmitting)
                            gImgMap.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.Red)), location.X + (cell.NumberOnLayer - minPlayedCell) * sampleSize + sampleSize / 4, location.Y + layer * sampleSize + sampleSize / 4, sampleSize / 2, sampleSize / 2);
                    }
                }
            }
        }
Example #27
0
        public void SetPositionNextToPointer(params Control[] controls)
        {
            //position form
            if (reading.UsePrevPopupPos)
                this.Location = PopupPos;
            else
            {
                PopupPos = reading.DblClickPos;
                PopupPos.Offset(0, (int)reading.LineH);

                this.Location = PopupPos;
            }

            //resize rtbDef & window
            if (controls.Contains(rtbDef))
            {
                resizeRtbDef();
                this.Height = rtbDef.Height + 6 + buttAdd.Height;

                if (this.Top + this.Height > Screen.PrimaryScreen.Bounds.Height)
                    this.Top = Math.Max(0, PopupPos.Y - (int)reading.LineH - this.Height);

                int totalW = 0;
                foreach (Control control in controls)
                    totalW += control.Width; //sum of controls' width
                if (controls.Length > 1)
                    totalW += 6 * (controls.Length - 1); //sum of width of gaps between controls

                if (this.Left + totalW > Screen.PrimaryScreen.Bounds.Width)
                    this.Left = Math.Max(0, Screen.PrimaryScreen.Bounds.Width - totalW);
            }

            //position controls
            if (controls.Length > 0)
            {
                controls[0].Location = new Point(0, 0);

                if (controls.Length > 1)
                    for (int i = 1; i < controls.Length; i++)
                    {
                        controls[i].Left = controls[i - 1].Left + controls[i - 1].Width + 6;
                        controls[i].Top = controls[i - 1].Top + controls[i - 1].Height - controls[i].Height;
                    }
            }

            //set Visible values
            HideAllControlsExcept(controls);
        }
Example #28
0
        public void OnMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            float scaleFactor = (float)container.ZoomFactor / 100;
            foreach (MovableDrawing drawing in drawingsToMove) {
                Point mouseDownScaledLocation = new Point((int)((double)e.Location.X / scaleFactor),
                                                    (int)((double)e.Location.Y / scaleFactor));
                mouseDownScaledLocation.Offset(container.HScrollBar.Value, container.VScrollBar.Value);

                if (drawing.Bounds.Contains(mouseDownScaledLocation)) {
                    startMovePoint = new Point(e.X, e.Y);
                    actionStarted = true;
                }

                drawing.InitialLocation = drawing.Drawing.Location;
            }
        }
Example #29
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            using (Image img = Resources.Connection_Manager)
            {
                g.DrawImage(img, 8, 8, 48, 48);
            }

            Point basePoint = new Point(48 + 16, 10);
            g.DrawString(CommanderBeta, new Font("Verdana", 21), Brushes.Black, basePoint.X, basePoint.Y);
            basePoint.Offset(-1, -1);
            g.DrawString(CommanderBeta, new Font("Verdana", 21), Brushes.White, basePoint.X, basePoint.Y);

            Font font = new Font("Verdana", 10);
            basePoint.Offset(20, 36);
            g.DrawString(" - \"For a better Windows experience\" ", new Font(font, FontStyle.Italic), Brushes.Black, basePoint.X, basePoint.Y);
            basePoint.Offset(-1, -1);
            g.DrawString(" - \"For a better Windows experience\" ", new Font(font, FontStyle.Italic), Brushes.White, basePoint.X, basePoint.Y);

            font = new Font("Consolas", 11);
            basePoint.Offset(-64, 50);
            g.DrawString(prompt + "commander -info", font, Brushes.Black, basePoint);
            basePoint.Offset(-1, -1);
            g.DrawString(prompt + "commander -info", font, Brushes.White, basePoint);

            basePoint.Offset(0, 24);
            g.DrawString("    Developed by: ", font, Brushes.Black, basePoint);
            basePoint.Offset(-1, -1);
            g.DrawString("    Developed by: ", font, Brushes.White, basePoint);

            basePoint.Offset(0, 24);
            g.DrawString("        Marcus Grenängen ([email protected])", font, Brushes.Black, basePoint);
            basePoint.Offset(-1, -1);
            g.DrawString("        Marcus Grenängen ([email protected])", font, Brushes.White, basePoint);
        }
Example #30
0
        public CaseClass(int x, int y)  // 建構子 初始化
        {
            myID = "Case" + id.ToString();
            coordinate = new Point(x, y);
            size = new Size(120, 70);
            this.x = x;
            this.y = y;
            coordinate.Offset(-(size.Width / 2), -(size.Height / 2));  // 橋好 圖片置中之後的 左上角座標

            Connect[0] = new Point(x - 3, y - (size.Height / 2) - 3);  // 上面點的位置
            Connect[1] = new Point(x - 3, y + (size.Height / 2) - 3);  // 下面點的位置
            Connect[2] = new Point(x - (size.Width / 2) - 3, y - 3);  // 左邊點的位置
            Connect[3] = new Point(x + (size.Width / 2) - 3, y - 3);  // 右邊點的位置
            
            Set_MyId(id);
            Set_Vertex();
        }