コード例 #1
0
        public static MenuItem GetAddStyleMenuItem(AddStyleTypes addStyleType, FeatureLayer featureLayer)
        {
            var command = new ObservedCommand(() => { }, () => !(GisEditor.LayerListManager.SelectedLayerListItems.Count > 0));

            var menuItem = GetMenuItem(GisEditor.LanguageManager.GetStringResource("StyleBuilderWindowAddStyleLabel"), "/GisEditorInfrastructure;component/Images/addstyle.png", null);

            menuItem.Items.Add(GetLoadFromLibraryMenuItem());
            menuItem.Items.Add(new Separator());
            AddSubMenuItems(addStyleType, menuItem);

            //ShapeFileFeatureLayer shpLayer = featureLayer as ShapeFileFeatureLayer;
            //if (shpLayer != null)
            {
                if (menuItem.Items.Count > 0)
                {
                    menuItem.Items.Add(new Separator());
                }
                menuItem.Items.Add(LayerListMenuItemHelper.GetAddStyleWizardMenuItem(featureLayer));
            }
            return(menuItem);
        }
コード例 #2
0
        private static void AddSubMenuItems(AddStyleTypes addStyleType, MenuItem menuItem)
        {
            if ((addStyleType & AddStyleTypes.AddAreaStyle) == AddStyleTypes.AddAreaStyle)
            {
                bool hasItems = false;
                foreach (StylePlugin stylePlugin in GisEditor.StyleManager
                         .GetStylePlugins(StyleCategories.Area | StyleCategories.Composite))
                {
                    hasItems = true;
                    menuItem.Items.Add(LayerListMenuItemHelper.GetAddSpecifiedStyleByPluginMenuItem(stylePlugin));
                }

                if (hasItems)
                {
                    menuItem.Items.Add(new Separator());
                }
            }

            if ((addStyleType & AddStyleTypes.AddLineStyle) == AddStyleTypes.AddLineStyle)
            {
                bool hasItems = false;
                foreach (StylePlugin stylePlugin in GisEditor.StyleManager
                         .GetStylePlugins(StyleCategories.Line | StyleCategories.Composite))
                {
                    hasItems = true;
                    menuItem.Items.Add(LayerListMenuItemHelper.GetAddSpecifiedStyleByPluginMenuItem(stylePlugin));
                }

                if (hasItems)
                {
                    menuItem.Items.Add(new Separator());
                }
            }

            if ((addStyleType & AddStyleTypes.AddPointStyle) == AddStyleTypes.AddPointStyle)
            {
                bool hasItems = false;
                foreach (StylePlugin stylePlugin in GisEditor.StyleManager
                         .GetStylePlugins(StyleCategories.Point | StyleCategories.Composite))
                {
                    hasItems = true;
                    menuItem.Items.Add(LayerListMenuItemHelper.GetAddSpecifiedStyleByPluginMenuItem(stylePlugin));
                }

                if (hasItems)
                {
                    menuItem.Items.Add(new Separator());
                }
            }

            if ((addStyleType & AddStyleTypes.AddTextStyle) == AddStyleTypes.AddTextStyle)
            {
                foreach (StylePlugin stylePlugin in GisEditor.StyleManager
                         .GetStylePlugins(StyleCategories.Label))
                {
                    menuItem.Items.Add(LayerListMenuItemHelper.GetAddSpecifiedStyleByPluginMenuItem(stylePlugin));
                }
            }

            var lastItem = menuItem.Items[menuItem.Items.Count - 1] as Separator;

            if (lastItem != null)
            {
                menuItem.Items.Remove(lastItem);
            }
        }