This class represents the information needed by graphics to paint when necessary.
상속: EventArgs
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            MyDrawObject.IsEnabled = false;
            ESRI.ArcGIS.Client.Geometry.Polyline polyline = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polyline;
            polyline.SpatialReference = MyMap.SpatialReference;

            Graphic polylineGraphic = new Graphic()
            {
                Geometry = polyline
            };
            List<Graphic> polylineList = new List<Graphic>();
            polylineList.Add(polylineGraphic);

            GeometryService geometryService =
              new GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
            geometryService.AutoCompleteCompleted += GeometryService_AutoCompleteCompleted;
            geometryService.Failed += GeometryService_Failed;

            GraphicsLayer graphicsLayer = MyMap.Layers["ParcelsGraphicsLayer"] as GraphicsLayer;
            List<Graphic> polygonList = new List<Graphic>();
            foreach (Graphic g in graphicsLayer.Graphics)
            {
                g.Geometry.SpatialReference = MyMap.SpatialReference;
                polygonList.Add(g);
            }

            geometryService.AutoCompleteAsync(polygonList, polylineList);
        }
예제 #2
0
파일: GrBesie.cs 프로젝트: virl/fresk
        public override void Draw(DrawEventArgs e)
        {
            if (e.Edited == this)
            {
                for (int i = 0; i < _points.Count - 1; ++i)
                {
                    e.Gr.DrawLine(
                        _boundsPen,
                        _points[i].X,
                        _points[i].Y,
                        _points[i + 1].X,
                        _points[i + 1].Y
                        );
                }

                DrawEventArgs args = new DrawEventArgs(e);
                args.Draw = true;

                foreach(GrPoint pnt in _points)
                    pnt.Draw(args);
            }

            if (e.Draw || e.Edited == this)
            {
                DrawSpline(e.Gr);
            }
        }
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            args.Geometry.SpatialReference = MyMap.SpatialReference;
            Graphic graphic = new Graphic(){ Geometry = args.Geometry };
            if (args.Geometry is Polyline)
              graphic.Symbol = LayoutRoot.Resources["DefaultLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
            else
              graphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;

            graphicsLayer.Graphics.Add(graphic);

            if (graphicsLayer.Graphics.Count == 1)
                MyDrawObject.DrawMode = DrawMode.Point;
            else if (graphicsLayer.Graphics.Count == 2)
            {
                MyDrawObject.IsEnabled = false;
                GeometryService geometryService =
                            new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
                geometryService.DistanceCompleted += GeometryService_DistanceCompleted;
                geometryService.Failed += GeometryService_Failed;

                MyDrawObject.DrawMode = DrawMode.Polyline;

                DistanceParameters distanceParameters = new DistanceParameters()
                {
                    DistanceUnit = LinearUnit.SurveyMile,
                    Geodesic = true
                };

                geometryService.DistanceAsync(graphicsLayer.Graphics[0].Geometry, graphicsLayer.Graphics[1].Geometry,distanceParameters);
                ResponseTextBlock.Text = "The distance between geometries is... ";
            }
        }
예제 #4
0
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            ESRI.ArcGIS.Client.Geometry.MapPoint point = args.Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint;
            point.SpatialReference = MyMap.SpatialReference;
            System.Windows.Point screenPnt = MyMap.MapToScreen(point);

            // Account for difference between Map and application origin
            GeneralTransform generalTransform = MyMap.TransformToVisual(null);
            System.Windows.Point transformScreenPnt = generalTransform.Transform(screenPnt);

            IEnumerable<Graphic> selected =
                parcelGraphicsLayer.FindGraphicsInHostCoordinates(transformScreenPnt);

            foreach (Graphic g in selected)
                if (g.Selected) { g.UnSelect(); selectedGraphics.Remove(g); }
                else { g.Select(); selectedGraphics.Add(g); }

            if (selectedGraphics.Count > 1)
            {
                UnionButton.IsEnabled = true;
                MyDrawObject.IsEnabled = false;
            }
            else
                UnionButton.IsEnabled = false;
        }
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            ESRI.ArcGIS.Client.Geometry.Polygon polygon = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polygon;
            polygon.SpatialReference = MyMap.SpatialReference;
            Graphic graphic = new Graphic()
            {
                Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
                Geometry = polygon,
            };

            GeometryService geometryService =
                new GeometryService("http://serverapps101.esri.com/arcgis/rest/services/Geometry/GeometryServer");
            geometryService.AreasAndLengthsCompleted += GeometryService_AreasAndLengthsCompleted;
            geometryService.Failed += GeometryService_Failed;

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.Graphics.Add(graphic);

            List<Graphic> graphicList = new List<Graphic>();
            graphicList.Add(graphic);

            // Since there are multiple overloads for AreasAndLengthsAsync, make sure to use appropriate signature with correct parameter types.
            geometryService.AreasAndLengthsAsync(graphicList,null,null, (CalculationType)calculationTypeCombo.SelectedValue );

            // GeometryService.AreasAndLengths returns distances and areas in the units of the spatial reference.
            // The units in the map view's projection is decimal degrees.
            // Use the Project method to convert graphic points to a projection that uses a measured unit (e.g. meters).
            // If the map units are in measured units, the call to Project is unnecessary.
            // Important: Use a projection appropriate for your area of interest.
        }
        void myDrawObject_DrawComplete(object sender, DrawEventArgs e)
        {
            _geometryService.CancelAsync();
            _queryTask.CancelAsync();

            Graphic clickGraphic = new Graphic();
            clickGraphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
            clickGraphic.Geometry = e.Geometry;
            // Input spatial reference for buffer operation defined by first feature of input geometry array
            clickGraphic.Geometry.SpatialReference = MyMap.SpatialReference;

            _pointAndBufferGraphicsLayer.ClearGraphics();
            _resultsGraphicsLayer.ClearGraphics();

            clickGraphic.SetZIndex(2);
            _pointAndBufferGraphicsLayer.Graphics.Add(clickGraphic);

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
            {
                BufferSpatialReference = new SpatialReference(4326),
                OutSpatialReference = MyMap.SpatialReference,
                Unit = LinearUnit.Meter,
            };
            bufferParams.Distances.Add(100);
            bufferParams.Features.Add(clickGraphic);

            _geometryService.BufferAsync(bufferParams);
        }
예제 #7
0
파일: GrContour.cs 프로젝트: virl/fresk
        public override void Draw(DrawEventArgs e)
        {
            if (Region.Contours.Count == 0
                || Region.Contours[0].Points.Count < 3)
            {
                base.Draw(e);
                return;
            }

            if (e.Draw || e.Edited == this)
            {
                DrawNonOriented(e.Gr);
            /*				if (_isOriented)
                {
                    DrawOriented(e.Gr);
                }
                else
                {
                    DrawNonOriented(e.Gr);
                }*/
            }

            if(e.Edited != this)
            {
                e.Draw = false;
            }
            base.Draw(e);
        }
        void myDrawObject_DrawComplete(object sender, DrawEventArgs e)
        {
            myDrawObject.IsEnabled = false;
            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();

            Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = e.Geometry,
                Symbol = LayoutRoot.Resources["DefaultClickSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };
            graphic.SetZIndex(1);
            graphicsLayer.Graphics.Add(graphic);

            GeometryService geometryService =
              new GeometryService("http://serverapps101.esri.com/arcgis/rest/services/Geometry/GeometryServer");
            geometryService.BufferCompleted += GeometryService_BufferCompleted;
            geometryService.Failed += GeometryService_Failed;

            BufferParameters bufferParams = new BufferParameters()
            {
                Unit = LinearUnit.StatuteMile,
                OutSpatialReference = MyMap.SpatialReference,
                Geodesic = true
            };
            bufferParams.Features.Add(graphic);
            bufferParams.Distances.Add(5);

            geometryService.BufferAsync(bufferParams);
        }
예제 #9
0
        private void myDrawingSurface_Draw(object sender, DrawEventArgs e)
        {
            game.state.Update(e);
            game.state.Draw(e);

            ThreadPool.QueueUserWorkItem(o =>
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    lScore.Content = Player.Score;
                }));
            });

            ThreadPool.QueueUserWorkItem(o =>
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    label1.Content = Player.LivesLeft;
                }));
            });

            if (Player.LivesLeft == 0)
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    this.Content = new GameOver();
                }));
            }
            e.InvalidateSurface();
        }
예제 #10
0
		private void myDrawingSurface_Draw( object sender, DrawEventArgs e )
		{
			// Render scene
			//sample.Go();
			// Let's go for another turn!
			e.InvalidateSurface();
		}
        void drawObject_DrawComplete(object sender, DrawEventArgs e)
        {
            if (e.Geometry.Extent.Height == 0 | e.Geometry.Extent.Width == 0)
            {
                MessageBox.Show("Please click and drag a box to define an extent", "Error", MessageBoxButton.OK);
                return;
            }

            myDrawObject.IsEnabled = false;

            ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = e.Geometry,
                Symbol = LayoutRoot.Resources["DrawFillSymbol"] as Symbol
            };
            graphicsLayer.Graphics.Add(graphic);

            ESRI.ArcGIS.Client.Geometry.Envelope aoiEnvelope = e.Geometry as ESRI.ArcGIS.Client.Geometry.Envelope;

            string SOEurl = "http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/Elevation/ESRI_Elevation_World/MapServer/exts/ElevationsSOE/ElevationLayers/1/GetElevationData?";

            SOEurl += string.Format(System.Globalization.CultureInfo.InvariantCulture, "Extent={{\"xmin\" : {0}, \"ymin\" : {1}, \"xmax\" : {2}, \"ymax\" :{3},\"spatialReference\" : {{\"wkid\" : {4}}}}}&Rows={5}&Columns={6}&f=json",
                aoiEnvelope.XMin, aoiEnvelope.YMin, aoiEnvelope.XMax, aoiEnvelope.YMax,
                MyMap.SpatialReference.WKID, HeightTextBox.Text, WidthTextBox.Text);

            webClient.OpenReadAsync(new Uri(SOEurl));
        }
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            MyDrawObject.IsEnabled = false;

            ESRI.ArcGIS.Client.Geometry.Polygon polygon = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polygon;
            polygon.SpatialReference = MyMap.SpatialReference;

            geometryService.SimplifyAsync(new List<Graphic>() { new Graphic(){ Geometry = polygon} });
        }
예제 #13
0
 protected override void PreDrawObjects(DrawEventArgs e)
 {
     base.PreDrawObjects(e);
     var vp = e.Display.Viewport;
     if (vp.DisplayMode.EnglishName.ToLower() == "wireframe")
       e.Display.DrawMeshWires(m_mesh, m_color);
     else
       e.Display.DrawMeshShaded(m_mesh, m_material);
 }
예제 #14
0
        private void DrawScene(Scene scene, DrawEventArgs e)
        {
            if (_isSoftwareRendered) return;

            ProcessKeyboardInput(scene);
            scene.Draw();
            // invalidate to get a callback next frame
            e.InvalidateSurface();
        }
예제 #15
0
파일: GrLine.cs 프로젝트: virl/fresk
        public override void Draw(DrawEventArgs e)
        {
            if (e.Draw || e.Edited == this)
            {
                GrUtil.DrawLine(e.Gr, this.Color, _p1.X, _p1.Y, _p2.X, _p2.Y);
            }

            e.Draw = (e.Edited == this);
            _p1.Draw(e); _p2.Draw(e);
        }
예제 #16
0
        private void myDrawingSurface_Draw(object sender, DrawEventArgs e)
        {
            this.appReference.MainViewModel.Manager.Tick();

            // Render scene
            scene.Draw();

            // Let's go for another turn!
            e.InvalidateSurface();
        }
예제 #17
0
        public override void OnPaint(DrawEventArgs pea)
        {
            // After all the children have done their drawing into our backing buffer
            // Display the backing buffer on the screen.
            int x = pea.ClipRect.Left;
            int y = pea.ClipRect.Top;
            int width = pea.ClipRect.Width;
            int height = pea.ClipRect.Height;

            // Render our image to the actual screen
            base.GraphPort.AlphaBlend(x, y, width, height, fBackingBuffer, x, y, width, height, 255);
        }
        private async void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            try
            {
                _myDrawObject.IsEnabled = false;

                if (_cts != null)
                    _cts.Cancel();

                _cts = new CancellationTokenSource();

                QueryTask queryTask =
                      new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/TaxParcel/AssessorsParcelCharacteristics/MapServer/1");
                Query query = new Query()
                {
                    Geometry = args.Geometry,
                    ReturnGeometry = true,
                    OutSpatialReference = MyMap.SpatialReference
                };

                QueryResult parcelsToIntersectResult = await queryTask.ExecuteTaskAsync(query, _cts.Token);

                List<Graphic> graphicList = new List<Graphic>();
                graphicList.Add(new Graphic() { Geometry = args.Geometry });
                SimplifyResult simplifiedIntersectGeometryResult = await _geometryService.SimplifyTaskAsync(graphicList, _cts.Token);

                IntersectResult intersectedParcelsResult = await _geometryService.IntersectTaskAsync(parcelsToIntersectResult.FeatureSet.ToList(), simplifiedIntersectGeometryResult.Results[0].Geometry, _cts.Token);

                Random random = new Random();
                foreach (Graphic g in intersectedParcelsResult.Results)
                {
                    SimpleFillSymbol symbol = new SimpleFillSymbol()
                    {
                        Fill = new System.Windows.Media.SolidColorBrush(
                            System.Windows.Media.Color.FromArgb(255, (byte)random.Next(0, 255), (byte)random.Next(0, 255),
                            (byte)random.Next(0, 255))),
                        BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Black),
                        BorderThickness = 1
                    };
                    g.Symbol = symbol;
                    _intersectGraphicsLayer.Graphics.Add(g);
                }
            }
            catch (Exception ex)
            {
                if (ex is ServiceException)
                {
                    MessageBox.Show(String.Format("{0}: {1}", (ex as ServiceException).Code.ToString(), (ex as ServiceException).Details[0]), "Error", MessageBoxButton.OK);
                    return;
                }
            }
        }
예제 #19
0
파일: GrHermite.cs 프로젝트: virl/fresk
        public override void Draw(DrawEventArgs e)
        {
            if (e.Draw || e.Edited == this)
            {
                DrawSpline(e.Gr);
            }

            if (e.Edited != this)
            {
                e.Draw = false;
            }
            _line1.Draw(e); _line2.Draw(e);
        }
        void drawObject_DrawComplete(object sender, DrawEventArgs e)
        {
            myDrawObject.IsEnabled = false;

            ESRI.ArcGIS.Client.Geometry.Envelope aoiEnvelope = e.Geometry as ESRI.ArcGIS.Client.Geometry.Envelope;

            string SOEurl = "http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/Elevation/ESRI_Elevation_World/MapServer/exts/ElevationsSOE/ElevationLayers/1/GetElevationData?";

            SOEurl += string.Format("Extent={{\"xmin\" : {0}, \"ymin\" : {1}, \"xmax\" : {2}, \"ymax\" :{3},\"spatialReference\" : {{\"wkid\" : {4}}}}}&Rows={5}&Columns={6}&f=json",
                aoiEnvelope.XMin, aoiEnvelope.YMin, aoiEnvelope.XMax, aoiEnvelope.YMax,
                MyMap.SpatialReference.WKID, HeightTextBox.Text, WidthTextBox.Text);

            webClient.OpenReadAsync(new Uri(SOEurl), aoiEnvelope);
        }
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            MyDrawObject.IsEnabled = false;

            ESRI.ArcGIS.Client.Geometry.Polyline polyline = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polyline;
            polyline.SpatialReference = MyMap.SpatialReference;

            GeometryService geometryService =
              new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

            geometryService.CutCompleted += GeometryService_CutCompleted;
            geometryService.Failed += GeometryService_Failed;

            geometryService.CutAsync(parcelGraphicsLayer.Graphics.ToList(), polyline);
        }
예제 #22
0
파일: Maze.cs 프로젝트: Andrusza/Pacman
        public void Draw(DrawEventArgs drawEventArgs, SpriteBatch spriteBatch)
        {
            for (int i = 0; i < numY; i++)
            {
                for (int j = 0; j < numX ; j++)
                {
                    Tile currentTile = Grid[j, i];

                    spriteBatch.Draw(currentTile.texture, currentTile.bounds, Color.White);
                    if (currentTile.coin != null)
                    {
                        Grid[j, i].coin.Draw(drawEventArgs, spriteBatch);
                    }
                }
            }
        }
예제 #23
0
        private void SurfaceOnDraw(object sender, DrawEventArgs args)
        {
            var graphicsDevice = GraphicsDeviceManager.Current.GraphicsDevice;

            graphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);
            graphicsDevice.RasterizerState = RasterizerState.CullNone;
            graphicsDevice.BlendState = BlendState.AlphaBlend;

            graphicsDevice.DepthStencilState = DepthStencilState.Default;

            if (this.ApplicationViewModel.Image != null)
            {
                this.ApplicationViewModel.Image.Draw(GraphicsDeviceManager.Current.GraphicsDevice, aspectRatio);
            }

            args.InvalidateSurface();
        }
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            outputGraphicsLayer.ClearGraphics();

            ESRI.ArcGIS.Client.Geometry.MapPoint point = args.Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint;
            point.SpatialReference = MyMap.SpatialReference;
            Graphic graphic = new Graphic()
            {
                Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
                Geometry = point
            };

            inputGraphicsLayer.Graphics.Add(graphic);

            if (inputGraphicsLayer.Graphics.Count >= 3)
                ConvexButton.IsEnabled = true;
        }
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            MyDrawObject.IsEnabled = false;

            if (MyDrawObject.DrawMode == DrawMode.Point)
            {
                ESRI.ArcGIS.Client.Geometry.MapPoint point = args.Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint;
                point.SpatialReference = MyMap.SpatialReference;
                System.Windows.Point screenPnt = MyMap.MapToScreen(point);

                // Account for difference between Map and application origin
                GeneralTransform generalTransform = MyMap.TransformToVisual(Application.Current.RootVisual);
                System.Windows.Point transformScreenPnt = generalTransform.Transform(screenPnt);

                IEnumerable<Graphic> selected =
                    parcelGraphicsLayer.FindGraphicsInHostCoordinates(transformScreenPnt);

                if (selected.ToArray().Length <= 0)
                {
                    MyDrawObject.IsEnabled = true;
                    return;
                }

                selectedGraphic = selected.ToList()[0] as Graphic;

                selectedGraphic.Select();

                MyDrawObject.DrawMode = DrawMode.Polyline;
                MyDrawObject.IsEnabled = true;

                InfoTextBlock.Text = LayoutRoot.Resources["EndText"] as string;
            }
            else
            {
                ESRI.ArcGIS.Client.Geometry.Polyline polyline = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polyline;
                polyline.SpatialReference = MyMap.SpatialReference;

                GeometryService geometryService =
                  new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

                geometryService.ReshapeCompleted += GeometryService_ReshapeCompleted;
                geometryService.Failed += GeometryService_Failed;

                geometryService.ReshapeAsync(selectedGraphic.Geometry, polyline);
            }
        }
예제 #26
0
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            MyDrawObject.IsEnabled = false;
            offsetGraphicsLayer.ClearGraphics();

            ESRI.ArcGIS.Client.Geometry.MapPoint point = args.Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint;
            point.SpatialReference = MyMap.SpatialReference;
            System.Windows.Point screenPnt = MyMap.MapToScreen(point);

            // Account for difference between Map and application origin
            GeneralTransform generalTransform = MyMap.TransformToVisual(null);
            System.Windows.Point transformScreenPnt = generalTransform.Transform(screenPnt);

            IEnumerable<Graphic> selected =
                parcelGraphicsLayer.FindGraphicsInHostCoordinates(transformScreenPnt);

            List<Graphic> graphicsList = new List<Graphic>();
            foreach (Graphic g in selected)
            {
                graphicsList.Add(g);
            }

            if (graphicsList.Count < 1)
            {
                MyDrawObject.IsEnabled = true;
                return;
            }

            geometryService =
              new GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

            geometryService.OffsetCompleted += GeometryService_OffsetCompleted;
            geometryService.Failed += GeometryService_Failed;

            OffsetParameters offsetParameters = new OffsetParameters()
            {
                BevelRatio = 1.1,
                OffsetDistance = -30,
                OffsetHow = GeometryOffset.Bevelled,
                OffsetUnit = LinearUnit.Meter,
                Simplify = true
            };

            geometryService.OffsetAsync(graphicsList, offsetParameters);
        }
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            ESRI.ArcGIS.Client.Geometry.Polyline polyline = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polyline;
            polyline.SpatialReference = MyMap.SpatialReference;
            Graphic graphic = new Graphic()
            {
                Symbol = LayoutRoot.Resources["DefaultLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
                Geometry = polyline
            };

            GeometryService geometryService =
                            new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
            geometryService.LengthsCompleted += GeometryService_LengthsCompleted;
            geometryService.Failed += GeometryService_Failed;

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.Graphics.Add(graphic);
            geometryService.LengthsAsync(graphicsLayer.Graphics.ToList(), LinearUnit.SurveyMile, CalculationType.Geodesic, null);
        }
예제 #28
0
파일: GrPoint.cs 프로젝트: virl/fresk
        public override void Draw(DrawEventArgs e)
        {
            if (e.Draw)
            {
                Point pnt = GetObjectToWorldTransform().Apply(0, 0);

                Rectangle rect = new Rectangle(
                    pnt.X - _width / 2,
                    pnt.Y - _height / 2,
                    _width - 1,
                    _height - 1
                    );

                e.Gr.FillEllipse(
                    Brushes.Blue,
                    rect
                    );
            }
        }
    protected override void PreDrawObjects(DrawEventArgs e)
    {
        base.PreDrawObjects(e);

        var c_plane = e.Display.Viewport.ConstructionPlane();
        var x_color = Rhino.ApplicationSettings.AppearanceSettings.GridXAxisLineColor;
        var y_color = Rhino.ApplicationSettings.AppearanceSettings.GridYAxisLineColor;
        var z_color = Rhino.ApplicationSettings.AppearanceSettings.GridZAxisLineColor;

        e.Display.PushDepthWriting(false);
        e.Display.PushDepthTesting(false);

        e.Display.DrawPoint(c_plane.Origin, System.Drawing.Color.White);
        e.Display.DrawArrow(new Line(c_plane.Origin, new Vector3d(c_plane.XAxis) * 10.0), x_color);
        e.Display.DrawArrow(new Line(c_plane.Origin, new Vector3d(c_plane.YAxis) * 10.0), y_color);
        e.Display.DrawArrow(new Line(c_plane.Origin, new Vector3d(c_plane.ZAxis) * 10.0), z_color);

        e.Display.PopDepthWriting();
        e.Display.PopDepthTesting();
    }
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            MyDrawObject.IsEnabled = false;

            resultsLayer.ClearGraphics();

            Polyline polyline = args.Geometry as Polyline;
            polyline.SpatialReference = MyMap.SpatialReference;

            geometryService =
            new GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
            geometryService.TrimExtendCompleted += GeometryService_TrimExtendCompleted;
            geometryService.Failed += GeometryService_Failed;

            List<Polyline> polylineList = new List<Polyline>();
            foreach (Graphic g in polylineLayer.Graphics)
                polylineList.Add(g.Geometry as Polyline);

            geometryService.TrimExtendAsync(polylineList, polyline, CurveExtension.DefaultCurveExtension);
        }
예제 #31
0
 public void DrawEditor(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e)
 {
     layer.World.RenderDirectionAxis(Axis, this.WorldMatrix(), 30);
 }
예제 #32
0
 public static void UpdateContext(DrawEventArgs args)
 {
     _hglrc            = OpenGL.wglGetCurrentContext();
     _viewSerialNumber = args.Display.Viewport.ParentView.RuntimeSerialNumber;
 }
예제 #33
0
        private void DrawObject(IObject3D object3D, List <Object3DView> transparentMeshes, bool parentSelected, DrawEventArgs e)
        {
            foreach (var item in object3D.VisibleMeshes())
            {
                // check for correct persistable rendering
                if (MeshViewerWidget.ViewOnlyTexture != null &&
                    item.Mesh.Faces.Count > 0)
                {
                    ImageBuffer faceTexture = null;
                    item.Mesh.FaceTexture.TryGetValue((item.Mesh.Faces[0], 0), out faceTexture);
                    bool hasPersistableTexture = faceTexture == MeshViewerWidget.ViewOnlyTexture;

                    if (item.WorldPersistable())
                    {
                        if (hasPersistableTexture)
                        {
                            // make sure it does not have the view only texture
                            item.Mesh.RemoveTexture(ViewOnlyTexture, 0);
                        }
                    }
                    else
                    {
                        if (!hasPersistableTexture)
                        {
                            // make sure it does have the view only texture
                            var aabb   = item.Mesh.GetAxisAlignedBoundingBox();
                            var matrix = Matrix4X4.CreateScale(.5, .5, 1);
                            matrix *= Matrix4X4.CreateRotationZ(MathHelper.Tau / 8);
                            item.Mesh.PlaceTexture(ViewOnlyTexture, matrix);
                        }
                    }
                }

                Color drawColor = GetItemColor(item);

                bool isDebugItem = (item == scene.DebugItem);

                if (!sceneContext.ViewState.ModelView)
                {
                    if (modelRenderStyle == ModelRenderStyle.WireframeAndSolid)
                    {
                        drawColor = gCodeMeshColor;
                    }
                    else if (modelRenderStyle == ModelRenderStyle.Wireframe)
                    {
                        drawColor = new Color(gCodeMeshColor, 1);
                    }
                    else if (modelRenderStyle == ModelRenderStyle.None)
                    {
                        drawColor = Color.Transparent;
                    }
                }

                if ((drawColor.alpha == 255 &&
                     !item.Mesh.FaceTexture.Where((ft) => ft.Value.HasTransparency).Any()) ||
                    isDebugItem)
                {
                    // Render as solid
                    GLHelper.Render(item.Mesh, drawColor, item.WorldMatrix(), sceneContext.ViewState.RenderType, item.WorldMatrix() * World.ModelviewMatrix, darkWireframe);
                }
                else if (drawColor != Color.Transparent)
                {
                    // Queue for transparency
                    transparentMeshes.Add(new Object3DView(item, drawColor));
                }

                var  selectedItem = scene.SelectedItem;
                bool isSelected   = selectedItem != null &&
                                    (selectedItem.DescendantsAndSelf().Any((i) => i == item) ||
                                     selectedItem.Parents <ModifiedMeshObject3D>().Any((mw) => mw == item));

                if (isSelected && scene.DrawSelection)
                {
                    var frustum = World.GetClippingFrustum();

                    var    selectionColor = Color.White;
                    double secondsSinceSelectionChanged = (UiThread.CurrentTimerMs - lastSelectionChangedMs) / 1000.0;
                    if (secondsSinceSelectionChanged < .5)
                    {
                        var accentColor = Color.LightGray;
                        if (secondsSinceSelectionChanged < .25)
                        {
                            selectionColor = Color.White.Blend(accentColor, Quadratic.InOut(secondsSinceSelectionChanged * 4));
                        }
                        else
                        {
                            selectionColor = accentColor.Blend(Color.White, Quadratic.InOut((secondsSinceSelectionChanged - .25) * 4));
                        }
                        Invalidate();
                    }

                    RenderSelection(item, frustum, selectionColor);
                }

#if DEBUG
                if (isDebugItem)
                {
                    var frustum = World.GetClippingFrustum();

                    var aabb = object3D.GetAxisAlignedBoundingBox(Matrix4X4.Identity);

                    World.RenderAabb(aabb, Matrix4X4.Identity, debugBorderColor, 1);

                    if (item.Mesh != null)
                    {
                        GLHelper.Render(item.Mesh, debugBorderColor, item.WorldMatrix(),
                                        RenderTypes.Wireframe, item.WorldMatrix() * World.ModelviewMatrix);
                    }
                }
#endif

                // RenderNormals(renderData);

                // turn lighting back on after rendering selection outlines
                GL.Enable(EnableCap.Lighting);
            }
        }
예제 #34
0
 void IInternalGameModule.Draw(DrawEventArgs e)
 {
     Draw();
     _updater.Drawing = false;
 }
예제 #35
0
        public void DrawEditor(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e)
        {
            var child = this.Children.FirstOrDefault();

            if (child is IPathObject pathObject)
            {
                // draw the line that is the rotation point
                var aabb         = this.GetAxisAlignedBoundingBox();
                var vertexSource = this.VertexSource.Transform(Matrix);
                var bounds       = vertexSource.GetBounds();
                var lineX        = bounds.Left + AxisPosition.Value(this);

                var start = new Vector3(lineX, aabb.MinXYZ.Y, aabb.MinXYZ.Z);
                var end   = new Vector3(lineX, aabb.MaxXYZ.Y, aabb.MinXYZ.Z);

                layer.World.Render3DLine(start, end, Color.Red, true);
                layer.World.Render3DLine(start, end, Color.Red.WithAlpha(20), false);
            }
        }
예제 #36
0
 /// <summary>
 /// Allows the game to run logic such as updating the world,
 /// checking for collisions, gathering input, and playing audio.
 /// </summary>
 public void Update(DrawEventArgs drawEventArgs)
 {
     HandleInput();
     level.Update(drawEventArgs);
 }
예제 #37
0
 public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
 {
     if (layer.Scene.SelectedItem != null &&
         layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any())
     {
         layer.World.RenderAxis(ScaleAbout, this.WorldMatrix(), 30, 1);
     }
 }
        public void DrawEditor(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e)
        {
            var parentOfSourceItems = this.SourceContainer.DescendantsAndSelfMultipleChildrenFirstOrSelf();

            var sourceItems = parentOfSourceItems.Children.ToList();

            foreach (var paintItem in sourceItems)
            {
                var paintItemResults  = this.Children.Where(i => i.OwnerID == paintItem.ID);
                var wasSelected       = ComputedChildren.Contains(paintItem.ID);
                var currentlySelected = SelectedChildren.Contains(paintItem.ID);

                if (currentlySelected)
                {
                    // if this is selected always paint a transparent source
                    foreach (var item in paintItem.VisibleMeshes())
                    {
                        transparentMeshes.Add(new Object3DView(item, new Color(item.WorldColor(this.SourceContainer), 80)));
                    }

                    // if it was also selected in before (the results are right)
                    if (wasSelected)
                    {
                        // paint solid results
                        if (paintItemResults != null)
                        {
                            foreach (var paintItemResult in paintItemResults)
                            {
                                foreach (var item in paintItemResult.VisibleMeshes())
                                {
                                    GLHelper.Render(item.Mesh,
                                                    item.WorldColor(),
                                                    item.WorldMatrix(),
                                                    RenderTypes.Outlines,
                                                    item.WorldMatrix() * layer.World.ModelviewMatrix);
                                }
                            }
                        }
                    }
                }
                else if (wasSelected)
                {
                    // it is not selected now but was selected before (changed state)
                    // pant the solid source
                    foreach (var item in paintItem.VisibleMeshes())
                    {
                        GLHelper.Render(item.Mesh,
                                        item.WorldColor(),
                                        item.WorldMatrix(),
                                        RenderTypes.Outlines,
                                        item.WorldMatrix() * layer.World.ModelviewMatrix);
                    }
                }
                else                 // it is not selected now and was not before (same state)
                {
                    // paint the results
                    if (paintItemResults != null && paintItemResults.Count() > 0)
                    {
                        foreach (var paintItemResult in paintItemResults)
                        {
                            foreach (var item in paintItemResult.VisibleMeshes())
                            {
                                GLHelper.Render(item.Mesh,
                                                item.WorldColor(),
                                                item.WorldMatrix(),
                                                RenderTypes.Outlines,
                                                item.WorldMatrix() * layer.World.ModelviewMatrix);
                            }
                        }
                    }
                    else                     // we don't have any results yet
                    {
                        foreach (var item in paintItem.VisibleMeshes())
                        {
                            GLHelper.Render(item.Mesh,
                                            item.WorldColor(),
                                            item.WorldMatrix(),
                                            RenderTypes.Outlines,
                                            item.WorldMatrix() * layer.World.ModelviewMatrix);
                        }
                    }
                }
            }
        }
예제 #39
0
 public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
 {
     this.DrawPath();
 }
예제 #40
0
 public void AddEditorTransparents(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e)
 {
 }
예제 #41
0
 public override void Reset(DrawEventArgs args)
 {
 }
예제 #42
0
        public void DrawEditor(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e)
        {
            var aabb = this.WorldAxisAlignedBoundingBox();

            layer.World.RenderCylinderOutline(Matrix4X4.Identity, aabb.Center, Diameter, aabb.ZSize, 90, Color.Red);
            // layer.World.RenderCylinderOutline(Matrix4X4.Identity, Vector3.Zero, Diameter, aabb.ZSize, 30, Color.Green);
        }
 private void DrawMouse(object drawingWidget, DrawEventArgs e)
 {
     automationRunner.RenderMouse(windowToDrawSimulatedMouseOn, e.graphics2D);
 }
예제 #44
0
 private void xrCheckBox2_Draw(object sender, DrawEventArgs e)
 {
 }
예제 #45
0
 private void Form_Drawn(object sender, DrawEventArgs e)
 {
     // draw the tiles and camera rectangle
     DrawMapTiles(e.SpriteBatch);
     DrawCameraRect(e.SpriteBatch);
 }
예제 #46
0
 /// <summary>
 /// Draws a gem in the appropriate color.
 /// </summary>
 public void Draw(DrawEventArgs drawEventArgs, SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(texture, Position, null, Color, 0.0f, origin, 1.0f, SpriteEffects.None, 0.0f);
 }
예제 #47
0
        public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
        {
            var sourceAabb = this.SourceContainer.GetAxisAlignedBoundingBox();
            var center     = sourceAabb.Center + new Vector3(RotationOffset);

            // render the top and bottom rings
            layer.World.RenderCylinderOutline(this.WorldMatrix(), center, 1, sourceAabb.ZSize, 15, Color.Red, Color.Red, 5);

            // turn the lighting back on
            GL.Enable(EnableCap.Lighting);
        }
예제 #48
0
        public void DrawEditor(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e)
        {
            var sourceAabb = this.SourceContainer.GetAxisAlignedBoundingBox();
            var distance   = Diameter / 2 + sourceAabb.YSize / 2;
            var center     = sourceAabb.Center + new Vector3(0, BendCcw ? distance : -distance, 0);

            center.X -= sourceAabb.XSize / 2 - (StartPercent / 100.0) * sourceAabb.XSize;

            // render the top and bottom rings
            layer.World.RenderCylinderOutline(this.WorldMatrix(), center, Diameter, sourceAabb.ZSize, 100, Color.Red, Color.Transparent);

            // render the split lines
            var radius        = Diameter / 2;
            var circumference = MathHelper.Tau * radius;
            var xxx           = sourceAabb.XSize * (StartPercent / 100.0);
            var startAngle    = MathHelper.Tau * 3 / 4 - xxx / circumference * MathHelper.Tau;

            layer.World.RenderCylinderOutline(this.WorldMatrix(), center, Diameter, sourceAabb.ZSize, (int)Math.Max(0, Math.Min(100, this.MinSidesPerRotation)), Color.Transparent, Color.Red, phase: startAngle);

            // turn the lighting back on
            GL.Enable(EnableCap.Lighting);
        }
예제 #49
0
 protected virtual DrawEventArgs OnBeforeDraw(DrawEventArgs arg)
 {
     return(this.BeforeDraw?.Invoke(arg));
 }
예제 #50
0
        private void Draw_GlTransparentContent(object sender, DrawEventArgs e)
        {
            var gcodeOptions = sceneContext.RendererOptions;

            switch (gcodeOptions.GCodeModelView)
            {
            case "Wireframe":
                modelRenderStyle = ModelRenderStyle.Wireframe;
                break;

            case "Semi-Transparent":
                modelRenderStyle = ModelRenderStyle.WireframeAndSolid;
                break;

            default:
                modelRenderStyle = ModelRenderStyle.None;
                break;
            }

            // Draw solid objects, extract transparent
            var transparentMeshes = new List <Object3DView>();

            foreach (var object3D in scene.Children)
            {
                if (object3D.Visible)
                {
                    DrawObject(object3D, transparentMeshes, false, e);
                }
            }

            transparentMeshes.Sort(BackToFrontXY);

            var bedNormalInViewSpace  = Vector3.TransformNormal(Vector3.UnitZ, World.ModelviewMatrix).GetNormal();
            var pointOnBedInViewSpace = Vector3.Transform(new Vector3(10, 10, 0), World.ModelviewMatrix);
            var lookingDownOnBed      = Vector3.Dot(bedNormalInViewSpace, pointOnBedInViewSpace) < 0;

            if (lookingDownOnBed)
            {
                RenderBedMesh(lookingDownOnBed);
            }

            var wireColor = Color.Transparent;

            switch (modelRenderStyle)
            {
            case ModelRenderStyle.Wireframe:
                wireColor = darkWireframe;
                break;

            case ModelRenderStyle.WireframeAndSolid:
                wireColor = lightWireframe;
                break;
            }
            // Draw transparent objects
            foreach (var item in transparentMeshes)
            {
                var object3D = item.Object3D;
                GLHelper.Render(
                    object3D.Mesh,
                    item.Color,
                    object3D.WorldMatrix(),
                    RenderTypes.Outlines,
                    object3D.WorldMatrix() * World.ModelviewMatrix,
                    wireColor);
            }

            if (!lookingDownOnBed)
            {
                RenderBedMesh(lookingDownOnBed);
            }

            // we don't want to render the bed or build volume before we load a model.
            if (scene.HasChildren() || AllowBedRenderingWhenEmpty)
            {
                if (false)                 // this is code to draw a small axis indicator
                {
                    double big   = 10;
                    double small = 1;
                    Mesh   xAxis = PlatonicSolids.CreateCube(big, small, small);
                    GLHelper.Render(xAxis, Color.Red);
                    Mesh yAxis = PlatonicSolids.CreateCube(small, big, small);
                    GLHelper.Render(yAxis, Color.Green);
                    Mesh zAxis = PlatonicSolids.CreateCube(small, small, big);
                    GLHelper.Render(zAxis, Color.Blue);
                }
            }

            DrawInteractionVolumes(e);

            if (scene.DebugItem?.Mesh != null)
            {
                var debugItem = scene.DebugItem;
                GLHelper.Render(debugItem.Mesh, debugBorderColor, debugItem.WorldMatrix(),
                                RenderTypes.Wireframe, debugItem.WorldMatrix() * World.ModelviewMatrix);
            }
        }
예제 #51
0
        private void DrawGlContent(DrawEventArgs e)
        {
            var gcodeOptions = sceneContext.RendererOptions;

            if (gcodeOptions.GCodeModelView)
            {
                modelRenderStyle = ModelRenderStyle.WireframeAndSolid;
            }
            else
            {
                modelRenderStyle = ModelRenderStyle.None;
            }

            foreach (var drawable in drawables.Where(d => d.DrawStage == DrawStage.First))
            {
                if (drawable.Enabled)
                {
                    drawable.Draw(this, e, Matrix4X4.Identity, this.World);
                }
            }

            GLHelper.SetGlContext(this.World, renderSource.TransformToScreenSpace(renderSource.LocalBounds), lighting);

            foreach (var drawable in drawables.Where(d => d.DrawStage == DrawStage.OpaqueContent))
            {
                if (drawable.Enabled)
                {
                    drawable.Draw(this, e, Matrix4X4.Identity, this.World);
                }
            }

            // Draw solid objects, extract transparent
            var transparentMeshes = new List <Object3DView>();

            var  selectedItem       = scene.SelectedItem;
            bool suppressNormalDraw = false;

            if (selectedItem != null)
            {
                // Invoke existing IEditorDraw when iterating items
                if (selectedItem is IEditorDraw editorDraw)
                {
                    // TODO: Putting the drawing code in the IObject3D means almost certain bindings to MatterControl in IObject3D. If instead
                    // we had a UI layer object that used binding to register scene drawing hooks for specific types, we could avoid the bindings
                    editorDraw.DrawEditor(this, transparentMeshes, e, ref suppressNormalDraw);
                }
            }

            foreach (var item in scene.Children)
            {
                if (item.Visible &&
                    (item != selectedItem || suppressNormalDraw == false))
                {
                    DrawObject(item, transparentMeshes, e);
                }
            }

            if (sceneContext.Printer?.Connection?.serialPort is PrinterEmulator.Emulator emulator)
            {
                void NozzlePositionChanged(object s, EventArgs e2)
                {
                    // limit max number of updates per second to 10
                    if (UiThread.CurrentTimerMs > lastEmulatorDrawMs + 100)
                    {
                        UiThread.RunOnIdle(Invalidate);
                        // set it to now
                        lastEmulatorDrawMs = UiThread.CurrentTimerMs;
                    }
                }

                var matrix = Matrix4X4.CreateTranslation(emulator.CurrentPosition + new Vector3(.5, .5, 5));
                GLHelper.Render(emulatorNozzleMesh,
                                MaterialRendering.Color(emulator.ExtruderIndex),
                                matrix,
                                RenderTypes.Shaded,
                                matrix * World.ModelviewMatrix);

                if (!emulatorHooked)
                {
                    emulator.DestinationChanged += NozzlePositionChanged;
                    emulatorHooked = true;
                }

                Closed += (s, e3) => emulator.DestinationChanged -= NozzlePositionChanged;
            }

            transparentMeshes.Sort(BackToFrontXY);

            var bedNormalInViewSpace  = Vector3Ex.TransformNormal(Vector3.UnitZ, World.ModelviewMatrix).GetNormal();
            var pointOnBedInViewSpace = Vector3Ex.Transform(new Vector3(10, 10, 0), World.ModelviewMatrix);
            var lookingDownOnBed      = Vector3Ex.Dot(bedNormalInViewSpace, pointOnBedInViewSpace) < 0;

            floorDrawable.LookingDownOnBed = lookingDownOnBed;

            if (lookingDownOnBed)
            {
                floorDrawable.Draw(this, e, Matrix4X4.Identity, this.World);
            }

            var wireColor = Color.Transparent;

            switch (modelRenderStyle)
            {
            case ModelRenderStyle.Wireframe:
                wireColor = darkWireframe;
                break;

            case ModelRenderStyle.WireframeAndSolid:
                wireColor = lightWireframe;
                break;
            }

            // Draw transparent objects
            foreach (var item in transparentMeshes)
            {
                var object3D = item.Object3D;
                GLHelper.Render(
                    object3D.Mesh,
                    item.Color,
                    object3D.WorldMatrix(),
                    RenderTypes.Outlines,
                    object3D.WorldMatrix() * World.ModelviewMatrix,
                    wireColor,
                    allowBspRendering: transparentMeshes.Count < 1000);
            }

            if (!lookingDownOnBed)
            {
                floorDrawable.Draw(this, e, Matrix4X4.Identity, this.World);
            }

            DrawInteractionVolumes(e);

            foreach (var drawable in drawables.Where(d => d.DrawStage == DrawStage.TransparentContent))
            {
                if (drawable.Enabled)
                {
                    drawable.Draw(this, e, Matrix4X4.Identity, this.World);
                }
            }

            GLHelper.UnsetGlContext();

            // Invoke DrawStage.Last item drawables
            foreach (var item in scene.Children)
            {
                // HACK: Consider how shared code in DrawObject can be reused to prevent duplicate execution
                bool isSelected = selectedItem != null &&
                                  selectedItem.DescendantsAndSelf().Any((i) => i == item);

                foreach (var itemDrawable in itemDrawables.Where(d => d.DrawStage == DrawStage.Last && d.Enabled))
                {
                    itemDrawable.Draw(this, item, isSelected, e, Matrix4X4.Identity, this.World);
                }
            }

            // Invoke DrawStage.Last scene drawables
            foreach (var drawable in drawables.Where(d => d.DrawStage == DrawStage.Last))
            {
                if (drawable.Enabled)
                {
                    drawable.Draw(this, e, Matrix4X4.Identity, this.World);
                }
            }
        }
예제 #52
0
파일: World.cs 프로젝트: idkiller/buttercat
        protected override void OnDraw(object sender, DrawEventArgs args)
        {
            var canvas = args.Canvas;

            canvas.ClipPath(clipPath);

            count = (count + 1) % fps;

            using (var paint = new SKPaint())
            {
                paint.Color = SkyColor;
                paint.Style = SKPaintStyle.Fill;
                canvas.DrawPaint(paint);
            }

            var start = Resource.Background.Width / fps * count;

            canvas.DrawImage(Resource.Background,
                             new SKRect(start, 0, Resource.Background.Width, Resource.Background.Height),
                             new SKRect(0, 0, Geometry.Right - start, Geometry.Bottom));
            if (start > 0)
            {
                canvas.DrawImage(Resource.Background,
                                 new SKRect(0, 0, start, Resource.Background.Height),
                                 new SKRect(Geometry.Right - start, 0, Geometry.Right, Geometry.Bottom));
            }

            if (isStarted)
            {
                foreach (var child in pipes.ToArray())
                {
                    child.Move(-1);
                    if (child.Geometry.Right <= 0)
                    {
                        Children.Remove(child);
                        pipes.Remove(child);
                    }

                    /*
                     * if (child.Geometry.Left < butterCat.Geometry.Right &&
                     *  child.Geometry.Right > butterCat.Geometry.Left &&
                     *  child.Geometry.Top < butterCat.Geometry.Bottom &&
                     *  child.Geometry.Bottom > butterCat.Geometry.Top)
                     * {
                     *  EndGame();
                     * }
                     */
                    if (child.Geometry.IntersectsWith(butterCat.Geometry))
                    {
                        EndGame();
                    }
                }

                int r;
                if (lastPipeTime++ > 80)
                {
                    distance.Distance++;
                    if ((r = random.Next(0, 101)) % 30 < 5)
                    {
                        var pipe = new Pipe(this, random.Next(50, 80), r > 30);
                        pipes.Add(pipe);

                        if (r > 60)
                        {
                            var pipe2 = new Pipe(this, random.Next(50, 120), false);
                            pipes.Add(pipe2);
                        }
                    }
                    lastPipeTime = 0;
                }
            }
        }
예제 #53
0
        private void DrawObject(IObject3D object3D, List <Object3DView> transparentMeshes, DrawEventArgs e)
        {
            var selectedItem = scene.SelectedItem;

            foreach (var item in object3D.VisibleMeshes())
            {
                // check for correct protection rendering
                ValidateViewOnlyTexturing(item);

                Color drawColor = this.GetItemColor(item, selectedItem);

                bool hasTransparentTextures = item.Mesh.FaceTextures.Any(ft => ft.Value.image.HasTransparency);

                if ((drawColor.alpha == 255 &&
                     !hasTransparentTextures) ||
                    (item == scene.DebugItem))
                {
                    // Render as solid
                    GLHelper.Render(item.Mesh,
                                    drawColor,
                                    item.WorldMatrix(),
                                    sceneContext.ViewState.RenderType,
                                    item.WorldMatrix() * World.ModelviewMatrix,
                                    darkWireframe,
                                    () => Invalidate());
                }
                else if (drawColor != Color.Transparent)
                {
                    // Queue for transparency
                    transparentMeshes.Add(new Object3DView(item, drawColor));
                }

                bool isSelected = selectedItem != null &&
                                  (item == selectedItem ||
                                   item.Ancestors().Any(p => p == selectedItem));

                // Invoke all item Drawables
                foreach (var drawable in itemDrawables.Where(d => d.DrawStage != DrawStage.Last && d.Enabled))
                {
                    drawable.Draw(this, item, isSelected, e, Matrix4X4.Identity, this.World);
                }

                // turn lighting back on after rendering selection outlines
                GL.Enable(EnableCap.Lighting);
            }
        }
예제 #54
0
 internal void FireDrawControl(DrawEventArgs args)
 {
     OnDrawControl(args);
 }
예제 #55
0
 public DrawGlContentEventArgs(bool zBuffered, DrawEventArgs e)
     : base(e.Graphics2D)
 {
     ZBuffered = zBuffered;
 }
예제 #56
0
        public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
        {
            if (layer.Scene.SelectedItem != null &&
                layer.Scene.SelectedItem == this)
            {
                suppressNormalDraw = true;

                var removeObjects = this.SourceContainer.VisibleMeshes()
                                    .Where((i) => SelectedChildren.Contains(i.Name)).ToList();
                var keepObjects = this.SourceContainer.VisibleMeshes()
                                  .Where((i) => !SelectedChildren.Contains(i.Name)).ToList();

                foreach (var item in removeObjects)
                {
                    transparentMeshes.Add(new Object3DView(item, new Color(item.WorldColor(SourceContainer), 128)));
                }

                foreach (var item in keepObjects)
                {
                    var subtractChild = this.Children.Where(i => i.Name == item.Name).FirstOrDefault();
                    if (subtractChild != null)
                    {
                        GLHelper.Render(subtractChild.Mesh,
                                        subtractChild.Color,
                                        subtractChild.WorldMatrix(),
                                        RenderTypes.Outlines,
                                        subtractChild.WorldMatrix() * layer.World.ModelviewMatrix);
                    }
                    else
                    {
                        GLHelper.Render(item.Mesh,
                                        item.WorldColor(SourceContainer),
                                        item.WorldMatrix(),
                                        RenderTypes.Outlines,
                                        item.WorldMatrix() * layer.World.ModelviewMatrix);
                    }
                }
            }
        }
예제 #57
0
 public static uiAreaDrawParams ToLibuiAreaDrawParams(DrawEventArgs args) => throw new NotSupportedException("This conversion is not supported.");
예제 #58
0
        public void Render3D(GCodeRenderInfo renderInfo, DrawEventArgs e)
        {
            if (renderInfo == null)
            {
                return;
            }

            if (layerVertexBuffer == null)
            {
                layerVertexBuffer = new List <GCodeVertexBuffer>(gCodeFileToDraw.LayerCount);
                for (int layerIndex = 0; layerIndex < gCodeFileToDraw.LayerCount; layerIndex++)
                {
                    layerVertexBuffer.Add(null);
                    featureStartIndex.Add(new List <int>());
                    featureEndIndex.Add(new List <int>());
                }
            }

            for (int layerIndex = 0; layerIndex < gCodeFileToDraw.LayerCount; layerIndex++)
            {
                CreateFeaturesForLayerIfRequired(layerIndex);
            }

            if (lastRenderType != renderInfo.CurrentRenderType)
            {
                Clear3DGCode();
                lastRenderType = renderInfo.CurrentRenderType;
            }

            if (renderFeatures.Count > 0)
            {
                for (int i = renderInfo.EndLayerIndex - 1; i >= renderInfo.StartLayerIndex; i--)
                {
                    // If its the first render or we change what we are trying to render then create vertex data.
                    if (layerVertexBuffer.Count > i &&
                        layerVertexBuffer[i] == null)
                    {
                        layerVertexBuffer[i] = Create3DDataForLayer(i, renderInfo);
                    }
                }

                GL.Disable(EnableCap.Texture2D);
                GL.PushAttrib(AttribMask.EnableBit);
                GL.DisableClientState(ArrayCap.TextureCoordArray);
                GL.Enable(EnableCap.PolygonSmooth);

                if (renderInfo.EndLayerIndex - 1 > renderInfo.StartLayerIndex)
                {
                    for (int i = renderInfo.StartLayerIndex; i < renderInfo.EndLayerIndex - 1; i++)
                    {
                        int featuresOnLayer = renderFeatures[i].Count;
                        if (featuresOnLayer > 1 &&
                            layerVertexBuffer[i] != null)
                        {
                            layerVertexBuffer[i].RenderRange(0, featureEndIndex[i][featuresOnLayer - 1]);
                        }
                    }
                }

                // draw the partial layer of end-1 from startRatio to endRatio
                {
                    int layerIndex      = renderInfo.EndLayerIndex - 1;
                    int featuresOnLayer = renderFeatures[layerIndex].Count;
                    int startFeature    = (int)(featuresOnLayer * renderInfo.FeatureToStartOnRatio0To1 + .5);
                    startFeature = Math.Max(0, Math.Min(startFeature, featuresOnLayer));

                    int endFeature = (int)(featuresOnLayer * renderInfo.FeatureToEndOnRatio0To1 + .5);
                    endFeature = Math.Max(0, Math.Min(endFeature, featuresOnLayer));

                    // try to make sure we always draw at least one feature
                    if (endFeature <= startFeature)
                    {
                        endFeature = Math.Min(startFeature + 1, featuresOnLayer);
                    }

                    if (startFeature >= endFeature)
                    {
                        // This can only happen if the start and end are set to the last feature
                        // Try to set the start feature to one from the end
                        startFeature = Math.Max(endFeature - 1, 0);
                    }

                    if (endFeature > startFeature &&
                        layerVertexBuffer[layerIndex] != null)
                    {
                        int ellementCount = featureEndIndex[layerIndex][endFeature - 1] - featureStartIndex[layerIndex][startFeature];

                        layerVertexBuffer[layerIndex].RenderRange(featureStartIndex[layerIndex][startFeature], ellementCount);
                    }
                }
                GL.PopAttrib();
            }
        }
예제 #59
0
 public void DrawEditor(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e)
 {
     this.DrawPath();
 }
예제 #60
0
 public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
 {
     ImageToPathObject3D.DrawPath(this);
 }