public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); drawArea.PasteTemplateObject(template); CommandPaste command = new CommandPaste(drawArea.TheLayers); drawArea.AddCommandToHistory(command); }
void Example3() { string imagePath = @"Assets\ODFSample\Examples\example3.png"; TextDocument document = new TextDocument(); document.New(); //Create standard paragraph Paragraph paragraphOuter = ParagraphBuilder.CreateStandardTextParagraph(document); //Create the frame with graphic Frame frame = new Frame(document, "frame1", "graphic1", imagePath); //Create a Draw Area Rectangle DrawAreaRectangle drawAreaRec = new DrawAreaRectangle( document, "0cm", "0cm", "1.5cm", "2.5cm", null); drawAreaRec.Href = "http://OpenDocument4all.com"; //Create a Draw Area Circle DrawAreaCircle drawAreaCircle = new DrawAreaCircle( document, "4cm", "4cm", "1.5cm", null); drawAreaCircle.Href = "http://AODL.OpenDocument4all.com"; DrawArea[] drawArea = new DrawArea[2] { drawAreaRec, drawAreaCircle }; //Create a Image Map ImageMap imageMap = new ImageMap(document, drawArea); //Add Image Map to the frame frame.Content.Add(imageMap); //Add frame to paragraph paragraphOuter.Content.Add(frame); //Add paragraph to document document.Content.Add(paragraphOuter); //Save the document document.SaveTo(@"example3_simpleImageMap.odt"); }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); DrawLine o =new DrawLine(p.X, p.Y, p.X + 1, p.Y + 1, System.Drawing.Color.Lime, 10); o.needcircle = true; AddNewObject(drawArea,o ); }
/// <summary> /// Mouse move - resize new polygon /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { drawArea.Cursor = Cursor; if (e.Button != MouseButtons.Left) return; if (newPolygon == null) return; // precaution Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y)); int distance = (e.X - lastX) * (e.X - lastX) + (e.Y - lastY) * (e.Y - lastY); if (distance < minDistance) { // Distance between last two points is less than minimum - // move last point newPolygon.MoveHandleTo(point, newPolygon.HandleCount); } else { // Add new point newPolygon.AddPoint(point); lastX = e.X; lastY = e.Y; } drawArea.Refresh(); }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); if (drawArea.CurrentPen == null) AddNewObject(drawArea, new DrawEllipse(p.X, p.Y, 1, 1, drawArea.LineColor, drawArea.FillColor, drawArea.DrawFilled, drawArea.LineWidth)); else AddNewObject(drawArea, new DrawEllipse(p.X, p.Y, 1, 1, drawArea.PenType, drawArea.FillColor, drawArea.DrawFilled)); }
/// <summary> /// Left nouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { // Create new polygon, add it to the list // and keep reference to it newPolygon = new DrawPolygon(e.X, e.Y, e.X + 1, e.Y + 1); AddNewObject(drawArea, newPolygon); lastX = e.X; lastY = e.Y; }
/// <summary> /// Left mouse is released. /// New object is created and resized. /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { drawArea.GraphicsList[0].Normalize(); drawArea.AddCommandToHistory(new CommandAdd(drawArea.GraphicsList[0])); drawArea.ActiveTool = DrawArea.DrawToolType.Pointer; drawArea.Capture = false; drawArea.Refresh(); }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); DrawText drawText = new DrawText(p,drawArea.LineColor,drawArea.BackColor); if (drawText.ShowPropertiesDialog()) { AddNewObject(drawArea, new DrawText(p, drawText.NowProperties)); drawArea.ActiveTool = DrawToolType.Pointer; } }
/// <summary> /// Left mouse is released. /// New object is created and resized. /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { int al = drawArea.TheLayers.ActiveLayerIndex; if (drawArea.TheLayers[al].Graphics.Count > 0) drawArea.TheLayers[al].Graphics[0].Normalize(); drawArea.AddCommandToHistory(new CommandAdd(drawArea.TheLayers[al].Graphics[0])); drawArea.ActiveTool = DrawToolType.Pointer; drawArea.Capture = false; drawArea.Refresh(); }
public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { drawArea.Cursor = Cursor; if ( e.Button == MouseButtons.Left ) { Point point = new Point(e.X, e.Y); drawArea.GraphicsList[0].MoveHandleTo(point, 2); drawArea.Refresh(); } }
public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { drawArea.Cursor = Cursor; int al = drawArea.TheLayers.ActiveLayerIndex; if (e.Button == MouseButtons.Left) { Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y)); drawArea.TheLayers[al].Graphics[0].MoveHandleTo(point, 5); drawArea.Refresh(); } }
/// <summary> /// Add new object to draw area. /// Function is called when user left-clicks draw area, /// and one of ToolObject-derived tools is active. /// </summary> /// <param name="drawArea"></param> /// <param name="o"></param> protected void AddNewObject(DrawArea drawArea, DrawObject o) { drawArea.GraphicsList.UnselectAll(); o.Selected = true; drawArea.GraphicsList.Add(o); drawArea.Capture = true; drawArea.Refresh(); drawArea.SetDirty(); }
private static void DrawBlockLineSeparated(float[] data, int lastFrameIndex, int windowEnd, DrawArea scale, Color color) { if (lastFrameIndex > windowEnd) { DrawBlockLine(data, windowEnd, lastFrameIndex, scale, color); } else { DrawBlockLine(data, 0, lastFrameIndex, scale, color); DrawBlockLine(data, windowEnd, MyProfiler.MAX_FRAMES - 1, scale, color); } }
public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "ѡ��һ�������ͼƬ"; ofd.Filter = "ͼƬ�ļ�(*.jpg,*.gif,*.bmp)|*.jpg;*.gif;*.bmp"; ofd.InitialDirectory = Environment.SpecialFolder.MyPictures.ToString(); int al = drawArea.TheLayers.ActiveLayerIndex; if (ofd.ShowDialog() == DialogResult.OK) { Bitmap d = new Bitmap(ofd.FileName); ((DrawImage)drawArea.TheLayers[al].Graphics[0]).image = (Bitmap)(d.Clone()); ((DrawImage)drawArea.TheLayers[al].Graphics[0]).ResizeImage(((DrawImage)drawArea.TheLayers[al].Graphics[0]).rectangle.Width, ((DrawImage)drawArea.TheLayers[al].Graphics[0]).rectangle.Height); } ofd.Dispose(); base.OnMouseUp(drawArea, e); }
/// <summary> /// Left nouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { // Create new polygon, add it to the list // and keep reference to it Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); if (drawArea.PenType == DrawingPens.PenType.Generic) newPolygon = new DrawPolygon(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.LineColor, drawArea.LineWidth); else newPolygon = new DrawPolygon(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.PenType); // Set the minimum distance variable according to current zoom level. minDistance = Convert.ToInt32((15 * drawArea.Zoom) * (15 * drawArea.Zoom)); AddNewObject(drawArea, newPolygon); lastX = e.X; lastY = e.Y; }
private static void DrawBlockLine(float[] data, int start, int end, DrawArea area, Color color) { Vector3 v0 = Vector3.Zero; Vector3 v1 = Vector3.Zero; for (int i = start + 1; i <= end; i++) { v0.X = -1.0f + area.x_start + area.x_scale * (i - 1) / 512.0f; v0.Y = area.y_start + data[i - 1] * area.y_scale * area.y_inv_range; v0.Z = 0; v1.X = -1.0f + area.x_start + area.x_scale * i / 512.0f; v1.Y = area.y_start + data[i] * area.y_scale * area.y_inv_range; v1.Z = 0; if (v0.Y - area.y_start > 1e-3f || v1.Y - area.y_start > 1e-3f) m_lineBatch.DrawOnScreenLine(v0, v1, color); } }
//public tooltipForm tpform = new tooltipForm(); public override void OnMouseDoubleClick(DrawArea drawArea, MouseEventArgs e) { commandChangeState = null; wasMove = false; selectMode = SelectionMode.None; Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y)); // Test for resizing (only if control is selected, cursor is on the handle) int al = drawArea.TheLayers.ActiveLayerIndex; int n = drawArea.TheLayers[al].Graphics.SelectionCount; // Test for move (cursor is on the object) if (selectMode == SelectionMode.None) { int n1 = drawArea.TheLayers[al].Graphics.Count; DrawObject o = null; for (int i = 0; i < n1; i++) { if (drawArea.TheLayers[al].Graphics[i].HitTest(point) == 0) { o = drawArea.TheLayers[al].Graphics[i]; break; } } if (o != null) { //if (drawArea.IsPainting) //{ // o.editProperties(); //} //else //{ // o.showProperties(); //} o.ShowPropertiesDialog(); drawArea.Refresh(); } } }
/// <summary> /// Add new object to draw area. /// Function is called when user left-clicks draw area, /// and one of ToolObject-derived tools is active. /// </summary> /// <param name="drawArea"></param> /// <param name="o"></param> protected void AddNewObject(DrawArea drawArea, DrawObject o) { int al = drawArea.TheLayers.ActiveLayerIndex; drawArea.TheLayers[al].Graphics.UnselectAll(); o.Selected = true; o.Dirty = true; int objectID = 0; // Set the object id now for (int i = 0; i < drawArea.TheLayers.Count; i++) { objectID = +drawArea.TheLayers[i].Graphics.Count; } objectID++; o.ID = objectID; drawArea.TheLayers[al].Graphics.Add(o); drawArea.Capture = true; drawArea.Refresh(); }
public AerialView(DrawArea.DrawArea vcontrol,ItopVectorControl tlVector) { this.components = null; tl1=tlVector; this.vectorControl = vcontrol; this.pageSetting = vcontrol.PageSettings; this.pageSetupdlg = new PageSetupDialog(); this.pageSetupdlg.PageSettings = this.pageSetting; this.margin = 0; this.printdoc = new PrintDocument(); this.pos = Point.Empty; this.scalex = 1f; this.scaley = 1f; this.startPoint = Point.Empty; this.oriPoint = Point.Empty; this.InitializeComponent(); this.printdoc.PrintPage += new PrintPageEventHandler(this.printdoc_PrintPage); this.label8.Cursor = SpecialCursors.handCurosr; this.CalculateScale(); }
/// <summary> /// Left mouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { commandChangeState = null; wasMove = false; selectMode = SelectionMode.None; Point point = new Point(e.X, e.Y); // Test for resizing (only if control is selected, cursor is on the handle) foreach (DrawObject o in drawArea.GraphicsList.Selection) { int handleNumber = o.HitTest(point); if (handleNumber > 0) { selectMode = SelectionMode.Size; // keep resized object in class member resizedObject = o; resizedObjectHandle = handleNumber; // Since we want to resize only one object, unselect all other objects drawArea.GraphicsList.UnselectAll(); o.Selected = true; commandChangeState = new CommandChangeState(drawArea.GraphicsList); break; } } // Test for move (cursor is on the object) if ( selectMode == SelectionMode.None ) { int n1 = drawArea.GraphicsList.Count; DrawObject o = null; for ( int i = 0; i < n1; i++ ) { if ( drawArea.GraphicsList[i].HitTest(point) == 0 ) { o = drawArea.GraphicsList[i]; break; } } if ( o != null ) { selectMode = SelectionMode.Move; // Unselect all if Ctrl is not pressed and clicked object is not selected yet if ( ( Control.ModifierKeys & Keys.Control ) == 0 && !o.Selected ) drawArea.GraphicsList.UnselectAll(); // Select clicked object o.Selected = true; commandChangeState = new CommandChangeState(drawArea.GraphicsList); drawArea.Cursor = Cursors.SizeAll; } } // Net selection if ( selectMode == SelectionMode.None ) { // click on background if ( ( Control.ModifierKeys & Keys.Control ) == 0 ) drawArea.GraphicsList.UnselectAll(); selectMode = SelectionMode.NetSelection; } lastPoint.X = e.X; lastPoint.Y = e.Y; startPoint.X = e.X; startPoint.Y = e.Y; drawArea.Capture = true; drawArea.Refresh(); if ( selectMode == SelectionMode.NetSelection ) { // Draw selection rectangle in initial position ControlPaint.DrawReversibleFrame( drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint)), Color.Black, FrameStyle.Dashed); } }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { AddNewObject(drawArea, new DrawLine(e.X, e.Y, e.X + 1, e.Y + 1)); }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { AddNewObject(drawArea, new AGMWallDual(e.X, e.Y, 50, 50)); }
// // Draw the track line with legend // private void trackLineLegend(XYChart c, int mouseX) { // Clear the current dynamic layer and get the DrawArea object to draw on it. DrawArea d = c.initDynamicLayer(); // The plot area object PlotArea plotArea = c.getPlotArea(); // Get the data x-value that is nearest to the mouse, and find its pixel coordinate. double xValue = c.getNearestXValue(mouseX); int xCoor = c.getXCoor(xValue); // Draw a vertical track line at the x-position d.vline(plotArea.getTopY(), plotArea.getBottomY(), xCoor, d.dashLineColor(0x000000, 0x0101)); // Container to hold the legend entries var legendEntries = new List <string>(); // Iterate through all layers to build the legend array for (int i = 0; i < c.getLayerCount(); ++i) { Layer layer = c.getLayerByZ(i); // The data array index of the x-value int xIndex = layer.getXIndexOf(xValue); // Iterate through all the data sets in the layer for (int j = 0; j < layer.getDataSetCount(); ++j) { ChartDirector.DataSet dataSet = layer.getDataSetByZ(j); // We are only interested in visible data sets with names string dataName = dataSet.getDataName(); int color = dataSet.getDataColor(); if ((!string.IsNullOrEmpty(dataName)) && (color != Chart.Transparent)) { // Build the legend entry, consist of the legend icon, name and data value. double dataValue = dataSet.getValue(xIndex); legendEntries.Add("<*block*>" + dataSet.getLegendIcon() + " " + dataName + ": " + (( dataValue == Chart.NoValue) ? "N/A" : c.formatValue(dataValue, "{value|P4}")) + "<*/*>"); // Draw a track dot for data points within the plot area int yCoor = c.getYCoor(dataSet.getPosition(xIndex), dataSet.getUseYAxis()); if ((yCoor >= plotArea.getTopY()) && (yCoor <= plotArea.getBottomY())) { d.circle(xCoor, yCoor, 4, 4, color, color); } } } } // Create the legend by joining the legend entries legendEntries.Reverse(); string legendText = "<*block,maxWidth=" + plotArea.getWidth() + "*><*block*><*font=Arial Bold*>[" + c.xAxis().getFormattedLabel(xValue, "mmm dd, yyyy") + "]<*/*> " + String.Join( " ", legendEntries) + "<*/*>"; // Display the legend on the top of the plot area TTFText t = d.text(legendText, "Arial", 8); t.draw(plotArea.getLeftX() + 5, plotArea.getTopY() - 3, 0x000000, Chart.BottomLeft); }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); AddNewObject(drawArea, new DrawImage(p.X, p.Y)); }
/// <summary> /// Draw the actual path coded in the PATfile (for a number of nodes that can be extended or reduced) /// </summary> /// <param name="drawArea">Area to draw upon</param> /// <param name="firstNode">The first node of the path to draw</param> /// <param name="firstNodeOfTail">The node that is the start of the tail (if available)</param> /// <param name="numberToDraw">The requested number of nodes to draw</param> /// <param name="drawnPathData">Data structure that we will fill with information about the path we have drawn</param> /// <returns>the number of nodes actually drawn (not taking into account nodes on a siding)</returns> public int Draw(DrawArea drawArea, TrainpathNode firstNode, TrainpathNode firstNodeOfTail, int numberToDraw, DrawnPathData drawnPathData) { //List of all nodes that need to be drawn. List<TrainpathNode> drawnNodes = new List<TrainpathNode>(); // start of path TrainpathNode currentSidingNode = null; // we start without siding path CurrentMainNode = firstNode; if (CurrentMainNode == null) { // no path, but there might still be a tail DrawTail(drawArea, colorSchemeMain, null, firstNodeOfTail); return 0; } drawnNodes.Add(CurrentMainNode); drawnPathData.AddNode(CurrentMainNode); // We want to draw only a certain number of nodes. And if there is a siding, for the siding // we also want to draw the same number of nodes from where it splits from the main track int numberDrawn = 1; while (numberDrawn < numberToDraw) { // If we have a current siding track, we draw it if (currentSidingNode != null) { //finish the complete siding path if the main path is at end of siding already int sidingNodesToDraw = (CurrentMainNode.NodeType == TrainpathNodeType.SidingEnd) ? Int32.MaxValue : 1; while (sidingNodesToDraw >= 1) { //while tracking a siding, it has its own next node TrainpathNode nextNodeOnSiding = currentSidingNode.NextSidingNode; if (nextNodeOnSiding != null) // because also this path can run off at the end { DrawPathOnVectorNode(drawArea, colorSchemeSiding, currentSidingNode, nextNodeOnSiding, currentSidingNode.NextSidingTvnIndex); drawnNodes.Add(nextNodeOnSiding); drawnPathData.AddNode(nextNodeOnSiding); //siding nodes will not be added to drawnPathData sidingNodesToDraw--; } else { sidingNodesToDraw = 0; } currentSidingNode = nextNodeOnSiding; } } // Draw the start of a siding path, so from this main line point to the next siding node. // If there is a next siding node, we also reset the currentSidingNode // but probably it is not allowed to have siding on a siding TrainpathNode nextSidingNode = CurrentMainNode.NextSidingNode; if (nextSidingNode != null) { DrawPathOnVectorNode(drawArea, colorSchemeSiding, CurrentMainNode, nextSidingNode, CurrentMainNode.NextSidingTvnIndex); drawnNodes.Add(nextSidingNode); drawnPathData.AddNode(nextSidingNode); currentSidingNode = nextSidingNode; } // From this mainline point to the next TrainpathNode nextMainNode = CurrentMainNode.NextMainNode; if (nextMainNode != null) { DrawPathOnVectorNode(drawArea, colorSchemeMain, CurrentMainNode, nextMainNode, CurrentMainNode.NextMainTvnIndex); drawnNodes.Add(nextMainNode); drawnPathData.AddNode(nextMainNode); drawnPathData.NoteAsDrawn(CurrentMainNode, nextMainNode); CurrentMainNode = nextMainNode; numberDrawn++; } else { // no more nodes, so leave the loop even if we did not draw the amount of points requested break; } } //Draw all the nodes themselves foreach (TrainpathNode node in drawnNodes) { DrawNodeItself(drawArea, node); } DrawTail(drawArea, colorSchemeMain, drawnNodes.Last(), firstNodeOfTail); return numberDrawn; }
public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { drawArea.Cursor = Cursor; }
/// <summary> /// Draw the connection between two nodes in case something is broken /// </summary> /// <param name="drawArea">Area to draw upon</param> /// <param name="colors">Colorscheme to use</param> /// <param name="currentNode">node to draw from</param> /// <param name="nextNode">node to draw to</param> private static void DrawPathBrokenNode(DrawArea drawArea, ColorScheme colors, TrainpathNode currentNode, TrainpathNode nextNode) { drawArea.DrawLine(1f, colors.BrokenPath , currentNode.Location, nextNode.Location); }
/// <summary> /// Draw the actual path coded in the PATfile, completely. /// </summary> /// <param name="drawArea">Area to draw upon</param> /// <param name="firstNode">The first node of the path to draw</param> public void Draw(DrawArea drawArea, TrainpathNode firstNode) { DrawnPathData dummyData = new DrawnPathData(); Draw(drawArea, firstNode, null, int.MaxValue, dummyData); }
/// <summary> /// Draw a path on a vector node, meaning that the vector node will be drawn (possibly partly), in path colors /// </summary> /// <param name="drawArea">Area to draw upon</param> /// <param name="colors">Colorscheme to use</param> /// <param name="currentNode">Current path node</param> /// <param name="nextNode">Next path Node</param> /// <param name="TvnIndex">The index of the track vector node that is between the two path nodes</param> /// <remarks>Note that it is not clear yet whether the direction of current to next is the same as the /// direction of the vector node</remarks> private void DrawPathOnVectorNode(DrawArea drawArea, ColorScheme colors, TrainpathNode currentNode, TrainpathNode nextNode, int TvnIndex) { if (currentNode.IsBrokenOffTrack || nextNode.IsBrokenOffTrack || (TvnIndex == -1)) { DrawPathBrokenNode(drawArea, colors, currentNode, nextNode); return; } TrackNode tn = trackDB.TrackNodes[TvnIndex]; TrainpathJunctionNode nextJunctionNode = nextNode as TrainpathJunctionNode; TrainpathVectorNode nextVectorNode = nextNode as TrainpathVectorNode; //Default situation (and most occuring) is to draw the complete vector node int tvsiStart = 0; int tvsiStop = tn.TrVectorNode.TrVectorSections.Length-1; float sectionOffsetStart = 0; float sectionOffsetStop = -1; if (currentNode is TrainpathJunctionNode) { // If both ends are junctions, just draw the full track. Otherwise: if (nextVectorNode != null) { // Draw from the current junction node to the next mid-point node if (nextVectorNode.IsEarlierOnTrackThan(currentNode)) { // trackvectornode is oriented the other way as path tvsiStart = nextVectorNode.TrackVectorSectionIndex; sectionOffsetStart = nextVectorNode.TrackSectionOffset; } else { // trackvectornode is oriented in the same way as path tvsiStop = nextVectorNode.TrackVectorSectionIndex; sectionOffsetStop = nextVectorNode.TrackSectionOffset; } } } else { TrainpathVectorNode currentVectorNode = currentNode as TrainpathVectorNode; if (nextJunctionNode != null) { // Draw from current mid-point node to next junction node if (currentVectorNode.IsEarlierOnTrackThan(nextNode)) { // trackvectornode is oriented in the same way as path tvsiStart = currentVectorNode.TrackVectorSectionIndex; sectionOffsetStart = currentVectorNode.TrackSectionOffset; } else { // trackvectornode is oriented the other way around. tvsiStop = currentVectorNode.TrackVectorSectionIndex; sectionOffsetStop = currentVectorNode.TrackSectionOffset; } } if (nextVectorNode != null) { // Draw from a current vector node to the next vector node, e.g. for multiple wait points if (currentVectorNode.IsEarlierOnTrackThan(nextVectorNode)) { // from current to next is in the direction of the vector node tvsiStart = currentVectorNode.TrackVectorSectionIndex; tvsiStop = nextVectorNode.TrackVectorSectionIndex; sectionOffsetStart = currentVectorNode.TrackSectionOffset; sectionOffsetStop = nextVectorNode.TrackSectionOffset; } else { // from next to current is in the direction of the vector node tvsiStart = nextVectorNode.TrackVectorSectionIndex; tvsiStop = currentVectorNode.TrackVectorSectionIndex; sectionOffsetStart = nextVectorNode.TrackSectionOffset; sectionOffsetStop = currentVectorNode.TrackSectionOffset; } } } DrawVectorNode(drawArea, tn, colors, tvsiStart, tvsiStop, sectionOffsetStart, sectionOffsetStop); }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { AddNewObject(drawArea, new AGMChannelDual(e.X, e.Y, 71, 27)); }
private void DrawArea_MouseMove(object sender, MouseEventArgs e) { Status.Items["CurPoss"].Text = e.X + ", " + e.Y; if (MouseDownDrawArea) { int X = e.X - SizePen / 2; int Y = e.Y - SizePen / 2; switch (CurTool) { case "Pen": PEN.Width = SizePen = 1; g.FillRectangle(PEN.Brush, X, Y, SizePen, SizePen); g.DrawLine(PEN, prevLocMouse.X + SizePen / 2, prevLocMouse.Y + SizePen / 2, X + SizePen / 2, Y + SizePen / 2); DrawArea.Invalidate(); break; case "Brush": if (SizePen > 1) { g.FillEllipse(PEN.Brush, X, Y, SizePen, SizePen); } else { g.FillRectangle(PEN.Brush, X, Y, SizePen, SizePen); } g.DrawLine(PEN, prevLocMouse.X + SizePen / 2, prevLocMouse.Y + SizePen / 2, X + SizePen / 2, Y + SizePen / 2); DrawArea.Invalidate(); break; case "Pattern": HatchBrush Hatch = new HatchBrush(HatchStyle.Horizontal + Pattern.ImageIndex, CurColor.BackColor, Color.FromArgb(0, 0, 0, 0)); if (SizePen > 1) { g.FillEllipse(Hatch, X, Y, SizePen, SizePen); } else { g.FillRectangle(Hatch, X, Y, SizePen, SizePen); } Hatch.Dispose(); DrawArea.Invalidate(); break; case "Figures": Contour.Clear(Color.White); Contour.DrawImage(DrawArea.Image, 0, 0); switch (Figures.ImageIndex) { case 0: Contour.DrawRectangle(PEN, (e.X > x) ? x : e.X, (e.Y > y) ? y : e.Y, (e.X > x) ? e.X - x : x - e.X, (e.Y > y) ? e.Y - y : y - e.Y); break; case 1: Contour.DrawEllipse(PEN, (e.X > x) ? x : e.X, (e.Y > y) ? y : e.Y, (e.X > x) ? e.X - x : x - e.X, (e.Y > y) ? e.Y - y : y - e.Y); break; case 3: Contour.DrawLine(PEN, x, y, e.X, e.Y); break; } DrawArea_G.DrawImageUnscaled(bufer, 0, 0); break; } prevLocMouse.X = X; prevLocMouse.Y = Y; } }
public virtual void MouseLeave(DrawArea drawArea, EventArgs e) { }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { AddNewObject(drawArea, new BOM(e.X, e.Y, 38, 43)); }
/// <summary> /// Left mouse button is released /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public virtual void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (!this.IsActive) { lostFocus = true; return; } TVUserInput.Update(); if (lostFocus) { // if the previous call was in inactive mode, we do want TVUserInput to be updated, but we will only // act on it the next round. To make sure moving the mouse to other locations and back is influencing // the location visible in trackviewer. lostFocus = false; return; } fontManager.Update(GraphicsDevice); if (DrawTrackDB != null) { // when update is called, we are not searching via menu DrawTrackDB.ClearHighlightOverrides(); } // First check all the buttons that can be kept down. if (this.drawPathChart.IsActived) { if (TVUserInput.IsDown(TVUserCommands.ShiftLeft)) { drawPathChart.Shift(-1); skipDrawAmount = 0; } if (TVUserInput.IsDown(TVUserCommands.ShiftRight)) { drawPathChart.Shift(1); skipDrawAmount = 0; } if (TVUserInput.IsDown(TVUserCommands.ZoomIn)) { drawPathChart.Zoom(-1); skipDrawAmount = 0; } if (TVUserInput.IsDown(TVUserCommands.ZoomOut)) { drawPathChart.Zoom(1); skipDrawAmount = 0; } } else { if (TVUserInput.IsDown(TVUserCommands.ShiftLeft)) { DrawArea.ShiftLeft(); skipDrawAmount = 0; } if (TVUserInput.IsDown(TVUserCommands.ShiftRight)) { DrawArea.ShiftRight(); skipDrawAmount = 0; } if (TVUserInput.IsDown(TVUserCommands.ShiftUp)) { DrawArea.ShiftUp(); skipDrawAmount = 0; } if (TVUserInput.IsDown(TVUserCommands.ShiftDown)) { DrawArea.ShiftDown(); skipDrawAmount = 0; } if (TVUserInput.IsDown(TVUserCommands.ZoomIn)) { DrawArea.Zoom(-1); skipDrawAmount = 0; } if (TVUserInput.IsDown(TVUserCommands.ZoomOut)) { DrawArea.Zoom(1); skipDrawAmount = 0; } } if (TVUserInput.Changed) { skipDrawAmount = 0; } if (TVUserInput.IsPressed(TVUserCommands.Quit)) { this.Quit(); } if (TVUserInput.IsPressed(TVUserCommands.ReloadRoute)) { this.ReloadRoute(); } if (TVUserInput.IsPressed(TVUserCommands.ShiftToMouseLocation)) { DrawArea.ShiftToLocation(DrawArea.MouseLocation); } if (TVUserInput.IsPressed(TVUserCommands.ZoomInSlow)) { DrawArea.Zoom(-1); } if (TVUserInput.IsPressed(TVUserCommands.ZoomOutSlow)) { DrawArea.Zoom(1); } if (TVUserInput.IsPressed(TVUserCommands.ZoomToTile)) { DrawArea.ZoomToTile(); } if (TVUserInput.IsPressed(TVUserCommands.ZoomReset)) { DrawArea.ZoomReset(DrawTrackDB); drawAreaInset.ZoomReset(DrawTrackDB); // needed in case window was resized } if (DrawPATfile != null && Properties.Settings.Default.showPATfile) { if (TVUserInput.IsPressed(TVUserCommands.ExtendPath)) { DrawPATfile.ExtendPath(); } if (TVUserInput.IsPressed(TVUserCommands.ExtendPathFull)) { DrawPATfile.ExtendPathFull(); } if (TVUserInput.IsPressed(TVUserCommands.ReducePath)) { DrawPATfile.ReducePath(); } if (TVUserInput.IsPressed(TVUserCommands.ReducePathFull)) { DrawPATfile.ReducePathFull(); } if (TVUserInput.IsDown(TVUserCommands.ShiftToPathLocation)) { DrawArea.ShiftToLocation(DrawPATfile.CurrentLocation); } } if (PathEditor != null && Properties.Settings.Default.showTrainpath) { if (TVUserInput.IsPressed(TVUserCommands.ExtendPath)) { PathEditor.ExtendPath(); } if (TVUserInput.IsPressed(TVUserCommands.ExtendPathFull)) { PathEditor.ExtendPathFull(); } if (TVUserInput.IsPressed(TVUserCommands.ReducePath)) { PathEditor.ReducePath(); } if (TVUserInput.IsPressed(TVUserCommands.ReducePathFull)) { PathEditor.ReducePathFull(); } if (TVUserInput.IsDown(TVUserCommands.ShiftToPathLocation)) { DrawArea.ShiftToLocation(PathEditor.CurrentLocation); } if (TVUserInput.IsPressed(TVUserCommands.EditorUndo)) { PathEditor.Undo(); } if (TVUserInput.IsPressed(TVUserCommands.EditorRedo)) { PathEditor.Redo(); } if (TVUserInput.IsMouseXButton1Pressed()) { PathEditor.Undo(); } if (TVUserInput.IsMouseXButton2Pressed()) { PathEditor.Redo(); } } if (PathEditor != null && PathEditor.EditingIsActive) { if (TVUserInput.IsMouseRightButtonPressed()) { PathEditor.OnLeftMouseRelease(); // any action done with left mouse is cancelled now PathEditor.PopupContextMenu(TVUserInput.MouseLocationX, TVUserInput.MouseLocationY); } if (TVUserInput.IsDown(TVUserCommands.EditorTakesMouseClick)) { if (TVUserInput.IsMouseLeftButtonPressed()) { PathEditor.OnLeftMouseClick(TVUserInput.MouseLocationX, TVUserInput.MouseLocationY); } if (TVUserInput.IsMouseLeftButtonDown()) { PathEditor.OnLeftMouseMoved(); // to make sure it is reactive enough, don't even care if mouse is really moved } if (TVUserInput.IsMouseLeftButtonReleased()) { PathEditor.OnLeftMouseRelease(); } } if (TVUserInput.IsReleased(TVUserCommands.EditorTakesMouseClick)) { PathEditor.OnLeftMouseCancel(); } drawPathChart.DrawDynamics(); } if (!TVUserInput.IsDown(TVUserCommands.EditorTakesMouseClick) && !this.MenuHasMouse && !this.drawPathChart.IsActived) { if (TVUserInput.IsMouseMoved() && TVUserInput.IsMouseLeftButtonDown()) { DrawArea.ShiftArea(TVUserInput.MouseMoveX(), TVUserInput.MouseMoveY()); } } if (TVUserInput.IsMouseWheelChanged()) { int mouseWheelChange = TVUserInput.MouseWheelChange(); if (!this.drawPathChart.IsActived) { if (TVUserInput.IsDown(TVUserCommands.MouseZoomSlow)) { DrawArea.Zoom(mouseWheelChange > 0 ? -1 : 1); } else { DrawArea.Zoom(-mouseWheelChange / 40); } } } DrawArea.Update(); drawAreaInset.Update(); drawAreaInset.Follow(DrawArea, 10f); if (TVUserInput.IsPressed(TVUserCommands.ToggleZoomAroundMouse)) { menuControl.MenuToggleZoomingAroundMouse(); } if (TVUserInput.IsPressed(TVUserCommands.ToggleShowTerrain)) { menuControl.MenuToggleShowTerrain(); } if (TVUserInput.IsPressed(TVUserCommands.ToggleShowDMTerrain)) { menuControl.MenuToggleShowDMTerrain(); } if (TVUserInput.IsPressed(TVUserCommands.ToggleShowPatchLines)) { menuControl.MenuToggleShowPatchLines(); } if (TVUserInput.IsPressed(TVUserCommands.ToggleShowSignals)) { menuControl.MenuToggleShowSignals(); } if (TVUserInput.IsPressed(TVUserCommands.ToggleShowSidings)) { menuControl.MenuToggleShowSidings(); } if (TVUserInput.IsPressed(TVUserCommands.ToggleShowSidingNames)) { menuControl.MenuToggleShowSidingNames(); } if (TVUserInput.IsPressed(TVUserCommands.ToggleShowPlatforms)) { menuControl.MenuToggleShowPlatforms(); } if (TVUserInput.IsPressed(TVUserCommands.ToggleShowPlatformNames)) { menuControl.MenuCirculatePlatformStationNames(); } if (TVUserInput.IsPressed(TVUserCommands.ToggleShowSpeedLimits)) { menuControl.MenuToggleShowSpeedLimits(); } if (TVUserInput.IsPressed(TVUserCommands.ToggleShowMilePosts)) { menuControl.MenuToggleShowMilePosts(); } if (TVUserInput.IsPressed(TVUserCommands.ToggleShowTrainpath)) { menuControl.MenuToggleShowTrainpath(); } if (TVUserInput.IsPressed(TVUserCommands.ToggleShowPatFile)) { menuControl.MenuToggleShowPatFile(); } if (TVUserInput.IsPressed(TVUserCommands.ToggleHighlightTracks)) { menuControl.MenuToggleHighlightTracks(); } if (TVUserInput.IsPressed(TVUserCommands.ToggleHighlightItems)) { menuControl.MenuToggleHighlightItems(); } if (TVUserInput.IsPressed(TVUserCommands.Debug)) { runDebug(); } base.Update(gameTime); }
public void RenderCycleGraph() { float w = Camera.main.pixelWidth; float h = Camera.main.pixelHeight; //Color strongColor = new Color(0, 0, 0, 1); Color weakColor = new Color(0.7f, 0.7f, 0.7f, 1); DrawArea graph = new DrawArea(new Vector3(w-0.49f*h,0.01f*h,0),new Vector3(w-0.01f*h,0.49f*h,0)); graph.canvasMin = new Vector3(-1.1f,-1.1f,0); graph.canvasMax = new Vector3( 1.1f, 1.1f,0); GL.Begin( GL.QUADS ); graph.DrawRect(new Vector3(-1,-1,0), new Vector3(1,1,0), new Color(0,0,0,0.2f)); GL.End(); GL.Begin( GL.LINES ); graph.DrawLine (-0.9f*Vector3.up, -1.1f*Vector3.up, weakColor); for (int i=0; i<90; i++) { graph.DrawLine ( Quaternion.AngleAxis( i /90.0f*360, Vector3.forward) * Vector3.up, Quaternion.AngleAxis((i+1)/90.0f*360, Vector3.forward) * Vector3.up, weakColor); } for (int leg=0; leg<legs.Length; leg++) { Color c = legs[leg].debugColor; Vector3 marker; marker = Quaternion.AngleAxis( 360.0f*legStates[leg].liftoffTime, -Vector3.forward ) * -Vector3.up; graph.DrawLine(marker*0.9f, marker*1.1f, c); marker = Quaternion.AngleAxis( 360.0f*legStates[leg].strikeTime, -Vector3.forward ) * -Vector3.up; graph.DrawLine(marker*0.9f, marker*1.1f, c); } GL.End(); GL.Begin( GL.QUADS ); for (int leg=0; leg<legs.Length; leg++) { Color c = legs[leg].debugColor; Vector3 cycleVect; cycleVect = Quaternion.AngleAxis( 360.0f*legStates[leg].cycleTime, -Vector3.forward ) * -Vector3.up; graph.DrawRect(cycleVect-Vector3.one*0.1f, cycleVect+Vector3.one*0.1f, c); float dictatedCycle = Util.CyclicDiff(normalizedTime, legStates[leg].stanceTime); cycleVect = Quaternion.AngleAxis(360.0f*dictatedCycle, -Vector3.forward) * -Vector3.up * 0.8f; graph.DrawRect(cycleVect-Vector3.one*0.05f, cycleVect+Vector3.one*0.05f, c); } GL.End(); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { // Even if there is nothing new to draw for main window, we might still need to draw for the shadow textures. if (DrawTrackDB != null && Properties.Settings.Default.showInset) { drawAreaInset.DrawShadowTextures(DrawTrackDB.DrawTracks, DrawColors.colorsNormal.ClearWindowInset); } // if there is nothing to draw, be done. if (--skipDrawAmount > 0) { return; } GraphicsDevice.Clear(DrawColors.colorsNormal.ClearWindow); if (DrawTrackDB == null) { return; } spriteBatch.Begin(); if (drawTerrain != null) { drawTerrain.Draw(DrawArea); } drawWorldTiles.Draw(DrawArea); DrawArea.DrawTileGrid(); if (drawTerrain != null) { drawTerrain.DrawPatchLines(DrawArea); } DrawTrackDB.DrawRoads(DrawArea); DrawTrackDB.DrawTracks(DrawArea); DrawTrackDB.DrawTrackHighlights(DrawArea, true); DrawTrackDB.DrawJunctionAndEndNodes(DrawArea); if (Properties.Settings.Default.showInset) { drawAreaInset.DrawBackground(DrawColors.colorsNormal.ClearWindowInset); //drawTrackDB.DrawTracks(drawAreaInset); //replaced by next line drawAreaInset.DrawShadowedTextures(); DrawTrackDB.DrawTrackHighlights(drawAreaInset, false); drawAreaInset.DrawBorder(Color.Red, DrawArea); drawAreaInset.DrawBorder(Color.Black); } if (DrawMultiplePaths != null) { DrawMultiplePaths.Draw(DrawArea); } if (DrawPATfile != null && Properties.Settings.Default.showPATfile) { DrawPATfile.Draw(DrawArea); } if (PathEditor != null && Properties.Settings.Default.showTrainpath) { PathEditor.Draw(DrawArea); } DrawTrackDB.DrawRoadTrackItems(DrawArea); DrawTrackDB.DrawTrackItems(DrawArea); DrawTrackDB.DrawItemHighlights(DrawArea); CalculateFPS(gameTime); statusBarControl.Update(this, DrawArea.MouseLocation); drawScaleRuler.Draw(); drawLongitudeLatitude.Draw(DrawArea.MouseLocation); DebugWindow.DrawAll(); spriteBatch.End(); base.Draw(gameTime); skipDrawAmount = maxSkipDrawAmount; }
public Paint() { InitializeComponent(); Cursor[] arrArrow = new Cursor[] { Cursors.SizeWE, Cursors.SizeNWSE, Cursors.SizeNS }; for (int i = 0; i < lbl.Length; i++) { lbl[i] = new Label(); lbl[i].TabIndex = i; lbl[i].FlatStyle = 0; lbl[i].BorderStyle = BorderStyle.FixedSingle; lbl[i].BackColor = Color.White;//BoxColor lbl[i].Cursor = arrArrow[i]; lbl[i].Text = ""; lbl[i].BringToFront(); lbl[i].MouseDown += new MouseEventHandler(this.lbl_MouseDown); lbl[i].MouseMove += new MouseEventHandler(this.lbl_MouseMove); lbl[i].MouseUp += new MouseEventHandler(this.lbl_MouseUp); lbl[i].Size = new Size(5, 5); this.panel.Controls.Add(lbl[i]); } lbl[0].Location = new Point(DrawArea.Right, DrawArea.Height / 2 + DrawArea.Top); lbl[1].Location = new Point(DrawArea.Right, DrawArea.Bottom); lbl[2].Location = new Point(DrawArea.Width / 2 + DrawArea.Left, DrawArea.Bottom); Status.Items["DrawSize"].Text = DrawArea.Size.Width + " x " + DrawArea.Size.Height; DrawArea.Image = new Bitmap(DrawArea.Width, DrawArea.Height); g = Graphics.FromImage(DrawArea.Image); for (int i = 0; i < CurColor.DropDownItems.Count; i++) { CurColor.DropDownItems[i].Click += new System.EventHandler(Color_Click); } CurColor.DropDownItems["RGB"].Click += new System.EventHandler(RGB_Click); PEN = new Pen(CurColor.BackColor, SizePen); SizeBrush.SelectedIndex = 9; curs.Add(CreateCursor(new Bitmap("../../source/pen.png"), 5, 23)); curs.Add(CreateCursor(new Bitmap("../../source/brush.png"), 3, 31)); curs.Add(CreateCursor(new Bitmap("../../source/fill.png"), 10, 28)); curs.Add(CreateCursor(new Bitmap("../../source/pattern.png"), 1, 31)); ToolBar.Items.Add(new ToolStripControlHost(this.Intensity)); Pattern = new ToolStripSplitButton(); Pattern.AutoSize = false; Pattern.BackgroundImageLayout = ImageLayout.None; Pattern.DisplayStyle = ToolStripItemDisplayStyle.None; Pattern.ImageScaling = ToolStripItemImageScaling.None; Pattern.ImageTransparentColor = Color.Magenta; Pattern.Size = new Size(68, 29); Pattern.Text = "Pattern"; Pattern.Name = "Pattern"; Pattern.Margin = new Padding(5, 0, 5, 0); Pattern.Click += new EventHandler(Pattern_Click); for (int i = 0; i < 53; i++) { Bitmap img = new Bitmap(Pattern.Width, Pattern.Height); Graphics.FromImage(img).FillRectangle(new HatchBrush(HatchStyle.Horizontal + i, Color.Green, Color.White), 0, 0, Pattern.Width, Pattern.Height); ToolStripMenuItem TSMI = new ToolStripMenuItem(); TSMI.AutoSize = false; TSMI.BackColor = Color.White; TSMI.BackgroundImage = img; TSMI.BackgroundImageLayout = ImageLayout.Stretch; TSMI.DisplayStyle = ToolStripItemDisplayStyle.Image; TSMI.Font = new Font("Segoe UI", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(204))); TSMI.ImageAlign = ContentAlignment.MiddleLeft; TSMI.ImageScaling = ToolStripItemImageScaling.None; TSMI.RightToLeft = RightToLeft.Yes; TSMI.Size = new Size(65, 29); TSMI.ImageIndex = i; TSMI.Click += new EventHandler(Pattern_Items_Click); Pattern.DropDownItems.Add(TSMI); } Pattern.BackgroundImage = Pattern.DropDownItems[0].BackgroundImage; Pattern.ImageIndex = Pattern.DropDownItems[0].ImageIndex; ToolBar.Items.Add(Pattern); Figures = new ToolStripSplitButton(); Figures.AutoSize = false; Figures.BackgroundImageLayout = ImageLayout.None; Figures.DisplayStyle = ToolStripItemDisplayStyle.None; Figures.ImageScaling = ToolStripItemImageScaling.None; Figures.ImageTransparentColor = Color.Magenta; Figures.Size = new Size(68, 29); Figures.Text = "Figures"; Figures.Name = "Figures"; Figures.Margin = new Padding(5, 0, 5, 0); Figures.Click += new EventHandler(Figures_Click); Figures.BackgroundImageLayout = ImageLayout.Stretch; Figures.BackColor = Color.White; for (int i = 0; i < 5; i++) { ToolStripMenuItem TSMI = new ToolStripMenuItem(); TSMI.AutoSize = false; TSMI.BackColor = Color.White; TSMI.BackgroundImageLayout = ImageLayout.Stretch; TSMI.TextImageRelation = TextImageRelation.Overlay; TSMI.DisplayStyle = ToolStripItemDisplayStyle.Image; TSMI.Font = new Font("Segoe UI", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(204))); TSMI.ImageAlign = ContentAlignment.MiddleLeft; TSMI.ImageScaling = ToolStripItemImageScaling.None; TSMI.RightToLeft = RightToLeft.Yes; TSMI.Size = new Size(68, 60); TSMI.ImageIndex = i; TSMI.Click += new EventHandler(Figures_Items_Click); Figures.DropDownItems.Add(TSMI); } Figures.DropDownItems[0].BackgroundImage = new Bitmap("../../source/f_rectangle.png"); Figures.DropDownItems[1].BackgroundImage = new Bitmap("../../source/f_ellipse.png"); Figures.DropDownItems[2].BackgroundImage = new Bitmap("../../source/f_triangle.png"); Figures.DropDownItems[3].BackgroundImage = new Bitmap("../../source/f_line.png"); Figures.DropDownItems[4].BackgroundImage = new Bitmap("../../source/f_polygon.png"); Figures.BackgroundImage = Figures.DropDownItems[0].BackgroundImage; Figures.ImageIndex = Figures.DropDownItems[0].ImageIndex; ToolBar.Items.Add(Figures); DrawArea_G = DrawArea.CreateGraphics(); bufer = new Bitmap(DrawArea.Width, DrawArea.Height); Contour = Graphics.FromImage(bufer); }
public static void HealthBar(RenderTarget Device, DrawArea drawArea, Entity player) { using (SolidColorBrush brush = new SolidColorBrush(Device, Color.FromArgb(1, 1, 1).toRawColor4())) { var health = player.Health > 100 ? 100 : player.Health; var x = drawArea.x - 5; var y1 = drawArea.y; var y2 = drawArea.y + drawArea.height; var y3 = drawArea.y + 1 + (drawArea.height - (health * (drawArea.height / 100))); var y4 = y2 - 1; if (visuals.HealthPostion == Settings.HealthDisplay.Right) { x = drawArea.x + drawArea.width + 5; } else if (visuals.HealthPostion != Settings.HealthDisplay.Left) { if (visuals.HealthPostion == Settings.HealthDisplay.Top) { x = drawArea.y - 5; } else { x = drawArea.y + drawArea.height + 5; } y1 = drawArea.x; y2 = drawArea.x + drawArea.width; y3 = drawArea.x - 1 + ((health * (drawArea.width / 100))); y4 = y1 + 1; } if (visuals.HealthPostion == Settings.HealthDisplay.Left || visuals.HealthPostion == Settings.HealthDisplay.Right) { Device.DrawLine(new RawVector2(x, y1), new RawVector2(x, y2), brush, 3); brush.Color = player.Health.HealthToColor().toRawColor4(); Device.DrawLine(new RawVector2(x, y3), new RawVector2(x, y4), brush, 1); } else { Device.DrawLine(new RawVector2(y1, x), new RawVector2(y2, x), brush, 3); brush.Color = player.Health.HealthToColor().toRawColor4(); Device.DrawLine(new RawVector2(y3, x), new RawVector2(y4, x), brush, 1); } TextFormat txtForm = new TextFormat(new SharpDX.DirectWrite.Factory(), "Calibri", FontWeight.Bold, SharpDX.DirectWrite.FontStyle.Normal, 10); txtForm.SetWordWrapping(WordWrapping.NoWrap); RawRectangleF rect = new RawRectangleF(); if (visuals.HealthPostion == Settings.HealthDisplay.Left) { rect = new RawRectangleF(x - 25, y1, x, y1 + 10); } else if (visuals.HealthPostion == Settings.HealthDisplay.Right) { rect = new RawRectangleF(x + 10, y1, x + 1, y1 + 10); } else if (visuals.HealthPostion == Settings.HealthDisplay.Top) { rect = new RawRectangleF(y1, x - 15, y2, x); } else if (visuals.HealthPostion == Settings.HealthDisplay.Bottom) { rect = new RawRectangleF(y1, x, y2, x); } if (visuals.HealthNumber) { brush.Color = Color.FromArgb(1, 1, 1).toRawColor4(); Device.DrawText(player.Health + "%", txtForm, rect, brush, DrawTextOptions.NoSnap); if (player.isTeam) { brush.Color = visColors.Team_Text.toRawColor4(); } else { brush.Color = visColors.Enemy_Text.toRawColor4(); } Device.DrawText(player.Health + "%", txtForm, rect, brush, DrawTextOptions.EnableColorFont | DrawTextOptions.DisableColorBitmapSnapping | DrawTextOptions.NoSnap); } } }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { AddNewObject(drawArea, new DrawRectangle(e.X, e.Y, 1, 1)); }
public static void Players(RenderTarget Device) { foreach (Entity player in EntityList.List) { foreach (Entity spec in EntityList.List) { if (player.Observe == spec.Ptr) { spectatorString += player.Name + " -> " + spec.Name + "\n"; } else if (player.Observe == Local.Ptr) { spectatorString += player.Name + " -> " + spec.Name + "<<\n"; } } if (Settings.userSettings.MiscSettings.Spectators && Local.Health > 0) { Spectators(Device); } if (!visuals.Enabled) { return; } if (player.Health <= 0 || player.Dormant) { continue; } if (player.isTeam && !visuals.DisplayTeam) { continue; } Vector2 screenPos = player.Position.ToScreen(); if (screenPos.x == -1f && screenPos.y == -1f) { continue; } Vector2 headPos = player.BonePosition(8).ToScreen(); if (headPos.x == -1f && headPos.y == -1f) { continue; } DrawArea drawArea = new DrawArea(); drawArea.height = (int)(screenPos.y - headPos.y); drawArea.width = (int)(drawArea.height / 2.1f); drawArea.x = (int)((screenPos.x + headPos.x) / 2f - drawArea.width / 2f); drawArea.y = (int)(headPos.y - drawArea.height / 10f); drawArea.height *= 1.1f; if (drawArea.x + drawArea.width + 20 < 0) { continue; } if (drawArea.y + drawArea.height + 20 < 0) { continue; } if (drawArea.x - 20 > gvar.OverlaySize.Width) { continue; } if (drawArea.y - 20 > gvar.OverlaySize.Height) { continue; } if (visuals.Snaplines) { Snaplines(Device, player); } if (visuals.BoxEsp == Settings.BoxDisplay._3D) { if (drawArea.x + drawArea.width >= 0) { if (drawArea.y + drawArea.height >= 0) { if (drawArea.x <= gvar.OverlaySize.Width) { if (drawArea.y <= gvar.OverlaySize.Height) { Boxes3D(Device, player); } } } } } if (visuals.BoxEsp == Settings.BoxDisplay._2D) { Boxes2D(Device, drawArea, player); } if (visuals.BoxEsp == Settings.BoxDisplay.Edges) { BoxesEdges(Device, drawArea, player); } if (visuals.Name) { Name(Device, drawArea, player); } if (visuals.Rank) { Rank(Device, drawArea, player); } if (visuals.ActiveWeapon) { ActiveWeapon(Device, drawArea, player); } if (visuals.HealthPostion != Settings.HealthDisplay.Off) { HealthBar(Device, drawArea, player); } } }
public override void OnDoubleClick(Object sender, EventArgs e) { string entryValue; if (_entry == EDirection.Left) { entryValue = "Left"; } else if (_entry == EDirection.Right) { entryValue = "Right"; } else if (_entry == EDirection.Up) { entryValue = "Up"; } else { entryValue = "Down"; } DrawArea drawArea = (DrawArea)sender; EditorDialog dlg = new EditorDialog(_logicIDTail, this, entryValue, drawArea.GraphicsList.AGMVerify, DeviceTypeEnum.AGM, DeviceTypeEnum.AGM_Sub_AGMChannelDual, drawArea.GraphicsList.IPVerify); // dlg.ArrayId = arrayId; if (dlg.ShowDialog() == DialogResult.OK) { if (this._tagIDBase != 0) { drawArea.GraphicsList.AGMVerify.Remove(_logicIDTail); } _logicIDTail = dlg.IDvalues; arrayId = dlg.ArrayId; this.x_axis = dlg.X_axis; this.y_axis = dlg.Y_axis; this.width = dlg.RWidth; this.height = dlg.RHeight; RecID = dlg.RecID; StationID = dlg.StationID; DeviceID = dlg.DeviceID; DeviceName = dlg.DeviceName; IpAdd = dlg.IpAdd; DeviceType = dlg.DeviceType; DeviceSubType = dlg.DeviceSubType; GroupID = dlg.GroupID; this.Device_H = dlg.Device_H; this.Device_W = dlg.Device_W; if (dlg.Entryvalues == "Left") { this.Entry = EDirection.Left; } else if (dlg.Entryvalues == "Right") { this.Entry = EDirection.Right; } else if (dlg.Entryvalues == "Up") { this.Entry = EDirection.Up; } else { this.Entry = EDirection.Down; } if (_tagIDBase == 0) { _flag = _objIdInc++; } if (drawArea.AddText(this)) { _tagIDBase = _flag; this.SetRectangle(x_axis, y_axis, width, height); drawArea.SetDirty(); drawArea.Refresh(); } } }
public static void BoxesEdges(RenderTarget Device, DrawArea drawArea, Entity player) { Color col = Color.Empty; if (player.Visible && player.isTeam) { col = visColors.Team_Box_Visible; } else if (!player.Visible && player.isTeam) { col = visColors.Team_Box_Hidden; } else if (player.Visible && !player.isTeam) { col = visColors.Enemy_Box_Visible; } else if (!player.Visible && !player.isTeam) { col = visColors.Enemy_Box_Hidden; } var len = (int)(drawArea.width / 3.5); var p1 = new RawVector2(drawArea.x, drawArea.y); var p2 = new RawVector2(drawArea.x + drawArea.width, drawArea.y); var p3 = new RawVector2(drawArea.x, drawArea.y + drawArea.height); var p4 = new RawVector2(p2.X, p3.Y); var p11 = new RawVector2(p1.X + len, p1.Y); var p12 = new RawVector2(p1.X, p1.Y + len); var p21 = new RawVector2(p2.X - len, p2.Y); var p22 = new RawVector2(p2.X, p2.Y + len); var p31 = new RawVector2(p3.X + len, p3.Y); var p32 = new RawVector2(p3.X, p3.Y - len); var p41 = new RawVector2(p4.X - len, p4.Y); var p42 = new RawVector2(p4.X, p4.Y - len); if (visuals.BoxOutline) { using (SolidColorBrush brush = new SolidColorBrush(Device, Color.FromArgb(1, 1, 1).toRawColor4())) { Device.DrawLine(p11, p1, brush, 3); Device.DrawLine(p1, p12, brush, 3); Device.DrawLine(p21, p2, brush, 3); Device.DrawLine(p2, p22, brush, 3); Device.DrawLine(p31, p3, brush, 3); Device.DrawLine(p3, p32, brush, 3); Device.DrawLine(p41, p4, brush, 3); Device.DrawLine(p4, p42, brush, 3); } } using (SolidColorBrush brush = new SolidColorBrush(Device, col.toRawColor4())) { Device.DrawLine(p11, p1, brush, 1); Device.DrawLine(p1, p12, brush, 1); Device.DrawLine(p21, p2, brush, 1); Device.DrawLine(p2, p22, brush, 1); Device.DrawLine(p31, p3, brush, 1); Device.DrawLine(p3, p32, brush, 1); Device.DrawLine(p41, p4, brush, 1); Device.DrawLine(p4, p42, brush, 1); } }
/// <summary> /// Загрузка проекта /// </summary> /// <param name="path"></param> /// <param name="testTabControl"></param> /// <param name="drawAreas"></param> /// <param name="processes"></param> /// <param name="mainprocess"></param> /// <returns></returns> public int LoadProjectExecute(string path, TabControl testTabControl, List <DrawArea> drawAreas, List <Process> processes, out Process mainprocess) { SaveProject temp = null; // Считываем иформацию о проекте using (FileStream stream = new FileStream(path, FileMode.Open)) { DataContractSerializer ser = new DataContractSerializer(typeof(SaveProject), types); temp = (ser.ReadObject(stream)) as SaveProject; } mainprocess = null; int num = 0; // Очищаем информацию testTabControl.Items.Clear(); drawAreas.Clear(); processes.Clear(); List <TabItem> tabitems = new List <TabItem>(); // Проходим по каждому процессу for (int i = 0; i < temp.ProcessList.Count; i++) { // Создаём процесс Process process = new Process() { Description = temp[i].ProcessName }; processes.Add(process); // Добавляем в список процессов var tabItem = new TabItem() { Header = process }; testTabControl.SelectedItem = tabItem; // Создаём область рисования var drawArea = new DrawArea() { Processes = processes }; drawAreas.Add(drawArea); tabItem.Content = drawArea; LoadProcess(temp[i], drawArea); processWorked.Add(temp[i].ProcessId, process); if (temp.MainProcessID == temp[i].ProcessId) { mainprocess = process; num = i; } //testTabControl.Items.Add(tabItem); tabitems.Add(tabItem); } // А теперь добавляем, чтобы было в нормальном порядке tabitems.Reverse(); foreach (var ch in tabitems) { testTabControl.Items.Add(ch); } //testTabControl.ItemsSource = tabitems; return(num); }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { AddNewShape(drawArea, new DrawEllipse(e.X, e.Y, Width, Height)); }
public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { newPolygon = null; base.OnMouseUp(drawArea, e); }
public int GetGridColumnCount() { return(DrawArea.GetCellsInWidth()); }
// // Draw track line with axis labels // private void trackLineAxis(XYChart c, int mouseX) { // Clear the current dynamic layer and get the DrawArea object to draw on it. DrawArea d = c.initDynamicLayer(); // The plot area object PlotArea plotArea = c.getPlotArea(); // Get the data x-value that is nearest to the mouse, and find its pixel coordinate. double xValue = c.getNearestXValue(mouseX); int xCoor = c.getXCoor(xValue); // The vertical track line is drawn up to the highest data point (the point with smallest // y-coordinate). We need to iterate all datasets in all layers to determine where it is. int minY = plotArea.getBottomY(); // Iterate through all layers to find the highest data point for (int i = 0; i < c.getLayerCount(); ++i) { Layer layer = c.getLayerByZ(i); // The data array index of the x-value int xIndex = layer.getXIndexOf(xValue); // Iterate through all the data sets in the layer for (int j = 0; j < layer.getDataSetCount(); ++j) { ChartDirector.DataSet dataSet = layer.getDataSetByZ(j); double dataPoint = dataSet.getPosition(xIndex); if ((dataPoint != Chart.NoValue) && (dataSet.getDataColor() != Chart.Transparent)) { minY = Math.Min(minY, c.getYCoor(dataPoint, dataSet.getUseYAxis())); } } } // Draw a vertical track line at the x-position up to the highest data point. d.vline(Math.Max(minY, plotArea.getTopY()), plotArea.getBottomY() + 6, xCoor, d.dashLineColor( 0x000000, 0x0101)); // Draw a label on the x-axis to show the track line position d.text("<*font,bgColor=000000*> " + c.xAxis().getFormattedLabel(xValue, "mmm dd, yyyy") + " <*/font*>", "Arial Bold", 8).draw(xCoor, plotArea.getBottomY() + 6, 0xffffff, Chart.Top); // Iterate through all layers to build the legend array for (int i = 0; i < c.getLayerCount(); ++i) { Layer layer = c.getLayerByZ(i); // The data array index of the x-value int xIndex = layer.getXIndexOf(xValue); // Iterate through all the data sets in the layer for (int j = 0; j < layer.getDataSetCount(); ++j) { ChartDirector.DataSet dataSet = layer.getDataSetByZ(j); // The positional value, axis binding, pixel coordinate and color of the data point. double dataPoint = dataSet.getPosition(xIndex); Axis yAxis = dataSet.getUseYAxis(); int yCoor = c.getYCoor(dataPoint, yAxis); int color = dataSet.getDataColor(); // Draw the axis label only for visible data points of named data sets if ((dataPoint != Chart.NoValue) && (color != Chart.Transparent) && (yCoor >= plotArea.getTopY()) && (yCoor <= plotArea.getBottomY())) { // The axis label consists of 3 parts - a track dot for the data point, an axis label, // and a line joining the track dot to the axis label. // Draw the line first. The end point of the line at the axis label side depends on // whether the label is at the left or right side of the axis (that is, on whether the // axis is on the left or right side of the plot area). int xPos = yAxis.getX() + ((yAxis.getAlignment() == Chart.Left) ? -4 : 4); d.hline(xCoor, xPos, yCoor, d.dashLineColor(color, 0x0101)); // Draw the track dot d.circle(xCoor, yCoor, 4, 4, color, color); // Draw the axis label. If the axis is on the left side of the plot area, the labels // should right aligned to the axis, and vice versa. d.text("<*font,bgColor=" + color.ToString("x") + "*> " + c.formatValue(dataPoint, "{value|P4}") + " <*/font*>", "Arial Bold", 8).draw(xPos, yCoor, 0xffffff, (( yAxis.getAlignment() == Chart.Left) ? Chart.Right : Chart.Left)); } } } }
public virtual void OnMouseDoubleClick(DrawArea drawArea, MouseEventArgs e) { }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { AddNewObject(drawArea, new DrawTools.Device.Array(e.X, e.Y, 50, 50)); }
public bool IsHover(Vector2D point) { var hoverZone = DrawArea.Reduce(reduceSize); return(hoverZone.Contains(point)); }
public DrawPath(int x1, int y1, int x2, int y2, Color lineColor, int lineWidth, DrawArea owner) { pointArray = new ArrayList(); pointArray.Add(new Point(x1, y1)); pointArray.Add(new Point(x2, y2)); Color = lineColor; PenWidth = lineWidth; LoadCursor(); Initialize(); this.owner = owner; }
public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { drawArea.ActiveTool = DrawToolType.Pointer; drawArea.Capture = false; drawArea.Refresh(); }
// // Draw the track line with legend // private void trackLineLabel(XYChart c, int mouseX) { // Clear the current dynamic layer and get the DrawArea object to draw on it. DrawArea d = c.initDynamicLayer(); // The plot area object PlotArea plotArea = c.getPlotArea(); // Get the data x-value that is nearest to the mouse, and find its pixel coordinate. double xValue = c.getNearestXValue(mouseX); int xCoor = c.getXCoor(xValue); // Draw a vertical track line at the x-position d.vline(plotArea.getTopY(), plotArea.getBottomY(), xCoor, d.dashLineColor(0x000000, 0x0101)); // Draw a label on the x-axis to show the track line position. string xlabel = "<*font,bgColor=000000*> " + c.xAxis().getFormattedLabel(xValue, "hh:nn:ss.f") + " <*/font*>"; TTFText t = d.text(xlabel, "Arial Bold", 8); // Restrict the x-pixel position of the label to make sure it stays inside the chart image. int xLabelPos = Math.Max(0, Math.Min(xCoor - t.getWidth() / 2, c.getWidth() - t.getWidth())); t.draw(xLabelPos, plotArea.getBottomY() + 6, 0xffffff); // Iterate through all layers to draw the data labels for (int i = 0; i < c.getLayerCount(); ++i) { Layer layer = c.getLayerByZ(i); // The data array index of the x-value int xIndex = layer.getXIndexOf(xValue); // Iterate through all the data sets in the layer for (int j = 0; j < layer.getDataSetCount(); ++j) { ChartDirector.DataSet dataSet = layer.getDataSetByZ(j); // Get the color and position of the data label int color = dataSet.getDataColor(); int yCoor = c.getYCoor(dataSet.getPosition(xIndex), dataSet.getUseYAxis()); // Draw a track dot with a label next to it for visible data points in the plot area if ((yCoor >= plotArea.getTopY()) && (yCoor <= plotArea.getBottomY()) && (color != Chart.Transparent) && (!string.IsNullOrEmpty(dataSet.getDataName()))) { d.circle(xCoor, yCoor, 4, 4, color, color); string label = "<*font,bgColor=" + color.ToString("x") + "*> " + c.formatValue( dataSet.getValue(xIndex), "{value|P4}") + " <*/font*>"; t = d.text(label, "Arial Bold", 16); // Draw the label on the right side of the dot if the mouse is on the left side the // chart, and vice versa. This ensures the label will not go outside the chart image. if (xCoor <= (plotArea.getLeftX() + plotArea.getRightX()) / 2) { //t.draw(xCoor + 5, yCoor, 0xffffff, Chart.Left); t.draw(xCoor + 5, yCoor, 0x000000, Chart.Left); } else { //t.draw(xCoor - 5, yCoor, 0xffffff, Chart.Right); t.draw(xCoor - 5, yCoor, 0x000000, Chart.Right); } } } } }
public void RenderMotionCycles() { //float w = Camera.main.pixelWidth; float h = Camera.main.pixelHeight; //Color strongColor = new Color(0, 0, 0, 1); Color weakColor = new Color(0.7f, 0.7f, 0.7f, 1); for (int m=0; m<legC.cycleMotions.Length; m++) { DrawArea graph = new DrawArea( new Vector3(0.01f*h+0.2f*h*m,0.31f*h,0), new Vector3(0.19f*h+0.2f*h*m,0.49f*h,0) ); graph.canvasMin = new Vector3(-1.1f,-1.1f,0); graph.canvasMax = new Vector3( 1.1f, 1.1f,0); GL.Begin( GL.LINES ); graph.DrawLine (-0.9f*Vector3.up, -1.1f*Vector3.up, weakColor); for (int i=0; i<90; i++) { graph.DrawLine ( Quaternion.AngleAxis( i /90.0f*360, Vector3.forward) * Vector3.up, Quaternion.AngleAxis((i+1)/90.0f*360, Vector3.forward) * Vector3.up, weakColor); } GL.End(); GL.Begin( GL.QUADS ); for (int leg=0; leg<legs.Length; leg++) { Color c = legs[leg].debugColor; Vector3 cycleVect; float t = ( legC.cycleMotions[m].cycles[leg].stanceTime - legC.cycleMotions[m].cycleOffset*(0.5f+0.5f*Mathf.Sin(Time.time*2)) ); cycleVect = Quaternion.AngleAxis(360.0f*t, -Vector3.forward) * -Vector3.up; graph.DrawRect(cycleVect-Vector3.one*0.1f, cycleVect+Vector3.one*0.1f, c); } GL.End(); } }
public virtual void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { }
/// <summary> /// Set and load a new route /// </summary> /// <param name="newRoute">The route to load, containing amongst other the directory name of the route</param> public void SetRoute(Route newRoute) { if (newRoute == null) { return; } if (!CanDiscardModifiedPath()) { return; } DrawLoadingMessage(catalog.GetString("Loading route...")); MessageDelegate messageHandler = new MessageDelegate(DrawLoadingMessage); try { RouteData = new RouteData(newRoute.Path, messageHandler); DrawTrackDB = new DrawTrackDB(this.RouteData, messageHandler); CurrentRoute = newRoute; Properties.Settings.Default.defaultRoute = CurrentRoute.Path.Split('\\').Last(); if (Properties.Settings.Default.zoomRoutePath != CurrentRoute.Path) { Properties.Settings.Default.zoomScale = -1; // To disable the use of zoom reset } Properties.Settings.Default.Save(); DrawArea.ZoomReset(DrawTrackDB); drawAreaInset.ZoomReset(DrawTrackDB); SetTitle(); } catch { MessageBox.Show(catalog.GetString("Route cannot be loaded. Sorry")); } if (CurrentRoute == null) { return; } PathEditor = null; DrawMultiplePaths = null; try { findPaths(); } catch { } try { drawWorldTiles.SetRoute(CurrentRoute.Path); drawTerrain = new DrawTerrain(CurrentRoute.Path, messageHandler, drawWorldTiles); drawTerrain.LoadContent(GraphicsDevice); menuControl.MenuSetShowTerrain(false); menuControl.MenuSetShowDMTerrain(false); } catch { } menuControl.PopulatePlatforms(); menuControl.PopulateStations(); menuControl.PopulateSidings(); }
/// <summary> /// Mouse move - resize new polygon /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { drawArea.Cursor = m_Cursor; //if (e.Button != MouseButtons.Left) // return; //if (newConnector == null) // return; // precaution Guid _guid = Guid.Empty; int _pinno = -1; bool _leftside = false; Point p; int PinType = (int)VarType.UNKNOWN; bool pinisused = true; bool result; string TipText; p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); result = drawArea.Pages.IsMouseOverPin(p, ref _guid, ref _leftside, ref _pinno, ref PinType); if (result) { TipText = String.Format("PinType = {0}", (VarType)PinType); toolTip.Show(TipText, drawArea, p, 2000); } if (result && !pinisused) { try { drawArea.Cursor = new Cursor(Application.StartupPath + "\\WireL.cur"); } catch (NullReferenceException ex) { MessageBox.Show(ex.Message.ToString()); } } else { drawArea.Cursor = m_Cursor; } if (_drawingInProcess == true) { if (result && !pinisused && CompatibeTypes(((DrawWire)drawArea.tempobject).StartPinType, PinType)) { try { drawArea.Cursor = new Cursor(Application.StartupPath + "\\WireL.cur"); } catch (NullReferenceException ex) { MessageBox.Show(ex.Message.ToString()); } } else { drawArea.Cursor = m_Cursor; } drawArea.tempobject.MoveHandleTo(p, 6); drawArea.Refresh(); } }