Beispiel #1
0
        private void SetupAnnotations()
        {
            annotationLayer = new AnnotationLayer(financialChart1);
            var dataService = DataService.GetService();
            var annotations = dataService.GetAnnotations("box-annotations");

            foreach (var anno in annotations)
            {
                var rectangle = new C1.Win.Chart.Annotation.Rectangle()
                {
                    Content     = "E",
                    Width       = 20,
                    Height      = 20,
                    Attachment  = AnnotationAttachment.DataIndex,
                    PointIndex  = anno.DataIndex,
                    TooltipText = anno.Description == null ?anno.Title : (anno.Title + "\n" + anno.Description)
                };
                rectangle.ContentStyle.StrokeColor = Color.White;
                rectangle.ContentStyle.Font        = new System.Drawing.Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
                rectangle.Style.FillColor          = Color.FromArgb(180, Color.Blue);
                rectangle.Style.StrokeColor        = Color.Black;
                rectangle.Style.StrokeWidth        = 1;
                annotationLayer.Annotations.Add(rectangle);
            }
        }
Beispiel #2
0
        private void SetupAnnotations()
        {
            annotationLayer = new AnnotationLayer(flexChart1);

            var arrowCallout = new Polygon("Low")
            {
                Attachment    = AnnotationAttachment.DataIndex,
                PointIndex    = 1,
                ContentCenter = new PointF(25, -50)
            };
            List <PointF> points = GetPointsForArrowCallout(arrowCallout.ContentCenter.Value.X, arrowCallout.ContentCenter.Value.Y, "Low");

            foreach (PointF p in points)
            {
                arrowCallout.Points.Add(p);
            }
            arrowCallout.ContentStyle.StrokeColor = Color.Black;
            arrowCallout.Style.FillColor          = Color.FromArgb(200, Color.Green);
            arrowCallout.Style.StrokeColor        = Color.Green;

            var lineCallout = new Polygon("High")
            {
                Attachment    = AnnotationAttachment.DataIndex,
                PointIndex    = 4,
                ContentCenter = new Point(-50, 75),
                Points        = { new Point(0, 0), new Point(-50, 50), new Point(-100, 50), new Point(-100, 100), new Point(0, 100), new Point(0, 50), new Point(-50, 50) }
            };

            lineCallout.ContentStyle.StrokeColor = Color.Black;
            lineCallout.Style.FillColor          = Color.FromArgb(200, Color.Red);
            lineCallout.Style.StrokeColor        = Color.Red;

            annotationLayer.Annotations.Add(arrowCallout);
            annotationLayer.Annotations.Add(lineCallout);
        }
Beispiel #3
0
        private async void Initialize()
        {
            // NOTE: to be a writable geodatabase, this geodatabase must be generated from a service with a GeodatabaseSyncTask. See the "Generate geodatabase" sample.
            try
            {
                // Create and load geodatabase.
                string      geodatabasePath = DataManager.GetDataFolder("74c0c9fa80f4498c9739cc42531e9948", "loudoun_anno.geodatabase");
                Geodatabase geodatabase     = await Geodatabase.OpenAsync(geodatabasePath);

                // Create feature layers from tables in the geodatabase.
                FeatureLayer addressFeatureLayer = new FeatureLayer(geodatabase.GeodatabaseFeatureTable("Loudoun_Address_Points_1"));
                FeatureLayer parcelFeatureLayer  = new FeatureLayer(geodatabase.GeodatabaseFeatureTable("ParcelLines_1"));

                // Create annotation layers from tables in the geodatabase.
                AnnotationLayer addressAnnotationLayer = new AnnotationLayer(geodatabase.GeodatabaseAnnotationTable("Loudoun_Address_PointsAnno_1"));
                AnnotationLayer parcelAnnotationLayer  = new AnnotationLayer(geodatabase.GeodatabaseAnnotationTable("ParcelLinesAnno_1"));

                // Create a map with the layers.
                _myMapView.Map = new Map(BasemapStyle.ArcGISLightGray);
                _myMapView.Map.OperationalLayers.AddRange(new List <Layer> {
                    addressFeatureLayer, parcelFeatureLayer, addressAnnotationLayer, parcelAnnotationLayer
                });

                // Zoom to the extent of the parcels.
                await parcelFeatureLayer.LoadAsync();

                _myMapView.SetViewpoint(new Viewpoint(parcelFeatureLayer.FullExtent));
            }
            catch (Exception ex)
            {
                new UIAlertView(ex.GetType().Name, ex.Message, (IUIAlertViewDelegate)null, "Ok", null).Show();
            }
        }
 /// <summary>
 /// Renders the annotations.
 /// </summary>
 /// <param name="rc">
 /// The render context.
 /// </param>
 /// <param name="layer">
 /// The layer.
 /// </param>
 private void RenderAnnotations(IRenderContext rc, AnnotationLayer layer)
 {
     foreach (var a in this.Annotations.Where(a => a.Layer == layer))
     {
         a.Render(rc, this);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Renders the annotations.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="layer">The layer.</param>
        private void RenderAnnotations(IRenderContext rc, AnnotationLayer layer)
        {
            foreach (var a in this.Annotations.Where(a => a.Layer == layer))
            {
                rc.SetToolTip(a.ToolTip);
                a.Render(rc);
            }

            rc.SetToolTip(null);
        }
Beispiel #6
0
        private void SetupChart()
        {
            flexChart.ChartType  = ChartType.Column;
            flexChart.BindingX   = "Date";
            flexChart.Background = new SolidColorBrush(Colors.White);

            // setup common X Axis
            xAxis = new Axis
            {
                Format         = "d MMM",
                GroupProvider  = new MyDateTimeGroupProvider(),
                GroupSeparator = AxisGroupSeparator.Horizontal
            };

            flexChart.Header      = "Monthly Temperature (°F)";
            flexChart.HeaderStyle = new ChartStyle
            {
                FontSize = 25
            };
            //flexChart.Footer = "Copyright (c) GrapeCity";
            flexChart.SelectionMode = ChartSelectionMode.Series;
            flexChart.LegendToggle  = true;

            flexChart.ToolTip = null;


            annotationLayer = new AnnotationLayer();
            flexChart.Layers.Add(annotationLayer);

            lineMarker = new C1LineMarker
            {
                LineWidth = 2,
                LineBrush = new SolidColorBrush(Colors.Gray)
            };
            lineMarker.PositionChanged += OnLineMarkerPositionChanged;
            flexChart.Layers.Add(lineMarker);

            flexChart.Rendered  += FlexChart_Rendered;
            flexChart.Rendering += FlexChart_Rendering;

            flexChart.AnimationSettings  = AnimationSettings.Load;
            flexChart.AnimationLoad.Type = AnimationType.Series;

            //flexChart.Palette = Palette.Cerulean;

            flexChart.LegendGroupHeaderStyle = new ChartStyle
            {
                FontWeight = FontWeights.Bold,
                FontSize   = 14,
                Stroke     = new SolidColorBrush(Color.FromRgb(82, 82, 82))
            };
        }
 private Task GetFirstSelectedAnnoFeatureAsync(AnnotationLayer annoLayer)
 {
     return(QueuedTask.Run(() => {
         var annoSelect = annoLayer.GetSelection();
         var rowcursor = annoLayer.GetSelection().Search(null);
         if (rowcursor.MoveNext())
         {
             var af = rowcursor.Current as AnnotationFeature;
             var graphic = af.GetGraphic() as CIMTextGraphic;
             Module1.Current.SetSelectedGraphic(annoLayer, graphic);
         }
     }));
 }
Beispiel #8
0
        private void SetupAnnotations()
        {
            var annotationLayer = new AnnotationLayer(this.flexChart1);
            var orderedCost     = _data.OrderBy(x => x.Cost).ToList();
            //Arrow Callouts
            var arrowCallout1 = new Polygon("Minimum Cost")
            {
                Attachment  = AnnotationAttachment.DataIndex,
                SeriesIndex = 0,
                PointIndex  = _data.IndexOf(orderedCost[0]),
            };

            arrowCallout1.Style.FillColor          = Color.FromArgb(200, Color.Green);
            arrowCallout1.Style.StrokeColor        = Color.Green;
            arrowCallout1.ContentStyle.StrokeColor = Color.White;
            foreach (PointF point in GetArrowCalloutPoints(arrowCallout1, orderedCost[0]))
            {
                arrowCallout1.Points.Add(point);
            }
            var arrowCallout2 = new Polygon("Maximum Cost")
            {
                Attachment  = AnnotationAttachment.DataIndex,
                SeriesIndex = 0,
                PointIndex  = _data.IndexOf(orderedCost[_data.Count - 1]),
            };

            arrowCallout2.Style.FillColor          = Color.FromArgb(200, Color.Red);
            arrowCallout2.Style.StrokeColor        = Color.Red;
            arrowCallout2.ContentStyle.StrokeColor = Color.White;
            foreach (PointF point in GetArrowCalloutPoints(arrowCallout2, orderedCost[_data.Count - 1]))
            {
                arrowCallout2.Points.Add(point);
            }

            var lineCallout = new Polygon("Highest Profit")
            {
                Attachment    = AnnotationAttachment.DataIndex,
                SeriesIndex   = 0,
                PointIndex    = _data.IndexOf(orderedCost[0]),
                ContentCenter = new PointF(30, -60),
                Points        = { new PointF(0, 0), new PointF(30, -40), new PointF(-30, -40), new PointF(-30, -80), new PointF(90, -80), new PointF(90, -40), new PointF(30, -40) }
            };

            lineCallout.Style.FillColor          = Color.FromArgb(200, Color.Blue);
            lineCallout.Style.StrokeColor        = Color.Blue;
            lineCallout.ContentStyle.StrokeColor = Color.White;

            annotationLayer.Annotations.Add(arrowCallout1);
            annotationLayer.Annotations.Add(arrowCallout2);
            annotationLayer.Annotations.Add(lineCallout);
        }
Beispiel #9
0
        private async void Initialize()
        {
            try
            {
                // Load the mobile map package.
                _mobileMapPackage = new MobileMapPackage(DataManager.GetDataFolder("b87307dcfb26411eb2e92e1627cb615b", "GasDeviceAnno.mmpk"));
                await _mobileMapPackage.LoadAsync();

                // Set the mapview to display the map from the package.
                _myMapView.Map = _mobileMapPackage.Maps.First();

                // Get the annotation layer from the MapView operational layers.
                AnnotationLayer annotationLayer = (AnnotationLayer)_myMapView.Map.OperationalLayers.Where(layer => layer is AnnotationLayer).First();

                // Load the annotation layer.
                await annotationLayer.LoadAsync();

                // Get the annotation sub layers.
                _closedSublayer = (AnnotationSublayer)annotationLayer.SublayerContents[0];
                _openSublayer   = (AnnotationSublayer)annotationLayer.SublayerContents[1];

                // Set the label content.
                _openLabel.Text   = $"{_openSublayer.Name} (1:{_openSublayer.MaxScale} - 1:{_openSublayer.MinScale})";
                _closedLabel.Text = _closedSublayer.Name;

                // Enable the check boxes.
                _openSwitch.Enabled   = true;
                _closedSwitch.Enabled = true;

                // Add event handler for changing the text to indicate whether the "open" sublayer is visible at the current scale.
                _myMapView.ViewpointChanged += (s, e) =>
                {
                    // Check if the sublayer is visible at the current map scale.
                    if (_openSublayer.IsVisibleAtScale(_myMapView.MapScale))
                    {
                        _openLabel.TextColor = UIColor.Black;
                    }
                    else
                    {
                        _openLabel.TextColor = UIColor.Gray;
                    }

                    // Set the current map scale text.
                    _scaleLabel.Text = "Current map scale: 1:" + (int)_myMapView.MapScale;
                };
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        protected override async void OnClick()
        {
            // get an anno layer
            AnnotationLayer annoLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <AnnotationLayer>().FirstOrDefault();

            if (annoLayer == null)
            {
                return;
            }

            bool result = await QueuedTask.Run(async() =>
            {
                // get an existing template
                EditingTemplate template = annoLayer.GetTemplates().FirstOrDefault();
                if (template == null)
                {
                    return(false);
                }

                // make sure it is active before you get the inspector
                await template.ActivateDefaultToolAsync();

                var insp = template.Inspector;
                if (insp == null)
                {
                    return(false);
                }

                // set up some properties
                AnnotationProperties annoProperties = insp.GetAnnotationProperties();
                annoProperties.TextString           = "special text";
                annoProperties.Color     = ColorFactory.Instance.GreenRGB;
                annoProperties.SmallCaps = true;
                insp.SetAnnotationProperties(annoProperties);

                // set up default tool - use daml-id rather than guid
                string defaultTool = "esri_editing_SketchStraightAnnoTool";

                // dont alter the filter or tags

                // create a new CIM template  - new extension method
                var newTemplate = annoLayer.CreateTemplate("template from existing template", "sample template description", insp, defaultTool);
                return(newTemplate != null);
            });
        }
        private void Initialize()
        {
            // Uris for the river data.
            Uri riverFeatureServiceUri = new Uri("https://services1.arcgis.com/6677msI40mnLuuLr/arcgis/rest/services/East_Lothian_Rivers/FeatureServer/0");
            Uri riverFeatureLayerUri   = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/RiversAnnotation/FeatureServer/0");

            // Create a map.
            Map map = new Map(BasemapType.LightGrayCanvasVector, 55.882436, -2.725610, 13);

            // Create a feature layer from a feature service.
            FeatureLayer riverFeatureLayer = new FeatureLayer(new ServiceFeatureTable(riverFeatureServiceUri));

            // Add the feature layer to the map.
            map.OperationalLayers.Add(riverFeatureLayer);

            // Create an annotation layer from a feature service.
            AnnotationLayer annotationLayer = new AnnotationLayer(riverFeatureLayerUri);

            // Add the annotation layer to the map.
            map.OperationalLayers.Add(annotationLayer);

            // Set the map to the map view.
            _myMapView.Map = map;
        }
        /// <summary>
        /// Called when the sketch finishes. This is where we will create the edit operation and then execute it.
        /// </summary>
        /// <param name="geometry">The geometry created by the sketch.</param>
        /// <returns>A Task returning a Boolean indicating if the sketch complete event was successfully handled.</returns>
        protected override async Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            if (CurrentTemplate == null || geometry == null)
            {
                return(false);
            }

            bool result = await QueuedTask.Run(() =>
            {
                // get the anno layer
                AnnotationLayer annoLayer = CurrentTemplate.Layer as AnnotationLayer;
                if (annoLayer == null)
                {
                    return(false);
                }

                // get the anno feature class
                var fc = annoLayer.GetFeatureClass() as ArcGIS.Core.Data.Mapping.AnnotationFeatureClass;
                if (fc == null)
                {
                    return(false);
                }

                // get the featureclass CIM definition which contains the labels, symbols
                var cimDefinition = fc.GetDefinition() as ArcGIS.Core.Data.Mapping.AnnotationFeatureClassDefinition;
                var labels        = cimDefinition.GetLabelClassCollection();
                var symbols       = cimDefinition.GetSymbolCollection();

                // make sure there are labels, symbols
                if ((labels.Count == 0) || (symbols.Count == 0))
                {
                    return(false);
                }


                // find the label class required
                //   typically you would use a subtype name or some other characteristic

                // use the first label class
                var label = labels[0];
                if (labels.Count > 1)
                {
                    // find a label class based on template name
                    foreach (var LabelClass in labels)
                    {
                        if (LabelClass.Name == CurrentTemplate.Name)
                        {
                            label = LabelClass;
                            break;
                        }
                    }
                }

                // each label has a textSymbol
                // the symbolName *should* be the symbolID to be used
                var symbolName = label.TextSymbol.SymbolName;
                int symbolID   = -1;
                if (!int.TryParse(symbolName, out symbolID))
                {
                    // int.TryParse fails - attempt to find the symbolName in the symbol collection
                    foreach (var symbol in symbols)
                    {
                        if (symbol.Name == symbolName)
                        {
                            symbolID = symbol.ID;
                            break;
                        }
                    }
                }
                // no symbol?
                if (symbolID == -1)
                {
                    return(false);
                }


                // use the template's inspector object
                var inspector = CurrentTemplate.Inspector;
                // get the annotation properties
                var annoProperties = inspector.GetAnnotationProperties();

                // AnnotationClassID, SymbolID and Shape are the bare minimum for an annotation feature

                // use the inspector[fieldName] to set the annotationClassid - this is allowed since annotationClassID is a guaranteed field in the annotation schema
                inspector["AnnotationClassID"] = label.ID;
                // set the symbolID too
                inspector["SymbolID"] = symbolID;

                // use the annotation properties to set the other attributes
                annoProperties.TextString        = "My annotation feature";
                annoProperties.Color             = ColorFactory.Instance.GreenRGB;
                annoProperties.VerticalAlignment = ArcGIS.Core.CIM.VerticalAlignment.Top;
                annoProperties.Underline         = true;

                // set the geometry to be the sketched line
                // when creating annotation features the shape to be passed in the create operation is the CIMTextGraphic shape
                annoProperties.Shape = geometry;

                // set the annotation properties back on the inspector
                inspector.SetAnnotationProperties(annoProperties);

                // Create an edit operation
                var createOperation  = new EditOperation();
                createOperation.Name = string.Format("Create {0}", CurrentTemplate.Layer.Name);
                createOperation.SelectNewFeatures = true;

                // create and execute using the inspector
                createOperation.Create(CurrentTemplate.Layer, inspector);
                return(createOperation.Execute());
            });

            return(result);
        }
 public SelectedGraphicChangedEventArgs(AnnotationLayer annoLayer, CIMTextGraphic graphic)
 {
     AnnotationLayer = annoLayer;
     SelectedGraphic = graphic;
 }
Beispiel #14
0
        private void SetupChart()
        {
            flexChart.ChartType  = ChartType.Column;
            flexChart.BindingX   = "Date";
            flexChart.Background = new SolidColorBrush(Colors.White);

            // setup common X Axis
            xAxis = new Axis
            {
                Format         = "d MMM",
                GroupProvider  = new MyDateTimeGroupProvider(),
                GroupSeparator = AxisGroupSeparator.Horizontal
            };

            flexChart.Header      = "Monthly Temperature (°F)";
            flexChart.HeaderStyle = new ChartStyle
            {
                FontSize = 25
            };
            //flexChart.Footer = "Copyright (c) GrapeCity";
            flexChart.SelectionMode = ChartSelectionMode.Series;
            flexChart.LegendToggle  = true;

            flexChart.ToolTip = null;


            annotationLayer = new AnnotationLayer();
            flexChart.Layers.Add(annotationLayer);

            al = new EditableAnnotationLayer(flexChart)
            {
                ContentEditor = new AnnotationEditor()
            };
            al.PolygonAddFunc = (pt) =>
            {
                return(new Polygon(string.Empty)
                {
                    Points =
                    {
                        pt, pt, pt
                    }
                });
            };
            al.PolygonReSizeFunc = (poly, rectangle) =>
            {
                var top   = new Point((float)(rectangle.Left + rectangle.Width / 2), rectangle.Y);
                var left  = new Point(rectangle.Left, rectangle.Bottom);
                var right = new Point(rectangle.Right, rectangle.Bottom);
                poly.Points[0] = Helpers.CoordsToAnnoPoint(flexChart, poly, top);
                poly.Points[1] = Helpers.CoordsToAnnoPoint(flexChart, poly, left);
                poly.Points[2] = Helpers.CoordsToAnnoPoint(flexChart, poly, right);
            };
            flexChart.Layers.Add(al);

            lineMarker = new C1LineMarker
            {
                LineWidth = 2,
                LineBrush = new SolidColorBrush(Colors.Gray)
            };
            lineMarker.PositionChanged += OnLineMarkerPositionChanged;
            flexChart.Layers.Add(lineMarker);

            flexChart.Rendered  += FlexChart_Rendered;
            flexChart.Rendering += FlexChart_Rendering;
            flexChart.MouseDown += FlexChart_MouseDown;
            flexChart.KeyDown   += FlexChart_KeyDown;

            flexChart.AnimationSettings  = AnimationSettings.Load;
            flexChart.AnimationLoad.Type = AnimationType.Series;

            //flexChart.Palette = Palette.Cerulean;

            flexChart.LegendGroupHeaderStyle = new ChartStyle
            {
                FontWeight = FontWeights.Bold,
                FontSize   = 14,
                Stroke     = new SolidColorBrush(Color.FromRgb(82, 82, 82))
            };
        }
Beispiel #15
0
        public void CreateTemplate()
        {
            string value1 = "";
            string value2 = "";
            string value3 = "";

            #region Create New Template using layer.CreateTemplate

            var layer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault();
            if (layer == null)
            {
                return;
            }
            QueuedTask.Run(() =>
            {
                var insp = new Inspector();
                insp.LoadSchema(layer);

                insp["Field1"] = value1;
                insp["Field2"] = value2;
                insp["Field3"] = value3;

                var tags = new[] { "Polygon", "tag1", "tag2" };

                // set defaultTool using a daml-id
                string defaultTool = "esri_editing_SketchCirclePolygonTool";

                // tool filter is the tools to filter OUT
                var toolFilter = new[] { "esri_editing_SketchTracePolygonTool" };

                // create a new template
                var newTemplate = layer.CreateTemplate("My new template", "description", insp, defaultTool, tags, toolFilter);
            });
            #endregion

            #region Create Annotation Template

            // get an anno layer
            AnnotationLayer annoLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <AnnotationLayer>().FirstOrDefault();
            if (annoLayer == null)
            {
                return;
            }

            QueuedTask.Run(() =>
            {
                Inspector insp = null;
                // get the anno feature class
                var fc = annoLayer.GetFeatureClass() as ArcGIS.Core.Data.Mapping.AnnotationFeatureClass;

                // get the featureclass CIM definition which contains the labels, symbols
                var cimDefinition = fc.GetDefinition() as ArcGIS.Core.Data.Mapping.AnnotationFeatureClassDefinition;
                var labels        = cimDefinition.GetLabelClassCollection();
                var symbols       = cimDefinition.GetSymbolCollection();

                // make sure there are labels, symbols
                if ((labels.Count == 0) || (symbols.Count == 0))
                {
                    return;
                }

                // find the label class required
                //   typically you would use a subtype name or some other characteristic
                // in this case lets just use the first one

                var label = labels[0];

                // each label has a textSymbol
                // the symbolName *should* be the symbolID to be used
                var symbolName = label.TextSymbol.SymbolName;
                int symbolID   = -1;
                if (!int.TryParse(symbolName, out symbolID))
                {
                    // int.TryParse fails - attempt to find the symbolName in the symbol collection
                    foreach (var symbol in symbols)
                    {
                        if (symbol.Name == symbolName)
                        {
                            symbolID = symbol.ID;
                            break;
                        }
                    }
                }
                // no symbol?
                if (symbolID == -1)
                {
                    return;
                }

                // load the schema
                insp = new Inspector();
                insp.LoadSchema(annoLayer);

                // ok to assign these fields using the inspector[fieldName] methodology
                //   these fields are guaranteed to exist in the annotation schema
                insp["AnnotationClassID"] = label.ID;
                insp["SymbolID"]          = symbolID;

                // set up some additional annotation properties
                AnnotationProperties annoProperties = insp.GetAnnotationProperties();
                annoProperties.FontSize             = 36;
                annoProperties.TextString           = "My Annotation feature";
                annoProperties.VerticalAlignment    = VerticalAlignment.Top;
                annoProperties.HorizontalAlignment  = HorizontalAlignment.Justify;

                insp.SetAnnotationProperties(annoProperties);

                var tags = new[] { "Annotation", "tag1", "tag2" };

                // use daml-id rather than guid
                string defaultTool = "esri_editing_SketchStraightAnnoTool";

                // tool filter is the tools to filter OUT
                var toolFilter = new[] { "esri_editing_SketchCurvedAnnoTool" };

                // create a new template
                var newTemplate = annoLayer.CreateTemplate("new anno template", "description", insp, defaultTool, tags, toolFilter);
            });

            #endregion
        }
Beispiel #16
0
        /// <summary>
        /// Renders the annotations.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="layer">The layer.</param>
        private void RenderAnnotations(IRenderContext rc, AnnotationLayer layer)
        {
            foreach (var a in this.Annotations.Where(a => a.Layer == layer))
            {
                rc.SetToolTip(a.ToolTip);
                a.Render(rc);
            }

            rc.SetToolTip(null);
        }
 /// <summary>
 /// Renders the annotations.
 /// </summary>
 /// <param name="rc">
 /// The render context.
 /// </param>
 /// <param name="layer">
 /// The layer.
 /// </param>
 private void RenderAnnotations(IRenderContext rc, AnnotationLayer layer)
 {
     foreach (var a in this.Annotations.Where(a => a.Layer == layer))
     {
         a.Render(rc, this);
     }
 }
        protected override async void OnClick()
        {
            // get an anno layer
            AnnotationLayer annoLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <AnnotationLayer>().FirstOrDefault();

            if (annoLayer == null)
            {
                return;
            }

            Inspector insp   = null;
            bool      result = await QueuedTask.Run(() =>
            {
                // get the anno feature class
                var fc = annoLayer.GetFeatureClass() as ArcGIS.Core.Data.Mapping.AnnotationFeatureClass;

                // get the featureclass CIM definition which contains the labels, symbols
                var cimDefinition = fc.GetDefinition() as ArcGIS.Core.Data.Mapping.AnnotationFeatureClassDefinition;
                var labels        = cimDefinition.GetLabelClassCollection();
                var symbols       = cimDefinition.GetSymbolCollection();

                // make sure there are labels, symbols
                if ((labels.Count == 0) || (symbols.Count == 0))
                {
                    return(false);
                }

                // find the label class required
                //   typically you would use a subtype name or some other characteristic
                // in this case lets just use the first one

                // var label = labels[0];

                // find the label class required
                //   typically you would use a subtype name or some other characteristic

                // use the first label class
                var label = labels[0];
                if (labels.Count > 1)
                {
                    // find a label class based on template name
                    foreach (var LabelClass in labels)
                    {
                        if (LabelClass.Name == "Basic")
                        {
                            label = LabelClass;
                            break;
                        }
                    }
                }

                // each label has a textSymbol
                // the symbolName *should* be the symbolID to be used
                var symbolName = label.TextSymbol.SymbolName;
                int symbolID   = -1;
                if (!int.TryParse(symbolName, out symbolID))
                {
                    // int.TryParse fails - attempt to find the symbolName in the symbol collection
                    foreach (var symbol in symbols)
                    {
                        if (symbol.Name == symbolName)
                        {
                            symbolID = symbol.ID;
                            break;
                        }
                    }
                }
                // no symbol?
                if (symbolID == -1)
                {
                    return(false);
                }

                // load the schema
                insp = new Inspector();
                insp.LoadSchema(annoLayer);

                // ok to access AnnotationClassID, SymbolID this way - it is guaranteed to exist
                insp["AnnotationClassID"] = label.ID;
                insp["SymbolID"]          = symbolID;

                // set up some text properties
                AnnotationProperties annoProperties = insp.GetAnnotationProperties();
                annoProperties.FontSize             = 36;
                annoProperties.TextString           = "My Annotation feature";
                annoProperties.VerticalAlignment    = VerticalAlignment.Top;
                annoProperties.HorizontalAlignment  = HorizontalAlignment.Justify;

                // assign the properties back to the inspector
                insp.SetAnnotationProperties(annoProperties);

                // set up tags
                var tags = new[] { "Annotation", "tag1", "tag2" };

                // set up default tool - use daml-id rather than guid
                string defaultTool = "esri_editing_SketchStraightAnnoTool";

                // tool filter is the tools to filter OUT
                var toolFilter = new[] { "esri_editing_SketchCurvedAnnoTool" };

                // create a new CIM template  - new extension method
                var newTemplate = annoLayer.CreateTemplate("My new template", "sample template description", insp, defaultTool, tags, toolFilter);

                return(newTemplate != null);
            });
        }
        /// <summary>
        /// Called when the sketch finishes. This is where we will create the edit operation and then execute it.
        /// </summary>
        /// <param name="geometry">The geometry created by the sketch.</param>
        /// <returns>A Task returning a Boolean indicating if the sketch complete event was successfully handled.</returns>
        protected override async Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            if (CurrentTemplate == null || geometry == null)
            {
                return(false);
            }

            bool result = await QueuedTask.Run(() =>
            {
                // get the anno layer
                AnnotationLayer annoLayer = CurrentTemplate.Layer as AnnotationLayer;
                if (annoLayer == null)
                {
                    return(false);
                }

                // get the anno feature class
                var fc = annoLayer.GetFeatureClass() as ArcGIS.Core.Data.Mapping.AnnotationFeatureClass;
                if (fc == null)
                {
                    return(false);
                }

                // get the featureclass CIM definition which contains the labels, symbols
                var cimDefinition = fc.GetDefinition() as ArcGIS.Core.Data.Mapping.AnnotationFeatureClassDefinition;
                var labels        = cimDefinition.GetLabelClassCollection();
                var symbols       = cimDefinition.GetSymbolCollection();

                // make sure there are labels, symbols
                if ((labels.Count == 0) || (symbols.Count == 0))
                {
                    return(false);
                }


                // find the label class required
                //   typically you would use a subtype name or some other characteristic

                // use the first label class
                var label = labels[0];
                if (labels.Count > 1)
                {
                    // find a label class based on template name
                    foreach (var LabelClass in labels)
                    {
                        if (LabelClass.Name == CurrentTemplate.Name)
                        {
                            label = LabelClass;
                            break;
                        }
                    }
                }

                // each label has a textSymbol
                // the symbolName *should* be the symbolID to be used
                var symbolName = label.TextSymbol.SymbolName;
                int symbolID   = -1;
                if (!int.TryParse(symbolName, out symbolID))
                {
                    // int.TryParse fails - attempt to find the symbolName in the symbol collection
                    foreach (var symbol in symbols)
                    {
                        if (symbol.Name == symbolName)
                        {
                            symbolID = symbol.ID;
                            break;
                        }
                    }
                }
                // no symbol?
                if (symbolID == -1)
                {
                    return(false);
                }

                // use a dictionary to set values
                Dictionary <string, object> values = new Dictionary <string, object>();

                // AnnotationClassID, SymbolID and Shape are the bare minimum for an annotation feature

                // set the SymbolID
                values.Add("SymbolID", symbolID);
                // set the AnnotationClassID
                values.Add("AnnotationClassID", label.ID);

                // you can also add text (if the field exists)
                // if you don't set text then the feature has the default value of 'Text'
                int idxField = cimDefinition.FindField("TextString");
                if (idxField != -1)
                {
                    values.Add("TextString", "My annotation feature");
                }

                // set the geometry to be the sketched line
                // when creating annotation features the shape to be passed in the create operation is the CIMTextGraphic shape
                values["SHAPE"] = geometry;


                // Create an edit operation
                var createOperation  = new EditOperation();
                createOperation.Name = string.Format("Create {0}", CurrentTemplate.Layer.Name);
                createOperation.SelectNewFeatures = true;

                // create and execute
                createOperation.Create(CurrentTemplate.Layer, values);
                return(createOperation.Execute());
            });

            return(result);
        }
Beispiel #20
0
        private void SetupAnnotations()
        {
            annotationLayer = new AnnotationLayer(flexChart1);

            var txtRelative = new C1.Win.Chart.Annotation.Text("Relative")
            {
                Location    = new PointF(0.55f, 0.15f),
                Attachment  = AnnotationAttachment.Relative,
                TooltipText = "This is a content annotation\r\nLocation: { x:0.55, y:0.15 }\r\nAttachment: Relative"
            };

            txtRelative.Style.StrokeColor = Color.Black;
            txtRelative.Style.Font        = new System.Drawing.Font(FontFamily.GenericSansSerif, 15);
            annotationLayer.Annotations.Add(txtRelative);

            var ellipseRelative = new Ellipse("Relative", 120, 80)
            {
                Location    = new PointF(0.4f, 0.45f),
                Attachment  = AnnotationAttachment.Relative,
                TooltipText = "This is a ellipse annotation\r\nLocation: { x:0.4, y:0.45 }\r\nAttachment: Relative"
            };

            ellipseRelative.ContentStyle.StrokeColor = Color.Black;
            ellipseRelative.ContentStyle.Font        = new System.Drawing.Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
            ellipseRelative.Style.FillColor          = Color.FromArgb(200, Color.Goldenrod);
            ellipseRelative.Style.StrokeColor        = Color.DarkGoldenrod;
            ellipseRelative.Style.StrokeWidth        = 2;
            annotationLayer.Annotations.Add(ellipseRelative);

            var circle = new Circle("DataIndex", 50)
            {
                SeriesIndex = 0,
                PointIndex  = 27,
                Attachment  = AnnotationAttachment.DataIndex,
                TooltipText = "This is a circle annotation\r\nRadius: 50\r\nPointIndex: 27\r\nAttachment: DataIndex"
            };

            circle.ContentStyle.StrokeColor = Color.Black;
            circle.ContentStyle.Font        = new System.Drawing.Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
            circle.Style.FillColor          = Color.FromArgb(200, Color.LightSeaGreen);
            circle.Style.StrokeColor        = Color.DarkCyan;
            circle.Style.StrokeWidth        = 2;
            annotationLayer.Annotations.Add(circle);

            var rectangle = new C1.Win.Chart.Annotation.Rectangle("DataCoordinate", 130, 100)
            {
                Location    = new PointF(37, 30),
                Attachment  = AnnotationAttachment.DataCoordinate,
                TooltipText = "This is a rectangle annotation\r\nLocation: { x:37, y:30 }\r\nAttachment: DataCoordinate"
            };

            rectangle.ContentStyle.StrokeColor = Color.Black;
            rectangle.ContentStyle.Font        = new System.Drawing.Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
            rectangle.Style.FillColor          = Color.FromArgb(200, Color.SlateBlue);
            rectangle.Style.StrokeColor        = Color.DarkSlateBlue;
            rectangle.Style.StrokeWidth        = 2;
            annotationLayer.Annotations.Add(rectangle);

            var square = new C1.Win.Chart.Annotation.Square("DataIndex", 80)
            {
                SeriesIndex = 0,
                PointIndex  = 45,
                Attachment  = AnnotationAttachment.DataIndex,
                TooltipText = "This is a square annotation\r\nLength: 80\r\nPointIndex: 45\r\nAttachment: DataIndex"
            };

            square.ContentStyle.StrokeColor = Color.Black;
            square.ContentStyle.Font        = new System.Drawing.Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
            square.Style.FillColor          = Color.FromArgb(200, Color.SandyBrown);
            square.Style.StrokeColor        = Color.Chocolate;
            square.Style.StrokeWidth        = 2;

            annotationLayer.Annotations.Add(square);

            var polygon = new C1.Win.Chart.Annotation.Polygon("Absolute")
            {
                Attachment = AnnotationAttachment.Absolute,
                Points     =
                {
                    new PointF(200,  25),
                    new PointF(150,  70),
                    new PointF(175, 115),
                    new PointF(225, 115),
                    new PointF(250, 70)
                },
                TooltipText = "This is a points annotation\r\nPoints: [(200, 25),(150, 70),(175, 115),(225, 115),(250, 70)]\r\nAttachment: Absolute"
            };

            polygon.ContentStyle.StrokeColor = Color.Black;
            polygon.ContentStyle.Font        = new System.Drawing.Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
            polygon.Style.FillColor          = Color.FromArgb(200, Color.Red);
            polygon.Style.StrokeColor        = Color.DarkTurquoise;
            polygon.Style.StrokeWidth        = 3;
            annotationLayer.Annotations.Add(polygon);

            var line = new C1.Win.Chart.Annotation.Line("Absolute", new Point(50, 200), new Point(300, 350))
            {
                Attachment  = AnnotationAttachment.Absolute,
                TooltipText = "This is a line annotation\r\nPoints: [(50, 200),(300, 350)]\r\nAttachment: Absolute"
            };

            line.ContentStyle.StrokeColor = Color.Black;
            line.ContentStyle.Font        = new System.Drawing.Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
            line.Style.StrokeWidth        = 4;
            line.Style.StrokeColor        = Color.DarkTurquoise;
            annotationLayer.Annotations.Add(line);

            annotationLayer.Annotations.Add(new C1.Win.Chart.Annotation.Image()
            {
                SourceImage = AnnotationExplorer.Properties.Resources.Image,
                Location    = new PointF(22, 30),
                Attachment  = AnnotationAttachment.DataCoordinate,
                TooltipText = "This is a image annotation\r\nLocation: { x:22, y:30 }\r\nAttachment: DataCoordinate"
            });
        }
Beispiel #21
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
            chart = new FlexChart();
            chart.LegendPosition = ChartPositionType.Bottom;
            chart.ChartType      = ChartType.Line;
            chart.BindingX       = "X";
            chart.Series.Add(new ChartSeries()
            {
                SeriesName = "Base dataList", Binding = "Y,Y"
            });
            chart.ItemsSource = new AnnotationViewModel().Data;
            this.Add(chart);

            Text text = new Text()
            {
                Content = "Relative", Location = new CGPoint(0.5, 0.5), Attachment = AnnotationAttachment.Relative
            };

            text.AnnotationStyle = new ChartStyle()
            {
                FontSize = 15, Stroke = UIColor.Black, FontFamily = UIFont.FromName("GenericSansSerif", 15)
            };

            Ellipse ellipse = new Ellipse()
            {
                Content = "Relative", Location = new CGPoint(0.4, 0.45), Width = 120, Height = 80, Attachment = AnnotationAttachment.Relative
            };

            ellipse.AnnotationStyle = new ChartStyle()
            {
                Fill = UIColor.FromRGBA(0.85f, 0.65f, 0.12f, 1.0f), Stroke = UIColor.FromRGBA(0.75f, 0.55f, 0.06f, 1.0f), FontFamily = UIFont.ItalicSystemFontOfSize(10)
            };

            Circle circle = new Circle()
            {
                Content = "DataIndex", Radius = 50, SeriesIndex = 0, PointIndex = 27, Attachment = AnnotationAttachment.DataIndex
            };

            circle.AnnotationStyle = new ChartStyle()
            {
                Fill = UIColor.FromRGBA(0.17f, 0.70f, 0.67f, 1.0f), Stroke = UIColor.FromRGBA(0.13f, 0.58f, 0.58f, 1.0f), FontFamily = UIFont.BoldSystemFontOfSize(10)
            };

            Rectangle rectangle = new Rectangle()
            {
                Content = "DataCoordinate", Width = 130, Height = 100, Location = new CGPoint(37, 80), Attachment = AnnotationAttachment.DataCoordinate
            };

            rectangle.AnnotationStyle = new ChartStyle()
            {
                Fill = UIColor.FromRGBA(0.42f, 0.35f, 0.80f, 1.0f), Stroke = UIColor.FromRGBA(0.29f, 0.25f, 0.57f, 1.0f), FontFamily = UIFont.BoldSystemFontOfSize(10)
            };

            Square square = new Square()
            {
                Content = "DataIndex", Length = 80, SeriesIndex = 0, PointIndex = 40, Attachment = AnnotationAttachment.DataIndex
            };

            square.AnnotationStyle = new ChartStyle()
            {
                Fill = UIColor.FromRGBA(0.96f, 0.64f, 0.38f, 1.0f), Stroke = UIColor.FromRGBA(0.89f, 0.54f, 0.25f, 1.0f), FontFamily = UIFont.BoldSystemFontOfSize(10)
            };

            Polygon polygon = new Polygon()
            {
                Content = "polygonAnno", Attachment = AnnotationAttachment.Absolute
            };

            polygon.Points          = CreatePoints();
            polygon.AnnotationStyle = new ChartStyle()
            {
                Fill = UIColor.Red, StrokeThickness = 3, Stroke = UIColor.FromRGBA(0.62f, 0.13f, 0.21f, 1.0f), FontFamily = UIFont.BoldSystemFontOfSize(10)
            };

            Line line = new Line()
            {
                Content = "Absolute", Start = new CGPoint(50, 200), End = new CGPoint(300, 350), Attachment = AnnotationAttachment.Absolute
            };

            line.AnnotationStyle = new ChartStyle()
            {
                StrokeThickness = 4, FontSize = 10, FontAttributes = CTFontSymbolicTraits.Bold, Stroke = UIColor.FromRGBA(0.20f, 0.81f, 0.82f, 1.0f), FontFamily = UIFont.BoldSystemFontOfSize(10)
            };

            Image image = new Image()
            {
                Location = new CGPoint(12, 20), Attachment = AnnotationAttachment.DataCoordinate
            };

            image.Source = new UIImage("Images/xuni_butterfly.png");

            AnnotationLayer layer = new AnnotationLayer();

            layer.Annotations.Add(text);
            layer.Annotations.Add(ellipse);
            layer.Annotations.Add(circle);
            layer.Annotations.Add(rectangle);
            layer.Annotations.Add(square);
            layer.Annotations.Add(polygon);
            layer.Annotations.Add(line);
            layer.Annotations.Add(image);
            chart.Layers.Add(layer);
        }
Beispiel #22
0
        private void SetupAnnotations()
        {
            annotationLayer = new AnnotationLayer(this.flexChart1);
            var lowestClose  = _stockData.Min(y => y.Close);
            var highestClose = _stockData.Max(y => y.Close);
            //Two lines to show rising wedges
            var risingLine = new Line("Rising Wedges")
            {
                Start      = new Point((int)_stockData[0].Date.ToOADate() + 5, (int)lowestClose + 40),
                End        = new Point((int)_stockData[0].Date.ToOADate() + 65, (int)highestClose),
                Attachment = AnnotationAttachment.DataCoordinate,
            };

            risingLine.ContentStyle.StrokeColor = Color.Black;
            risingLine.ContentStyle.Font        = _contentFont;
            risingLine.Style.StrokeColor        = Color.Aqua;
            risingLine.Style.StrokeWidth        = 1;

            var emptyLine = new Line()
            {
                Start      = new Point((int)_stockData[0].Date.ToOADate() + 5, (int)lowestClose),
                End        = new Point((int)_stockData[0].Date.ToOADate() + 65, (int)highestClose - 40),
                Attachment = AnnotationAttachment.DataCoordinate,
            };

            emptyLine.Style.StrokeColor = Color.Aqua;
            emptyLine.Style.StrokeWidth = 1;

            annotationLayer.Annotations.Add(risingLine);
            annotationLayer.Annotations.Add(emptyLine);

            foreach (var stock in _stockData)
            {
                if (stock.Volume >= 180)
                {
                    var dSquare = new Square("D", 20)
                    {
                        SeriesIndex = 1,
                        PointIndex  = _stockData.IndexOf(stock),
                        Attachment  = AnnotationAttachment.DataIndex,
                        TooltipText = "Dividend"
                    };
                    dSquare.ContentStyle.StrokeColor = Color.White;
                    dSquare.ContentStyle.Font        = _contentFont;
                    dSquare.Style.FillColor          = Color.FromArgb(150, Color.Blue);
                    dSquare.Style.StrokeColor        = Color.Transparent;
                    dSquare.Style.StrokeWidth        = 1;
                    annotationLayer.Annotations.Add(dSquare);
                }
                if (stock.Date.Day % 10 == 0)
                {
                    var eSquare = new Square("E", 20)
                    {
                        SeriesIndex = 0,
                        PointIndex  = _stockData.IndexOf(stock),
                        Attachment  = AnnotationAttachment.DataIndex,
                        TooltipText = "Close"
                    };
                    eSquare.ContentStyle.StrokeColor = Color.Black;
                    eSquare.ContentStyle.Font        = _contentFont;
                    eSquare.Style.FillColor          = Color.FromArgb(150, Color.Aqua);
                    eSquare.Style.StrokeColor        = Color.Black;
                    eSquare.Style.StrokeWidth        = 1;
                    annotationLayer.Annotations.Add(eSquare);
                }
            }
            annotationLayer.Annotations.Add(new C1.Win.Chart.Annotation.Image(Properties.Resources.flag)
            {
                Attachment  = AnnotationAttachment.DataIndex,
                SeriesIndex = 0,
                PointIndex  = 25,
                Position    = AnnotationPosition.Top,
            });
            var textJustD = new Text("Justdial Ltd")
            {
                Attachment  = AnnotationAttachment.DataIndex,
                SeriesIndex = 0,
                PointIndex  = 25,
                Position    = AnnotationPosition.Left,
            };

            textJustD.Style.Font        = _textFont;
            textJustD.Style.StrokeColor = Color.Black;
            annotationLayer.Annotations.Add(textJustD);
            annotationLayer.Annotations.Add(new C1.Win.Chart.Annotation.Image(Properties.Resources.flag)
            {
                Attachment  = AnnotationAttachment.DataIndex,
                SeriesIndex = 0,
                PointIndex  = 75,
                Position    = AnnotationPosition.Top,
            });
            var textAli = new Text("Alibaba Group Holding Ltd")
            {
                Attachment  = AnnotationAttachment.DataIndex,
                SeriesIndex = 0,
                PointIndex  = 75,
                Position    = AnnotationPosition.Left,
            };

            textAli.Style.Font        = _textFont;
            textAli.Style.StrokeColor = Color.Black;
            annotationLayer.Annotations.Add(textAli);
            //Image annotations to show bid
            annotationLayer.Annotations.Add(new C1.Win.Chart.Annotation.Image(Properties.Resources.arrowDOWN)
            {
                Attachment  = AnnotationAttachment.DataIndex,
                SeriesIndex = 0,
                PointIndex  = 30,
                TooltipText = "Bid : $75.3",
            });
            annotationLayer.Annotations.Add(new C1.Win.Chart.Annotation.Image(Properties.Resources.arrowUP)
            {
                Attachment  = AnnotationAttachment.DataIndex,
                SeriesIndex = 0,
                PointIndex  = 60,
                TooltipText = "Bid : $75.3",
            });
            //rectangle annotation to show HLOC values
            _infoAnnotation = new C1.Win.Chart.Annotation.Rectangle("", 100, 100)
            {
                Attachment = AnnotationAttachment.Absolute,
                Location   = new PointF(100, 110),
            };
            _infoAnnotation.ContentStyle.StrokeColor = Color.Brown;
            _infoAnnotation.ContentStyle.Font        = _contentFont;
            _infoAnnotation.Style.StrokeColor        = Color.Chocolate;
            _infoAnnotation.Style.StrokeWidth        = 1;
            _infoAnnotation.Style.FillColor          = Color.FromArgb(200, Color.SandyBrown);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_annotation);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = GetString(Resource.String.annotation);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            // initializing widgets
            mChart           = this.FindViewById <FlexChart>(Resource.Id.flexchart);
            mChart.ChartType = ChartType.Line;
            mChart.BindingX  = "X";
            mChart.Series.Add(new ChartSeries()
            {
                SeriesName = "Base dataList", Binding = "Y,Y"
            });
            mChart.ItemsSource    = new AnnotationViewModel().Data;
            mChart.LegendPosition = ChartPositionType.None;

            Text text = new Text()
            {
                Content = "Relative", Location = new C1Point(0.5, 0.5), Attachment = AnnotationAttachment.Relative
            };

            text.AnnotationStyle = new ChartStyle()
            {
                FontSize = 15, FontFamily = "GenericSansSerif"
            };

            Ellipse ellipse = new Ellipse()
            {
                Content = "Relative", Location = new C1Point(0.4, 0.45), Width = 60, Height = 40, Attachment = AnnotationAttachment.Relative
            };

            ellipse.AnnotationStyle = new ChartStyle()
            {
                Fill = Color.Goldenrod, Stroke = Color.Argb(1 * 255, (int)(0.75 * 255), (int)(0.55 * 255), (int)(0.06 * 255)), FontAttributes = TypefaceStyle.Bold, FontSize = 10, FontFamily = "GenericSansSerif"
            };

            Circle circle = new Circle()
            {
                Content = "DataIndex", Radius = 40, SeriesIndex = 0, PointIndex = 27, Attachment = AnnotationAttachment.DataIndex
            };

            circle.AnnotationStyle = new ChartStyle()
            {
                Fill = Color.LightSeaGreen, Stroke = Color.Argb((int)(1.0 * 255), (int)(0.13 * 255), (int)(0.58 * 255), (int)(0.58 * 255)), FontFamily = "GenericSansSerif", FontAttributes = TypefaceStyle.Bold
            };

            Rectangle rectangle = new Rectangle()
            {
                Content = "DataCoordinate", Width = 100, Height = 50, Location = new C1Point(37, 80), Attachment = AnnotationAttachment.DataCoordinate
            };

            rectangle.AnnotationStyle = new ChartStyle()
            {
                Fill = Color.SlateBlue, Stroke = Color.Argb((int)(1.0 * 255), (int)(0.29 * 255), (int)(0.25 * 255), (int)(0.57 * 255)), FontFamily = "GenericSansSerif", FontSize = 10
            };

            Square square = new Square()
            {
                Content = "DataIndex", Length = 70, SeriesIndex = 0, PointIndex = 40, Attachment = AnnotationAttachment.DataIndex
            };

            square.AnnotationStyle = new ChartStyle()
            {
                Fill = Color.SandyBrown, Stroke = Color.Chocolate, FontAttributes = TypefaceStyle.Bold, FontFamily = "GenericSansSerif"
            };

            Polygon polygon = new Polygon()
            {
                Content = "polygonAnno", Attachment = AnnotationAttachment.Absolute
            };

            polygon.Points          = CreatePoints();
            polygon.AnnotationStyle = new ChartStyle()
            {
                Fill = Color.Red, StrokeThickness = 3, Stroke = Color.DarkRed, FontAttributes = TypefaceStyle.Bold, FontFamily = "GenericSansSerif"
            };

            Line line = new Line()
            {
                Content = "Absolute", Start = new C1Point(50, 200), End = new C1Point(300, 350), Attachment = AnnotationAttachment.Absolute
            };

            line.AnnotationStyle = new ChartStyle()
            {
                StrokeThickness = 4, FontSize = 10, FontAttributes = TypefaceStyle.Bold, Stroke = Color.Argb((int)(1.0 * 255), (int)(0.20 * 255), (int)(0.81 * 255), (int)(0.82 * 255)), FontFamily = "GenericSansSerif"
            };

            Image image = new Image()
            {
                Location = new C1Point(12, 20), Attachment = AnnotationAttachment.DataCoordinate, Width = 30, Height = 30
            };

            image.Source = BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.xuni_butterfly);

            AnnotationLayer layer = new AnnotationLayer(ApplicationContext);

            layer.Annotations.Add(text);
            layer.Annotations.Add(ellipse);
            layer.Annotations.Add(circle);
            layer.Annotations.Add(rectangle);
            layer.Annotations.Add(square);
            layer.Annotations.Add(polygon);
            layer.Annotations.Add(line);
            layer.Annotations.Add(image);
            mChart.Layers.Add(layer);
        }
        private void SetupAnnotations()
        {
            annotationLayer = new AnnotationLayer(flexChart1);
            var greenRect = new C1.Win.Chart.Annotation.Rectangle("", 10580, 1285)
            {
                Location   = new PointF((float)dataList[20].Date.ToOADate(), 100),
                Attachment = AnnotationAttachment.DataCoordinate,
                Position   = AnnotationPosition.Right,
            };

            greenRect.ContentStyle.StrokeColor = Color.Black;
            greenRect.ContentStyle.Font        = new System.Drawing.Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
            greenRect.Style.FillColor          = Color.FromArgb(25, Color.Green);
            greenRect.Style.StrokeColor        = Color.Transparent;
            greenRect.Style.StrokeWidth        = 1;
            annotationLayer.Annotations.Add(greenRect);

            foreach (var data in dataList)
            {
                if (data.Volume >= 9)
                {
                    var dSquare = new C1.Win.Chart.Annotation.Square("D", 20)
                    {
                        SeriesIndex = 1,
                        PointIndex  = dataList.IndexOf(data),
                        Attachment  = AnnotationAttachment.DataIndex,
                        TooltipText = "Dividend"
                    };
                    dSquare.ContentStyle.StrokeColor = Color.White;
                    dSquare.ContentStyle.Font        = new System.Drawing.Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
                    dSquare.Style.FillColor          = Color.FromArgb(150, Color.Blue);
                    dSquare.Style.StrokeColor        = Color.Transparent;
                    dSquare.Style.StrokeWidth        = 1;
                    annotationLayer.Annotations.Add(dSquare);
                }
                if (data.Date.Day % 10 == 0)
                {
                    var eSquare = new C1.Win.Chart.Annotation.Square("E", 20)
                    {
                        SeriesIndex = 0,
                        PointIndex  = dataList.IndexOf(data),
                        Attachment  = AnnotationAttachment.DataIndex,
                        TooltipText = "Close"
                    };
                    eSquare.ContentStyle.StrokeColor = Color.Black;
                    eSquare.ContentStyle.Font        = new System.Drawing.Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
                    eSquare.Style.FillColor          = Color.FromArgb(150, Color.Aqua);
                    eSquare.Style.StrokeColor        = Color.Black;
                    eSquare.Style.StrokeWidth        = 1;
                    annotationLayer.Annotations.Add(eSquare);
                }
            }

            var lineRising = new C1.Win.Chart.Annotation.Line("Rising wedge")
            {
                Start      = new Point((int)dataList[10].Date.ToOADate(), 20),
                End        = new Point((int)dataList[40].Date.ToOADate(), 100),
                Attachment = AnnotationAttachment.DataCoordinate,
            };

            lineRising.ContentStyle.StrokeColor = Color.Black;
            lineRising.ContentStyle.Font        = new System.Drawing.Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
            lineRising.Style.StrokeColor        = Color.Aqua;
            lineRising.Style.StrokeWidth        = 1;
            annotationLayer.Annotations.Add(lineRising);
            var lineEmpty = new C1.Win.Chart.Annotation.Line("")
            {
                Start      = new Point((int)dataList[20].Date.ToOADate(), 0),
                End        = new Point((int)dataList[50].Date.ToOADate(), 80),
                Attachment = AnnotationAttachment.DataCoordinate,
            };

            lineEmpty.ContentStyle.StrokeColor = Color.Black;
            lineEmpty.ContentStyle.Font        = new System.Drawing.Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
            lineEmpty.Style.StrokeColor        = Color.Aqua;
            lineEmpty.Style.StrokeWidth        = 1;
            annotationLayer.Annotations.Add(lineEmpty);

            annotationLayer.Annotations.Add(new C1.Win.Chart.Annotation.Image(AnnotationExplorer.Properties.Resources.flag)
            {
                SeriesIndex = 0,
                PointIndex  = 20,
                Attachment  = AnnotationAttachment.DataIndex,
                Position    = AnnotationPosition.Top
            });
            var txtFB = new C1.Win.Chart.Annotation.Text("Facebook inc to acquire LifeRail.")
            {
                SeriesIndex = 0,
                PointIndex  = 20,
                Attachment  = AnnotationAttachment.DataIndex,
                Position    = AnnotationPosition.Left,
            };

            txtFB.Style.StrokeColor = Color.Black;
            txtFB.Style.Font        = new Font(FontFamily.GenericSansSerif, 12);
            annotationLayer.Annotations.Add(txtFB);

            annotationLayer.Annotations.Add(new C1.Win.Chart.Annotation.Image(AnnotationExplorer.Properties.Resources.flag)
            {
                SeriesIndex = 0,
                PointIndex  = 70,
                Attachment  = AnnotationAttachment.DataIndex,
                Position    = AnnotationPosition.Top,
            });
            var txtAli = new C1.Win.Chart.Annotation.Text("Alibaba Group Holding Ltd")
            {
                SeriesIndex = 0,
                PointIndex  = 70,
                Attachment  = AnnotationAttachment.DataIndex,
                Position    = AnnotationPosition.Left,
            };

            txtAli.Style.StrokeColor = Color.Black;
            txtAli.Style.Font        = new Font(FontFamily.GenericSansSerif, 12);
            annotationLayer.Annotations.Add(txtAli);

            annotationLayer.Annotations.Add(new C1.Win.Chart.Annotation.Image(AnnotationExplorer.Properties.Resources.arrowDOWN)
            {
                SeriesIndex = 0,
                PointIndex  = 30,
                Attachment  = AnnotationAttachment.DataIndex,
                TooltipText = "Bid: $73.59"
            });
            annotationLayer.Annotations.Add(new C1.Win.Chart.Annotation.Image(AnnotationExplorer.Properties.Resources.arrowUP)
            {
                SeriesIndex = 0,
                PointIndex  = 50,
                Attachment  = AnnotationAttachment.DataIndex,
                TooltipText = "Bid: $73.59"
            });

            infoAnnotation = new C1.Win.Chart.Annotation.Rectangle("", 120, 100)
            {
                Location   = new PointF(130, 60),
                Attachment = AnnotationAttachment.Absolute,
            };
            infoAnnotation.ContentStyle.StrokeColor = Color.Brown;
            infoAnnotation.ContentStyle.Font        = new System.Drawing.Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
            infoAnnotation.Style.FillColor          = Color.FromArgb(200, Color.SandyBrown);
            infoAnnotation.Style.StrokeColor        = Color.Chocolate;
            infoAnnotation.Style.StrokeWidth        = 1;
        }
 public void SetSelectedGraphic(AnnotationLayer annoLayer, CIMTextGraphic graphic)
 {
     _annoLayer       = annoLayer;
     _selectedGraphic = graphic;
     SelectedGraphicChangedEvent.Publish(new SelectedGraphicChangedEventArgs(_annoLayer, _selectedGraphic));
 }