private void CreateStroke() { // create an arrow head style which uses a custom shape NArrowheadStyle defaultStyle = new NArrowheadStyle( ArrowheadShape.Custom, "Double Opened Arrow", new NSizeL(13, 13), new NColorFillStyle(Color.OrangeRed), new NStrokeStyle(1, Color.Black)); // create a polyline which uses this arrowhead style NPointF[] points = new NPointF[] { new NPointF(290, 50), new NPointF(207, 199), new NPointF(40, 50), new NPointF(234, 95), new NPointF(94, 184) }; NPolylineShape polyline = new NPolylineShape(points); polyline.Style.StartArrowheadStyle = defaultStyle.Clone() as NArrowheadStyle; polyline.Style.EndArrowheadStyle = defaultStyle.Clone() as NArrowheadStyle; document.ActiveLayer.AddChild(polyline); }
public void CreatePolygon() { // create polygon NRectangleF cell = this.DocumentHelper.GetGridCell(0, 2); int xdeviation = (int)cell.Width / 4; int ydeviation = (int)cell.Height / 4; NPointF[] points = new NPointF[] { new NPointF(cell.X + Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)), new NPointF(cell.Right - Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)), new NPointF(cell.Right - Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)), new NPointF(cell.X + Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)), new NPointF(cell.X + Random.Next((int)cell.Width), cell.Y + Random.Next((int)cell.Height)) }; NPolygonShape polygon = new NPolygonShape(points); // set fill and stroke styles polygon.Style.FillStyle = new NGradientFillStyle(GradientStyle.FromCenter, GradientVariant.Variant1, Color.Green, Color.Yellow); polygon.Style.StrokeStyle = new NStrokeStyle(1, Color.Black, LinePattern.DashDot); // add to active layer Document.ActiveLayer.AddChild(polygon); // add description cell = this.DocumentHelper.GetGridCell(1, 2); NTextShape text = new NTextShape("Polygon with gradient fill style and dash-dot stroke style", cell); Document.ActiveLayer.AddChild(text); }
public void Animate(IList <NPointF> path, bool reversed) { NPointF pinOffset = m_Shape.PinPoint - m_Shape.Location; NPointFList points = new NPointFList(path); if (reversed) { points.Reverse(); } int i, count = points.Count - 1; for (i = 0; i < count; i++) { // Determine the start and end point NPointF p1 = points[i] - pinOffset; NPointF p2 = points[i + 1] - pinOffset; // Create the animation float distance = p1.Distance(p2); float duration = distance / m_Speed; NTranslateAnimation move = new NTranslateAnimation(m_CurrentTime, duration); move.StartOffset = p1 - m_Shape.Location; move.EndOffset = p2 - m_Shape.Location; if (m_Shape.Style.AnimationsStyle == null) { m_Shape.Style.AnimationsStyle = new NAnimationsStyle(); } m_Shape.Style.AnimationsStyle.Animations.Add(move); m_CurrentTime += duration; } }
public void CreateClosedCurve() { // create curve NRectangleF cell = this.DocumentHelper.GetGridCell(0, 3); int xdeviation = (int)cell.Width / 4; int ydeviation = (int)cell.Height / 4; NPointF[] points = new NPointF[] { new NPointF(cell.X + Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)), new NPointF(cell.Right - Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)), new NPointF(cell.Right - Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)), new NPointF(cell.X + Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)), new NPointF(cell.X + Random.Next((int)cell.Width), cell.Y + Random.Next((int)cell.Height)) }; NClosedCurveShape curve = new NClosedCurveShape(points, 1); // set fill and stroke styles curve.Style.FillStyle = new NHatchFillStyle(HatchStyle.SmallGrid, Color.LightSalmon, Color.Chocolate); curve.Style.StrokeStyle = new NStrokeStyle(1, Color.Black, LinePattern.DashDotDot); // add to active layer Document.ActiveLayer.AddChild(curve); // add description cell = this.DocumentHelper.GetGridCell(1, 3); NTextShape text = new NTextShape("Closed curve with hatch fill style and dash-dot-dot stroke style", cell); Document.ActiveLayer.AddChild(text); }
public void CreateDoubleArrow() { // create double arrow NRectangleF cell = this.DocumentHelper.GetGridCell(2, 1); NPointF startPoint = new NPointF(cell.X, cell.Y + cell.Height / 2); NPointF endPoint = new NPointF(cell.Right, cell.Y + cell.Height / 2); NArrowShape arrow = new NArrowShape(ArrowType.DoubleArrow, startPoint, endPoint, 20, 45, 60); // set styles try { Bitmap bmp = new Bitmap(this.MapPathSecure(this.TemplateSourceDirectory + "\\..\\Images\\ConceptCar2.png")); arrow.Style.FillStyle = new NImageFillStyle(bmp, 125); } catch (Exception ex) { Debug.WriteLine("Failed to load concept car resource. Exception was: " + ex.Message); } arrow.Style.StrokeStyle = new NStrokeStyle(1, Color.Black, LinePattern.Solid); // add to the active layer Document.ActiveLayer.AddChild(arrow); // add description cell = this.DocumentHelper.GetGridCell(3, 1); NTextShape text = new NTextShape("Single arrow with semi transparent image fill style and solid stroke style", cell); Document.ActiveLayer.AddChild(text); }
protected NCompositeShape CreateState(XmlElement state) { string pathPoints = state.Attributes["PathPoints"].Value.ToString(); string pathTypes = state.Attributes["PathTypes"].Value.ToString(); string[] pathPointsStr = pathPoints.Split(' '); NPointF[] pathPointsF = new NPointF[pathPointsStr.Length]; float scaleX = NDrawingView1.Dimensions.Width; float scaleY = NDrawingView1.Dimensions.Height; for (int i = 0; i < pathPointsStr.Length; i++) { string[] xyStr = pathPointsStr[i].Split(','); pathPointsF[i].X = (Single.Parse(xyStr[0])) * scaleX; pathPointsF[i].Y = (Single.Parse(xyStr[1])) * scaleY; } string[] pathTypesStr = pathTypes.Split(' '); byte[] pathTypesB = new byte[pathTypesStr.Length]; for (int i = 0; i < pathTypesStr.Length; i++) { pathTypesB[i] = Byte.Parse(pathTypesStr[i]); } NCustomPath path = new NCustomPath(pathPointsF, pathTypesB, PathType.ClosedFigure); NCompositeShape shape = new NCompositeShape(); shape.Primitives.AddChild(path); shape.UpdateModelBounds(); return(shape); }
/// <summary> /// Gets the data point from the specified point /// </summary> /// <param name="point"></param> /// <returns></returns> protected int GetDataPointIndexFromPoint(NPoint point) { NPointSeries pointSeries = m_DragPlane.PointSeries; NChart chart = pointSeries.Chart; NModel3DToViewTransformation model3DToViewTransformation = new NModel3DToViewTransformation(GetView().Context, chart.Projection); float xHotSpotArea = 10; float yHotSpotArea = 10; int dataPointIndex = -1; for (int i = 0; i < pointSeries.Values.Count; i++) { double x = (double)pointSeries.XValues[i]; double y = (double)pointSeries.Values[i]; double z = (double)pointSeries.ZValues[i]; NVector3DF vecModelPoint; vecModelPoint.X = chart.Axis(StandardAxis.PrimaryX).TransformScaleToModel(false, x); vecModelPoint.Y = chart.Axis(StandardAxis.PrimaryY).TransformScaleToModel(false, y); vecModelPoint.Z = chart.Axis(StandardAxis.Depth).TransformScaleToModel(false, z); NPointF viewPoint = NPointF.Empty; model3DToViewTransformation.Transform(vecModelPoint, ref viewPoint); if (Math.Abs(viewPoint.X - point.X) < xHotSpotArea && Math.Abs(viewPoint.Y - point.Y) < yHotSpotArea) { dataPointIndex = i; break; } } return(dataPointIndex); }
private void CreateShapeWithLogicalLinePort() { NPointF[] points = new NPointF[] { new NPointF(151, 291), new NPointF(151, 316), new NPointF(123, 336), new NPointF(151, 350), new NPointF(158, 319), new NPointF(180, 312) }; // create a polyline shape with a logical line port NPolylineShape shape = new NPolylineShape(points); shape.Name = "Shape with a Logical Line Port"; shape.Bounds = base.GetGridCell(5, 1); // create the ports shape.CreateShapeElements(ShapeElementsMask.Ports); NLogicalLinePort port = new NLogicalLinePort(shape.UniqueId, 30); shape.Ports.RemoveAllChildren(); shape.Ports.AddChild(port); shape.Ports.DefaultInwardPortUniqueId = port.UniqueId; // connect it with the center shape document.ActiveLayer.AddChild(shape); ConnectShapes(centerShape, shape); // descibte it NTextShape text = new NTextShape("Shape with Logical Line Port", base.GetGridCell(5, 2, 0, 1)); document.ActiveLayer.AddChild(text); }
protected NRectangleF GetElementBounds(int column, int row) { NSizeF size = new NSizeF(45, 80); NPointF origin = new NPointF(45, 45); float x = origin.X + (column - 1) * size.Width; float y = origin.Y + (row - 1) * size.Height; return(new NRectangleF(x, y, size.Width, size.Height)); }
NPointF[] ApplyOffset(NPointF[] points, NPointF offset) { int length = points.Length; NPointF[] result = new NPointF[length]; for (int i = 0; i < length; i++) { result[i] = new NPointF(points[i].X + offset.X, points[i].Y + offset.Y); } return(result); }
public override void OnAsyncCustomCommand(string webControlId, System.Web.HttpContext context, NStateObject state, NCallbackCustomCommandArgs args) { switch (args.Command.Name) { case "setDataWindowWidth": NPointF ptViewPoint = new NPointF(float.Parse(args.Command.Arguments["x"] as string), 0f); DataWindowWidth = double.Parse(args.Command.Arguments["width"] as string); UpdateDataWindow(webControlId, context, state, ptViewPoint); break; } }
/// <summary> /// Gets a random set of points constrained in the specified bounds /// </summary> /// <param name="bounds"></param> /// <param name="pointsCount"></param> /// <returns></returns> protected NPointF[] GetRandomPoints(NRectangleF bounds, int pointsCount) { NPointF[] points = new NPointF[pointsCount]; for (int i = 0; i < points.Length; i++) { points[i] = GetRandomPoint(bounds); } return(points); }
void CreateInnerHallway(NPointF offset) { NPointF[] points = ApplyOffset(InnerHallway.points, offset); NPolygonShape p = new NPolygonShape(points); p.Text = "Inn.Hallway, H=270"; p.Style.TextStyle = txMain.Clone() as NTextStyle; document.ActiveLayer.AddChild(p); CreateLabeledPolyOutline(points, p, null, "Inner Hallway"); }
void CreateKitchen(NPointF offset) { NPointF[] points = ApplyOffset(Kitchen.points, offset); NPolygonShape p = new NPolygonShape(points); p.Text = "Kitchen, H=265"; p.Style.TextStyle = txMain.Clone() as NTextStyle; document.ActiveLayer.AddChild(p); CreateLabeledPolyOutline(points, p, null, "Kitchen"); }
void CreateBalcony2(NPointF offset) { NPointF[] points = ApplyOffset(Balcony2.points, offset); NPolygonShape p = new NPolygonShape(points); p.Text = "Bedroom Balcony"; p.Style.TextStyle = txMain.Clone() as NTextStyle; document.ActiveLayer.AddChild(p); CreateLabeledPolyOutline(points, p, null, "Bedroom Balcony"); }
void CreateGuestRoom(NPointF offset) { NPointF[] points = ApplyOffset(GuestRoom.points, offset); NPolygonShape p = new NPolygonShape(points); p.Text = "Guest Room, H=270"; p.Style.TextStyle = txMain.Clone() as NTextStyle; document.ActiveLayer.AddChild(p); CreateLabeledPolyOutline(points, p, null, "Guest Room"); }
public override void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs) { if (m_Parent.m_bUpdateWatermark == false) { return; } // intercepts the on chart after paint event and converts // point or XYZ coordniates to chart viewport coordinates // used to position the custom watermark NChartControl chartControl = m_Parent.nChartControl1; NWatermark watermark = chartControl.Watermarks[0]; NChart chart = m_Parent.nChartControl1.Charts[0]; NPointF viewPoint = new NPointF(); NVector3DF vecModelPoint = new NVector3DF(); NModel3DToViewTransformation model3DToViewTransformation = new NModel3DToViewTransformation(chartControl.View.Context, chart.Projection); switch (m_Parent.WatermarkPositionComboBox.SelectedIndex) { case 0: vecModelPoint.X = chart.Axis(StandardAxis.PrimaryX).TransformScaleToModel(false, (double)m_Parent.XPositionNumericUpDown.Value); vecModelPoint.Y = chart.Axis(StandardAxis.PrimaryY).TransformScaleToModel(false, (double)m_Parent.YPositionNumericUpDown.Value); vecModelPoint.Z = chart.Axis(StandardAxis.Depth).TransformScaleToModel(false, (double)m_Parent.ZPositionNumericUpDown.Value); break; case 1: NVector3DF vecPoint = new NVector3DF(); int nIndex = (int)m_Parent.DataPointNumericUpDown.Value; vecPoint.X = (float)(double)(m_Parent.m_Point.XValues[nIndex]); vecPoint.Y = (float)(double)(m_Parent.m_Point.Values[nIndex]); vecPoint.Z = (float)(double)(m_Parent.m_Point.ZValues[nIndex]); vecModelPoint.X = chart.Axis(StandardAxis.PrimaryX).TransformScaleToModel(false, vecPoint.X); vecModelPoint.Y = chart.Axis(StandardAxis.PrimaryY).TransformScaleToModel(false, vecPoint.Y); vecModelPoint.Z = chart.Axis(StandardAxis.Depth).TransformScaleToModel(false, vecPoint.Z); break; } model3DToViewTransformation.Transform(vecModelPoint, ref viewPoint); // convert the view point to parent pixel coordinates watermark.TransformViewPointToParent(ref viewPoint); watermark.Location = new NPointL( new NLength(viewPoint.X, NGraphicsUnit.Pixel), new NLength(viewPoint.Y, NGraphicsUnit.Pixel)); m_Parent.nChartControl1.RecalcLayout(); }
protected void nChartControl2_AsyncCustomCommand(object sender, EventArgs e) { NCallbackCustomCommandArgs args = e as NCallbackCustomCommandArgs; switch (args.Command.Name) { case "displayDataWindow": double dataWindowWidth = double.Parse(args.Command.Arguments["width"] as string); NCartesianChart zoomChart = nChartControl2.Charts[0] as NCartesianChart; NSmoothLineSeries zoomLine = zoomChart.Series[0] as NSmoothLineSeries; NCartesianChart previewChart = nChartControl1.Charts[0] as NCartesianChart; NAxis previewXAxis = previewChart.Axis(StandardAxis.PrimaryX); NPointF ptViewPoint = new NPointF(float.Parse(args.Command.Arguments["x"] as string), 0); NVector2DD vecScalePoint = new NVector2DD(); using (NChartRasterView view = new NChartRasterView(nChartControl1.Document, nChartControl1.Dimensions, NResolution.ScreenResolution)) { view.RecalcLayout(); NViewToScale2DTransformation viewToScale = new NViewToScale2DTransformation( view.Context, previewChart, (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY ); if (viewToScale.Transform(ptViewPoint, ref vecScalePoint)) { double rangeMin = vecScalePoint.X - dataWindowWidth / 2; rangeMin = previewXAxis.Scale.ViewRange.GetValueInRange(rangeMin); double rangeMax = rangeMin + dataWindowWidth; rangeMax = previewXAxis.Scale.ViewRange.GetValueInRange(rangeMax); rangeMin = rangeMax - dataWindowWidth; // reinitialize data points zoomLine.XValues.Clear(); zoomLine.Values.Clear(); for (int i = (int)rangeMin; i <= (int)rangeMax; i++) { zoomLine.XValues.Add(i); zoomLine.Values.Add(waveData[i]); } } } break; } }
protected NGroup CreateCartesianScaleGroup() { NGroup group = new NGroup(); // rect 1 uses cartesian scaling NRectangleShape rect1 = new NRectangleShape(0, 0, 75, 75); rect1.Rotate(CoordinateSystem.Scene, 45, rect1.PinPoint); rect1.ResizeInAggregate = ResizeInAggregate.CartesianScale; rect1.Text = "Cartesian Scale"; group.Shapes.AddChild(rect1); // rect 2 uses cartesian X scaling and Y reposition NRectangleShape rect2 = new NRectangleShape(150, 0, 75, 75); rect2.Rotate(CoordinateSystem.Scene, 45, rect2.PinPoint); rect2.ResizeInAggregate = ResizeInAggregate.CartesianScaleXRepositionY; rect2.Text = "Cartesian Scale X and Reposition Y"; group.Shapes.AddChild(rect2); // rect 3 uses cartesian Y scaling and X reposition NRectangleShape rect3 = new NRectangleShape(0, 150, 75, 75); rect3.Rotate(CoordinateSystem.Scene, 45, rect3.PinPoint); rect3.ResizeInAggregate = ResizeInAggregate.CartesianScaleYRepositionX; rect3.Text = "Cartesian Scale Y and Reposition X"; group.Shapes.AddChild(rect3); // rect 4 uses cartesian scale and reposition NRectangleShape rect4 = new NRectangleShape(150, 150, 75, 75); rect4.Rotate(CoordinateSystem.Scene, 45, rect4.PinPoint); rect4.ResizeInAggregate = ResizeInAggregate.CartesianScaleAndReposition; rect4.Text = "Cartesian Scale and Reposition"; group.Shapes.AddChild(rect4); // update the group model bounds group.UpdateModelBounds(); // in order to demonstrate the reposition, all shapes // are pinned to the bottom rigth corner of the group NPointF pin = new NPointF(group.Bounds.Right, group.Bounds.Bottom); foreach (NShape shape in group.Shapes) { shape.PinPoint = pin; } // add the group to the active layer document.ActiveLayer.AddChild(group); return(group); }
/// <summary> /// Initializer constructor /// </summary> /// <param name="form">main application form</param> public NDiagramExampleUC(NMainForm form) : base(form) { InitializeComponent(); view = form.View; document = form.Document; eventHandlingPauseCounter = 0; defaultGridOrigin = new NPointF(15, 15); defaultGridCellSize = new NSizeF(100, 100); defaultGridSpacing = new NSizeF(20, 20); }
/// <summary> /// Default constructor /// </summary> public NDiagramExampleUC() { InitializeComponent(); view = null; document = null; eventHandlingPauseCounter = 0; defaultGridOrigin = new NPointF(15, 15); defaultGridCellSize = new NSizeF(100, 100); defaultGridSpacing = new NSizeF(20, 20); }
private void CreateCurveShape(int row, int col) { NRectangleF cell = GetGridCell(row, col); Color color = GetPredefinedColor(5); int xdeviation = (int)cell.Width / 4; int ydeviation = (int)cell.Height / 4; NPointF[] points = new NPointF[] { new NPointF(cell.X + Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)), new NPointF(cell.Right - Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)), new NPointF(cell.Right - Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)), new NPointF(cell.X + Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)), new NPointF(cell.X + Random.Next((int)cell.Width), cell.Y + Random.Next((int)cell.Height)) }; // create curve NCurveShape curve = new NCurveShape(points, 1); // set stroke style curve.Style.StrokeStyle = new NStrokeStyle(2, color, LinePattern.DashDotDot); // set arrowheads style NArrowheadStyle arrowheadStyle = new NArrowheadStyle( ArrowheadShape.QuillArrow, "", new NSizeL(12, 12), new NColorFillStyle(color), new NStrokeStyle(1, Color.Black)); curve.Style.StartArrowheadStyle = arrowheadStyle; arrowheadStyle = new NArrowheadStyle( ArrowheadShape.SunkenArrow, "", new NSizeL(12, 12), new NColorFillStyle(color), new NStrokeStyle(1, Color.Black)); curve.Style.EndArrowheadStyle = arrowheadStyle; // add to the active layer document.ActiveLayer.AddChild(curve); // add description cell = GetGridCell(row + 1, col); NTextShape text = new NTextShape("Curve with dash-dot-dot style and QuillArrow and SunkenArrow arrowheads", cell); document.ActiveLayer.AddChild(text); }
NLineShape ConnectPointsLabeled(NPointF p1, NPointF p2, ref int hIndex, ref int vIndex, ref int index) { float dx = p2.X - p1.X; float dy = p2.Y - p1.Y; float distance = (float)Math.Sqrt(dx * dx + dy * dy); string letter; if (Math.Floor(dy) == 0) { hIndex++; letter = "a" + hIndex; } else { vIndex++; letter = "b" + vIndex; } index++; NLineShape line = new NLineShape(p1, p2); document.ActiveLayer.AddChild(line); if (index % 2 == 0) { line.Style.StrokeStyle = sstEven; } else { line.Style.StrokeStyle = sstOdd; } if (displayLengths) { line.Style.TextStyle = txLine.Clone() as NTextStyle; if (distance < minNormalLineLength) { line.Text = distance.ToString(); line.Style.TextStyle = txLineSmall; } else { line.Text = string.Format("{0}={1}", letter, distance.ToString()); } line.Style.TextStyle.Offset = lineTextOffset; } return(line); }
private void OnChartMouseDown(object sender, MouseEventArgs e) { if (MouseModeComboBox.SelectedIndex != 0) { return; } NPointF ptViewPoint = new NPointF((float)e.X, (float)e.Y); NVector3DD vecScalePoint = new NVector3DD(); NViewToScale3DTransformation viewToScale; NAxis xAxis = m_Chart.Axis(StandardAxis.PrimaryX); NAxis yAxis = m_Chart.Axis(StandardAxis.PrimaryY); NAxis zAxis = m_Chart.Axis(StandardAxis.Depth); if (CreatePointAtPlaneComboBox.SelectedIndex == 0) { viewToScale = new NViewToScale3DTransformation(m_Chart, (int)StandardAxis.PrimaryX, (int)StandardAxis.Depth, (int)StandardAxis.PrimaryY, (double)XZPlaneValueNumericUpDown.Value); if (viewToScale.Transform(ptViewPoint, ref vecScalePoint)) { if (ClampValuesToRulerCheckBox.Checked) { vecScalePoint.X = xAxis.Scale.ViewRange.GetValueInRange(vecScalePoint.X); vecScalePoint.Z = yAxis.Scale.ViewRange.GetValueInRange(vecScalePoint.Z); vecScalePoint.Y = zAxis.Scale.ViewRange.GetValueInRange(vecScalePoint.Y); } m_Point.AddDataPoint(new NDataPoint(vecScalePoint.X, vecScalePoint.Z, vecScalePoint.Y, "Point" + m_Point.Values.Count.ToString())); nChartControl1.Refresh(); } } else { viewToScale = new NViewToScale3DTransformation(m_Chart, (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY, (int)StandardAxis.Depth, (double)XYPlaneValueNumericUpDown.Value); if (viewToScale.Transform(ptViewPoint, ref vecScalePoint)) { if (ClampValuesToRulerCheckBox.Checked) { vecScalePoint.X = xAxis.Scale.ViewRange.GetValueInRange(vecScalePoint.X); vecScalePoint.Y = yAxis.Scale.ViewRange.GetValueInRange(vecScalePoint.Y); vecScalePoint.Z = zAxis.Scale.ViewRange.GetValueInRange(vecScalePoint.Z); } m_Point.AddDataPoint(new NDataPoint(vecScalePoint.X, vecScalePoint.Y, vecScalePoint.Z, "Point" + m_Point.Values.Count.ToString())); nChartControl1.Refresh(); } } }
/// <summary> /// Zooms the view to the dragged zoom rect /// </summary> protected virtual void ZoomToRect() { NRectangleF zoomRect = m_ZoomRect.Bounds; if (zoomRect.Width != 0 || zoomRect.Height != 0) { float scaleFactor = ComputeZoomFactor(); if (View.IsValidScaleFactor(scaleFactor)) { NPointF viewportCenter = new NPointF(zoomRect.X + zoomRect.Width / 2, zoomRect.Y + zoomRect.Height / 2); View.Zoom(scaleFactor, viewportCenter, true); } } }
/// <summary> /// Return true if dragging can start /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <returns></returns> public override bool CanBeginDrag(object sender, Nevron.Chart.Windows.NMouseEventArgs e) { if (!base.CanBeginDrag(sender, e)) { return(false); } NPoint point = new NPoint(e.X, e.Y); NPointSeries pointSeries = m_DragPlane.PointSeries; NChart chart = pointSeries.Chart; NModel3DToViewTransformation model3DToViewTransformation = new NModel3DToViewTransformation(GetView().Context, chart.Projection); float xHotSpotArea = 10; float yHotSpotArea = 10; int dataPointIndex = -1; for (int i = 0; i < pointSeries.Values.Count; i++) { double x = (double)pointSeries.XValues[i]; double y = (double)pointSeries.Values[i]; double z = (double)pointSeries.ZValues[i]; NVector3DF vecModelPoint; vecModelPoint.X = chart.Axis(StandardAxis.PrimaryX).TransformScaleToModel(false, x); vecModelPoint.Y = chart.Axis(StandardAxis.PrimaryY).TransformScaleToModel(false, y); vecModelPoint.Z = chart.Axis(StandardAxis.Depth).TransformScaleToModel(false, z); NPointF viewPoint = NPointF.Empty; model3DToViewTransformation.Transform(vecModelPoint, ref viewPoint); if (Math.Abs(viewPoint.X - point.X) < xHotSpotArea && Math.Abs(viewPoint.Y - point.Y) < yHotSpotArea) { dataPointIndex = i; break; } } if (dataPointIndex == -1) { return(false); } m_DataPointIndex = dataPointIndex; m_OriginalPosition = m_DragPlane.GetVectorFromPoint(m_DataPointIndex); return(true); }
public void SetPause(NPointF location, float duration) { NTranslateAnimation move = new NTranslateAnimation(m_CurrentTime, duration); move.EndOffset = location - m_Shape.PinPoint; move.StartOffset = move.EndOffset; if (m_Shape.Style.AnimationsStyle == null) { m_Shape.Style.AnimationsStyle = new NAnimationsStyle(); } m_Shape.Style.AnimationsStyle.Animations.Add(move); m_CurrentTime += duration; }
void CreateHallway(NPointF offset) { NPointF[] points = ApplyOffset(Hallway.points, offset); NPolygonShape p = new NPolygonShape(points); p.Text = "Hallway, H=270"; p.Style.TextStyle = txMain.Clone() as NTextStyle; p.Style.TextStyle.Offset = new NPointL(-60, 0); document.ActiveLayer.AddChild(p); NNodeList labels = new NNodeList(); labels.Add(AddLabel(ApplyOffset(Hallway.section1Center, offset), "H=240", false)); CreateLabeledPolyOutline(points, p, labels, "Hallway"); }
void CreateLivingRoom(NPointF offset) { NPointF[] points = ApplyOffset(LivingRoom.points, offset); NPolygonShape p = new NPolygonShape(points); p.Text = "Living Room, H=265"; p.Style.TextStyle = txMain; document.ActiveLayer.AddChild(p); NNodeList labels = new NNodeList(); labels.Add(AddLabel(LivingRoom.section1Center, "H=240", false)); labels.Add(AddLabel(LivingRoom.section2Center, "H=240", true)); CreateLabeledPolyOutline(points, p, labels, "Living Room"); }
NLineShape AddLabel(NPointF center, string text, bool small) { NLineShape line = new NLineShape(center, new NPointF(center.X + 0.01f, center.Y + 0.01f)); document.ActiveLayer.AddChild(line); line.Style.StrokeStyle = new NStrokeStyle(0, Color.White); line.Text = text; if (small) { line.Style.TextStyle = txLineSmall; } else { line.Style.TextStyle = txLine; } return(line); }