private async Task GetFieldsAsync()
        {
            ReportFields.Clear();
            SelectedFields.Clear();
            if (SelectedLayer == null)
            {
                return;
            }

            await QueuedTask.Run((Action)(() =>
            {
                foreach (FieldDescription fd in SelectedLayer?.GetFieldDescriptions())
                {
                    string shapeField = SelectedLayer.GetFeatureClass().GetDefinition().GetShapeField();
                    if (fd.Name == shapeField)
                    {
                        continue;                        //filter out the shape field.
                    }
                    var defFieldAction = (Action)(() =>
                    {
                        var field = new ReportField {
                            IsSelected = false, DisplayName = fd.Alias, Name = fd.Name
                        };
                        ReportFields.Add(field);
                        field.FieldSelectionChanged += this.Field_FieldSelectionChanged;
                        //field.IsSelected = true;
                    });
                    ActionOnGuiThread(defFieldAction);
                }
            }));
        }
Ejemplo n.º 2
0
        private List <LayerModel> GetLayers()
        {
            if (SelectedLayer == null)
            {
                return(new List <LayerModel>());
            }

            lock (SelectedLayer)
            {
                // Get the layers that must be drawn
                List <LayerModel> drawLayers;
                if (ShowAll)
                {
                    drawLayers = SelectedProfile.GetLayers();
                }
                else if (SelectedLayer.LayerType is FolderType)
                {
                    drawLayers = SelectedLayer.GetLayers().ToList();
                }
                else
                {
                    drawLayers = new List <LayerModel> {
                        SelectedLayer
                    }
                };

                return(drawLayers);
            }
        }

        #endregion
    }
Ejemplo n.º 3
0
 public void CloseFeatureLayer()
 {
     if (SelectedLayer != null && SelectedLayer.IsOpen)
     {
         lock (SelectedLayer) SelectedLayer.Close();
     }
 }
        public List <LayerModel> GetRenderLayers()
        {
            // Get the layers that must be drawn
            List <LayerModel> drawLayers;

            if (ShowAll)
            {
                return(SelectedProfile.GetRenderLayers(null, false, true));
            }

            if (SelectedLayer == null || !SelectedLayer.Enabled)
            {
                return(new EditableList <LayerModel>());
            }

            if (SelectedLayer.LayerType is FolderType)
            {
                drawLayers = SelectedLayer.GetRenderLayers(null, false, true);
            }
            else
            {
                drawLayers = new List <LayerModel> {
                    SelectedLayer
                }
            };

            return(drawLayers);
        }
Ejemplo n.º 5
0
        void Skew()
        {
            var skew = Parameters["Skew"] as ObjcParameter;

            if (skew != null)
            {
                double horizontal = skew.GetValueAsDouble("Hrzn");
                double vertical   = skew.GetValueAsDouble("Vrtc");

                Console.WriteLine("Skew: {0} {1}", horizontal, vertical);

                if (horizontal != 0.0)
                {
                    double offset = ActiveDrawable.Height *
                                    Math.Tan(GetRad(horizontal));
                    SelectedLayer.TransformShear(OrientationType.Horizontal, offset,
                                                 true, TransformResize.Adjust);
                }

                if (vertical != 0.0)
                {
                    double offset = ActiveDrawable.Width * Math.Tan(GetRad(vertical));
                    SelectedLayer.TransformShear(OrientationType.Vertical, offset,
                                                 true, TransformResize.Adjust);
                }
            }
        }
        private Task ModifyLayerSelection(SelectionCombinationMethod method)
        {
            Task t = QueuedTask.Run(() =>
            {
                System.Diagnostics.Debug.WriteLine("Mod Layer Selection");
                if (MapView.Active == null || SelectedLayer == null || UicSelection == null)
                {
                    return;
                }

                //if (!ValidateExpresion(false))
                //    return;
                string wc = string.Format("FacilityID = \"{0}\"", UicSelection);
                System.Diagnostics.Debug.WriteLine(wc);
                SelectedLayer.Select(new QueryFilter()
                {
                    WhereClause = wc
                }, method);
                MapView.Active.ZoomToSelected();
            });

            this.UpdateModel(UicSelection);
            this.showPaneTest("esri_editing_AttributesDockPane");
            return(t);
        }
Ejemplo n.º 7
0
        public Bitmap GetSelection()
        {
            var bounds = new RectangleF(new PointF(0, 0), Image.Size);

            if (Selection != null)
            {
                bounds = Selection.Path.GetBounds();
            }
            var bmp = new Bitmap((int)bounds.Width, (int)bounds.Height);

            using (var g = Graphics.FromImage(bmp))
            {
                g.TranslateTransform(-bounds.X, -bounds.Y);
                if (Selection != null)
                {
                    g.Clip = new Region(Selection.Path);
                }
                if (SelectedLayer is MaskedLayer)
                {
                    (SelectedLayer as MaskedLayer).ColorMatrix.Matrix33 = 1;
                }
                SelectedLayer.Paint(g);
                if (SelectedLayer is MaskedLayer)
                {
                    (SelectedLayer as MaskedLayer).ColorMatrix.Matrix33 = 0.5f;
                }
            }
            return(bmp);
        }
Ejemplo n.º 8
0
 public void OpenFeatureLayer()
 {
     if (SelectedLayer != null && !SelectedLayer.IsOpen)
     {
         SelectedLayer.Open();
     }
 }
Ejemplo n.º 9
0
        private void AddAction(string classPath)
        {
            var instance = (Action)Activator.CreateInstance("Color", classPath).Unwrap();

            SelectedLayer.actions.Add(instance);
            SelectedLayer.ApplyActions();
            EventBus.OnLayerActionAdded(this);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Удалить выбраннй слой
 /// </summary>
 public void DeleteSelectedLayer()
 {
     RevercedLayerList.Remove(SelectedLayer);
     LayerList.Remove(SelectedLayer);
     SelectedLayer.Destroy();
     SelectedLayer = null;
     ChooseLayer(RevercedLayerList[0]);
 }
Ejemplo n.º 11
0
        override public bool Execute()
        {
            double newWidth  = ActiveDrawable.Width;
            double newHeight = ActiveDrawable.Height;
            double oldWidth  = newWidth;
            double oldHeight = newHeight;

            Offset oldOffset = SelectedLayer.Offsets;

            var width = Parameters["Wdth"] as DoubleParameter;

            if (width != null)
            {
                newWidth = width.GetPixels(SelectedLayer.Width);
            }

            var height = Parameters["Hght"] as DoubleParameter;

            if (height != null)
            {
                newHeight = width.GetPixels(SelectedLayer.Height);
            }

            if (_needScaling)
            {
                SelectedLayer.Scale((int)newWidth, (int)newHeight, true);

                EnumParameter side = Parameters["FTcs"] as EnumParameter;

                switch (side.Value)
                {
                case "Qcs7":
                    SelectedLayer.Offsets = oldOffset;
                    break;

                case "Qcs5":
                    SelectedLayer.Offsets =
                        new Offset(oldOffset.X + (int)(oldWidth - newWidth),
                                   oldOffset.Y + (int)(oldHeight - newHeight));
                    break;

                case "Qcsa":
                    Console.WriteLine("TransformLayerEvent: Qcsa not supported yet");
                    break;

                default:
                    Console.WriteLine("FTcs: " + side.Value);
                    break;
                }
            }

            Offset();
            Translate();
            Skew();
            Rotate();

            return(true);
        }
Ejemplo n.º 12
0
 void Translate()
 {
     if (_needPosition)
     {
         int horizontal = (int)_horizontal * ActiveDrawable.Width / 100;
         int vertical   = (int)_vertical * ActiveDrawable.Height / 100;
         SelectedLayer.Translate(horizontal, vertical);
     }
 }
Ejemplo n.º 13
0
        void Rotate()
        {
            var angle = Parameters["Angl"] as DoubleParameter;

            if (angle != null)
            {
                Console.WriteLine("Rotate: " + angle.Value);
                SelectedLayer.TransformRotate(GetRad(angle.Value), true,
                                              0, 0, true, false);
            }
        }
        private Task UpdateForActiveMap(bool activeMapChanged = true, Dictionary <MapMember, List <long> > mapSelection = null)
        {
            return(QueuedTask.Run(() =>
            {
                SelectedLayerInfo selectedLayerInfo = null;
                if (!_selectedLayerInfos.ContainsKey(_activeMap))
                {
                    selectedLayerInfo = new SelectedLayerInfo();
                    _selectedLayerInfos.Add(_activeMap, selectedLayerInfo);
                }
                else
                {
                    selectedLayerInfo = _selectedLayerInfos[_activeMap];
                }

                if (activeMapChanged)
                {
                    RefreshLayerCollection();

                    SetProperty(ref _selectedLayer, (selectedLayerInfo.SelectedLayer != null) ? selectedLayerInfo.SelectedLayer : Layers.FirstOrDefault(), () => SelectedLayer);
                    if (_selectedLayer == null)
                    {
                        FrameworkApplication.SetCurrentToolAsync("esri_mapping_exploreTool");
                        return;
                    }
                    selectedLayerInfo.SelectedLayer = SelectedLayer;
                }

                if (SelectedLayer == null)
                {
                    RefreshSelectionOIDs(new List <long>());
                }
                else
                {
                    List <long> oids = new List <long>();
                    if (mapSelection != null)
                    {
                        if (mapSelection.ContainsKey(SelectedLayer))
                        {
                            oids.AddRange(mapSelection[SelectedLayer]);
                        }
                    }
                    else
                    {
                        oids.AddRange(SelectedLayer.GetSelection().GetObjectIDs());
                    }
                    RefreshSelectionOIDs(oids);
                }

                SetProperty(ref _selectedOID, (selectedLayerInfo.SelectedOID != null && LayerSelection.Contains(selectedLayerInfo.SelectedOID)) ? selectedLayerInfo.SelectedOID : LayerSelection.FirstOrDefault(), () => SelectedOID);
                selectedLayerInfo.SelectedOID = SelectedOID;
                ShowAttributes();
            }));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Ends user intercation logic, like mouseup
        /// </summary>
        /// <param name="p">Last point</param>
        public void PressUp(Point p)
        {
            if ((((HasNoLayers)|(!_pressed))) || (!SelectedLayer.IsVisible))
                return;

            _pressed = false;

            if (PanMode)
                return;
            SelectedLayer.Apply();
            _points.Clear();
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Remove selected layer from scene
        /// </summary>
        public void RemoveSelectedLayer()
        {
            if (HasNoLayers)
                return;
            SelectedLayer.Dispose();
            Layers.RemoveAt(SelectedLayerIndex);
            if (HasNoLayers)
                _selectedLayerIndex = -1;
            else
                _selectedLayerIndex = 0;

            Invalidate();
            InvalidateLayersOrder();
        }
        private Task ShowAttributes()
        {
            return(QueuedTask.Run(() =>
            {
                try
                {
                    _fieldAttributes.Clear();
                    if (SelectedLayer == null || SelectedOID == null)
                    {
                        return;
                    }

                    var oidField = SelectedLayer.GetTable().GetDefinition().GetObjectIDField();
                    var qf = new ArcGIS.Core.Data.QueryFilter()
                    {
                        WhereClause = string.Format("{0} = {1}", oidField, SelectedOID)
                    };
                    var cursor = SelectedLayer.Search(qf);
                    Row row = null;

                    if (cursor.MoveNext())
                    {
                        row = cursor.Current;
                    }

                    if (row == null)
                    {
                        return;
                    }

                    var fields = row.GetFields();
                    lock (_lock)
                    {
                        foreach (ArcGIS.Core.Data.Field field in fields)
                        {
                            if (field.FieldType == FieldType.Geometry)
                            {
                                continue;
                            }
                            var val = row[field.Name];
                            FieldAttributeInfo fa = new FieldAttributeInfo(field, (val is DBNull || val == null) ? null : val.ToString());
                            _fieldAttributes.Add(fa);
                        }
                    }
                }
                catch (Exception)
                {
                }
            }));
        }
Ejemplo n.º 18
0
        private void AddMenuItem(string[] segments, MenuItemAction action, int depth = 0, MenuItem menuItem = null)
        {
            var     segment   = segments[depth].Replace(@"\", "");
            dynamic menuItm   = (object)menuItem ?? mainMenu;
            var     childMenu = GetChildMenuItem(menuItm, segment);

            if (childMenu != null && depth + 1 < segments.Length)
            {
                AddMenuItem(segments, action, depth + 1, childMenu);
                return;
            }
            else
            {
                var newItem = new MenuItem {
                    Header = segment, DataContext = action
                };
                if (depth + 1 < segments.Length)
                {
                    menuItm.Items.Add(newItem);
                    // newItem.Items.SortDescriptions.Add()
                    AddMenuItem(segments, action, depth + 1, newItem);
                }
                else
                {
                    int addedIndex = -1;
                    int itemCount  = menuItm.Items.Count;
                    // int itidx = (int)(action.order.GetValue(0) ?? 0);
                    // var idx = itemCount < itidx ? -1 : action.order[0];
                    // if (idx > -1) menuItm.Items.Insert(idx, newItem);
                    // else
                    addedIndex = menuItm.Items.Add(newItem);

                    // if (itemCount > 1) {
                    //   var separatorAttr = Attribute.GetCustomAttribute(action.action, typeof(MenuItemSeparatorAttribute));
                    //   if (separatorAttr != null) {
                    //     var separator = new Separator();
                    //     // menuItm.Items.Insert(addedIndex > -1 ? addedIndex : idx, separator);
                    //   }
                    // }
                    newItem.Click += (sender, evt) => {
                        var menuItem = (MenuItemAction)((MenuItem)sender).DataContext;
                        var instance = (Action)Activator.CreateInstance(menuItem.action);
                        SelectedLayer.actions.Add(instance);
                        SelectedLayer.ApplyActions();
                        EventBus.OnLayerActionAdded(this);
                    };
                }
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Checks that drawed point or line in layer bounds,
        /// if not increase bounds to contains drawing
        /// </summary>
        /// <param name="points">Points of drawing</param>
        private void CheckLayerPostionAndSize(Point[] points)
        {
            if (HasNoLayers)
            {
                return;
            }

            var needToChangeSize = false;
            var halfThickness    = Thickness / 2;
            var minX             = points.Min(c => c.X) - halfThickness;
            var minY             = points.Min(c => c.Y) - halfThickness;
            var maxX             = points.Max(c => c.X) + halfThickness;
            var maxY             = points.Max(c => c.Y) + halfThickness;

            var newPosition = SelectedLayer.Position;
            var newSize     = SelectedLayer.Size;

            if (minX < SelectedLayer.Position.X)
            {
                newPosition.X    = minX;
                needToChangeSize = true;
            }
            if (minY < SelectedLayer.Position.Y)
            {
                newPosition.Y    = minY;
                needToChangeSize = true;
            }

            if (maxX >= SelectedLayer.Position.X + SelectedLayer.Size.Width)
            {
                newSize.Width    = maxX - newPosition.X;
                needToChangeSize = true;
            }

            if (maxY >= SelectedLayer.Position.Y + SelectedLayer.Size.Height)
            {
                newSize.Height   = maxY - newPosition.Y;
                needToChangeSize = true;
            }

            if (needToChangeSize)
            {
                var dx = SelectedLayer.Position.X - newPosition.X;
                var dy = SelectedLayer.Position.Y - newPosition.Y;
                newSize.Width  += dx;
                newSize.Height += dy;
                SelectedLayer.ChangeSizeAndPosition(newPosition, newSize);
            }
        }
Ejemplo n.º 20
0
        private Task EditAnnotationSymbolAsync()
        {
            return(QueuedTask.Run(() => {
                EditOperation op = new EditOperation();
                op.Name = "Change annotation graphic";

                //At 2.1 we must use an edit operation Callback...
                op.Callback(context => {
                    RowCursor rowCursor;
                    if (SelectedLayer.GetSelection().GetCount() == 0) //The Selected layer has no selection
                    {
                        rowCursor = SelectedLayer.GetTable().Search(null, false);
                    }
                    else //Selection exists
                    {
                        var oidList = SelectedLayer.GetSelection().GetObjectIDs();
                        var oid = SelectedLayer.GetTable().GetDefinition().GetObjectIDField();
                        QueryFilter qf = new QueryFilter()
                        {
                            WhereClause = string.Format("({0} in ({1}))", oid, string.Join(",", oidList))
                        };
                        //Cursor must be non-recycling. Use the table ~not~ the layer..i.e. "GetTable().Search()"
                        //SelectedLayer is ~your~ Annotation layer
                        rowCursor = SelectedLayer.GetTable().Search(qf, false);
                    }
                    while (rowCursor.MoveNext())
                    {
                        using (var af = rowCursor.Current as AnnotationFeature)
                        {
                            var graphic = af.GetGraphic() as CIMTextGraphic;
                            graphic.Symbol = SelectedTextStyle.Symbol.MakeSymbolReference();
                            // update the graphic
                            af.SetGraphic(graphic);
                            // store is required
                            af.Store();
                            //refresh layer cache
                            context.Invalidate(af);
                        }
                    }
                }, SelectedLayer.GetTable());

                op.Execute();
                //set the label's visiblity
                if (IsLabelVisible)
                {
                    (SelectedLayer as AnnotationLayer).SetVisibility(true);
                }
            }));
        }
 private Task SelectedLayerChanged()
 {
     return(QueuedTask.Run(() =>
     {
         if (SelectedLayer == null)
         {
             RefreshSelectionOIDs(new List <long>());
         }
         else
         {
             var selection = SelectedLayer.GetSelection();
             RefreshSelectionOIDs(selection.GetObjectIDs());
         }
         SelectedOID = LayerSelection.FirstOrDefault();
     }));
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Start user interaction logic, like MouseDown on control
        /// If not pan mode draw point
        /// </summary>
        /// <param name="p">Start point</param>
        public void PressDown(Point p)
        {
            if ((HasNoLayers)||(!SelectedLayer.IsVisible))
                return;

            _pressed = true;
            _lastPoint = p;

            if (!PanMode)
            {
                CheckLayerPostionAndSize(new[] {new Point(p.X, p.Y)});
                var normalized = p.Normalize(SelectedLayer.Position);
                SelectedLayer.DrawPoint(_brush, Thickness, normalized);
                _points = new List<Point>();
                _points.Add(p);
            }          
        }
Ejemplo n.º 23
0
        void Offset()
        {
            var offset = Parameters["Ofst"] as ObjcParameter;

            if (offset != null)
            {
                double horizontal = offset.GetValueAsDouble("Hrzn");
                double vertical   = offset.GetValueAsDouble("Vrtc");

                int h = (int)(horizontal * ActiveDrawable.Width / 100);
                int v = (int)(vertical * ActiveDrawable.Height / 100);

                Console.WriteLine("Offset: {0}, {1}", h, v);

                SelectedLayer.Translate(h, v);
            }
        }
        private Task ModifyLayerSelection(SelectionCombinationMethod method)
        {
            return(QueuedTask.Run(() =>
            {
                if (MapView.Active == null || SelectedLayer == null || WhereClause == null)
                {
                    return;
                }

                if (!ValidateExpresion(false))
                {
                    return;
                }

                SelectedLayer.Select(new QueryFilter()
                {
                    WhereClause = WhereClause
                }, method);
            }));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Remove selected layer from scene
        /// </summary>
        public void RemoveSelectedLayer()
        {
            if (HasNoLayers)
            {
                return;
            }
            SelectedLayer.Dispose();
            Layers.RemoveAt(SelectedLayerIndex);
            if (HasNoLayers)
            {
                _selectedLayerIndex = -1;
            }
            else
            {
                _selectedLayerIndex = 0;
            }

            Invalidate();
            InvalidateLayersOrder();
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Draw line or move layer (depends on pan mode)
        /// </summary>
        /// <param name="p">Point to move</param>
        public void Move(Point p)
        {
            if ((((HasNoLayers) | (!_pressed))) || (!SelectedLayer.IsVisible))
                return;

            if (PanMode)
            {
                var dx = p.X - _lastPoint.X ;
                var dy = p.Y - _lastPoint.Y;
                SelectedLayer.Offset(dx, dy);
            }
            else
            {
                CheckLayerPostionAndSize(new[] { new Point(p.X, p.Y), new Point(_lastPoint.X,_lastPoint.Y)  });
                _points.Add(p);
                SelectedLayer.DrawLines(_pen,_points.Select(c=>c.Normalize(SelectedLayer.Position)).ToArray());
            }

            _lastPoint = p;
        }
Ejemplo n.º 27
0
        public void ClipboardToLayer()
        {
            if (!ActiveWindowHelper.MainWindowActive || !IsActive)
            {
                return;
            }

            try
            {
                GeneralHelpers.ExecuteSta(() =>
                {
                    var data = (string)Clipboard.GetData("layer");
                    if (data == null)
                    {
                        return;
                    }

                    var layerModel = JsonConvert.DeserializeObject <LayerModel>(data);
                    if (layerModel == null)
                    {
                        return;
                    }

                    if (SelectedLayer != null)
                    {
                        SelectedLayer.InsertAfter(layerModel);
                    }
                    else
                    {
                        SelectedProfile.Layers.Add(layerModel);
                        SelectedProfile.FixOrder();
                    }
                    Execute.OnUIThread(() => UpdateLayerList(layerModel));
                });
            }
            catch (Exception)
            {
                // ignored
            }
        }
Ejemplo n.º 28
0
        private List <LayerModel> GetLayers()
        {
            if (ShowAll)
            {
                return(SelectedProfile.GetLayers());
            }
            if (SelectedLayer == null)
            {
                return(new List <LayerModel>());
            }

            lock (SelectedLayer)
            {
                // Get the layers that must be drawn
                if (SelectedLayer.LayerType is FolderType)
                {
                    return(SelectedLayer.GetLayers().ToList());
                }
                return(new List <LayerModel> {
                    SelectedLayer
                });
            }
        }
        private Task ApplyLabelFeatureLayerAsync()
        {
            return(QueuedTask.Run(() =>
            {
                //Get the layer's definition
                var lyrDefn = SelectedLayer.GetDefinition() as CIMFeatureLayer;
                //Get the label classes - we need the first one
                var listLabelClasses = lyrDefn.LabelClasses.ToList();
                var theLabelClass = listLabelClasses.FirstOrDefault();
                //Place all labels horizontally
                theLabelClass.StandardLabelPlacementProperties.LineLabelPosition.Horizontal = true;
                //Set the label classes' symbol to the custom text symbol
                theLabelClass.TextSymbol.Symbol = SelectedTextStyle.Symbol;
                lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back
                SelectedLayer.SetDefinition(lyrDefn);

                //set the label's visiblity
                if (IsLabelVisible)
                {
                    (SelectedLayer as FeatureLayer).SetLabelVisibility(true);
                }
            }));
        }
Ejemplo n.º 30
0
        override public bool Execute()
        {
            switch (_direction)
            {
            case "Bckw":
                SelectedLayer.Lower();
                break;

            case "Frwr":
                SelectedLayer.Raise();
                break;

            case "Prvs":
                // TODO: What's the difference with this and "Bckw"?
                SelectedLayer.Lower();
                break;

            default:
                Console.WriteLine("MoveLayerEvents: " + _direction);
                break;
            }
            return(true);
        }