コード例 #1
0
        /// <summary>
        /// Setup the menu
        /// </summary>
        private void SetupMenu()
        {
            var menu = new ObservableCollection <LiteMenuCategoryViewModel>();

            var cat = new LiteMenuCategoryViewModel {
                Title = ApplicationResources.FeatureEditInsertCategoryHeader
            };

            foreach (var item in Items)
            {
                var menuItem = new LiteMenuItemViewModel(item.Name)
                {
                    Command = new RelayCommand(() => InsertItem(item), () => item.IsEnabled)
                };
                cat.Items.Add(menuItem);
                item.PropertyChanged += (s, e) => SetupMenuItem(s, e, menuItem);
            }

            // Only add the category if there are any items
            if (cat.Items.Any())
            {
                menu.Add(cat);
            }

            // Set the menu
            MenuItems = menu;

            // Notify
            RaisePropertyChanged(ViewVisibilityPropertyName);
        }
コード例 #2
0
        /// <summary>
        /// Set up the commands
        /// </summary>
        private void SetupMenuCommands()
        {
            // Setup the menu items
            var items = new ObservableCollection <LiteMenuCategoryViewModel>();

            var cat = new LiteMenuCategoryViewModel {
                Title = ApplicationResources.MapTrailCreateCategoryHeader
            };

            cat.Items.Add(new LiteMenuItemViewModel(ApplicationResources.TrailPoint, "MetroIcon.Content.TrailPoint")
            {
                Command = new RelayCommand(() => NewTrail(new RedliningPoint(CoordinateSystem)), CanAddNewElement),
            });
            cat.Items.Add(new LiteMenuItemViewModel(ApplicationResources.TrailCurve, "MetroIcon.Content.TrailCurve")
            {
                Command = new RelayCommand(() => NewTrail(new RedliningCurve(CoordinateSystem)), CanAddNewElement),
            });
            cat.Items.Add(new LiteMenuItemViewModel(ApplicationResources.TrailPolygon, "MetroIcon.Content.TrailPolygon")
            {
                Command = new RelayCommand(() => NewTrail(new RedliningPolygon(CoordinateSystem)), CanAddNewElement),
            });
            cat.Items.Add(new LiteMenuItemViewModel(ApplicationResources.TrailCircle, "MetroIcon.Content.TrailCircle")
            {
                Command = new RelayCommand(() => NewTrail(new RedliningCircle(CoordinateSystem)), CanAddNewElement),
            });
            cat.Items.Add(new LiteMenuItemViewModel(ApplicationResources.TrailRectangle, "MetroIcon.Content.TrailRectangle")
            {
                Command = new RelayCommand(() => NewTrail(new RedliningRectangle(CoordinateSystem)), CanAddNewElement),
            });
            items.Add(cat);

            var catActions = new LiteMenuCategoryViewModel {
                Title = ApplicationResources.MapTrailActionsCategoryHeader
            };

            catActions.Items.Add(new LiteMenuItemViewModel(ApplicationResources.MapTrailClearAll, "MetroIcon.Content.TrailClear")
            {
                Command = new RelayCommand(ClearElements, HasElements),
            });

            items.Add(catActions);

            MenuItems = items;
        }
コード例 #3
0
        /// <summary>
        /// Set up the commands
        /// </summary>
        private void SetupMenuCommands()
        {
            // Setup the menu items
            var items = new ObservableCollection <LiteMenuCategoryViewModel>();

            var cat = new LiteMenuCategoryViewModel {
                Title = ApplicationResources.MapMeasurerModeCategoryHeader
            };

            cat.Items.Add(new LiteMenuItemViewModel(ApplicationResources.MapMeasureFreeMode, "MetroIcon.Content.MeasureFree")
            {
                Command = new RelayCommand(() => MeasureFreeIsActive = true),
            });
            cat.Items.Add(new LiteMenuItemViewModel(ApplicationResources.MapMeasureDimMode, "MetroIcon.Content.MeasureDim")
            {
                Command = new RelayCommand(() => MeasureDimIsActive = true),
            });

            items.Add(cat);

            MenuItems = items;
        }
コード例 #4
0
        /// <summary>
        /// Set up the menu commands
        /// </summary>
        private void SetupMenuCommands()
        {
            // Setup the menu items
            var items = new ObservableCollection <LiteMenuCategoryViewModel>();

            // Setup the clipboard actions
            {
                var cat = new LiteMenuCategoryViewModel {
                    Title = "Clipboard", BorderVisibility = Visibility.Collapsed
                };
                cat.Items.Add(new LiteMenuItemViewModel(ApplicationResources.MapPopupCopyCoordinateToClipboard, "MetroIcon.Content.Clipboard")
                {
                    Command = new RelayCommand(CopyMouseCoordinateToClipboard)
                });

                items.Add(cat);
            }

            // Setup the selection actions
            {
                var cat = new LiteMenuCategoryViewModel {
                    Title = "Selection", BorderVisibility = Visibility.Visible
                };
                cat.Items.Add(new LiteMenuItemViewModel(ApplicationResources.MapPopupGotoSelection, "MetroIcon.Content.GotoSelection")
                {
                    Command = new RelayCommand(GoToSelection, HasSelection)
                });
                cat.Items.Add(new LiteMenuItemViewModel(ApplicationResources.MapPopupClearSelection, "MetroIcon.Content.ClearSelection")
                {
                    Command = new RelayCommand(ClearSelection, HasSelection)
                });
                cat.Items.Add(new LiteMenuItemViewModel(ApplicationResources.MapPopupEditGeometrySelection, "MetroIcon.Content.EditSelection")
                {
                    Command             = new RelayCommand(EditSelectedGeometry),
                    VisibilityPredicate = HasEditableGeometrySelection
                });

                items.Add(cat);
            }

            // Setup the trail actions
            {
                var cat = new LiteMenuCategoryViewModel {
                    Title = "Trail", BorderVisibility = Visibility.Visible
                };
                cat.Items.Add(new LiteMenuItemViewModel(ApplicationResources.MapPopupCreateTrailFromSelection, "MetroIcon.Content.Trail")
                {
                    Command = new RelayCommand(CreateTrailFromSelection, HasSelectionForTrailCreation)
                });
                cat.Items.Add(new LiteMenuItemViewModel(ApplicationResources.MapPopupRemoveTrail, "MetroIcon.Content.TrailClear")
                {
                    Command = new RelayCommand(RemoveSelectedTrail, HasTrailSelection)
                });

                items.Add(cat);
            }

            // Setup the object properties actions
            {
                var cat = new LiteMenuCategoryViewModel {
                    Title = "Properties", BorderVisibility = Visibility.Visible
                };
                cat.Items.Add(new LiteMenuItemViewModel(ApplicationResources.MapPopupObjectProperties, "MetroIcon.Content.Details")
                {
                    Command = new RelayCommand(DisplayObjectProperties, HasSelection)
                });

                items.Add(cat);
            }

            // Set the new menu
            MenuItems = items;
        }