// Constructor public Gui() { Application.Init(); ioh = new IoHandler(); win = new Window("Drawing lines"); darea = new DrawingArea(); painter = new DrawShape(DrawLine); listenOnMouse = false; // Við hlustum ekki á mús við núllstöðu. // Aukum viðburðasett teikniborðs með ,möskum'. darea.AddEvents( (int)Gdk.EventMask.PointerMotionMask | (int)Gdk.EventMask.ButtonPressMask | (int)Gdk.EventMask.ButtonReleaseMask); // Úthlutum virkni á viðburði. win.Hidden += delegate {Application.Quit();}; win.KeyPressEvent += onKeyboardPressed; darea.ExposeEvent += onDrawingAreaExposed; darea.ButtonPressEvent += onMouseClicked; darea.ButtonReleaseEvent += onMouseReleased; darea.MotionNotifyEvent += onMouseMotion; // Grunnstillum stærð glugga. win.SetDefaultSize(500,500); // Lokasamantekt til að virkja glugga. win.Add(darea); win.ShowAll(); Application.Run(); }
/// <summary>Construct Add Graphics Interactively sample control</summary> public AddInteractively() { InitializeComponent(); DataContext = this; _currentDrawShape = DrawShape.Point; _inDrawMode = false; }
/// <summary>Construct Add Graphics Interactively sample control</summary> public AddInteractively() { InitializeComponent(); DataContext = this; _currentDrawShape = DrawShape.Point; _graphicsLayer = MyMapView.Map.Layers["graphicsLayer"] as GraphicsLayer; _inDrawMode = false; }
public S57SearchSample() { InitializeComponent(); DataContext = this; _currentDrawShape = DrawShape.Point; _searchResults = new ObservableCollection<S57FeatureObject>(); ResultList.ItemsSource = _searchResults; // Reference layers that are used _hydrographicLayers = MyMapView.Map.Layers.OfType<GroupLayer>().First(); _drawGraphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; _polygonResultGraphicsOverlay = MyMapView.GraphicsOverlays["polygonResultsOverlay"]; _lineResultGraphicsOverlay = MyMapView.GraphicsOverlays["lineResultsOverlay"]; _pointResultGraphicsOverlay = MyMapView.GraphicsOverlays["pointResultsOverlay"]; ZoomToHydrographicLayers(); }
internal static Brush GetBrush(RectangleF Coords, TShapeProperties ShProp, ExcelFile Workbook, TShadowInfo ShadowInfo, float Zoom100) { return(DrawShape.GetBrush(Coords, ShProp, Workbook, ShadowInfo, Zoom100)); }
private void panel5_Paint(object sender, PaintEventArgs e) { DrawShape drawShape = new DrawShape(); drawShape.leftLine(panel5); }
//Contains all of the components which are on the window private void setupWindow() { //Vertical box (3 sections) which is the main container VBox MainVBox = new VBox(false, 6); /*********************Start of menu bar components*********************/ //Note: Flow of menus are: //Menubar contains MenuItems (e.g. File, Edit, About, etc...) //MenuItems contains one Menu (i.e. a Submenu) //Menu contains multiple MenuItems (e.g. Save, Save As, Load, etc...) MenuBar MainMenuBar = new MenuBar (); Menu FileMenu = new Menu (); MenuItem File = new MenuItem ("File"); File.Submenu = FileMenu; MenuItem ExitItem = new MenuItem ("Exit"); ExitItem.Activated += quitProgram; FileMenu.Append (ExitItem); Menu GestureMenu = new Menu (); MenuItem Gesture = new MenuItem ("Gestures"); Gesture.Submenu = GestureMenu; MenuItem LoadGesture = new MenuItem ("Load Gesture"); LoadGesture.Activated += openGesture; GestureMenu.Append (LoadGesture); MenuItem SaveGestureItem = new MenuItem ("Save Gesture"); SaveGestureItem.Activated += createGesture; GestureMenu.Append (SaveGestureItem); Menu PointsMenu = new Menu (); MenuItem Points = new MenuItem ("Data Points"); Points.Submenu = PointsMenu; MenuItem LoadPointsItem = new MenuItem ("Load Points"); LoadPointsItem.Activated += loadDataPoints; PointsMenu.Append (LoadPointsItem); MenuItem RecordPointsItem = new MenuItem ("Record Points"); RecordPointsItem.Activated += recordPoints; PointsMenu.Append (RecordPointsItem); MenuItem BatchRecognizeItem = new MenuItem ("Batch Recognize"); BatchRecognizeItem.Activated += batchRecognize; PointsMenu.Append (BatchRecognizeItem); Menu HelpMenu = new Menu (); MenuItem Help = new MenuItem ("Help"); Help.Submenu = HelpMenu; MenuItem AboutMenuItem = new MenuItem("About"); HelpMenu.Append (AboutMenuItem); MainMenuBar.Append (File); MainMenuBar.Append (Gesture); MainMenuBar.Append (Points); MainMenuBar.Append (Help); /*********************End of menu bar components*********************/ //Drawing area which is the core component of the application dArea = new DrawingArea (); dArea.SetSizeRequest (500, 500); //Horizontal box (4 sections) which contains all of the buttons along the //bottom of the window HBox ButtonHBox = new HBox (false, 6); /*********************Start of Buttons*********************/ Button BtnCreateGesture = new Button ("Create"); Button BtnRecognizeGesture = new Button ("Recognize"); Button BtnClearScreen = new Button ("Clear"); Button BtnRecordPoints = new Button ("Record points"); Button BtnChangeColour = new Button ("Change colour"); //Button functions BtnCreateGesture.Clicked += new EventHandler (createGesture); BtnRecognizeGesture.Clicked += new EventHandler (recognizeGesture); BtnClearScreen.Clicked += new EventHandler (clearScreen); BtnRecordPoints.Clicked += new EventHandler (recordPoints); BtnChangeColour.Clicked += changeColour; //Adding buttons to the current horizontal box ButtonHBox.PackStart (BtnCreateGesture, true, false, 0); ButtonHBox.PackStart (BtnRecognizeGesture, true, false, 0); ButtonHBox.PackStart (BtnClearScreen, true, false, 0); ButtonHBox.PackStart (BtnRecordPoints, true, false, 0); ButtonHBox.PackStart (BtnChangeColour, true, false, 0); /*********************End of Buttons*********************/ //Status bar which shows the score and recognized gesture sBar = new Statusbar (); sBar.Push (1, "Ready"); //Entry box for batch function name to be used on the files batchFunctionName = new Entry ("Recorded points function name"); batchFunctionName.AddEvents ( (int)Gdk.EventMask.ButtonPressMask ); batchFunctionName.ButtonPressEvent += clearTextBox; //Adding all components to the Vertical box MainVBox.PackStart (MainMenuBar, false, false, 0); MainVBox.PackStart (dArea, false, false, 0); MainVBox.PackStart (ButtonHBox, false, false, 0); MainVBox.PackStart (batchFunctionName, false, false, 0); MainVBox.PackStart (sBar, false, false, 0); Add (MainVBox); ShowAll (); //Surface 'pattern' for area to be covered surface = new ImageSurface(Format.Argb32, 500, 500); //Adding mouse events to the drawing area and assigning functions dArea.AddEvents( //Mouse Related Events (int)Gdk.EventMask.PointerMotionMask |(int)Gdk.EventMask.ButtonPressMask |(int)Gdk.EventMask.ButtonReleaseMask ); //Repaint the Canvas Internally. dArea.ExposeEvent += OnDrawingAreaExposed; //Do this on MousePress inside Area dArea.ButtonPressEvent += OnMousePress; //Do this on MouseReleased inside Area dArea.ButtonReleaseEvent += OnMouseRelease; //Do this if a Motion Occurs inside the Drawing Area dArea.MotionNotifyEvent += OnMouseMotion2; //Assigning close function to the window DeleteEvent += delegate { Application.Quit(); }; //Checking to see if bool for using the dot function is true //And assigning the required function as the delegate's operation //Note: This will always be true, no current way to switch while //application is running, has not been needed as of yet if (isDot) { Painter = new DrawShape (DrawDot); myoPainter = new DrawShape (DrawDot); } else { Painter = new DrawShape (DrawLine); } }
// Request geometry and new message to the layer private async void AddSymbolAsync(DrawShape requestedShape) { try { // Keep adding messages until next symbol is selected while (true) { Esri.ArcGISRuntime.Geometry.Geometry geometry = null; try { geometry = await MyMapView.Editor.RequestShapeAsync(requestedShape, null, null); } catch { } if (geometry == null) { return; } // Create a new message Message msg = new Message(); // Set the ID and other parts of the message msg.Id = Guid.NewGuid().ToString(); msg.Add("_type", "position_report"); msg.Add("_action", "update"); msg.Add("_wkid", MyMapView.SpatialReference.Wkid.ToString()); msg.Add("sic", _selectedSymbol.SymbolID); msg.Add("uniquedesignation", "1"); // Construct the Control Points based on the geometry type of the drawn geometry. switch (requestedShape) { case DrawShape.Point: MapPoint point = geometry as MapPoint; msg.Add("_control_points", point.X.ToString(CultureInfo.InvariantCulture) + "," + point.Y.ToString(CultureInfo.InvariantCulture)); break; case DrawShape.Polygon: Polygon polygon = geometry as Polygon; string cpts = string.Empty; foreach (var pt in polygon.Parts[0].GetPoints()) { cpts += ";" + pt.X.ToString(CultureInfo.InvariantCulture) + "," + pt.Y.ToString(CultureInfo.InvariantCulture); } msg.Add("_control_points", cpts); break; case DrawShape.Polyline: Polyline polyline = geometry as Polyline; cpts = string.Empty; foreach (var pt in polyline.Parts[0].GetPoints()) { cpts += ";" + pt.X.ToString(CultureInfo.InvariantCulture) + "," + pt.Y.ToString(CultureInfo.InvariantCulture); } msg.Add("_control_points", cpts); break; } // Process the message if (!_messageLayer.ProcessMessage(msg)) { MessageBox.Show("Failed to process message."); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Symbol Dictionary Search Sample"); } }
private void FormPuntoVentaNuevo_Paint(object sender, PaintEventArgs e) { DrawShape drawShape = new DrawShape(); drawShape.lineBorder(panel12, 157, 157, 157); }
private void FormScreenshot_MouseUp(object sender, MouseEventArgs e) { if (!draw) { if (e.Button == MouseButtons.Left) { // 正常绘制鼠标抬起 if (!draw && cropBoxControl == 0 && !cropBoxRectangleMove) { cropBoxRectangle = GetRectangleFromPoint(startPoint, e.Location); } // 调整裁剪框大小 if (cropBoxControl != 0 && !cropBoxRectangleMove) { cropBoxControl = 0; cropBoxRectangle = GetRectangleFromSize(cropBoxRectangle.Location, cropBoxRectangle.Size); } // 移动裁剪框 if (cropBoxRectangleMove) { cropBoxRectangleMove = false; } draw = true; DrawInitialization(); } } else { if (draw && toolbarPanelActive != null && cropBoxRectangle.Contains(startPoint)) { string type = GetToolbarPanelActive(); if (type == "Rectangle" || type == "Circular") { DrawShape temp = GetDrawShape(GetToolbarPanelActive(), e); if (temp.rect.X < maxCropPoint.X) { maxCropPoint.X = temp.rect.X; } if (temp.rect.Y < maxCropPoint.Y) { maxCropPoint.Y = temp.rect.Y; } if (temp.rect.X + temp.rect.Width > minCropPoint.X) { minCropPoint.X = temp.rect.X + temp.rect.Width; } if (temp.rect.Y + temp.rect.Height > minCropPoint.Y) { minCropPoint.Y = temp.rect.Y + temp.rect.Height; } drawShapeList.Add(temp); } if (type == "Brush") { drawShapeList.Add(DrawShapeBrushTemp); DrawShapeBrushTemp = null; } } if (e.Button == MouseButtons.Right && drawShapeList.Count == 0 && !cropBoxRectangle.Contains(e.Location)) { draw = false; cropBoxRectangle = new Rectangle(); toolbarPanel.Visible = false; colorPanel.Visible = false; } } }
/* ---------------------------------------------------------------------- MyDrawShape uses a delegate to indicate which method to call ----------------------------------------------------------------------*/ private void MyDrawShape(DrawShape theDelegate ) { // Are any text fields blank? if (txtLeft.Text.Length == 0 || txtTop.Text.Length == 0 || txtWidth.Text.Length == 0 || txtHeight.Text.Length == 0) { MessageBox.Show("Please fill in all text boxes", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Get the coordinate values entered in the text fields Rectangle aRect = new Rectangle(Int32.Parse(txtLeft.Text), Int32.Parse(txtTop.Text), Int32.Parse(txtWidth.Text), Int32.Parse(txtHeight.Text)); // Make sure the coordinates are in range if (mRect.Contains(aRect)) { // Get the color of the btnColor button Brush aBrush = new SolidBrush(btnColor.BackColor); // Call the delegate, to draw the specified shape theDelegate(aBrush, aRect); } else { // Display error message, and return immediately MessageBox.Show("Coordinates are outside drawing area", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/** Draw this shape so that it touches the left edge of the target shape, * or if gap is > 0 then place that many pixels of gap between the two shapes. * * @param graphics the IGraphics context used to draw the shape * @param target the target shape on whose left edge this is drawn * @param targetOffsetX the X amount to offset the target shape. Note that * the target shape is placed with the offset and this shape * is placed to the left of it. * @param targetOffsetY the Y amount to offset the target shape * @param gap amount of space between the two shapes. If zero, * then the two shapes touch. If 1, then there is one * pixel between them, etc. * @see #draw */ public void drawLeftOf(IGraphics graphics, DrawShape target, int targetOffsetX, int targetOffsetY, int gap) { // Note that to get the two shapes to just touch with zero gap, the // value of _rightEdge must be one left of the value of target._leftEdge int offsetX = targetOffsetX + target._leftEdge - (_rightEdge + gap + 1); graphics.Translate(offsetX, targetOffsetY); graphics.DrawPolyline(_xPoints, _yPoints, _xPoints.Length); graphics.Translate(-offsetX, -targetOffsetY); }
// Request geometry and new message to the layer private async Task AddSymbolAsync(DrawShape requestedShape) { try { // Keep adding messages until next symbol is selected while (true) { var geometry = await mapView.Editor.RequestShapeAsync(requestedShape, null, null); // Create a new message Message msg = new Message(); // Set the ID and other parts of the message msg.Id = Guid.NewGuid().ToString(); msg.Add("_type", "position_report"); msg.Add("_action", "update"); msg.Add("_wkid", "3857"); msg.Add("sic", _selectedSymbol.SymbolID); msg.Add("uniquedesignation", "1"); // Construct the Control Points based on the geometry type of the drawn geometry. switch (requestedShape) { case DrawShape.Point: MapPoint point = geometry as MapPoint; msg.Add("_control_points", point.X.ToString(CultureInfo.InvariantCulture) + "," + point.Y.ToString(CultureInfo.InvariantCulture)); break; case DrawShape.Polygon: Polygon polygon = geometry as Polygon; string cpts = string.Empty; foreach (var pt in polygon.Rings[0]) { cpts += ";" + pt.X.ToString(CultureInfo.InvariantCulture) + "," + pt.Y.ToString(CultureInfo.InvariantCulture); } msg.Add("_control_points", cpts); break; case DrawShape.Polyline: Polyline polyline = geometry as Polyline; cpts = string.Empty; foreach (var pt in polyline.Paths[0]) { cpts += ";" + pt.X.ToString(CultureInfo.InvariantCulture) + "," + pt.Y.ToString(CultureInfo.InvariantCulture); } msg.Add("_control_points", cpts); break; } // Process the message if (!_messageLayer.ProcessMessage(msg)) { await new MessageDialog("Failed to process message.", "Symbol Dictionary Search Sample").ShowAsync(); } } } catch (TaskCanceledException taskCanceledException) { // Requsting geometry was canceled. } catch (Exception ex) { var _ = new MessageDialog(ex.Message, "Symbol Dictionary Search Sample").ShowAsync(); } }
private void panel2_Paint(object sender, PaintEventArgs e) { DrawShape drawShape = new DrawShape(); drawShape.lineBorder(panel2, 157, 157, 157); }
/// <summary> /// /// </summary> /// <param name="cam"></param> /// <param name="windowWidth"></param> /// <param name="windowHeight"></param> public void Draw(Camera cam, int windowWidth, int windowHeight) { // if model not loaded do nothing if (JointManager == null) { return; } // store previous hitbox state info CalculatePreviousState(); // reset model parts if (ModelPartsIndices != null) { for (int i = 0; i < ModelPartsIndices.Length; i++) { ModelPartsIndices[i].AnimIndex = -1; } } // process ftcmd SubactionProcess.SetFrame(viewport.Frame); // update display info JointManager.DOBJManager.OverlayColor = SubactionProcess.OverlayColor; JointManager._settings.RenderBones = bonesToolStripMenuItem.Checked; // apply model animations JointManager.Frame = viewport.Frame; JointManager.UpdateNoRender(); // character invisibility if (!SubactionProcess.CharacterInvisibility && modelToolStripMenuItem.Checked) { JointManager.Render(cam, false); } // hurtbox collision if (hurtboxesToolStripMenuItem.Checked) { HurtboxRenderer.Render(JointManager, Hurtboxes, null, SubactionProcess.BoneCollisionStates, SubactionProcess.BodyCollisionState); } // hitbox collision int hitboxId = 0; bool isHitboxSelected = false; foreach (var hb in SubactionProcess.Hitboxes) { if (!hb.Active) { hitboxId++; continue; } float alpha = 0.4f; Vector3 hbColor = HitboxColor; var worldPosition = hb.GetWorldPosition(JointManager); var worldTransform = Matrix4.CreateTranslation(worldPosition); if (hb.Element == 8) { hbColor = GrabboxColor; } if (subActionList.SelectedIndices.Count == 1 && hb.CommandIndex == subActionList.SelectedIndex) { hbColor = HitboxSelectedColor; isHitboxSelected = true; _transWidget.Transform = hb.GetWorldTransform(JointManager); } // drawing a capsule takes more processing power, so only draw it if necessary if (hb.Interpolate && interpolationToolStripMenuItem.Checked) { capsule.SetParameters(worldPosition, PreviousPositions[hitboxId], hb.Size); capsule.Draw(Matrix4.Identity, new Vector4(hbColor, alpha)); } else { DrawShape.DrawSphere(worldTransform, hb.Size, 16, 16, hbColor, alpha); } // draw hitbox angle if (hitboxInfoToolStripMenuItem.Checked) { if (hb.Angle != 361) { DrawShape.DrawAngleLine(cam, worldTransform, hb.Size, MathHelper.DegreesToRadians(hb.Angle)); } else { DrawShape.DrawSakuraiAngle(cam, worldTransform, hb.Size); } GLTextRenderer.RenderText(cam, hitboxId.ToString(), worldTransform, StringAlignment.Center, true); } hitboxId++; } // draw shield during guard animation if (DisplayShieldSize > 0) { DrawShape.DrawSphere(JointManager.GetWorldTransform(JointManager.JointCount - 2), DisplayShieldSize, 16, 16, ShieldColor, 0.5f); } // gfx spawn indicator foreach (var gfx in SubactionProcess.GFXOnFrame) { var boneID = gfx.Bone; if (boneID == 0) { if (JointManager.GetJOBJ(1) != null && JointManager.GetJOBJ(1).Child == null) // special case for character like mewtwo with a leading bone { boneID = 2; } else { boneID = 1; } } var transform = Matrix4.CreateTranslation(gfx.Position) * JointManager.GetWorldTransform(boneID); transform = transform.ClearScale(); DrawShape.DrawSphere(transform, 1f, 16, 16, ThrowDummyColor, 0.5f); } // environment collision if (ECB != null) { var topN = JointManager.GetWorldTransform(1).ExtractTranslation(); var bone1 = Vector3.TransformPosition(Vector3.Zero, JointManager.GetWorldTransform(ECB.ECBBone1)); var bone2 = Vector3.TransformPosition(Vector3.Zero, JointManager.GetWorldTransform(ECB.ECBBone2)); var bone3 = Vector3.TransformPosition(Vector3.Zero, JointManager.GetWorldTransform(ECB.ECBBone3)); var bone4 = Vector3.TransformPosition(Vector3.Zero, JointManager.GetWorldTransform(ECB.ECBBone4)); var bone5 = Vector3.TransformPosition(Vector3.Zero, JointManager.GetWorldTransform(ECB.ECBBone5)); var bone6 = Vector3.TransformPosition(Vector3.Zero, JointManager.GetWorldTransform(ECB.ECBBone6)); var minx = float.MaxValue; var miny = float.MaxValue; var maxx = float.MinValue; var maxy = float.MinValue; foreach (var p in new Vector3[] { bone1, bone2, bone3, bone4, bone5, bone6 }) { minx = Math.Min(minx, p.Z); maxx = Math.Max(maxx, p.Z); miny = Math.Min(miny, p.Y); maxy = Math.Max(maxy, p.Y); } // ecb diamond if (eCBToolStripMenuItem.Checked) { DrawShape.DrawECB(topN, minx, miny, maxx, maxy, groundECH.Checked); } // ledge grav if (ledgeGrabBoxToolStripMenuItem.Checked) { var correct = Math.Abs(minx - maxx) / 2; //behind DrawShape.DrawLedgeBox( topN.Z, topN.Y + ECB.VerticalOffsetFromTop - ECB.VerticalScale / 2, topN.Z - (correct + ECB.HorizontalScale), topN.Y + ECB.VerticalOffsetFromTop + ECB.VerticalScale / 2, Color.Red); // in front DrawShape.DrawLedgeBox( topN.Z, topN.Y + ECB.VerticalOffsetFromTop - ECB.VerticalScale / 2, topN.Z + correct + ECB.HorizontalScale, topN.Y + ECB.VerticalOffsetFromTop + ECB.VerticalScale / 2, Color.Blue); } } // throw dummy if (ThrowDummyManager.Animation.NodeCount != 0 && throwModelToolStripMenuItem.Checked && !SubactionProcess.ThrownFighter && ThrowDummyManager.JointCount > 0) { if (viewport.Frame < ThrowDummyManager.Animation.FrameCount) { ThrowDummyManager.Frame = viewport.Frame; } ThrowDummyManager.SetWorldTransform(4, JointManager.GetWorldTransform(JointManager.JointCount - 2)); ThrowDummyManager.Render(cam, false); if (ThrowDummyLookupTable.Count == 0) { DrawShape.DrawSphere(ThrowDummyManager.GetWorldTransform(35), 1.5f, 16, 16, ThrowDummyColor, 0.5f); DrawShape.DrawSphere(ThrowDummyManager.GetWorldTransform(4), 1.5f, 16, 16, ThrowDummyColor, 0.5f); DrawShape.DrawSphere(ThrowDummyManager.GetWorldTransform(10), 1f, 16, 16, ThrowDummyColor, 0.5f); DrawShape.DrawSphere(ThrowDummyManager.GetWorldTransform(15), 1f, 16, 16, ThrowDummyColor, 0.5f); DrawShape.DrawSphere(ThrowDummyManager.GetWorldTransform(22), 1f, 16, 16, ThrowDummyColor, 0.5f); DrawShape.DrawSphere(ThrowDummyManager.GetWorldTransform(40), 1f, 16, 16, ThrowDummyColor, 0.5f); } } if (isHitboxSelected) { _transWidget.Render(cam); } // sword trail //AfterImageRenderer.RenderAfterImage(JointManager, viewport.Frame, after_desc); }
private async Task<Graphic> CreateGraphicAsync(Symbol symbol, DrawShape drawShape) { try { // wait for user to draw the shape var geometry = await CurrentEsriMapView.Editor.RequestShapeAsync(drawShape, symbol); // add the new graphic to the graphic layer var graphic = new Graphic(geometry, symbol); return graphic; } catch (TaskCanceledException) { } catch (Exception ex) { _model.SetMessageInfo("Error drawing graphic: " + ex.Message); } return null; }
void LineClicked(object sender, EventArgs args) { isDrawingPoint = false; Painter = new DrawShape(DrawLine); }
private async void DrawBarrier(DrawShape drawShape) { try { var geometry = await Editor.RequestShapeAsync(drawShape); if(geometry is MapPoint) { ((GraphicsLayer)Map.Layers["PointBarriers"]).Graphics.Add(new Graphic(geometry)); } else if (geometry is Polyline) { ((GraphicsLayer)Map.Layers["PolylineBarriers"]).Graphics.Add(new Graphic(geometry)); } else if (geometry is Polygon) { ((GraphicsLayer)Map.Layers["PolygonBarriers"]).Graphics.Add(new Graphic(geometry)); } if (m_lastRouteLocation != null) UpdateRoute(m_lastRouteLocation); } catch (OperationCanceledException) { } //ignore }
void PenClicked(object sender, EventArgs args) { isDrawingPoint = true; Painter = new DrawShape(DrawPoint); }
private void panelHeader_Paint(object sender, PaintEventArgs e) { DrawShape drawShape = new DrawShape(); drawShape.bottomLine(panelHeader); }
internal static Pen GetPen(TShapeProperties ShProp, ExcelFile Workbook, TShadowInfo ShadowInfo) { return(DrawShape.GetPen(ShProp, Workbook, ShadowInfo)); }
// Request geometry and new message to the layer private async Task AddSymbolAsync(DrawShape requestedShape) { try { // Keep adding messages until next symbol is selected while (true) { var geometry = await mapView.Editor.RequestShapeAsync(requestedShape, null, null); // Create a new message Message msg = new Message(); // Set the ID and other parts of the message msg.Id = Guid.NewGuid().ToString(); msg.Add("_type", "position_report"); msg.Add("_action", "update"); msg.Add("_wkid", "3857"); msg.Add("sic", _selectedSymbol.SymbolID); msg.Add("uniquedesignation", "1"); // Construct the Control Points based on the geometry type of the drawn geometry. switch (requestedShape) { case DrawShape.Point: MapPoint point = geometry as MapPoint; msg.Add("_control_points", point.X.ToString(CultureInfo.InvariantCulture) + "," + point.Y.ToString(CultureInfo.InvariantCulture)); break; case DrawShape.Polygon: Polygon polygon = geometry as Polygon; string cpts = string.Empty; foreach (var pt in polygon.Rings[0]) cpts += ";" + pt.X.ToString(CultureInfo.InvariantCulture) + "," + pt.Y.ToString(CultureInfo.InvariantCulture); msg.Add("_control_points", cpts); break; case DrawShape.Polyline: Polyline polyline = geometry as Polyline; cpts = string.Empty; foreach (var pt in polyline.Paths[0]) cpts += ";" + pt.X.ToString(CultureInfo.InvariantCulture) + "," + pt.Y.ToString(CultureInfo.InvariantCulture); msg.Add("_control_points", cpts); break; } // Process the message if (!_messageLayer.ProcessMessage(msg)) await new MessageDialog("Failed to process message.", "Symbol Dictionary Search Sample").ShowAsync(); } } catch (TaskCanceledException taskCanceledException) { // Requsting geometry was canceled. } catch (Exception ex) { var _ = new MessageDialog(ex.Message, "Symbol Dictionary Search Sample").ShowAsync(); } }
public void Work(object obj) { IsObsolete = true; string message; DrawShape type = (DrawShape)obj; Symbol symbol = null; switch (type) { case DrawShape.Point: symbol = new SimpleMarkerSymbol(); ((SimpleMarkerSymbol)symbol).Color = System.Windows.Media.Colors.Blue; ((SimpleMarkerSymbol)symbol).Size = 15; break; case DrawShape.Polyline: symbol = new SimpleLineSymbol(); ((SimpleLineSymbol)symbol).Color = System.Windows.Media.Colors.Blue; ((SimpleLineSymbol)symbol).Style = SimpleLineStyle.Dash; ((SimpleLineSymbol)symbol).Width = 2; break; case DrawShape.Polygon: symbol = new SimpleLineSymbol(); ((SimpleLineSymbol)symbol).Color = System.Windows.Media.Colors.Blue; ((SimpleLineSymbol)symbol).Style = SimpleLineStyle.Dash; ((SimpleLineSymbol)symbol).Width = 2; break; case DrawShape.Circle: symbol = new SimpleLineSymbol(); ((SimpleLineSymbol)symbol).Color = System.Windows.Media.Colors.Blue; ((SimpleLineSymbol)symbol).Style = SimpleLineStyle.Dash; ((SimpleLineSymbol)symbol).Width = 2; break; case DrawShape.Envelope: break; case DrawShape.Rectangle: symbol = new SimpleLineSymbol(); ((SimpleLineSymbol)symbol).Color = System.Windows.Media.Colors.Blue; ((SimpleLineSymbol)symbol).Style = SimpleLineStyle.Dash; ((SimpleLineSymbol)symbol).Width = 2; break; case DrawShape.Freehand: break; case DrawShape.Arrow: break; case DrawShape.Triangle: break; case DrawShape.Ellipse: break; case DrawShape.LineSegment: break; default: throw new ArgumentOutOfRangeException(); } Geometry geo; if (symbol != null) { _map.Dispatcher.Invoke( new Action( async delegate { if (_map.MapView.Editor.IsActive) { _map.MapView.Editor.Cancel.Execute(null); } try { geo = await _map.MapView.Editor.RequestShapeAsync(type, symbol); } catch { geo = null; return; } if (geo != null) { // create a new graphic; set the Geometry and Symbol Graphic graphic = new Graphic { Geometry = geo, Symbol = symbol }; // add the graphic to the graphics layer _map.GetGraphicLayer("Drawing").Graphics.Add(graphic); message = "<Document TaskGuid=\"" + Map.TaskGuid + "\" DataGuid = \"" + Id + "\" DataType=\"" + _dataType + "\">"; if (geo is MapPoint) { MapPoint pt = geo as MapPoint; message += "<Geometry Type=\"MapPoint\"><X>" + pt.X + "</X><Y>" + pt.Y + "</Y>"; } else if (geo is Polyline) { Polyline pl = geo as Polyline; message += "<Geometry Type=\"Polyline\">"; foreach (ReadOnlySegmentCollection p in pl.Parts) { message += "<Part>"; foreach (MapPoint pt in p.GetPoints()) { message += "<X>" + pt.X + "</X><Y>" + pt.Y + "</Y>"; } message += "</Part>"; } } else if (geo is Polygon) { Polygon pg = geo as Polygon; message += "<Geometry Type=\"Polygon\">"; foreach (ReadOnlySegmentCollection p in pg.Parts) { message += "<Part>"; message = p.GetPoints().Aggregate(message, (current, pt) => current + ("<X>" + pt.X + "</X><Y>" + pt.Y + "</Y>")); message += "</Part>"; } } message += "</Geometry></Document>"; Callback?.Invoke(message); } else { message = "<Document TaskGuid=\"" + Map.TaskGuid + "\" DataGuid = \"" + Id + "\" DataType=\"" + _dataType + "\">绘制失败</Document>"; Callback?.Invoke(message); } } ) ); } else { message = "<Document TaskGuid=\"" + Map.TaskGuid + "\" DataGuid = \"" + Id + "\" DataType=\"" + _dataType + "\">异常的绘制类型</Document>"; Callback?.Invoke(message); } }
private void panelOrdenVisualizacion_Paint(object sender, PaintEventArgs e) { DrawShape drawShape = new DrawShape(); drawShape.lineBorder(panelOrdenVisualizacion, 157, 157, 157); }
// Retrieve the given shape type from the user private async Task<Geometry> RequestUserShape(DrawShape drawShape, Symbol symbol) { try { graphicsLayer.Graphics.Clear(); var shape = await mapView.Editor.RequestShapeAsync(drawShape, symbol); graphicsLayer.Graphics.Add(new Graphic(shape, symbol)); return shape; } catch (Exception ex) { MessageBox.Show(ex.Message, "Shape Drawing Error"); return null; } }
private void FormDocumentoIdetificaionNuevo_Paint(object sender, PaintEventArgs e) { DrawShape drawShape = new DrawShape(); drawShape.lineBorder(panel12, 157, 157, 157); }
/// <summary> /// /// </summary> /// <param name="cam"></param> /// <param name="windowWidth"></param> /// <param name="windowHeight"></param> public void Draw(Camera cam, int windowWidth, int windowHeight) { // store previous hitbox state info Dictionary <int, Vector3> previousPosition = CalculatePreviousState(); // reset model parts if (ModelPartsIndices != null) { for (int i = 0; i < ModelPartsIndices.Length; i++) { ModelPartsIndices[i].AnimIndex = -1; } } // process ftcmd SubactionProcess.SetFrame(viewport.Frame); // update display info JOBJManager.DOBJManager.OverlayColor = SubactionProcess.OverlayColor; JOBJManager.settings.RenderBones = bonesToolStripMenuItem.Checked; // apply model animations JOBJManager.Frame = viewport.Frame; JOBJManager.UpdateNoRender(); // character invisibility if (!SubactionProcess.CharacterInvisibility && modelToolStripMenuItem.Checked) { JOBJManager.Render(cam, false); } // hurtbox collision if (hurtboxesToolStripMenuItem.Checked) { HurtboxRenderer.Render(JOBJManager, Hurtboxes, null, SubactionProcess.BoneCollisionStates, SubactionProcess.BodyCollisionState); } // hitbox collision foreach (var hb in SubactionProcess.Hitboxes) { var boneID = hb.BoneID; if (boneID == 0) { if (JOBJManager.GetJOBJ(1).Child == null) // special case for character like mewtwo with a leading bone { boneID = 2; } else { boneID = 1; } } var transform = Matrix4.CreateTranslation(hb.Point1) * JOBJManager.GetWorldTransform(boneID); transform = transform.ClearScale(); float alpha = 0.4f; Vector3 hbColor = HitboxColor; if (hb.Element == 8) { hbColor = GrabboxColor; } // drawing a capsule takes more processing power, so only draw it if necessary if (interpolationToolStripMenuItem.Checked && previousPosition != null && previousPosition.ContainsKey(hb.ID)) { var pos = Vector3.TransformPosition(Vector3.Zero, transform); var cap = new Capsule(pos, previousPosition[hb.ID], hb.Size); cap.Draw(Matrix4.Identity, new Vector4(hbColor, alpha)); } else { DrawShape.DrawSphere(transform, hb.Size, 16, 16, hbColor, alpha); } // draw hitbox angle if (hitboxInfoToolStripMenuItem.Checked) { if (hb.Angle != 361) { DrawShape.DrawAngleLine(cam, transform, hb.Size, MathHelper.DegreesToRadians(hb.Angle)); } else { DrawShape.DrawSakuraiAngle(cam, transform, hb.Size); } GLTextRenderer.RenderText(cam, hb.ID.ToString(), transform, StringAlignment.Center, true); } } // environment collision if (ECB != null) { var topN = JOBJManager.GetWorldTransform(1).ExtractTranslation(); var bone1 = Vector3.TransformPosition(Vector3.Zero, JOBJManager.GetWorldTransform(ECB.ECBBone1)); var bone2 = Vector3.TransformPosition(Vector3.Zero, JOBJManager.GetWorldTransform(ECB.ECBBone2)); var bone3 = Vector3.TransformPosition(Vector3.Zero, JOBJManager.GetWorldTransform(ECB.ECBBone3)); var bone4 = Vector3.TransformPosition(Vector3.Zero, JOBJManager.GetWorldTransform(ECB.ECBBone4)); var bone5 = Vector3.TransformPosition(Vector3.Zero, JOBJManager.GetWorldTransform(ECB.ECBBone5)); var bone6 = Vector3.TransformPosition(Vector3.Zero, JOBJManager.GetWorldTransform(ECB.ECBBone6)); var minx = float.MaxValue; var miny = float.MaxValue; var maxx = float.MinValue; var maxy = float.MinValue; foreach (var p in new Vector3[] { bone1, bone2, bone3, bone4, bone5, bone6 }) { minx = Math.Min(minx, p.Z); maxx = Math.Max(maxx, p.Z); miny = Math.Min(miny, p.Y); maxy = Math.Max(maxy, p.Y); } // ecb diamond if (eCBToolStripMenuItem.Checked) { DrawShape.DrawECB(topN, minx, miny, maxx, maxy, groundECH.Checked); } // ledge grav if (ledgeGrabBoxToolStripMenuItem.Checked) { var correct = Math.Abs(minx - maxx) / 2; //behind DrawShape.DrawLedgeBox( topN.Z, topN.Y + ECB.VerticalOffsetFromTop - ECB.VerticalScale / 2, topN.Z - (correct + ECB.HorizontalScale), topN.Y + ECB.VerticalOffsetFromTop + ECB.VerticalScale / 2, Color.Red); // in front DrawShape.DrawLedgeBox( topN.Z, topN.Y + ECB.VerticalOffsetFromTop - ECB.VerticalScale / 2, topN.Z + correct + ECB.HorizontalScale, topN.Y + ECB.VerticalOffsetFromTop + ECB.VerticalScale / 2, Color.Blue); } } // throw dummy if (throwModelToolStripMenuItem.Checked && !SubactionProcess.ThrownFighter && ThrowDummyManager.JointCount > 0) { if (viewport.Frame < ThrowDummyManager.Animation.FrameCount) { ThrowDummyManager.Frame = viewport.Frame; } ThrowDummyManager.SetWorldTransform(4, JOBJManager.GetWorldTransform(JOBJManager.JointCount - 2)); ThrowDummyManager.Render(cam, false); DrawShape.DrawSphere(ThrowDummyManager.GetWorldTransform(35), 1.5f, 16, 16, ThrowDummyColor, 0.5f); DrawShape.DrawSphere(ThrowDummyManager.GetWorldTransform(4), 1.5f, 16, 16, ThrowDummyColor, 0.5f); DrawShape.DrawSphere(ThrowDummyManager.GetWorldTransform(10), 1f, 16, 16, ThrowDummyColor, 0.5f); DrawShape.DrawSphere(ThrowDummyManager.GetWorldTransform(15), 1f, 16, 16, ThrowDummyColor, 0.5f); DrawShape.DrawSphere(ThrowDummyManager.GetWorldTransform(22), 1f, 16, 16, ThrowDummyColor, 0.5f); DrawShape.DrawSphere(ThrowDummyManager.GetWorldTransform(40), 1f, 16, 16, ThrowDummyColor, 0.5f); } }
private void panelFooter_Paint(object sender, PaintEventArgs e) { DrawShape drawShape = new DrawShape(); drawShape.topLine(panelFooter); }
static void Main(string[] args) { DrawShape d = new DrawShape(); d.DrawRec(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void panel1_Paint(object sender, PaintEventArgs e) { if (!ReadyToRender) { return; } panel1.MakeCurrent(); GL.Viewport(0, 0, panel1.Width, panel1.Height); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.PushAttrib(AttribMask.AllAttribBits); GL.MatrixMode(MatrixMode.Modelview); var v = _camera.MvpMatrix; GL.LoadMatrix(ref v); if (EnableCrossHair) { GL.PointSize(5f); GL.Color3(Color.Yellow); GL.Begin(PrimitiveType.Points); GL.Vertex3(CrossHair); GL.End(); } if (EnableFloor) { DrawShape.Floor(); } foreach (var r in Drawables) { r.Draw(_camera, panel1.Width, panel1.Height); } GL.PopAttrib(); if (Selecting) { GL.MatrixMode(MatrixMode.Modelview); GL.LoadIdentity(); var x1 = (mouseStart.X / panel1.Width) * 2 - 1f; var y1 = 1f - (mouseStart.Y / panel1.Height) * 2; var x2 = (mouseEnd.X / panel1.Width) * 2 - 1f; var y2 = 1f - (mouseEnd.Y / panel1.Height) * 2; GL.LineWidth(1f); GL.Color3(1f, 1f, 1f); GL.Begin(PrimitiveType.LineLoop); GL.Vertex2(x1, y1); GL.Vertex2(x2, y1); GL.Vertex2(x2, y2); GL.Vertex2(x1, y2); GL.End(); } panel1.SwapBuffers(); }
/// <summary> /// Adds new feature. Uses Editor to request geometry for the new graphic. /// </summary> private async void AddFeature(TemplatePicker.TemplatePickedEventArgs parameters) { var targetLayer = parameters.Layer; var featureTemplate = parameters.FeatureTemplate; Exception exceptionToHandle = null; // Clear selection since we are now addding new features SelectedFeature = null; _selectedLayer = null; foreach (var layer in Map.Layers.OfType <FeatureLayer>()) { layer.ClearSelection(); } try { // Get symbol for the editor that is used when sketching Symbol symbol = null; var renderer = targetLayer.Renderer ?? targetLayer.FeatureTable.ServiceInfo.DrawingInfo.Renderer; if (renderer != null) { symbol = renderer.GetSymbol(new Graphic(featureTemplate.Prototype.Attributes)); } DrawShape requestedShape = DrawShape.Point; // TODO commented out since always return freehand, in this demo we want to use specific geometry editing //switch (featureTemplate.DrawingTool) //{ // case FeatureEditTool.Polygon: // requestedShape = DrawShape.Polygon; break; // case FeatureEditTool.Freehand: // requestedShape = DrawShape.Freehand; break; // case FeatureEditTool.Point: // requestedShape = DrawShape.Point; break; // case FeatureEditTool.Line: // requestedShape = DrawShape.Polyline; break; // default: // throw new NotImplementedException(); //} if (targetLayer.ID.ToLowerInvariant().Contains("lines")) { requestedShape = DrawShape.Polyline; } else if (targetLayer.ID.ToLowerInvariant().Contains("polygons")) { requestedShape = DrawShape.Polygon; } // Enable geometry editing and wait until it is done, returned geometry is the edited version. var requestedGeometry = await Editor.RequestShapeAsync(requestedShape, symbol, _editingProgress); // Create new feature based on the feature schema and give created geometry to new feature var geodatabaseFeature = new GeodatabaseFeature(targetLayer.FeatureTable.Schema); geodatabaseFeature.Geometry = requestedGeometry; // Copy initial vaulues for attributes from prototype // This is needed since features might have non-nullable fields and in this case // Points uses "EventType" to definde symbol and lines and polygons "symbolId" foreach (var attribute in featureTemplate.Prototype.Attributes) { geodatabaseFeature.Attributes.Add(attribute.Key, attribute.Value); } // Add feature to the layer var newID = await targetLayer.FeatureTable.AddAsync(geodatabaseFeature); // When working with GeodatabaseFeatureServiceTable, edits are not automatically sent to the server // So you can have fine grained control when to do apply edits, here it automatically sends // update when it is done on the client. if (targetLayer.FeatureTable is GeodatabaseFeatureServiceTable) { var featureTable = (GeodatabaseFeatureServiceTable)targetLayer.FeatureTable; await featureTable.ApplyEditsAsync(); } } catch (TaskCanceledException editCancelledException) { // This is raised when editing is cancelled so eat it. } catch (Exception exception) { exceptionToHandle = exception; } if (exceptionToHandle != null) { // Initialization failed, show message and return await MessageService.Instance.ShowMessage(string.Format( "Could not create basemap. Error = {0}", exceptionToHandle.ToString()), "An error occured"); } }
public DrawOptionVm(DrawShape shape, Symbol symbol) { Shape = shape; this.Symbol = symbol; }
private List<MapPoint> AdjustMapPoints(Polyline polyline, DrawShape drawShape) { if (polyline == null || polyline.Parts == null || !polyline.Parts.Any()) { return null; } var mapPoints = new List<MapPoint>(); var points = polyline.Parts.First().GetPoints().ToList(); if (drawShape == DrawShape.Arrow) { // Arrow shapes like axis of advance // requires at least 3 points, 1 back, 2 front, 3 width if (points.Count() == 2) { // add a third point, otherwise the message processor will fail var thridPoint = new MapPoint(points.Last().X, points.Last().Y); points.Add(thridPoint); } mapPoints.AddRange(points.Where(point => point != points.Last())); mapPoints.Reverse(); mapPoints.Add(points.Last()); } else { mapPoints = points; } return mapPoints; }
// Draw and densify a user defined polygon private async void DensifyButton_Click(object sender, RoutedEventArgs e) { try { resultsPanel.Visibility = Visibility.Collapsed; _inputOverlay.Graphics.Clear(); _resultsOverlay.Graphics.Clear(); // Request polygon or polyline from the user DrawShape drawShape = (DrawShape)comboShapeType.SelectedValue; // Use polyline as default Symbol symbolToUse = _lineSymbol; if (drawShape == DrawShape.Polygon) { symbolToUse = _fillSymbol; } var original = await MyMapView.Editor.RequestShapeAsync(drawShape, symbolToUse); // Account for WrapAround var normalized = GeometryEngine.NormalizeCentralMeridian(original); // Add original shape vertices to input graphics layer var coordsOriginal = (normalized as Multipart).Parts.First().GetPoints(); foreach (var mapPoint in coordsOriginal) { _inputOverlay.Graphics.Add(new Graphic(mapPoint, _origVertexSymbol)); } // Get current viewpoints extent from the MapView var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); var viewpointExtent = currentViewpoint.TargetGeometry.Extent; // Densify the shape var densify = GeometryEngine.GeodesicDensify(normalized, viewpointExtent.Width / 100, LinearUnits.Meters); if (densify.GeometryType == GeometryType.Polygon) { _inputOverlay.Graphics.Add(new Graphic(densify, _fillSymbol)); } else { _inputOverlay.Graphics.Add(new Graphic(densify, _lineSymbol)); } // Add new vertices to result graphics layer var coordsDensify = (densify as Multipart).Parts.First().GetPoints(); foreach (var mapPoint in coordsDensify) { _resultsOverlay.Graphics.Add(new Graphic(mapPoint, _newVertexSymbol)); } // Results Dictionary <string, object> results = new Dictionary <string, object>(); results["Length"] = GeometryEngine.GeodesicLength(densify) * METERS_TO_MILES; if (normalized is Polygon) { results["Area"] = GeometryEngine.GeodesicArea(densify) * SQUARE_METERS_TO_MILES; } else { results["Area"] = "N/A"; } results["Vertices Before"] = coordsOriginal.Count(); results["Vertices After"] = coordsDensify.Count(); resultsListView.ItemsSource = results; resultsPanel.Visibility = Visibility.Visible; } catch (TaskCanceledException) { } catch (Exception ex) { MessageBox.Show("Densify Error: " + ex.Message, "Geodesic Densify Sample"); } }
// Retrieve the given shape type from the user private async Task<Geometry> RequestUserShape(DrawShape drawShape, Symbol symbol) { if (_mapView == null) return null; try { _graphicsOverlay.Graphics.Clear(); var shape = await _mapView.Editor.RequestShapeAsync(drawShape, symbol); _graphicsOverlay.Graphics.Add(new Graphic(shape, symbol)); return shape; } catch (TaskCanceledException) { return null; } catch (Exception ex) { MessageBox.Show(ex.Message, "Shape Drawing Error"); return null; } }
// Retrieve the given shape type from the user private async Task<Geometry> RequestUserShape(DrawShape drawShape, Symbols.Symbol symbol) { try { _graphicsOverlay.Graphics.Clear(); var shape = await MyMapView.Editor.RequestShapeAsync(drawShape, symbol); _graphicsOverlay.Graphics.Add(new Graphic(shape, symbol)); return shape; } catch (TaskCanceledException) { return null; } catch (Exception ex) { var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync(); return null; } }
// Performs a HitTest on the rendered Messages and selects the results private async Task FindIntersectingGraphicsAsync(DrawShape drawMode) { // Get sub layers of the MessageLayer var messageSubLayers = _messageLayer.ChildLayers.Cast <MessageSubLayer>(); // Create an empty result set IEnumerable <Graphic> results = Enumerable.Empty <Graphic>(); // Set the max hits to 1 int maxHits = 1; // Handle the individual Message selection mode if (drawMode == DrawShape.Point) { // Ask the user for the point of interest MapPoint mapPoint = null; try { mapPoint = await MyMapView.Editor.RequestPointAsync(); } catch (TaskCanceledException) { } // Check the geometry if (Geometry.IsNullOrEmpty(mapPoint)) { return; } // Get the location in screen coordinates var screenPoint = MyMapView.LocationToScreen(mapPoint); // Iterate the Message sub layers and await the HitTestAsync method on each layer foreach (var l in messageSubLayers) { results = results.Concat(await l.HitTestAsync(MyMapView, screenPoint, maxHits)); } } // Handle the multiple Message selection mode else { // Increase the max hits value maxHits = 100; // Ask the user for the area of interest Envelope envelope = null; try { envelope = await MyMapView.Editor.RequestShapeAsync(drawMode) as Envelope; } catch (TaskCanceledException) { } // Check the geometry if (Geometry.IsNullOrEmpty(envelope)) { return; } // Get the screen location of the upper left var upperLeft = MyMapView.LocationToScreen (new MapPoint(envelope.XMin, envelope.YMax, envelope.SpatialReference)); // Get the screen location of the lower right var lowerRight = MyMapView.LocationToScreen (new MapPoint(envelope.XMax, envelope.YMin, envelope.SpatialReference)); // Create a Rect from the two corners var rect = new Rect(upperLeft, lowerRight); // Iterate the Message sub layers and await the HitTestAsync method on each layer foreach (var l in messageSubLayers) { results = results.Concat(await l.HitTestAsync(MyMapView, rect, maxHits)); } } if (results.Count() == 0) { return; } // Iterate the results and modify the Action value to Select then reprocess each Message foreach (var graphic in results) { // Retrieve the Message representation from the MessageLayer for each Graphic returned MilitaryMessage message = _messageLayer.GetMessage(graphic.Attributes["_id"].ToString()) as MilitaryMessage; // Modify the Action to Select message.MessageAction = MilitaryMessageAction.Select; // Reprocess the Message and add to the list if (_messageLayer.ProcessMessage(message)) { selectedMessages.Add(message); } } }
private async Task FindIntersectingGraphicsAsync(DrawShape drawMode) { var messageSubLayers = _messageLayer.ChildLayers.Cast<MessageSubLayer>(); IEnumerable<Graphic> results = Enumerable.Empty<Graphic>(); int maxHits = 1; if (drawMode == DrawShape.Point) { var mapPoint = await MyMapView.Editor.RequestPointAsync(); var screenPoint = MyMapView.LocationToScreen(mapPoint); foreach (var l in messageSubLayers) results = results.Concat(await l.HitTestAsync(MyMapView, screenPoint, maxHits)); } else { maxHits = 100; var geometry = await MyMapView.Editor.RequestShapeAsync(drawMode); var mapEnvelope = (geometry as Envelope).Extent; var upperLeft = MyMapView.LocationToScreen (new MapPoint(mapEnvelope.XMin, mapEnvelope.YMax, geometry.SpatialReference)); var lowerRight = MyMapView.LocationToScreen (new MapPoint(mapEnvelope.XMax, mapEnvelope.YMin, geometry.SpatialReference)); var rect = new Rect(upperLeft, lowerRight); foreach (var l in messageSubLayers) results = results.Concat(await l.HitTestAsync(MyMapView, rect, maxHits)); } if (results.Count() == 0) return; foreach (var graphic in results) { MilitaryMessage message = _messageLayer.GetMessage(graphic.Attributes["_id"].ToString()) as MilitaryMessage; message.MessageAction = MilitaryMessageAction.Select; if (_messageLayer.ProcessMessage(message)) { selectedMessages.Add(message); } } }
// Draw and densify a user defined polygon private async void DensifyButton_Click(object sender, RoutedEventArgs e) { try { resultsPanel.Visibility = Visibility.Collapsed; _inputOverlay.Graphics.Clear(); _resultsOverlay.Graphics.Clear(); // Request polygon or polyline from the user DrawShape drawShape = (DrawShape)comboShapeType.SelectedValue; // Use polyline as default Symbol symbolToUse = _lineSymbol; if (drawShape == DrawShape.Polygon) { symbolToUse = _fillSymbol; } var original = await MyMapView.Editor.RequestShapeAsync(drawShape, symbolToUse); // Account for WrapAround var normalized = GeometryEngine.NormalizeCentralMeridian(original); // Add original shape vertices to input graphics layer var coordsOriginal = (normalized as Multipart).Parts.First().GetPoints(); foreach (var coord in coordsOriginal) { _inputOverlay.Graphics.Add(new Graphic(coord, _origVertexSymbol)); } // Densify the shape var densify = GeometryEngine.GeodesicDensify(normalized, MyMapView.Extent.Width / 100, LinearUnits.Meters); if (densify.GeometryType == GeometryType.Polygon) { _inputOverlay.Graphics.Add(new Graphic(densify, _fillSymbol)); } else { _inputOverlay.Graphics.Add(new Graphic(densify, _lineSymbol)); } // Add new vertices to result graphics layer var coordsDensify = (densify as Multipart).Parts.First().GetPoints(); foreach (var coord in coordsDensify) { _resultsOverlay.Graphics.Add(new Graphic(coord, _newVertexSymbol)); } // Results var results = new List <Tuple <string, object> >() { new Tuple <string, object>("Length", GeometryEngine.GeodesicLength(densify) * METERS_TO_MILES), new Tuple <string, object>("Area", (normalized is Polygon) ? (GeometryEngine.GeodesicArea(densify) * SQUARE_METERS_TO_MILES).ToString("0.000") : "N/A"), new Tuple <string, object>("Vertices Before", coordsOriginal.Count()), new Tuple <string, object>("Vertices After", coordsDensify.Count()) }; resultsListView.ItemsSource = results; resultsPanel.Visibility = Visibility.Visible; } catch (TaskCanceledException) { } catch (Exception ex) { var _x = new MessageDialog("Densify Error: " + ex.Message, "Sample Error").ShowAsync(); } }
// Request geometry and new message to the layer private async void AddSymbolAsync(DrawShape requestedShape) { try { // Keep adding messages until next symbol is selected while (true) { Esri.ArcGISRuntime.Geometry.Geometry geometry = null; try { geometry = await MyMapView.Editor.RequestShapeAsync(requestedShape, null, null); } catch { } if (geometry == null) return; // Create a new message Message msg = new Message(); // Set the ID and other parts of the message msg.Id = Guid.NewGuid().ToString(); msg.Add("_type", "position_report"); msg.Add("_action", "update"); msg.Add("_wkid", MyMapView.SpatialReference.Wkid.ToString()); msg.Add("sic", _selectedSymbol.SymbolID); msg.Add("uniquedesignation", "1"); // Construct the Control Points based on the geometry type of the drawn geometry. switch (requestedShape) { case DrawShape.Point: MapPoint point = geometry as MapPoint; msg.Add("_control_points", point.X.ToString(CultureInfo.InvariantCulture) + "," + point.Y.ToString(CultureInfo.InvariantCulture)); break; case DrawShape.Polygon: Polygon polygon = geometry as Polygon; string cpts = string.Empty; foreach (var pt in polygon.Parts[0].GetPoints()) cpts += ";" + pt.X.ToString(CultureInfo.InvariantCulture) + "," + pt.Y.ToString(CultureInfo.InvariantCulture); msg.Add("_control_points", cpts); break; case DrawShape.Polyline: Polyline polyline = geometry as Polyline; cpts = string.Empty; foreach (var pt in polyline.Parts[0].GetPoints()) cpts += ";" + pt.X.ToString(CultureInfo.InvariantCulture) + "," + pt.Y.ToString(CultureInfo.InvariantCulture); msg.Add("_control_points", cpts); break; } // Process the message if (!_messageLayer.ProcessMessage(msg)) MessageBox.Show("Failed to process message."); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Symbol Dictionary Search Sample"); } }
// Request geometry and new message to the layer private async void AddSymbolAsync(SymbolViewModel symbolViewModel) { try { Dictionary <string, string> values = (Dictionary <string, string>)symbolViewModel.Model.Values; string geometryControlType = values["GeometryType"]; DrawShape requestedShape = DrawShape.Point; switch (geometryControlType) { case "Point": requestedShape = DrawShape.Point; break; case "Line": requestedShape = DrawShape.Polyline; break; case "Polygon": requestedShape = DrawShape.Polygon; break; case "Circle": requestedShape = DrawShape.Circle; break; case "Rectangular": requestedShape = DrawShape.Rectangle; break; default: await new MessageDialog("Selected symbol is not supported in this sample", "Symbol Dictionary Search Sample").ShowAsync(); return; } Esri.ArcGISRuntime.Geometry.Geometry geometry = null; try { geometry = await MyMapView.Editor.RequestShapeAsync(requestedShape, null, null); } catch { } if (geometry == null) { return; } // Create a new message Message msg = new Message(); // Set the ID and other parts of the message msg.Id = Guid.NewGuid().ToString(); msg.Add("_type", "position_report"); msg.Add("_action", "update"); msg.Add("_wkid", MyMapView.SpatialReference.Wkid.ToString()); msg.Add("sic", _selectedSymbol.SymbolID); msg.Add("uniquedesignation", "1"); // Construct the Control Points based on the geometry type of the drawn geometry. switch (requestedShape) { case DrawShape.Point: MapPoint point = geometry as MapPoint; msg.Add("_control_points", point.X.ToString(CultureInfo.InvariantCulture) + "," + point.Y.ToString(CultureInfo.InvariantCulture)); break; case DrawShape.Polygon: Polygon polygon = geometry as Polygon; string cpts = string.Empty; foreach (var pt in polygon.Parts[0].GetPoints()) { cpts += ";" + pt.X.ToString(CultureInfo.InvariantCulture) + "," + pt.Y.ToString(CultureInfo.InvariantCulture); } msg.Add("_control_points", cpts); break; case DrawShape.Polyline: Polyline polyline = geometry as Polyline; cpts = string.Empty; foreach (var pt in polyline.Parts[0].GetPoints()) { cpts += ";" + pt.X.ToString(CultureInfo.InvariantCulture) + "," + pt.Y.ToString(CultureInfo.InvariantCulture); } msg.Add("_control_points", cpts); break; } // Process the message if (!_messageLayer.ProcessMessage(msg)) { await new MessageDialog("Failed to process message.", "Symbol Dictionary Search Sample").ShowAsync(); } } catch (Exception ex) { var _ = new MessageDialog(ex.Message, "Symbol Dictionary Search Sample").ShowAsync(); } }
/* ---------------------------------------------------------------- Handle the Click event for the btnDrawRect button ----------------------------------------------------------------*/ private void btnDrawRect_Click(object sender, System.EventArgs e) { // Create a Graphics object (we need its FillRectangle method) Graphics aGraphics = CreateGraphics(); // Declare a MyDelegate variable DrawShape DrawRectangleMethod; // Create a delegate object, and bind to the FillRectangle method DrawRectangleMethod = new DrawShape(aGraphics.FillRectangle); // Call MyDrawShape, and pass the delegate as a parameter MyDrawShape(DrawRectangleMethod); }
private void NextShape(DrawShape shape) { //SelectedShape = shape; model.Shape = shape; }
private void panelContainer_Paint(object sender, PaintEventArgs e) { DrawShape drawShape = new DrawShape(); drawShape.lineBorder(panelContainer); }
/// <summary> /// /// </summary> /// <param name="cam"></param> /// <param name="frame"></param> public void Render(Camera cam, float frame) { if (frame == -1 && entryAnimation.Count > 0) { entryAnimation.Clear(); } if (frame == 0) { entryAnimation.Clear(); // Load Animation foreach (var i in Icons) { if (i.AnimJoint == null) { continue; } var a = new JointAnimManager(); a.FromAnimJoint(i.AnimJoint); entryAnimation.Add(i, a); } } for (int i = 0; i < Icons.Length; i++) { var ico = Icons[i]; if (ico.Joint == null) { continue; } var transform = Matrix4.Identity; if (entryAnimation.ContainsKey(ico)) { transform = entryAnimation[ico].GetAnimatedMatrix(frame, 0, ico.Joint); } else { transform = Matrix4.CreateScale(ico.Joint.SX, ico.Joint.SY, ico.Joint.SZ) * Matrix4.CreateFromQuaternion(Math3D.FromEulerAngles(ico.Joint.RZ, ico.Joint.RY, ico.Joint.RX)) * Matrix4.CreateTranslation(ico.Joint.TX, ico.Joint.TY, ico.Joint.TZ); } if (IconJOBJManager.JointCount > 0) { IconJOBJManager.SetWorldTransform(0, transform); ico.IconTOBJ.Flags = TOBJ_FLAGS.LIGHTMAP_DIFFUSE | TOBJ_FLAGS.COLORMAP_MODULATE | TOBJ_FLAGS.ALPHAMAP_MODULATE; IconJOBJManager.GetJOBJ(0).Child.Dobj.Next.Mobj.Textures = ico.IconTOBJ; IconJOBJManager.Render(cam, false); } if (sssEditor.SelectedIndices.Contains(i)) { if (sssEditor.SelectedIndices.Count == 1 && StageNameJOBJManager.JointCount > 0) { ico.NameTOBJ.Flags = TOBJ_FLAGS.LIGHTMAP_DIFFUSE | TOBJ_FLAGS.COLORMAP_MODULATE | TOBJ_FLAGS.ALPHAMAP_MODULATE; StageNameJOBJManager.GetJOBJ(0).Child.Child.Dobj.Mobj.Textures = ico.NameTOBJ; } var rect = ico.ToRectangle(); DrawShape.DrawRectangle(rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height, ico.Joint.TZ, 2, MEX_CSSIconEntry.SelectedIconColor); if (Dragging) { DrawShape.Line(new Vector3(-100, rect.Y, 0), new Vector3(100, rect.Y, 0), SnapColor, 1); DrawShape.Line(new Vector3(rect.X, -100, 0), new Vector3(rect.X, 100, 0), SnapColor, 1); DrawShape.Line(new Vector3(-100, rect.Y + rect.Height, 0), new Vector3(100, rect.Y + rect.Height, 0), SnapColor, 1); DrawShape.Line(new Vector3(rect.X + rect.Width, -100, 0), new Vector3(rect.X + rect.Width, 100, 0), SnapColor, 1); } } } StageNameJOBJManager.Render(cam); }
// Performs a HitTest on the rendered Messages and selects the results private async Task FindIntersectingGraphicsAsync(DrawShape drawMode) { // Get sub layers of the MessageLayer var messageSubLayers = _messageLayer.ChildLayers.Cast<MessageSubLayer>(); // Create an empty result set IEnumerable<Graphic> results = Enumerable.Empty<Graphic>(); // Set the max hits to 1 int maxHits = 1; // Handle the individual Message selection mode if (drawMode == DrawShape.Point) { // Ask the user for the point of interest MapPoint mapPoint = null; try { mapPoint = await MyMapView.Editor.RequestPointAsync(); } catch (TaskCanceledException) { } // Check the geometry if (Geometry.IsNullOrEmpty(mapPoint)) return; // Get the location in screen coordinates var screenPoint = MyMapView.LocationToScreen(mapPoint); // Iterate the Message sub layers and await the HitTestAsync method on each layer foreach (var l in messageSubLayers) results = results.Concat(await l.HitTestAsync(MyMapView, screenPoint, maxHits)); } // Handle the multiple Message selection mode else { // Increase the max hits value maxHits = 100; // Ask the user for the area of interest Envelope envelope = null; try { envelope = await MyMapView.Editor.RequestShapeAsync(drawMode) as Envelope; } catch (TaskCanceledException) { } // Check the geometry if (Geometry.IsNullOrEmpty(envelope)) return; // Get the screen location of the upper left var upperLeft = MyMapView.LocationToScreen (new MapPoint(envelope.XMin, envelope.YMax, envelope.SpatialReference)); // Get the screen location of the lower right var lowerRight = MyMapView.LocationToScreen (new MapPoint(envelope.XMax, envelope.YMin, envelope.SpatialReference)); // Create a Rect from the two corners var rect = new Rect(upperLeft, lowerRight); // Iterate the Message sub layers and await the HitTestAsync method on each layer foreach (var l in messageSubLayers) results = results.Concat(await l.HitTestAsync(MyMapView, rect, maxHits)); } if (results.Count() == 0) return; // Iterate the results and modify the Action value to Select then reprocess each Message foreach (var graphic in results) { // Retrieve the Message representation from the MessageLayer for each Graphic returned MilitaryMessage message = _messageLayer.GetMessage(graphic.Attributes["_id"].ToString()) as MilitaryMessage; // Modify the Action to Select message.MessageAction = MilitaryMessageAction.Select; // Reprocess the Message and add to the list if (_messageLayer.ProcessMessage(message)) { selectedMessages.Add(message); } } }
/** Same as drawLeftOf (IGraphics, DrawShape, int, int, int) but takes the * offset as a FinalPoint. * * @see #drawLeftOf (IGraphics, DrawShape, int, int, int) */ public void drawLeftOf(IGraphics graphics, DrawShape target, FinalPoint targetOffset, int gap) { drawLeftOf(graphics, target, targetOffset.x, targetOffset.y, gap); }