public List <Label> getLabels(LabelParameters parameters) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } List <Label> cases = new List <Label>(); bool f = !parameters.variables["limit"]; //Флаг, которые отвечает за получениех всех или не всех обращений с запроса int limit = 0, page = 1; //В Omnidesk счет начинается с 0 do { RestRequest request = new RestRequest("labels.json", Method.GET); request.AddHeader("Content-Type", "application/json"); if (!f) { if (parameters.variables["page"]) { request.AddParameter("page", parameters.page); } if (parameters.variables["limit"]) { request.AddParameter("limit", parameters.limit); } } else { request.AddParameter("page", page); } var response = Connection.Execute(request); var content = response.Content; JObject obj = JObject.Parse(content); if (f) { int.TryParse(obj.GetValue("total_count").ToString(), out limit); } foreach (JProperty t in obj.Properties()) { if (t.Name == "total_count") { continue; } var c = JsonConvert.DeserializeObject <Label>(t.Value["label"].ToString()); cases.Add(c); } } while (page++ < limit / 100 + 1); return(cases); }
public static LegendToggleCommand CreateToggleLayerLabelCommand(MapPresenter map, ILayer layer, LabelParameters labels) { LegendToggleCommand result = new LegendToggleCommand(); result.PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarTextSerif; result.NotCheckedPathMarkup = IRI.Jab.Common.Assets.ShapeStrings.AppbarExtension.appbarTextSerifNone; result.ToolTip = "نمایش برچسب عوارض"; result.Layer = layer; EventHandler <CustomEventArgs <LabelParameters> > labels_IsInScaleRangeChanged = (sender, e) => { if (e.Arg != null) { result.IsEnabled = e.Arg.IsInScaleRange; } }; EventHandler <CustomEventArgs <LabelParameters> > layer_OnLabelChanged = (sender, e) => { if (e.Arg != null) { e.Arg.OnIsInScaleRangeChanged -= labels_IsInScaleRangeChanged; e.Arg.OnIsInScaleRangeChanged += labels_IsInScaleRangeChanged; } }; layer.OnLabelChanged -= layer_OnLabelChanged; layer.OnLabelChanged += layer_OnLabelChanged; layer.Labels = labels; result.Command = new RelayCommand(param => { if (layer == null) { return; } if (result.IsSelected) { result.Layer.Labels.IsOn = true; //map.Refresh(); } else { result.Layer.Labels.IsOn = false; //map.Refresh(); } map.RefreshLayerVisibility(result.Layer); }); return(result); }
public override void Label(LabelParameters parameters) { throw new NotImplementedException(); }
public void DrawGeometryLablePairs(GeometryLabelPairs geometries, string name, VisualParameters parameters, LabelParameters labelParameters) { this.RequestDrawGeometryLablePairs?.Invoke(geometries, name, parameters, labelParameters); }
public static void DrawLabels(List <NamedSqlGeometry> namedGeometries, drawing.Bitmap image, Func <Point, Point> mapToScreen, LabelParameters labelParameters) { //var mapCoordinates = geometries..ConvertAll( // (g) => // { // return labelParameters.PositionFunc(g).AsWpfPoint(); // }).ToList(); var font = new drawing.Font(labelParameters.FontFamily.FamilyNames.First().Value, labelParameters.FontSize); var graphic = drawing.Graphics.FromImage(image); graphic.SmoothingMode = drawing.Drawing2D.SmoothingMode.AntiAlias; graphic.InterpolationMode = drawing.Drawing2D.InterpolationMode.HighQualityBicubic; graphic.PixelOffsetMode = drawing.Drawing2D.PixelOffsetMode.HighQuality; graphic.TextRenderingHint = drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; for (int i = 0; i < namedGeometries.Count; i++) { //var location = mapToScreen(mapCoordinates[i]); //graphic.DrawString(labels[i], font, labelParameters.Foreground.AsGdiBrush(), (float)location.X, (float)location.Y); var location = mapToScreen(labelParameters.PositionFunc(namedGeometries[i].Geometry).AsWpfPoint()); graphic.DrawString(namedGeometries[i].Label ?? string.Empty, font, labelParameters.Foreground.AsGdiBrush(), (float)location.X, (float)location.Y); } graphic.Flush(); }
//Labeling public static void DrawLabels(List <string> labels, List <SqlGeometry> geometries, drawing.Bitmap image, Func <Point, Point> mapToScreen, LabelParameters labelParameters) { if (labels.Count != geometries.Count) { return; } var mapCoordinates = geometries.ConvertAll( (g) => { return(labelParameters.PositionFunc(g).AsWpfPoint()); }).ToList(); var font = new drawing.Font(labelParameters.FontFamily.FamilyNames.First().Value, labelParameters.FontSize, drawing.FontStyle.Bold); var graphic = drawing.Graphics.FromImage(image); graphic.SmoothingMode = drawing.Drawing2D.SmoothingMode.AntiAlias; graphic.InterpolationMode = drawing.Drawing2D.InterpolationMode.HighQualityBicubic; graphic.PixelOffsetMode = drawing.Drawing2D.PixelOffsetMode.HighQuality; graphic.TextRenderingHint = drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; for (int i = 0; i < labels.Count; i++) { var location = mapToScreen(mapCoordinates[i]); System.Drawing.StringFormat format = new drawing.StringFormat(); if (labelParameters.IsRtl) { format.FormatFlags = drawing.StringFormatFlags.DirectionRightToLeft; } var stringSize = graphic.MeasureString(labels[i], font); graphic.DrawString(labels[i], font, labelParameters.Foreground.AsGdiBrush(), (float)(location.X - stringSize.Width / 2.0), (float)(location.Y - stringSize.Height / 2.0), format); } graphic.Flush(); }