public override async Task <PointsArray> GetRandomGraphic(PointsCount pointsCount, ServerCallContext context) { if (pointsCount.PointsCount_ == 0) { logger.LogError("Был получен график с 0 точками"); throw new ArgumentNullException("Был получен график с 0 точками"); } if (pointsCount.PointsCount_ == 1) { logger.LogError("График не может состоять из 1 точки"); throw new Exception("График не может состоять из 1 точки"); } PointsArray result = new PointsArray(); try { double[] line = await service.GenerateRandomGraphic(pointsCount.PointsCount_); result.GraphicPoints.AddRange(line); return(result); } catch (Exception ex) { logger.LogCritical(ex.Message); throw new Exception(ex.Message); } }
private async void mGraphicsGenerateRandom_Click(object sender, RoutedEventArgs e) { try { PointsArray reply = await client.GetRandomGraphicAsync(new PointsCount() { PointsCount_ = 5 }); VM.AddNewLine(reply.GraphicPoints.ToArray()); } catch (Grpc.Core.RpcException ex) { if (App.Language == CultureInfo.GetCultureInfoByIetfLanguageTag("ru-RU")) { MessageBox.Show("Возникли проблемы с сервером. Возможные причины:" + Environment.NewLine + "1) Сервер не подключен" + Environment.NewLine + "2) При запросе возникла ошибка" + Environment.NewLine + Environment.NewLine + ex.Message , "Ошибка" , MessageBoxButton.OK, MessageBoxImage.Error); } else { MessageBox.Show("There is a problem with the server. Possible reasons:" + Environment.NewLine + "1) Server is not connected" + Environment.NewLine + "2) An error occurred when requesting" + Environment.NewLine + Environment.NewLine + ex.Message , "Error" , MessageBoxButton.OK, MessageBoxImage.Error); } } }
public override async Task <PointsArray> GetCustomGraphic(PointsArray pointsArray, ServerCallContext context) { if (pointsArray.GraphicPoints.Count == 0) { logger.LogError("Был получен пустой массив"); throw new ArgumentNullException("Был получен пустой массив"); } if (pointsArray.GraphicPoints.Count == 1) { logger.LogError("График не может состоять из 1 точки"); throw new Exception("График не может состоять из 1 точки"); } try { PointsArray result = new PointsArray(); double[] line = await service.GenerateCustomGraphic(pointsArray.GraphicPoints.ToArray()); result.GraphicPoints.AddRange(line); return(result); } catch (Exception ex) { logger.LogError(ex.Message); throw new Exception(ex.Message); } }
static void Main() { // Create new document Document pdfDocument = new Document(); pdfDocument.RegistrationName = "demo"; pdfDocument.RegistrationKey = "demo"; // If you wish to load an existing document uncomment the line below and comment the Add page section instead // pdfDocument.Load(@".\existing_document.pdf"); // Add page Page page = new Page(PaperFormat.A4); pdfDocument.Pages.Add(page); // Draw sample markup annotations SquareAnnotation squareAnnotation = new SquareAnnotation(20, 20, 80, 80); squareAnnotation.BackgroundColor = new ColorRGB(255, 240, 240); squareAnnotation.BorderStyle.Style = BorderStyle.Dashed; squareAnnotation.BorderStyle.DashPattern = new DashPattern(new float[] { 3, 1, 3 }); page.Annotations.Add(squareAnnotation); CircleAnnotation circleAnnotation = new CircleAnnotation(120, 20, 80, 80); circleAnnotation.BackgroundColor = new ColorRGB(240, 250, 240); circleAnnotation.Color = new ColorRGB(128, 0, 128); circleAnnotation.BorderEffect.Effect = BorderEffect.Cloudy; circleAnnotation.BorderEffect.Intensity = 2; page.Annotations.Add(circleAnnotation); LineAnnotation lineAnnotation = new LineAnnotation(20, 180, 100, 120); lineAnnotation.Color = new ColorRGB(255, 0, 0); lineAnnotation.StartLineStyle = LineEndingStyle.Butt; lineAnnotation.EndLineStyle = LineEndingStyle.OpenArrow; page.Annotations.Add(lineAnnotation); PointF[] pp = { new PointF(120, 120), new PointF(130, 130), new PointF(140, 120), new PointF(150, 130), new PointF(160, 120), new PointF(170, 130) }; PointsArray points = new PointsArray(pp); PolylineAnnotation polylineAnnotation = new PolylineAnnotation(points); polylineAnnotation.BorderStyle.Width = 2; page.Annotations.Add(polylineAnnotation); // Save document to file pdfDocument.Save("result.pdf"); // Cleanup pdfDocument.Dispose(); // Open result document in default associated application (for demo purpose) ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf"); processStartInfo.UseShellExecute = true; Process.Start(processStartInfo); }
/// <summary> /// Initializes a new instance of the Bytescout.PDF.LineAnnotation class. /// </summary> /// <param name="x1" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The x-coordinate of the first point.</param> /// <param name="y1" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The y-coordinate of the first point.</param> /// <param name="x2" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The x-coordinate of the second point.</param> /// <param name="y2" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The y-coordinate of the second point.</param> public LineAnnotation(float x1, float y1, float x2, float y2) : base(null) { Dictionary.AddItem("Subtype", new PDFName("Line")); _coordinates = new PointsArray(); _coordinates.AddPoint(new PointF(x1, y1)); _coordinates.AddPoint(new PointF(x2, y2)); Dictionary.AddItem("L", _coordinates.Array); Color = new ColorRGB(0, 0, 0); }
public override void DeletePoint(int n) { if (PointsArray.Count == 3) { return; } PointsArray.RemoveAt(n); polygon.Points.RemoveAt(n); Global.control.UpdatePolygonLocalPosition(polygon); Global.control.Refresh(); }
public DrawPolyline(PointLatLng p1, PointLatLng p2, int zoom, TOOL_TYPE type) : base() { property = new PropertyLine(); property.LocalPosition = p1; property.DefaultZoom = zoom; property.Type = type; Overlay = Global.control.Overlays.Count - 1; PointsArray.Add(p1); PointsArray.Add(p2); }
static void Main() { // Create new document Document pdfDocument = new Document(); pdfDocument.RegistrationName = "demo"; pdfDocument.RegistrationKey = "demo"; // Add page Page page = new Page(PaperFormat.A4); pdfDocument.Pages.Add(page); // Draw sample markup annotations SquareAnnotation squareAnnotation = new SquareAnnotation(20, 20, 80, 80); squareAnnotation.BackgroundColor = new ColorRGB(255, 240, 240); squareAnnotation.BorderStyle.Style = BorderStyle.Dashed; squareAnnotation.BorderStyle.DashPattern = new DashPattern(new float[] { 3, 1, 3 }); page.Annotations.Add(squareAnnotation); CircleAnnotation circleAnnotation = new CircleAnnotation(120, 20, 80, 80); circleAnnotation.BackgroundColor = new ColorRGB(240, 250, 240); circleAnnotation.Color = new ColorRGB(128, 0, 128); circleAnnotation.BorderEffect.Effect = BorderEffect.Cloudy; circleAnnotation.BorderEffect.Intensity = 2; page.Annotations.Add(circleAnnotation); LineAnnotation lineAnnotation = new LineAnnotation(20, 180, 100, 120); lineAnnotation.Color = new ColorRGB(255, 0, 0); lineAnnotation.StartLineStyle = LineEndingStyle.Butt; lineAnnotation.EndLineStyle = LineEndingStyle.OpenArrow; page.Annotations.Add(lineAnnotation); PointF[] pp = { new PointF(120, 120), new PointF(130, 130), new PointF(140, 120), new PointF(150, 130), new PointF(160, 120), new PointF(170, 130) }; PointsArray points = new PointsArray(pp); PolylineAnnotation polylineAnnotation = new PolylineAnnotation(points); polylineAnnotation.BorderStyle.Width = 2; page.Annotations.Add(polylineAnnotation); // Save document to file pdfDocument.Save("result.pdf"); // Cleanup pdfDocument.Dispose(); // Open document in default PDF viewer app Process.Start("result.pdf"); }
public override void DeletePoint(int n) { if (PointsArray.Count == 2) { return; } PointsArray.RemoveAt(n); route.Points.RemoveAt(n); Global.control.UpdateRouteLocalPosition(route); property.Distance = route.Distance; Global.control.ObjectSelected(property); }
public DrawPolygon(int x, int y, int zoom, TOOL_TYPE type) : base() { property = new PropertyPolygon(); property.DefaultZoom = zoom; property.LocalPosition = Global.control.FromLocalToLatLng(x, y); property.Type = type; Overlay = Global.control.Overlays.Count - 1; PointsArray.Add(Global.control.FromLocalToLatLng(x, y)); PointsArray.Add(Global.control.FromLocalToLatLng(x + 30, y)); PointsArray.Add(Global.control.FromLocalToLatLng(x + 30, y + 30)); PointsArray.Add(Global.control.FromLocalToLatLng(x, y + 30)); }
/* * public override void ClearLinkSelected() * { * List<string> listRemove = new List<string>(); * foreach (KeyValuePair<string, LinkObject> o in mapLink) * { * if (o.Value.type == ACTION_TYPE.selected) * { * Global.control.Overlays[Overlay].Routes.Remove(o.Value.route); * o.Value.marker.Clear(); * listRemove.Add(o.Key); * } * } * foreach (string o in listRemove) * { * mapLink.Remove(o); * } * } */ public override void AddPoint(Point point) { if (route == null) { return; } PointLatLng p = Global.control.FromLocalToLatLng((int)point.X, (int)point.Y); PointsArray.Add(p); route.Points.Add(p); Global.control.UpdateRouteLocalPosition(route); property.Distance = route.Distance; Global.control.ObjectSelected(property); }
/// <summary> </summary> public PointsArray CreatePointsArray(object[] array) { PointsArray result = new PointsArray(); for (int i = 0; i < array.Length; i++) { object[] point = array[i] as object[]; if (point != null && point.Length == 2) { result.AddPoint(new PointF(Convert.ToSingle(point[0]), Convert.ToSingle(point[1]))); } } return(result); }
public DrawPolyline(int x, int y, int zoom, TOOL_TYPE type) : base() { property = new PropertyLine(); property.LocalPosition = Global.control.FromLocalToLatLng(x, y); property.DefaultZoom = zoom; property.Type = type; Overlay = Global.control.Overlays.Count - 1; PointLatLng p; p = Global.control.FromLocalToLatLng(x, y); PointsArray.Add(p); p = Global.control.FromLocalToLatLng(x + 15, y + 15); PointsArray.Add(p); }
private async void chartMain_DataClick(object sender, ChartPoint chartPoint) { LineSeries line = (LineSeries)chartPoint.SeriesView; EditGraphicForm form = new EditGraphicForm(line); form.ShowDialog(); //проверка на закрытие формы if (form.newLinePoints.Count == 0 || form.newLine.Count == 0) { return; } try { PointsArray pointsArray = new PointsArray(); pointsArray.GraphicPoints.Add(form.newLinePoints); await client.GetCustomGraphicAsync(pointsArray); } catch (Grpc.Core.RpcException ex) { if (App.Language == CultureInfo.GetCultureInfoByIetfLanguageTag("ru-RU")) { MessageBox.Show("Возникли проблемы с сервером. Возможные причины:" + Environment.NewLine + "1) Сервер не подключен" + Environment.NewLine + "2) При запросе возникла ошибка" + Environment.NewLine + Environment.NewLine + ex.Message , "Ошибка" , MessageBoxButton.OK, MessageBoxImage.Error); } else { MessageBox.Show("There is a problem with the server. Possible reasons:" + Environment.NewLine + "1) Server is not connected" + Environment.NewLine + "2) An error occurred when requesting" + Environment.NewLine + Environment.NewLine + ex.Message , "Error" , MessageBoxButton.OK, MessageBoxImage.Error); } } VM.ChangeCustomLine(((LineSeries)chartPoint.SeriesView).Title, form.newLine); }
public override void InsertPoint(Point point) { //查找最近的两点距离 int n = PointsArray.Count; int index = 0; PointLatLng p = Global.control.FromLocalToLatLng((int)point.X, (int)point.Y); List <PointLatLng> routePoints = new List <PointLatLng>(); routePoints.Add(PointsArray[0]); routePoints.Add(p); GMapRoute routeA = new GMapRoute(routePoints, "A"); routePoints.Clear(); routePoints.Add(PointsArray[1]); routePoints.Add(p); GMapRoute routeB = new GMapRoute(routePoints, "B"); double MinDistance = routeA.Distance + routeB.Distance; routeA.Dispose(); routeB.Dispose(); for (int i = 1; i < n - 1; i++) { routePoints.Clear(); routePoints.Add(PointsArray[i]); routePoints.Add(p); routeA = new GMapRoute(routePoints, "A"); routePoints.Clear(); routePoints.Add(PointsArray[i + 1]); routePoints.Add(p); routeB = new GMapRoute(routePoints, "B"); double distance = routeA.Distance + routeB.Distance; routeA.Dispose(); routeB.Dispose(); if (distance < MinDistance) { MinDistance = distance; index = i; } } PointsArray.Insert(index + 1, p); route.Points.Insert(index + 1, p); Global.control.UpdateRouteLocalPosition(route); property.Distance = route.Distance; Global.control.ObjectSelected(property); }
public DrawEllipse(int x, int y,int zoom, TOOL_TYPE type) : base() { property = new PropertyPolygon(); property.LocalPosition = Global.control.FromLocalToLatLng(x, y); property.DefaultZoom = zoom; property.Type = type; Overlay = Global.control.Overlays.Count - 1; Rectangle rect = new Rectangle(x, y, 40, 40); PointsArray.Add(Global.control.FromLocalToLatLng(x, y)); PointsArray.Add(Global.control.FromLocalToLatLng(x + rect.Width, y)); PointsArray.Add(Global.control.FromLocalToLatLng(x + rect.Width, y + rect.Height)); PointsArray.Add(Global.control.FromLocalToLatLng(x, y + rect.Height)); SetRectangle(rect); }
public DrawImage(int x, int y, int zoom, TOOL_TYPE type) : base() { property = new PropertyImage(); property.DefaultZoom = zoom; property.Type = type; property.LocalPosition = Global.control.FromLocalToLatLng(x, y); Overlay = Global.control.Overlays.Count - 1; Bitmap bmp = new Bitmap(property.ImageFile); Rectangle rect = new Rectangle(x, y, (int)bmp.Width * 3 / 4, (int)bmp.Height * 3 / 4); PointsArray.Add(Global.control.FromLocalToLatLng(x, y)); PointsArray.Add(Global.control.FromLocalToLatLng(x + rect.Width, y)); PointsArray.Add(Global.control.FromLocalToLatLng(x + rect.Width, y + rect.Height)); PointsArray.Add(Global.control.FromLocalToLatLng(x, y + rect.Height)); SetRectangle(rect); }
/// <summary> /// Adds an array of points to the end of the collection. /// </summary> /// <param name="array">The value to be added to the end of the collection.</param> public void AddArray(PointsArray array) { if (array == null) { throw new ArgumentNullException(); } PointsArray newArr = new PointsArray(); newArr.Page = _page; newArr.AddRange(array.ToArray()); newArr.ChangedPointsArray += changedPointsArray; _array.AddItem(newArr.Array); _listArrays.Add(newArr); if (ChangedInkList != null) { ChangedInkList(this); } }
public DrawMarker(long pid, int x, int y, int zoom, TOOL_TYPE type, MARKER_TYPE markerType) : base() { PointLatLng latlng = Global.control.FromLocalToLatLng(x, y); PointsArray.Add(latlng); property = new PropertyMarker(); property.DefaultZoom = zoom; property.LocalPosition = latlng; property.Type = type; property.MarkerType = markerType; if (type == TOOL_TYPE.camera) { property.ImageFile = @"image\camera_0.ico"; } else if (type == TOOL_TYPE.model) { property.ImageFile = @"image\model.ico"; } else if (type == TOOL_TYPE.marker) { if (markerType == MARKER_TYPE.Green) { property.ImageFile = @"image\marker_0.ico"; } else if (markerType == MARKER_TYPE.Yellow) { property.ImageFile = @"image\marker_2.ico"; } else if (markerType == MARKER_TYPE.Red) { property.ImageFile = @"image\marker_1.ico"; } else if (markerType == MARKER_TYPE.Gray) { property.ImageFile = @"image\marker_3.ico"; } } }
public DrawText(int x, int y, int zoom, TOOL_TYPE type) : base() { property = new PropertyText(); property.DefaultZoom = zoom; property.LocalPosition = Global.control.FromLocalToLatLng(x, y); property.Type = type; Overlay = Global.control.Overlays.Count - 1; Graphics g = Graphics.FromImage(new Bitmap(1, 1)); SizeF size = g.MeasureString(property.Name, property.Font); rectangle = new Rectangle(x, y, (int)(size.Width * 1.5), (int)size.Height); PointsArray.Add(Global.control.FromLocalToLatLng(x, y)); PointsArray.Add(Global.control.FromLocalToLatLng(x + rectangle.Width, y)); PointsArray.Add(Global.control.FromLocalToLatLng(x + rectangle.Width, y + rectangle.Height)); PointsArray.Add(Global.control.FromLocalToLatLng(x, y + rectangle.Height)); //SetRectangle(rectangle); }
internal PolygonPolylineAnnotation(PointsArray points, IDocumentEssential owner) : base(null) { if (points == null) { throw new ArgumentNullException("points"); } if (points.Page != null) { _pointsArray = new PointsArray(); _pointsArray.AddRange(points.ToArray()); } else { _pointsArray = points; } _pointsArray.ChangedPointsArray += changedPointsArray; Dictionary.AddItem("Vertices", _pointsArray.Array); Color = new ColorRGB(0, 0, 0); }
public void TesPolylineAnnotation() { Document document = new Document(); document.Pages.Add(new Page(PaperFormat.A4)); PointsArray points = new PointsArray(); points.AddPoint(new Point(150, 275)); points.AddPoint(new Point(250, 150)); points.AddPoint(new Point(350, 275)); points.AddPoint(new Point(125, 200)); points.AddPoint(new Point(375, 200)); points.AddPoint(new Point(150, 275)); PolylineAnnotation annot = new PolylineAnnotation(points); annot.Contents = "Polyline annotations..."; document.Pages[0].Annotations.Add(annot); document.Save(OutputFolder + @"\TestPolylineAnnotation.pdf"); document.Dispose(); //Process.Start("TestPolylineAnnotation.pdf"); }
public override async Task <GraphicsArray> GetGraphicsFromFile(EmptyMessage a, ServerCallContext context) { try { GraphicsArray result = new GraphicsArray(); List <List <double> > lines = await service.GetGraphicsFromFile(); foreach (var line in lines) { PointsArray newLine = new PointsArray(); newLine.GraphicPoints.Add(line.ToArray()); result.Lines.Add(newLine); } return(result); } catch (Exception ex) { logger.LogError(ex.Message); throw new Exception(ex.Message); } }
private void initCoordinates() { _coordinates = new PointsArray(); PDFArray array = Dictionary["L"] as PDFArray; if (array == null) { _coordinates.AddPoint(new PointF(0, 0)); _coordinates.AddPoint(new PointF(0, 0)); } else { if (array.Count != 2) { _coordinates.AddPoint(new PointF(0, 0)); _coordinates.AddPoint(new PointF(0, 0)); Dictionary.AddItem("L", _coordinates.Array); } else { _coordinates = new PointsArray(array, Page); } } }
/// <summary> /// Initializes a new instance of the Bytescout.PDF.PolylineAnnotation class. /// </summary> /// <param name="points">The Bytescout.PDF.PointsArray that represents the vertices of the polyline.</param> public PolylineAnnotation(PointsArray points) : base(points, null) { Dictionary.AddItem("Subtype", new PDFName("PolyLine")); }
/// <summary> </summary> public PolylineAnnotation CreatePolylineAnnotation(PointsArray pointsArray) { return(new PolylineAnnotation(pointsArray)); }
/// <summary> /// Load object from serialization stream /// </summary> /// <param name="info"></param> /// <param name="orderNumber"></param> public virtual void LoadFromStream(SerializationInfo info, int orderNumber) { GetProperty().ID = info.GetInt64( String.Format(CultureInfo.InvariantCulture, "{0}{1}", entryID, orderNumber)); GetProperty().Name = info.GetString( String.Format(CultureInfo.InvariantCulture, "{0}{1}", entryName, orderNumber)); overlay = info.GetInt32( String.Format(CultureInfo.InvariantCulture, "{0}{1}", entryOverlay, orderNumber)); GetProperty().Type = (TOOL_TYPE)info.GetInt32( String.Format(CultureInfo.InvariantCulture, "{0}{1}", entryType, orderNumber)); GetProperty().MaxZoom = info.GetInt32( String.Format(CultureInfo.InvariantCulture, "{0}{1}", entryMaxZoom, orderNumber)); GetProperty().MinZoom = info.GetInt32( String.Format(CultureInfo.InvariantCulture, "{0}{1}", entryMinZoom, orderNumber)); GetProperty().DefaultZoom = info.GetInt32( String.Format(CultureInfo.InvariantCulture, "{0}{1}", entryDefaultZoom, orderNumber)); GetProperty().LocalPosition = (PointLatLng)info.GetValue( String.Format(CultureInfo.InvariantCulture, "{0}{1}", entryLocalPosition, orderNumber), typeof(PointLatLng)); PointsArray.Clear(); PointLatLng point; int n = info.GetInt32( String.Format(CultureInfo.InvariantCulture, "{0}{1}", entryLengthPoint, orderNumber)); for (int i = 0; i < n; i++) { point = (PointLatLng)info.GetValue( String.Format(CultureInfo.InvariantCulture, "{0}{1}-{2}", entryPoint, orderNumber, i), typeof(PointLatLng)); PointsArray.Add(point); } n = info.GetInt32( String.Format(CultureInfo.InvariantCulture, "{0}{1}", entryLengthLink, orderNumber)); linkArray.Clear(); for (int i = 0; i < n; i++) { Object link = (Object)info.GetValue( String.Format(CultureInfo.InvariantCulture, "{0}{1}-{2}", entryLink, orderNumber, i), typeof(Object)); linkArray.Add(link); } }