Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of the frmOptionsManager class
        /// </summary>
        public frmOptionsManager(LegendControl.Legend legend, int handle)
        {
            InitializeComponent();

            m_handle   = handle;
            m_noEvents = true;

            m_legend = legend;

            m_layer = m_legend.GetLayer(m_handle);
            if (m_layer == null)
            {
                throw new NullReferenceException("Invalid layer handle");
            }

            Globals.FillSymbologyList(listView1, m_layer.FileName, true, ref m_noEvents);

            if (listView1.Items.Count > 0)
            {
                LoadLayer();
            }

            RefreshControlsState();

            m_noEvents = false;
        }
Exemplo n.º 2
0
        public ProsperityForm(LegendControl.Legend legend, int layerHandle)
        {
            InitializeComponent();

            var gs = new GlobalSettings();

            gs.ForceHideLabels = true;
            //初始化form
            _legend      = legend;
            _layerHandle = layerHandle;
            _layer       = _legend.GetLayer(_layerHandle);
            _shapefile   = _layer.GetObject() as Shapefile;
            _settings    = Globals.get_LayerSettings(_layerHandle);
            this.Text    = "图层属性: " + _layer.Name;

            //锁定图层
            LockLegendAndMap(true);
            _initState = SaveState();

            // 颜色框中的第一种颜色应该是shapefile的填充/线条颜色
            Globals.LayerColors.SetDefaultColorScheme(_shapefile);

            //选项卡初始化,禁止触发事件
            _noEvents = true;

            initGategoiresTab();

            //事件触发正常
            _noEvents = false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Generate label categories for the given set of shapefile categories
        /// </summary>
        /// <param name="mapWin">The reference to MapWindow</param>
        /// <param name="layerHandle">The handle of the layer</param>
        internal static void GenerateCategories(LegendControl.Legend legend, int layerHandle)
        {
            Layer     lyr = legend.GetLayer(layerHandle);
            Shapefile sf  = lyr.GetObject() as MapWinGIS.Shapefile;
            Labels    lb  = sf.Labels;

            sf.Labels.ClearCategories();
            for (int i = 0; i < sf.Categories.Count; i++)
            {
                ShapefileCategory cat      = sf.Categories.get_Item(i);
                LabelCategory     labelCat = lb.AddCategory(cat.Name);
                labelCat.Expression = cat.Expression;
            }

            SymbologySettings settings = Globals.get_LayerSettings(layerHandle);
            ColorBlend        blend    = (ColorBlend)settings.LabelsScheme;

            if (blend != null)
            {
                ColorScheme scheme = ColorSchemes.ColorBlend2ColorScheme(blend);
                if (settings.LabelsRandomColors)
                {
                    lb.ApplyColorScheme(tkColorSchemeType.ctSchemeRandom, scheme);
                }
                else
                {
                    lb.ApplyColorScheme(tkColorSchemeType.ctSchemeGraduated, scheme);
                }
            }

            if (settings.LabelsVariableSize)
            {
                for (int i = 0; i < lb.NumCategories; i++)
                {
                    lb.get_Category(i).FontSize = (int)((double)sf.Labels.FontSize +
                                                        (double)settings.LabelsSizeRange / ((double)lb.NumCategories - 1) * (double)i);
                }
            }

            // Expressions aren't supported by labels yet, therefore we need to copy indices from the symbology
            for (int i = 0; i < lb.Count; i++)
            {
                MapWinGIS.Label label = lb.get_Label(i, 0);
                label.Category = sf.get_ShapeCategory(i);
            }
        }
        /// <summary>
        /// Creates new instance of the SymbologyMainForm class
        /// </summary>
        public frmSymbologyMain(LegendControl.Legend legend, int layerHandle)
        {
            // Required for Windows Form Designer support
            InitializeComponent();

            var gs = new GlobalSettings();

            gs.ForceHideLabels = true;

            // setting member variables (some of them for faster access)
            _legend      = legend;
            _layerHandle = layerHandle;
            _layer       = _legend.GetLayer(_layerHandle);
            _shapefile   = _layer.GetObject() as Shapefile;

            _settings = Globals.get_LayerSettings(_layerHandle);
            this.Text = "Layer properties: " + _layer.Name;

            // update map at once button is off by default which is equal to locked state of the map
            LockLegendAndMap(true);

            _initState = SaveState();

            // the first color in color scheme should be the fill/line color of the shapefile
            Globals.LayerColors.SetDefaultColorScheme(_shapefile);

            _noEvents = true;

            InitGeneralTab();

            InitModeTab();

            InitAppearanceTab();

            InitCategoriesTab();

            InitLabelsTab();

            InitChartsTab();

            InitExpressionTab();

            InitVisibilityTab();

            UpdateColorSchemes();

            // the state should be set after the loading as otherwise we can trigger unnecessary redraws
            chkRedrawMap.Checked = false; //_settings.UpdateMapAtOnce;

            _noEvents = false;

            // sets the enabled state of the controls
            RefreshControlsState(null, null);

            //DrawAllPreviews();

            AddTooltips();

            // displaying the last tab
            tabControl1.SelectedIndex = _tabIndex;

            tabControl1.TabPages.Remove(tabCharts);
            tabControl1.TabPages.Remove(tabLabels);
            tabControl1.TabPages.Remove(tabDefault);

            this.Shown += frmSymbologyMain_Shown;
        }
 /// <summary>
 /// Refreshes the preview of the default style
 /// </summary>
 private void DrawPreview()
 {
     Layer     lyr = m_legend.GetLayer(m_layerHandle);
     Shapefile sf  = lyr.GetObject() as MapWinGIS.Shapefile;
 }