Example #1
0
 public void AddCommand(ICommandItem command)
 {
     lock (m_commands)
     {
         m_commands.Add(command);
     }
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MenuItemViewModel"/> class.
        /// </summary>
        /// <param name="commandItem">The command item. Must not be <see langword="null"/>.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="commandItem"/> is <see langword="null"/>.
        /// </exception>
        public MenuItemViewModel(ICommandItem commandItem)
        {
            if (commandItem == null)
                throw new ArgumentNullException(nameof(commandItem));

            CommandItem = commandItem;
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ToolBarItemViewModel"/> class.
        /// </summary>
        /// <param name="commandItem">The command item.  Must not be <see langword="null"/>.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="commandItem"/> is <see langword="null"/>.
        /// </exception>
        protected ToolBarItemViewModel(ICommandItem commandItem)
        {
            if (commandItem == null)
                throw new ArgumentNullException(nameof(commandItem));

            CommandItem = commandItem;
        }
Example #4
0
 private void RemoveCommand(ICommandItem command)
 {
     if (command.IsVisible(Sce.Atf.Applications.CommandVisibility.Toolbar) && command.MenuTag != null)
     {
         var menu = GetMenu(command.MenuTag) as RootMenu;
         menu.ChildCollection.Remove(command);
         menu.Invalidate();
     }
 }
Example #5
0
        public static ItemWrapper Create(ICommandItem item)
        {
            var @this = new ItemWrapper();

            @this.NativePointer = ObjectiveC.AllocAndInitObject(ObjectiveC.GetNativeClass(typeof(ItemWrapper), true));
            lock (itemDictionary) itemDictionary.Add(@this.NativePointer, item);

            return @this;
        }
Example #6
0
        /// <summary>
        /// Unregisters a command for a command client</summary>
        /// <param name="command">ICommandItem for command</param>
        /// <param name="client">Client that handles the command</param>
        public void UnregisterCommand(ICommandItem command, ICommandClient client)
        {
            if (command.CommandTag is StandardCommand)
                return;

            if (client == null)
                m_commandClients.Remove(command.CommandTag);
            else
                m_commandClients.Remove(command.CommandTag, client);

            if (!m_commandClients.TryGetFirst(command.CommandTag, out client))
            {
                m_commandsLookup.Remove(command.CommandTag);
                int index = m_commands.IndexOf(command);
                m_commands.Remove(command);
                CommandRemoved.Raise<ItemRemovedEventArgs<ICommandItem>>(this, new ItemRemovedEventArgs<ICommandItem>(index, command));
            }
        }
Example #7
0
        public static void BuildSubMenus(ICommandItem command, Menu menu)
        {
            var subMenus = menu.ChildCollection;

            foreach (var segment in command.MenuPath)
            {
                // Try and find an existing submenu
                var subMenu = (Menu)subMenus.FirstOrDefault<IMenuItem>(x => (x is Menu) && (((Menu)x).Text == segment));
                if (subMenu == null)
                {
                    // No existing submenu found - add a new one
                    subMenu = new Menu(menu, command.MenuTag, null, segment, segment);
                    subMenus.Add(subMenu);
                }
                subMenus = subMenu.ChildCollection;
                menu = subMenu;
            }

            subMenus.Add(command);
        }
Example #8
0
        public override void UnregisterCommand(object commandTag, ICommandClient client)
        {
            base.UnregisterCommand(commandTag, client);

            // If there are no more clients associated with this command
            // then remove it
            if (!m_commandClients.TryGetFirst(commandTag, out client))
            {
                ICommandItem command = m_commandsLookup[commandTag];
                m_commandsLookup.Remove(commandTag);

                // Remove from composition
                var commandItem = command as CommandItem;
                if (commandItem != null && commandItem.ComposablePart != null)
                {
                    m_composer.RemovePart(commandItem.ComposablePart);
                    commandItem.ComposablePart = null;
                }
            }
        }
        /// <summary>
        /// Removes the command item.
        /// </summary>
        /// <param name="commandItem">The command item to be removed.</param>
        public void RemoveCommand(ICommandItem commandItem)
        {
            if (commandItem == null)
            {
                throw new ArgumentNullException(@"commandItem");
            }

            lock (this.commands)
            {
                if (this.commands.Contains(commandItem))
                {
                    commandItem.CommandAdded   -= this.HandleCommandAdded;
                    commandItem.CommandRemoved -= this.HandleCommandRemoved;
                    commandItem.CommandChanged -= this.HandleCommandChanged;
                    this.commands.Remove(commandItem);
                    this.OnCommandRemoved(commandItem);
                    commandItem.Dispose();
                }
            }
        }
Example #10
0
        public static void BuildSubMenus(ICommandItem command, Menu menu)
        {
            var subMenus = menu.ChildCollection;

            foreach (var segment in command.MenuPath)
            {
                // Try and find an existing submenu
                var subMenu = (Menu)subMenus.FirstOrDefault <IMenuItem>(x => (x is Menu) && (((Menu)x).Text == segment));
                if (subMenu == null)
                {
                    // No existing submenu found - add a new one
                    subMenu = new Menu(menu, command.MenuTag, null, segment, segment);
                    subMenus.Add(subMenu);
                }
                subMenus = subMenu.ChildCollection;
                menu     = subMenu;
            }

            subMenus.Add(command);
        }
        /// <summary>
        /// Called when a command item has been removed.
        /// </summary>
        /// <param name="commandItem">The command Item.</param>
        protected void OnCommandRemoved(ICommandItem commandItem)
        {
            if (commandItem == null)
            {
                throw new ArgumentNullException(@"commandItem");
            }

            if (Logger.IsDebugEnabled)
            {
                var message = string.Format(CultureInfo.CurrentUICulture, Resources.CommandItem_HasBeenRemoved, commandItem.Text);
                Logger.Debug(message);
            }

            var commandChanged = this.CommandRemoved;

            if (commandChanged != null)
            {
                commandChanged(null, new CommandEventArgs(commandItem));
            }
        }
Example #12
0
        /// <summary>
        /// Does a command</summary>
        /// <param name="command">Command</param>
        public void DoCommand(object command)
        {
            ICommandItem commandItem = command as ICommandItem;

            Requires.NotNull(commandItem, "Command specified is from class that doesn't implement ICommandItem.  Most likely, this is a not a command from WPF, and it should be.");
            IDockContent dockContent = commandItem.CommandTag as IDockContent;

            if (dockContent != null)
            {
                if (m_dockPanel.IsContentVisible(dockContent))
                {
                    m_dockPanel.HideContent(dockContent);
                }
                else
                {
                    m_dockPanel.ShowContent(dockContent);
                    commandItem.IsChecked = true;
                }
            }
        }
Example #13
0
        public ICommandItem AddCommand(ICommandItem commandItem)
        {
            var newItem = new CommandViewItem(commandItem, this.commandViewFactory, this);

            lock (this.commands)
            {
                this.commands.Add(newItem);
                newItem.SortIndex       = commandItem.SortIndex;
                newItem.CommandAdded   += this.HandleCommandAdded;
                newItem.CommandRemoved += this.HandleCommandRemoved;
                newItem.CommandChanged += this.HandleCommandChanged;
                this.OnCommandAdded(newItem);

                foreach (var commandProviderItem in commandItem.ChildCommands)
                {
                    this.commandViewFactory.AddProviderCommand(commandProviderItem, this);
                }
            }

            return(newItem);
        }
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            if (m_application == null)
            {
                return;
            }

            UID osmToolbarCLSID = new UIDClass();

            osmToolbarCLSID.Value = "{980ae216-f181-4fe7-95b7-6c0a7342f71b}";

            ICommandBars commandBars = m_application.Document.CommandBars;
            ICommandItem commandItem = commandBars.Find(osmToolbarCLSID, true, false);

            ICommandBar osmCommandBar = commandItem as ICommandBar;

            if (osmCommandBar != null)
            {
                osmCommandBar.Dock(esriDockFlags.esriDockToggle, null);
            }
        }
Example #15
0
        /// <summary>
        /// Gets command tags for context menu (right click) commands</summary>
        /// <param name="context">Context containing target object</param>
        /// <param name="target">Right clicked object, or null if none</param>
        /// <returns>Command tags for context menu</returns>
        public IEnumerable <object> GetCommands(object context, object target)
        {
            if (ShowContextHelp && HelpFilePath != null)
            {
                m_lastContextMenuKeys = TryGetHelpKeys(target);

                if (m_lastContextMenuKeys == null)
                {
                    m_lastContextMenuKeys = TryGetHelpKeys(context);
                }

                if (m_lastContextMenuKeys != null)
                {
                    for (int i = 0; i < m_lastContextMenuKeys.Length; i++)
                    {
                        ICommandItem command = m_contextMenuHelpCommands[i].GetCommandItem();
                        command.Text = m_lastContextMenuKeys[i];
                        yield return(m_contextMenuHelpCommands[i].CommandTag);
                    }
                }
            }
        }
Example #16
0
        private void button1_Click(object sender, EventArgs e)
        {
            UID pUID  = new UID();
            UID pUID2 = new UID();
            UID pUID3 = new UID();
            UID pUID4 = new UID();

            pUID.Value    = "{488CBE4F-CD34-4649-B1ED-8CD1B8149041}";
            pUID2.Value   = "{78FFF793-98B4-11D1-873B-0000F8751720}";
            pUID3.Value   = "{8841A0D9-4F49-11D2-AE2D-080009EC732A}";
            pUID4.Value   = "{8841A0DA-4F49-11D2-AE2D-080009EC732A}";
            pUID4.SubType = 2;

            ICommandItem CommandItem  = ArcMap.Application.Document.CommandBars.Find(pUID, false, true);
            ICommandItem CommandItem2 = ArcMap.Application.Document.CommandBars.Find(pUID2, false, true);
            ICommandItem CommandItem3 = ArcMap.Application.Document.CommandBars.Find(pUID3, false, true);
            ICommandItem CommandItem4 = ArcMap.Application.Document.CommandBars.Find(pUID4, false, true);

            CommandItem.Execute();
            CommandItem2.Execute();
            CommandItem3.Execute();
            CommandItem4.Execute();
        }
        /// <summary>
        /// Updates the buttons bitmap according to mode
        /// </summary>
        private void UpdateBitmap()
        {
            try
            {
                ICommandItem commandItem = ArcMap.Application.Document.CommandBars.Find("Umbriel_Project_Umbriel.ArcMap.Addin.OneSelectableLayer_OneSelectableLayerButton", true, true);

                if (this.forceOneSelectableLayerOn)
                {
                    commandItem.FaceID = this.onBitmapPictureDisp;
                    commandItem.Refresh();
                }
                else
                {
                    commandItem.FaceID = this.offBitmapPictureDisp;
                    commandItem.Refresh();
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine(e.StackTrace);
                throw;
            }
        }
        /// <summary>
        /// Gets the ICommandItem associated with this CommandInfo</summary>
        /// <param name="commandInfo">CommandInfo</param>
        /// <returns>The command item</returns>
        public static ICommandItem GetCommandItem(this CommandInfo commandInfo)
        {
            if (commandInfo.CommandService == null)
            {
                throw new NullReferenceException("CommandInfo has not been registered to a CommandService.");
            }

            var commandService = (CommandService)commandInfo.CommandService;

            if (commandService == null)
            {
                throw new InvalidTransactionException("CommandInfo was registered to an ICommandService, but not specifically to a CommandService.");
            }

            ICommandItem commanditem = commandService.GetCommand(commandInfo.CommandTag);

            if (commanditem == null)
            {
                throw new InvalidTransactionException("CommandService to which CommandInfo thinks it's registered has no record of it.");
            }

            return(commanditem);
        }
Example #19
0

        
Example #20
0
        /// <summary>
        /// Does the command</summary>
        /// <param name="commandObj">Command to be done</param>
        public void DoCommand(object commandObj)
        {
            ICommandItem command = commandObj as ICommandItem;

            Requires.NotNull(command, "Object specified is from class that doesn't implement ICommandItem.  Most likely, this is a not a command from WPF, and it should be.");
            switch ((Commands)command.CommandTag)
            {
            case Commands.EditLabel:
                var target = m_contextRegistry.GetCommandTarget <object>();
                if (target != null)
                {
                    var labelEditingContext = m_contextRegistry.GetActiveContext <ILabelEditingContext>();
                    if (labelEditingContext != null)
                    {
                        labelEditingContext.EditLabel(target);
                    }
                }
                break;

            default:
                break;
            }
        }
Example #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandItemVm" /> class.
        /// </summary>
        /// <param name="cmdItem">The CMD item.</param>
        public CommandItemVm(ICommandItem cmdItem)
        {
            try
            {
                this.ExecuteCommand = new DelegateCommand(this.ExeCmd);

                this.CommandItem = cmdItem;
                this.CommandItem.CommandChanged += this.OnCommandChanged;
                this.CommandItem.CommandAdded   += this.OnCommandAdded;
                this.CommandItem.CommandRemoved += this.OnCommandRemoved;

                this.UpdateProperties();
            }
            catch (Exception ex)
            {
                if (Logger.IsErrorEnabled)
                {
                    Logger.Error(Resources.InstantiationOfCommandItemFailed, ex);
                }

                throw;
            }
        }
Example #22
0
        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (hook == null)
            {
                return;
            }

            //Get the appropriate zoom in command based on application
            m_application  = hook as IApplication;
            base.m_enabled = false;

            if (m_application != null)
            {
                UID cmdUID = new UIDClass();
                switch (m_application.Name) //or test by casting the appropriate application interface
                {
                case "ArcMap":
                    cmdUID.Value = "esriArcMapUI.ZoomInFixedCommand";
                    break;

                case "ArcGlobe":
                    cmdUID.Value = "esriArcGlobe.GMxNarrowFOVCommand";
                    break;

                case "ArcScene":
                    cmdUID.Value = "esriArcScene.SxNarrowFOVCommand";
                    break;
                }

                ICommandBars docBars = m_application.Document.CommandBars;
                m_xoomCommand = docBars.Find(cmdUID, false, false);

                //Enable only when the delegate command is available
                base.m_enabled = m_xoomCommand != null;
            }
        }
        /// <summary>
        /// Removes the provider command.
        /// </summary>
        /// <param name="providerCommandItem">The provider command item.</param>
        /// <param name="commandView">The command view.</param>
        public virtual void RemoveProviderCommand(ICommandItem providerCommandItem, ICommandProvider commandView)
        {
            if (providerCommandItem == null)
            {
                throw new ArgumentNullException(@"providerCommandItem");
            }

            if (commandView == null)
            {
                throw new ArgumentNullException(@"commandView");
            }

            var commandToRemoveInView = commandView.FindCommand(providerCommandItem.Id);
            var parentCommandViewItem = commandToRemoveInView.ParentCommand;

            if (parentCommandViewItem != null)
            {
                parentCommandViewItem.RemoveCommand(commandToRemoveInView);
            }
            else
            {
                commandView.RemoveCommand(commandToRemoveInView);
            }
        }
Example #24
0
        /// <summary>
        /// Unregisters a command for a command client</summary>
        /// <param name="command">ICommandItem for command</param>
        /// <param name="client">Client that handles the command</param>
        public void UnregisterCommand(ICommandItem command, ICommandClient client)
        {
            if (command.CommandTag is StandardCommand)
            {
                return;
            }

            if (client == null)
            {
                m_commandClients.Remove(command.CommandTag);
            }
            else
            {
                m_commandClients.Remove(command.CommandTag, client);
            }

            if (!m_commandClients.TryGetFirst(command.CommandTag, out client))
            {
                m_commandsLookup.Remove(command.CommandTag);
                int index = m_commands.IndexOf(command);
                m_commands.Remove(command);
                CommandRemoved.Raise <ItemRemovedEventArgs <ICommandItem> >(this, new ItemRemovedEventArgs <ICommandItem>(index, command));
            }
        }
        public static void AddCommandItem(string menu, string command, object index)
        {
            IApplication application = ArcMap.Application;
            IDocument    document    = application.Document;
            ICommandBars commandBars = document.CommandBars;

            var menuUid = new UID {
                Value = menu
            };
            var contextMenu = commandBars.Find(menuUid) as ICommandBar;

            if (contextMenu != null)
            {
                var commandUid = new UID {
                    Value = command
                };
                ICommandItem commandItem = contextMenu.Find(commandUid);

                if (commandItem == null)
                {
                    contextMenu.Add(commandUid, ref index);
                }
            }
        }
        public static void RemoveCommandItem(string menu, string command)
        {
            IApplication application = ArcMap.Application;
            IDocument    document    = application.Document;
            ICommandBars commandBars = document.CommandBars;

            var menuUid = new UID {
                Value = menu
            };
            var contextMenu = commandBars.Find(menuUid) as ICommandBar;

            if (contextMenu != null)
            {
                var commandUid = new UID {
                    Value = command
                };
                ICommandItem commandItem = contextMenu.Find(commandUid);

                if (commandItem != null)
                {
                    commandItem.Delete();
                }
            }
        }
Example #27
0
 /// <summary>
 /// Adds the command.
 /// </summary>
 /// <param name="commandItem">The command item.</param>
 /// <returns>The new command item.</returns>
 public ICommandItem AddCommand(ICommandItem commandItem)
 {
     return(this.commandProvider.AddCommand(commandItem));
 }
        private void CommitEdits()
        {
            try
            {
                if (InEditingSession)
                {
                    _editor.StopOperation(String.Empty);
                    if (_saveEditsCmd == null)
                        _saveEditsCmd = FindSaveEditsCommand();

                    if (_saveEditsCmd != null)
                    {
                        _saveEditsCmd.Execute(); // only way to save edits without closing edit session
                    }
                    else
                    {
                        _editor.StopEditing(true);
                        _editor.StartEditing((IWorkspace)_hluWS);
                    }
                }
                else
                {
                    _hluWorkspaceEdit.StopEditOperation();
                    _hluWorkspaceEdit.StopEditing(true);
                    _hluWorkspaceEdit = null;
                }
            }
            catch { DiscardEdits(); }
        }
 private void StartEditing()
 {
     try
     {
         if (InEditingSession)
         {
             if (_saveEditsCmd == null)
                 _saveEditsCmd = FindSaveEditsCommand();
             _editor.StartOperation();
         }
         else
         {
             _hluWorkspaceEdit = StartEditingWorkspace(_hluWS);
         }
     }
     catch { }
 }
Example #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ToolBarQuickFindViewModel"/> class.
 /// </summary>
 /// <param name="commandItem">The command item. Must not be <see langword="null"/>.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="commandItem"/> is <see langword="null"/>.
 /// </exception>
 public ToolBarQuickFindViewModel(ICommandItem commandItem)
     : base(commandItem)
 {
     Width = 150;
     Query = (commandItem as QuickFindCommandItem)?.SearchExtension?.Query;
 }
Example #31
0
        public void UpdatePoint(PointMeasurementData measurementData, int index)
        {
            _index = index;
            bool notCreated = NotCreated;
            MeasurementPointS measurementPoint = measurementData.measurementPoint;
            double            x = measurementPoint.x;
            double            y = measurementPoint.y;
            double            z = measurementPoint.z;

            _point = ArcUtils.GsToMapPoint(x, y, z);

            IActiveView            activeView = ArcUtils.ActiveView;
            var                    display    = activeView.ScreenDisplay;
            IDisplayTransformation dispTrans  = display.DisplayTransformation;
            double                 size       = dispTrans.FromPoints(PointSize);
            double                 xmin       = x - size;
            double                 xmax       = x + size;
            double                 ymin       = y - size;
            double                 ymax       = y + size;

            _oldEnvelope = _envelope;

            foreach (var observation in _observations)
            {
                double[] obs = observation.Value;

                if (obs.Length >= 2)
                {
                    double xdir = (_point.X - obs[0]) / 2;
                    double ydir = (_point.Y - obs[1]) / 2;
                    xmin = Math.Min(xmin, _point.X + xdir);
                    ymin = Math.Min(ymin, _point.Y + ydir);
                    xmax = Math.Max(xmax, obs[0]);
                    ymax = Math.Max(ymax, obs[1]);
                }
            }

            _envelope = new EnvelopeClass {
                XMin = xmin, XMax = xmax, YMin = ymin, YMax = ymax
            };
            var avEvents = ArcUtils.ActiveViewEvents;

            if (avEvents != null)
            {
                if (!notCreated)
                {
                    avEvents.AfterDraw -= AvEventsAfterDraw;
                }

                avEvents.AfterDraw += AvEventsAfterDraw;
            }

            IEditor3 editor = ArcUtils.Editor;
            var      sketch = editor as IEditSketch3;

            if ((sketch != null) && (_measurement != null))
            {
                IGeometry geometry = sketch.Geometry;
                int       nrPoints;
                var       ptColl = _measurement.ToPointCollection(geometry, out nrPoints);

                if ((ptColl != null) && _measurement.IsSketch)
                {
                    if (_intId <= nrPoints)
                    {
                        IPoint pointC = ptColl.Point[_intId - 1];

                        if (!IsSame(pointC))
                        {
                            ISketchOperation2 sketchOp = new SketchOperationClass();
                            sketchOp.Start(editor);
                            IPoint point = new PointClass {
                                X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware
                            };

                            if (_measurement.IsPointMeasurement)
                            {
                                sketch.Geometry = point;
                            }
                            else
                            {
                                ptColl.UpdatePoint((_intId - 1), point);

                                if ((_intId == 1) && ((nrPoints + 1) == ptColl.PointCount))
                                {
                                    ptColl.UpdatePoint((ptColl.PointCount - 1), point);
                                }

                                sketch.Geometry = ptColl as IGeometry;
                            }

                            geometry = sketch.Geometry;

                            if (geometry != null)
                            {
                                sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry);
                            }
                        }
                    }
                    else
                    {
                        ISketchOperation2 sketchOp = new SketchOperationClass();
                        sketchOp.Start(editor);
                        IPoint point = new PointClass {
                            X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware
                        };
                        int nrPoints2 = ptColl.PointCount;

                        switch (nrPoints2)
                        {
                        case 0:
                            ptColl.AddPoint(point);

                            if (geometry is IPolygon4)
                            {
                                ptColl.AddPoint(point);
                            }
                            break;

                        case 1:
                            ptColl.AddPoint(point);
                            break;

                        default:
                            if (_intId <= (nrPoints + 1))
                            {
                                object point1 = ((_intId - 1) == nrPoints2) ? Type.Missing : (_intId - 1);
                                object point2 = Type.Missing;
                                ptColl.AddPoint(point, ref point1, ref point2);
                            }

                            break;
                        }

                        sketch.Geometry = ptColl as IGeometry;
                        geometry        = sketch.Geometry;

                        if (geometry != null)
                        {
                            sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry);
                        }
                    }
                }
                else
                {
                    if (geometry is IPoint)
                    {
                        if (geometry.IsEmpty)
                        {
                            if ((!double.IsNaN(_point.X)) && (!double.IsNaN(_point.Y)))
                            {
                                if (!_added)
                                {
                                    IApplication application = ArcMap.Application;
                                    ICommandItem tool        = application.CurrentTool;
                                    ICommand     command     = tool.Command;

                                    if (!(command is IEditTool))
                                    {
                                        _added = true;
                                        var    editorZ = editor as IEditorZ;
                                        double zOffset = 0.0;

                                        if (editorZ != null)
                                        {
                                            zOffset         = editorZ.ZOffset;
                                            editorZ.ZOffset = _point.Z;
                                        }

                                        ISketchOperation2 sketchOp = new SketchOperationClass();
                                        sketchOp.Start(editor);
                                        IPoint point = new PointClass {
                                            X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware
                                        };
                                        sketch.Geometry = point;
                                        geometry        = sketch.Geometry;
                                        sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry);
                                        sketch.FinishSketch();

                                        if (editorZ != null)
                                        {
                                            editorZ.ZOffset = zOffset;
                                        }

                                        _added = false;
                                    }
                                }
                            }
                        }
                        else
                        {
                            var pointC = geometry as IPoint;

                            if (!IsSame(pointC))
                            {
                                if ((!double.IsNaN(_point.X)) && (!double.IsNaN(_point.Y)))
                                {
                                    ISketchOperation2 sketchOp = new SketchOperationClass();
                                    sketchOp.Start(editor);
                                    IPoint point = new PointClass {
                                        X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware
                                    };
                                    sketch.Geometry = point;
                                    geometry        = sketch.Geometry;
                                    sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry);
                                }
                            }
                        }
                    }
                }
            }

            Update();
        }
Example #32
0
 private void ExecuteCommand(ICommandItem command)
 {
     if (command != null)
     {
         var client = GetClient(command.CommandTag);
         if(client != null)
             client.DoCommand(command.CommandTag);
     }
 }
Example #33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ToolBarSplitButtonViewModel"/> class.
 /// </summary>
 /// <param name="commandItem">The command item. Must not be <see langword="null"/>.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="commandItem"/> is <see langword="null"/>.
 /// </exception>
 public ToolBarSplitButtonViewModel(ICommandItem commandItem)
     : base(commandItem)
 {
 }
        public static void LoadCommand()
        {
            try
            {
                AAState.commandItem = ArcMap.Application.Document.CommandBars.Find("ArcGIS4LocalGovernment_AttributeAssistantToggleCommand", true);
            }
            catch//(Exception ex)
            {
                //  MessageBox.Show(ex.Message);

            }
        }
 public static void LoadCommand()
 {
     try
     {
         AAState.commandItem = ArcMap.Application.Document.CommandBars.Find("ArcGIS4LocalGovernment_AttributeAssistantToggleCommand", true, false);
     }
     catch
     {
     }
 }
Example #36
0
 /// <summary>
 /// Removes the command item.
 /// </summary>
 /// <param name="commandItem">The command item to be removed.</param>
 public void RemoveCommand(ICommandItem commandItem)
 {
     this.commandProvider.RemoveCommand(commandItem);
 }
Example #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ToolBarComboBoxViewModel"/> class.
 /// </summary>
 /// <param name="commandItem">The command item. Must not be <see langword="null"/>.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="commandItem"/> is <see langword="null"/>.
 /// </exception>
 public ToolBarComboBoxViewModel(ICommandItem commandItem)
     : base(commandItem)
 {
 }
Example #38
0
 /// <summary>
 /// Adds the command item.
 /// </summary>
 /// <param name="item">The command item.</param>
 public static void AddItem(ICommandItem item)
 {
     if (CommandItems == null)
     CommandItems = new List<ICommandItem>();
      CommandItems.Add(item);
 }
Example #39
0
 public virtual bool ValidateItem(ICommandItem item)
 {
     if (item.Command != null)
         return ValidateCommand(item.Command);
     else if (ObjectiveC.InstancesRespondToSelector(super.Class, CommonSelectors.ValidateUserInterfaceItem))
     {
         if (super.Receiver == IntPtr.Zero) super.Receiver = NativePointer;
         using (var wrapper = ItemWrapper.Create(item))
             return SafeNativeMethods.objc_msgSendSuper_get_Boolean(ref super, CommonSelectors.ValidateUserInterfaceItem, wrapper.NativePointer);
     }
     else
         return false;
 }
        /// <summary>
        ///     The select button click event handler
        /// </summary>
        /// <param name="sender">
        ///     The sender.
        /// </param>
        /// <param name="e">
        ///     The e.
        /// </param>
        private void SelectButtonClick(object sender, EventArgs e)
        {
            this.ResetGbd();

            if (ArcMap.Application.CurrentTool.Name != ThisAddIn.IDs.Gbdx_Gbd_Selector)
            {
                // if there was already a listener established close it.
                GbdRelay.Instance.AoiHasBeenDrawn -= this.InstanceAoiHasBeenDrawn;
                GbdRelay.Instance.AoiHasBeenDrawn += this.InstanceAoiHasBeenDrawn;

                var commandBars = ArcMap.Application.Document.CommandBars;
                var commandId = new UIDClass { Value = ThisAddIn.IDs.Gbdx_Gbd_Selector };
                var commandItem = commandBars.Find(commandId, false, false);

                if (commandItem != null)
                {
                    this.previouslySelectedItem = ArcMap.Application.CurrentTool;
                    ArcMap.Application.CurrentTool = commandItem;
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandEventArgs"/> class.
 /// </summary>
 /// <param name="command">The command.</param>
 public CommandEventArgs(ICommandItem command)
 {
     this.command = command;
 }
        // =========================================================================
        // Private Functions
        // =========================================================================
        private void AddObs(Bitmap bitmap, FrmGlobespotter frmGlobespotter, int entityId, int pointId,
                            MeasurementObservation observation)
        {
            if (_entityId != entityId)
            {
                _lastPointIdUpd = null;
            }

            string               imageId      = observation.imageId;
            GsExtension          extension    = GsExtension.GetExtension();
            CycloMediaGroupLayer groupLayer   = extension.CycloMediaGroupLayer;
            IMappedFeature       locationInfo = groupLayer.GetLocationInfo(imageId);
            var    recordingInfo = locationInfo as Recording;
            double stdX          = (recordingInfo == null) ? 0 : (recordingInfo.LongitudePrecision ?? 0);
            double stdY          = (recordingInfo == null) ? 0 : (recordingInfo.LatitudePrecision ?? 0);
            double stdZ          = (recordingInfo == null) ? 0 : (recordingInfo.HeightPrecision ?? 0);
            string std           = string.Format("{0:0.00} {1:0.00} {2:0.00}", stdX, stdY, stdZ);

            if ((_entityId != entityId) || (_pointId != pointId))
            {
                ClearForm(false);
                _entityId           = entityId;
                _pointId            = pointId;
                _measurementPoint   = null;
                _measurementPointS  = null;
                txtNumber.Text      = string.Empty;
                txtPosition.Text    = string.Empty;
                txtPositionStd.Text = string.Empty;
                RelO.Image          = null;
                SetOpenClose(false);
            }

            Measurement measurement = Measurement.Get(_entityId);

            if (measurement != null)
            {
                _measurementPointS = measurement[_pointId];
                _measurementPointS.UpdateObservation(imageId, observation.x, observation.y, observation.z);
                txtNumber.Text = _measurementPointS.M.ToString(_ci);

                if (measurement.IsPointMeasurement)
                {
                    SetOpenClose(true);

                    if (_commandItem == null)
                    {
                        _commandItem = ArcMap.Application.CurrentTool;
                        ArcUtils.SetToolActiveInToolBar("esriEditor.EditTool");
                    }
                }
            }

            if (bitmap != null)
            {
                _bitmapImageId.Add(imageId);
                _idBitmap.Add(bitmap);
            }

            bool add = true;

            foreach (ListViewItem item in lvObservations.Items)
            {
                var obs = item.Tag as MeasurementObservation;

                if (obs != null)
                {
                    if (obs.imageId == imageId)
                    {
                        add = false;
                    }
                }
            }

            if (add)
            {
                _frmGlobespotter = frmGlobespotter;
                var items        = new[] { imageId, std, "X" };
                var listViewItem = new ListViewItem(items)
                {
                    Tag = observation
                };
                lvObservations.Items.Add(listViewItem);
                DrawObservations();
                RedrawObservationList();
            }
        }
        public static void LoadAttributeTransfer(IApplication app, List <AttributeTransferDetails> attTransferDetails)
        {
            IEditor                  editor        = null;
            UID                      pUID          = null;
            IAttributeTransfer       pAttTrans     = null;
            IAttributeTransferType   pAttTransType = null;
            IFieldMap                pFieldMap     = null;
            AttributeTransferDetails attConfig     = null;
            IFeatureLayer            pSfl          = null;
            IFeatureLayer            pTfl          = null;
            IField                   pSourceField  = null;
            IField                   pTargetField  = null;

            ICommandItem pCmdItem = null;
            IAttributeTransferDefaultSettings pATDS = null;

            try
            {
                editor = Globals.getEditor(app);

                if (editor.EditState == esriEditState.esriStateNotEditing)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("MustBEditg") + " " + A4LGSharedFunctions.Localizer.GetString("StrtEditing"));
                    return;
                }

                if (attTransferDetails == null)
                {
                    return;
                }
                if (attTransferDetails.Count == 0)
                {
                    return;
                }


                pAttTransType = (IAttributeTransferType)editor;
                pAttTrans     = pAttTransType.AttributeTransfer;



                for (int j = 0; j < attTransferDetails.Count; j++)
                {
                    attConfig = attTransferDetails[j];

                    string aSourceName     = attConfig.SourceLayerName;
                    string aTargetName     = attConfig.TargetLayerName;
                    bool   FCorLayerSource = true;
                    bool   FCorLayerTarget = true;
                    pSfl = Globals.FindLayer(app, aSourceName, ref FCorLayerSource) as IFeatureLayer;
                    pTfl = Globals.FindLayer(app, aTargetName, ref FCorLayerTarget) as IFeatureLayer;
                    if (pSfl == null || pTfl == null)
                    {
                        //MessageBox.Show("The source or target layer is not present");
                        //return;
                    }
                    else
                    {
                        pFieldMap = pAttTrans.FindFieldMap(pSfl.FeatureClass, pTfl.FeatureClass);
                        if (pFieldMap != null)
                        {
                            pAttTrans.DeleteFieldMap(pFieldMap);
                        }
                        pFieldMap = new FieldMapClass();

                        pFieldMap.SourceClass = pSfl.FeatureClass;
                        pFieldMap.TargetClass = pTfl.FeatureClass;



                        for (int i = 0; i < attConfig.FromToFields.Length; i++)
                        {
                            if (attConfig.FromToFields[i] == null)
                            {
                                MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttrTrasftLoadRError_1"));
                                return;
                            }
                            if (attConfig.FromToFields[i].SourceField == null || attConfig.FromToFields[i].TargetField == null)
                            {
                                MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttrTrasftLoadRError_1"));
                                return;
                            }
                            pSourceField = Globals.GetField(pSfl.FeatureClass.Fields, attConfig.FromToFields[i].SourceField);
                            pTargetField = Globals.GetField(pTfl.FeatureClass.Fields, attConfig.FromToFields[i].TargetField);
                            if (pSourceField != null && pTargetField != null)
                            {
                                pFieldMap.SetFieldMap(pSourceField, pTargetField);
                            }
                        }


                        pAttTrans.FieldMap = pFieldMap;

                        pATDS = (IAttributeTransferDefaultSettings)pAttTrans;

                        pATDS.SourceName = aSourceName;
                        pATDS.TargetName = aTargetName;
                    }
                }


                pUID       = new UIDClass();
                pUID.Value = "esriEditorExt.FieldMappingCommand";


                app.CurrentTool = null;


                pCmdItem = app.Document.CommandBars.Find(pUID);
                pCmdItem.Execute();
            }
            catch (Exception ex)
            {
                MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorInThe") + "LoadAttributeTransfer: " + ex.ToString());
            }
            finally
            {
                editor        = null;
                pUID          = null;
                pAttTrans     = null;
                pAttTransType = null;
                pFieldMap     = null;
                attConfig     = null;
                pSfl          = null;
                pTfl          = null;
                pSourceField  = null;
                pTargetField  = null;

                pCmdItem = null;
                pATDS    = null;
            }
        }
        /// <summary>
        ///     Event handler for when the select area button is clicked.
        /// </summary>
        /// <param name="sender">
        ///     the button that is clicked
        /// </param>
        /// <param name="e">
        ///     event arguments that get sent by the button
        /// </param>
        private void EventHandlerSelectAreaButtonClick(object sender, EventArgs e)
        {
            // Draw Rectangle option
            if (this.aoiTypeComboBox.SelectedIndex == 0)
            {
                // Reset this variable to allow the user to differentiate between normal and query search.
                this.usingQuerySource = false;
                this.treeView1.CheckBoxes = true;

                if (ArcMap.Application.CurrentTool.Name != "DigitalGlobe_Inc_sma_VectorIndex")
                {
                    // Unsubscribe from any previous events.  Prevents awesome mode
                    VectorIndexRelay.Instance.PolygonHasBeenSet -= this.InstancePolygonHasBeenSet;

                    // Subscribe to the event
                    VectorIndexRelay.Instance.PolygonHasBeenSet += this.InstancePolygonHasBeenSet;

                    // Clear any current drawn images
                    if (this.boundingBoxGraphicElement != null)
                    {
                        ArcUtility.DeleteElementFromGraphicContainer(
                            ArcMap.Document.ActivatedView,
                            this.boundingBoxGraphicElement);
                        this.boundingBoxGraphicElement = null;
                    }

                    // Clear the treeview
                    this.treeView1.Nodes.Clear();
                    this.textBoxSearch.Clear();

                    this.currentApplicationState = this.applicationStateGenerator.Next();
                    var commandBars = ArcMap.Application.Document.CommandBars;
                    var commandId = new UIDClass { Value = "DigitalGlobe_Inc_sma_VectorIndex" };

                    var commandItem = commandBars.Find(commandId, false, false);
                    if (commandItem != null)
                    {
                        this.originallySelectedItem = ArcMap.Application.CurrentTool;
                        ArcMap.Application.CurrentTool = commandItem;
                    }
                }
            }

            // Use selected AOI
            else if (this.aoiTypeComboBox.SelectedIndex == 1)
            {
                // Clear any current drawn images
                if (this.boundingBoxGraphicElement != null)
                {
                    ArcUtility.DeleteElementFromGraphicContainer(
                        ArcMap.Document.ActivatedView,
                        this.boundingBoxGraphicElement);
                    this.boundingBoxGraphicElement = null;
                }

                this.ShapeAoi();
            }
        }
Example #45
0
        private void SetCurrentSketchTool()
        {
            if (m_application != null)
            {
                ICommandBars documentBars = m_application.Document.CommandBars;
                UID          cmdID        = new UIDClass();
                switch (strGeometryType)
                {
                case "点":
                case "线":
                case "多边形":
                    cmdID.Value = "{B479F48A-199D-11D1-9646-0000F8037368}";    //sketch tool
                    break;

                case "矩形":
                    cmdID.Value = "{6F0ED2CC-C099-4895-BD7E-BEEC2F78ADBF}";     //esriEditor.RectangleTool
                    break;

                case "圆":
                    cmdID.Value = "{09C6F589-A3CE-48AB-81BC-46965C58F264}";    //esriEditor.CircleTool
                    break;

                default:
                    break;
                }
                ICommandItem cmdItem = documentBars.Find(cmdID, false, false);
                m_application.CurrentTool = cmdItem;
            }
            if (m_mapControl != null)
            {
                ICommand tool = null;
                switch (strGeometryType)
                {
                case "点":
                    tool = new 空间查询与空间分析.createPointTool(tempFeatureLayer);      //CreatePointTool
                    break;

                case "线":
                    tool = new 空间查询与空间分析.CreatePolylineTool(tempFeatureLayer);      //CreatePolylineTool
                    break;

                case "多边形":
                    tool = new 空间查询与空间分析.CreatePolygonTool(tempFeatureLayer);      //CreatePolygonTool
                    break;

                case "矩形":
                    tool = new 空间查询与空间分析.CreateRectangleTool(tempFeatureLayer);      //CreateRectangleTool
                    break;

                case "圆":
                    tool = new 空间查询与空间分析.CreateCircleTool(tempFeatureLayer);     //CreateCircleTool
                    break;

                default:
                    break;
                }
                if (tool == null)
                {
                    return;
                }
                tool.OnCreate(m_mapControl);
                m_mapControl.CurrentTool  = tool as ITool;
                m_mapControl.MousePointer = esriControlsMousePointer.esriPointerHand;
            }
        }
        public static void LoadCommand()
        {
            try
            {
                AAState.commandItem = ArcMap.Application.Document.CommandBars.Find("ESRI_WaterUtilitiesTemplate_AttributeAssistantToggleCommand");
            }
            catch
            {
                // MessageBox.Show(ex.Message);

            }
        }
Example #47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FilePathMenuItemViewModel"/> class.
 /// </summary>
 /// <param name="commandItem">The command item. Must not be <see langword="null"/>.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="commandItem"/> is <see langword="null"/>.
 /// </exception>
 public FilePathMenuItemViewModel(ICommandItem commandItem)
     : base(commandItem)
 {
 }
        private static void OnSelectionChanged()
        {
            try
            {
                IApplication application = ArcMap.Application;
                ICommandItem tool        = application.CurrentTool;
                string       name        = tool.Name;

                IEditor3 editor = ArcUtils.Editor;
                LogClient.Info("On Selection Changed");

                if (editor != null)
                {
                    IEnumFeature editSelection = editor.EditSelection;

                    if (editSelection != null)
                    {
                        editSelection.Reset();
                        EditFeatures.Clear();
                        IFeature feature;

                        while ((feature = editSelection.Next()) != null)
                        {
                            EditFeatures.Add(feature);
                        }

                        if (FeatureStartEditEvent != null)
                        {
                            var geometries = new List <IGeometry>();
                            editSelection.Reset();
                            bool isPointLayer = false;

                            while ((feature = editSelection.Next()) != null)
                            {
                                VectorLayer vectorLayer = GetLayer(feature);

                                if ((vectorLayer != null) && (vectorLayer.IsVisibleInGlobespotter))
                                {
                                    geometries.Add(feature.Shape);
                                    isPointLayer = isPointLayer || (Measurement.GetTypeOfLayer(feature.Shape) == TypeOfLayer.Point);
                                }
                            }

                            if ((_doSelection && (name != "Query_SelectFeatures")) || (!isPointLayer))
                            {
                                FeatureStartEditEvent(geometries);
                                AvContentChanged();

                                _doSelection = false;

                                if (_nextSelectionTimer == null)
                                {
                                    var       checkEvent  = new AutoResetEvent(true);
                                    const int timeOutTime = 1500;

                                    var checkTimerCallBack = new TimerCallback(CheckTimerCallBack);

                                    _nextSelectionTimer = new Timer(checkTimerCallBack, checkEvent, timeOutTime, -1);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogClient.Error("VectorLayer.OnSelectionChanged", ex.Message, ex);
                Trace.WriteLine(ex.Message, "VectorLayer.OnSelectionChanged");
            }
        }
Example #49
0
 private bool CanExecuteCommand(ICommandItem command)
 {
     if (command != null)
     {
         var client = GetClient(command.CommandTag);
         if (client != null)
             return client.CanDoCommand(command.CommandTag);
     }
     return false;
 }
Example #50
0
        /// <summary>
        /// Performs base validation logic
        /// </summary>
        /// <param name="context"></param>
        /// <param name="resource"></param>
        /// <param name="recurse"></param>
        /// <returns></returns>
        protected static ValidationIssue[] ValidateBase(ResourceValidationContext context, IResource resource, bool recurse)
        {
            Check.ArgumentNotNull(context, nameof(context));

            if (context.IsAlreadyValidated(resource.ResourceID))
            {
                return(null);
            }

            if (resource.ResourceType != ResourceTypes.WebLayout.ToString())
            {
                return(null);
            }

            List <ValidationIssue> issues = new List <ValidationIssue>();

            IWebLayout layout = resource as IWebLayout;

            if (layout.Map == null || layout.Map.ResourceId == null)
            {
                issues.Add(new ValidationIssue(layout, ValidationStatus.Error, ValidationStatusCode.Error_WebLayout_MissingMap, string.Format(Strings.WL_MissingMapError)));
            }
            else
            {
                //Check for duplicate command names
                var cmdSet = layout.CommandSet;
                Dictionary <string, ICommand> cmds = new Dictionary <string, ICommand>();
                foreach (ICommand cmd in cmdSet.Commands)
                {
                    if (cmds.ContainsKey(cmd.Name))
                    {
                        issues.Add(new ValidationIssue(layout, ValidationStatus.Error, ValidationStatusCode.Error_WebLayout_DuplicateCommandName, string.Format(Strings.WL_DuplicateCommandName, cmd.Name)));
                    }
                    else
                    {
                        cmds[cmd.Name] = cmd;
                    }
                }

                //Check for duplicate property references in search commands
                foreach (ISearchCommand search in cmdSet.Commands.OfType <ISearchCommand>())
                {
                    Dictionary <string, string> resColProps = new Dictionary <string, string>();
                    foreach (IResultColumn resCol in search.ResultColumns.Column)
                    {
                        if (resColProps.ContainsKey(resCol.Property))
                        {
                            issues.Add(new ValidationIssue(layout, ValidationStatus.Error, ValidationStatusCode.Error_WebLayout_DuplicateSearchCommandResultColumn, string.Format(Strings.WL_DuplicateSearchResultColumn, search.Name, resCol.Property)));
                        }
                        else
                        {
                            resColProps.Add(resCol.Property, resCol.Property);
                        }
                    }
                }

                //Check for command references to non-existent commands
                foreach (IUIItem item in layout.ContextMenu.Items)
                {
                    if (item.Function == UIItemFunctionType.Command)
                    {
                        ICommandItem cmdRef = (ICommandItem)item;
                        if (!cmds.ContainsKey(cmdRef.Command))
                        {
                            issues.Add(new ValidationIssue(layout, ValidationStatus.Error, ValidationStatusCode.Error_WebLayout_NonExistentContextMenuCommandReference, string.Format(Strings.WL_NonExistentMenuCommandReference, cmdRef.Command)));
                        }
                    }
                }

                foreach (IUIItem item in layout.TaskPane.TaskBar.Items)
                {
                    if (item.Function == UIItemFunctionType.Command)
                    {
                        ICommandItem cmdRef = (ICommandItem)item;
                        if (!cmds.ContainsKey(cmdRef.Command))
                        {
                            issues.Add(new ValidationIssue(layout, ValidationStatus.Error, ValidationStatusCode.Error_WebLayout_NonExistentTaskPaneCommandReference, string.Format(Strings.WL_NonExistentTaskPaneCommandReference, cmdRef.Command)));
                        }
                    }
                }

                foreach (IUIItem item in layout.ToolBar.Items)
                {
                    if (item.Function == UIItemFunctionType.Command)
                    {
                        ICommandItem cmdRef = (ICommandItem)item;
                        if (!cmds.ContainsKey(cmdRef.Command))
                        {
                            issues.Add(new ValidationIssue(layout, ValidationStatus.Error, ValidationStatusCode.Error_WebLayout_NonExistentToolbarCommandReference, string.Format(Strings.WL_NonExistentToolbarCommandReference, cmdRef.Command)));
                        }
                    }
                }

                try
                {
                    IMapDefinition mdef = (IMapDefinition)context.GetResource(layout.Map.ResourceId);
                    if (layout.Map.InitialView != null)
                    {
                        var mapEnv = ObjectFactory.CreateEnvelope(mdef.Extents.MinX, mdef.Extents.MinY, mdef.Extents.MaxX, mdef.Extents.MaxY);
                        if (!mapEnv.Contains(layout.Map.InitialView.CenterX, layout.Map.InitialView.CenterY))
                        {
                            issues.Add(new ValidationIssue(mdef, ValidationStatus.Warning, ValidationStatusCode.Warning_WebLayout_InitialViewOutsideMapExtents, string.Format(Strings.WL_StartViewOutsideExtentsWarning)));
                        }
                    }

                    if (recurse)
                    {
                        issues.AddRange(ResourceValidatorSet.Validate(context, mdef, true));
                    }
                }
                catch (Exception ex)
                {
                    string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                    issues.Add(new ValidationIssue(layout, ValidationStatus.Error, ValidationStatusCode.Error_WebLayout_Generic, string.Format(Strings.WL_MapValidationError, layout.Map.ResourceId, msg)));
                }
            }

            context.MarkValidated(resource.ResourceID);

            return(issues.ToArray());
        }
Example #51
0
        private void LegacyUpdateCommand(ICommandItem item)
        {
            ICommandClient client = GetClient(item.CommandTag);
            if (client == null)
                client = m_activeClient;

            if (client != null)
            {
                var commandState = new CommandState { Text = item.Text, Check = item.IsChecked };
                client.UpdateCommand(item.CommandTag, commandState);
                item.Text = commandState.Text.Trim();
                item.IsChecked = commandState.Check;
            }
        }
Example #52
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FilePathMenuItemViewModel"/> class.
 /// </summary>
 /// <param name="commandItem">The command item. Must not be <see langword="null"/>.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="commandItem"/> is <see langword="null"/>.
 /// </exception>
 public FilePathMenuItemViewModel(ICommandItem commandItem)
     : base(commandItem)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ToolBarQuickFindViewModel"/> class.
 /// </summary>
 /// <param name="commandItem">The command item. Must not be <see langword="null"/>.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="commandItem"/> is <see langword="null"/>.
 /// </exception>
 public ToolBarQuickFindViewModel(ICommandItem commandItem)
     : base(commandItem)
 {
     Width = 150;
     Query = (commandItem as QuickFindCommandItem)?.SearchExtension?.Query;
 }
        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (hook == null)
                return;

            //Get the appropriate zoom in command based on application
            m_application = hook as IApplication;
            base.m_enabled = false;

            if (m_application != null)
            {
                UID cmdUID = new UIDClass();
                switch (m_application.Name) //or test by casting the appropriate application interface
                {
                    case "ArcMap":
                        cmdUID.Value = "esriArcMapUI.ZoomInFixedCommand";
                        break;
                    case "ArcGlobe":
                        cmdUID.Value = "esriArcGlobe.GMxNarrowFOVCommand";
                        break;
                    case "ArcScene":
                        cmdUID.Value = "esriArcScene.SxNarrowFOVCommand";
                        break;
                }

                ICommandBars docBars = m_application.Document.CommandBars;
                m_xoomCommand = docBars.Find(cmdUID, false, false);

                //Enable only when the delegate command is available
                base.m_enabled = m_xoomCommand != null;
            }
        }
Example #55
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ToolBarSplitButtonViewModel"/> class.
 /// </summary>
 /// <param name="commandItem">The command item. Must not be <see langword="null"/>.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="commandItem"/> is <see langword="null"/>.
 /// </exception>
 public ToolBarDropDownButtonViewModel(ICommandItem commandItem)
     : base(commandItem)
 {
 }
        private void drawButton_Click(object sender, EventArgs e)
        {
            // if there is already a element on the screen remove it.
            if (this.drawnElement != null)
            {
                ArcUtility.DeleteElementFromGraphicContainer(ArcMap.Document.ActiveView, this.drawnElement);
            }

            this.drawnPolygon = null;
            this.drawnElement = null;

            // Unsubscribe to pre-existing events if any then subscibe so only one
            // subscription is active.
            AnswerFactoryRelay.Instance.AoiHasBeenDrawn -= this.Instance_AoiHasBeenDrawn;
            AnswerFactoryRelay.Instance.AoiHasBeenDrawn += this.Instance_AoiHasBeenDrawn;

            var commandBars = ArcMap.Application.Document.CommandBars;
            var commandId = new UIDClass { Value = ThisAddIn.IDs.Gbdx_Answer_Factory_AnswerFactorySelector };
            var commandItem = commandBars.Find(commandId, false, false);

            if (commandItem != null)
            {
                this.PreviouslySelectedItem = ArcMap.Application.CurrentTool;
                ArcMap.Application.CurrentTool = commandItem;
            }
        }