/// <summary> /// Constructor for setting label expression and options /// </summary> public LabelStyleForm(LegendControl.Legend legend, MapWinGIS.Shapefile sf, int handle) { if (sf == null) { throw new Exception("LabelStyleForm: unexpected null parameter"); } m_legend = legend; m_shapefile = sf; m_handle = handle; InitializeComponent(); //LabelStyle style = new LabelStyle( m_shapefile.Labels.Options); // old-style labels not based on expression if (m_shapefile.Labels.Expression == "" && m_shapefile.Labels.Count > 0 && m_shapefile.Labels.get_Label(0, 0).Text != "") { richTextBox1.Text = "<no expression>"; listBox1.Enabled = false; btnPlus.Enabled = false; btnQuotes.Enabled = false; btnNewLine.Enabled = false; richTextBox1.Enabled = false; } else { richTextBox1.Text = LabelUtilities.StripNewLineQuotes(m_shapefile.Labels.Expression); } this.Initialize(m_shapefile.Labels.Options); tabControl1.SelectedIndex = tabNumber; }
/// <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; }
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; }
/// <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 a new instance of the frmOptionsChooser class /// </summary> public frmOptionsChooser(LegendControl.Legend legend, string filename, int handle) { InitializeComponent(); if (!System.IO.File.Exists(filename)) { throw new Exception("File doesn't exists"); return; } m_legend = legend; m_filename = filename; m_handle = handle; Globals.FillSymbologyList(listView1, filename, false, ref m_NoEvents); m_NoEvents = true; LoadLayer(); m_NoEvents = false; }
/// <summary> /// Displays symbology form of the appropriate type /// </summary> public static Form GetSymbologyForm(LegendControl.Legend legend, int layerHandle, ShpfileType type, ShapeDrawingOptions options, bool applyDisabled) { Form form = null; var shpType = Globals.ShapefileType2D(type); var layer = legend.Layers.ItemByHandle(layerHandle); if (shpType == ShpfileType.SHP_POINT || shpType == ShpfileType.SHP_MULTIPOINT) { form = new PointsForm(legend, layer, options, applyDisabled); } else if (shpType == ShpfileType.SHP_POLYLINE) { form = new LinesForm(legend, layer, options, applyDisabled); } else if (shpType == ShpfileType.SHP_POLYGON) { form = new PolygonsForm(legend, layer, options, applyDisabled); } return(form); }
/// <summary> /// Creates a new instance of the frmGenerateLabelCategories class /// </summary> public frmGenerateLabelCategories(LegendControl.Legend legend, MapWinGIS.Shapefile sf, int layerHandle) { InitializeComponent(); m_shapefile = sf; m_legend = legend; m_layerHandle = layerHandle; Layer layer = legend.Layers.ItemByHandle(layerHandle); // classification cboClassificationType.Items.Clear(); cboClassificationType.Items.Add("Natural breaks"); cboClassificationType.Items.Add("Unique values"); cboClassificationType.Items.Add("Quantiles"); cboClassificationType.Items.Add("Equal intervals"); // number of categories cboCategoriesCount.Items.Clear(); for (int i = 3; i <= 25; i++) { cboCategoriesCount.Items.Add(Convert.ToString(i)); } // initializing for list of color schemes icbFrame.ComboStyle = ImageComboStyle.ColorSchemeGraduated; Globals.LayerColors.SetFirstColorScheme(m_shapefile.Labels.FrameBackColor); icbFrame.ColorSchemes = Globals.LayerColors; udMinSize.Value = sf.Labels.FontSize; LoadOptions(); RefreshControlsState(null, null); DrawPreview(); }
/// <summary> /// Initializes a new instance of the ChartStyleForm class /// </summary> public ChartStyleForm(LegendControl.Legend legend, MapWinGIS.Shapefile sf, bool legendCall, int handle) { InitializeComponent(); _shapefile = sf; _charts = sf.Charts; m_legend = legend; _handle = handle; MapWinGIS.tkSavingMode mode = _charts.SavingMode; _charts.SavingMode = MapWinGIS.tkSavingMode.modeNone; _initState = _charts.Serialize(); _charts.SavingMode = mode; _noEvents = true; panelPieChart.Top = panelBarChart.Top; panelPieChart.Left = panelBarChart.Left; foreach (FontFamily family in FontFamily.Families) { cboFontName.Items.Add(family.Name); } cboValuesStyle.Items.Clear(); cboValuesStyle.Items.Add("Horizontal"); cboValuesStyle.Items.Add("Vertical"); cboChartVerticalPosition.Items.Clear(); cboChartVerticalPosition.Items.Add("Above current layer"); cboChartVerticalPosition.Items.Add("Above all layers"); optBarCharts.Checked = (_charts.ChartType == MapWinGIS.tkChartType.chtBarChart); optPieCharts.Checked = (_charts.ChartType == MapWinGIS.tkChartType.chtPieChart); // initializing for list of color schemes icbColors.ColorSchemes = Globals.ChartColors; icbColors.ComboStyle = ImageComboStyle.ColorSchemeGraduated; if (icbColors.Items.Count > 0) { icbColors.SelectedIndex = 0; } string[] scales = { "1", "10", "100", "1000", "5000", "10000", "25000", "50000", "100000", "250000", "500000", "1000000", "10000000" }; cboMinScale.Items.Clear(); cboMaxScale.Items.Clear(); for (int i = 0; i < scales.Length; i++) { cboMinScale.Items.Add(scales[i]); cboMaxScale.Items.Add(scales[i]); } txtChartExpression.Text = sf.Charts.VisibilityExpression; SetChartsType(); InitFields(); _noEvents = false; Settings2GUI(); Draw(); RefreshControlsState(); tabControl1.SelectedIndex = _selectedTab; }
public PointsForm(LegendControl.Legend legend, Layer layer, ShapeDrawingOptions options, bool applyDisabled) { InitializeComponent(); if (options == null || legend == null) { throw new Exception("PointsForm: Unexpected null parameter"); } m_legend = legend; // setting values to the controls _options = options; m_layer = layer; _initState = _options.Serialize(); _noEvents = true; btnApply.Visible = !applyDisabled; clpFillColor.SelectedColorChanged += clpFillColor_SelectedColorChanged; cboIconCollection.SelectedIndexChanged += CboIconCollectionSelectedIndexChanged; cboFillType.SelectedIndexChanged += cboFillType_SelectedIndexChanged; icbPointShape.ComboStyle = ImageComboStyle.PointShape; icbLineType.ComboStyle = ImageComboStyle.LineStyle; icbLineWidth.ComboStyle = ImageComboStyle.LineWidth; icbHatchStyle.ComboStyle = ImageComboStyle.HatchStyle; pnlFillPicture.Parent = groupBox3; pnlFillPicture.Top = pnlFillHatch.Top; pnlFillPicture.Left = pnlFillHatch.Left; pnlFillGradient.Parent = groupBox3; pnlFillGradient.Top = pnlFillHatch.Top; pnlFillGradient.Left = pnlFillHatch.Left; cboFillType.Items.Clear(); cboFillType.Items.Add("Solid"); cboFillType.Items.Add("Hatch"); cboFillType.Items.Add("Gradient"); cboGradientType.Items.Clear(); cboGradientType.Items.Add("Linear"); cboGradientType.Items.Add("Retangular"); cboGradientType.Items.Add("Circle"); cboFontName.SelectedIndexChanged += cboFontName_SelectedIndexChanged; RefreshFontList(null, null); characterControl1.SelectedCharacterCode = (byte)_options.PointCharacter; RefreshIconCombo(); chkScaleIcons.Checked = _options.PictureScaleX != 1.0 || _options.PictureScaleY != 1.0; //if (layer != null) //{ //SymbologySettings settings = Globals.get_LayerSettings(m_layer.Handle); //if (settings != null) //{ // iconControl1.SelectedIndex = settings.IconIndex; // chkScaleIcons.Checked = settings.ScaleIcons; // string name = settings.IconCollection.ToLower(); // for (int i = 0; i < cboIconCollection.Items.Count; i++) // { // if (cboIconCollection.Items[i].ToString().ToLower() == name) // { // cboIconCollection.SelectedIndex = i; // break; // } // } //} //} Options2Gui(); _noEvents = false; // ----------------------------------------------------- // 订阅事件 // ----------------------------------------------------- udRotation.ValueChanged += Gui2Options; udPointNumSides.ValueChanged += Gui2Options; udSideRatio.ValueChanged += Gui2Options; udSize.ValueChanged += Gui2Options; chkShowAllFonts.CheckedChanged += RefreshFontList; // 线 chkOutlineVisible.CheckedChanged += Gui2Options; icbLineType.SelectedIndexChanged += Gui2Options; icbLineWidth.SelectedIndexChanged += Gui2Options; clpOutline.SelectedColorChanged += clpOutline_SelectedColorChanged; chkFillVisible.CheckedChanged += Gui2Options; iconControl1.SelectionChanged += IconControl1SelectionChanged; chkScaleIcons.CheckedChanged += Gui2Options; // 字符 characterControl1.SelectionChanged += characterControl1_SelectionChanged; symbolControl1.SelectionChanged += SymbolControl1SelectionChanged; // hatch填充 icbHatchStyle.SelectedIndexChanged += Gui2Options; chkFillBgTransparent.CheckedChanged += Gui2Options; clpHatchBack.SelectedColorChanged += Gui2Options; // gradient填充 clpGradient2.SelectedColorChanged += Gui2Options; udGradientRotation.ValueChanged += Gui2Options; cboGradientType.SelectedIndexChanged += Gui2Options; DrawPreview(); tabControl1.SelectedIndex = _tabIndex; }
/// <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> /// Creates a new instance of PolygonsForm class /// </summary> public PolygonsForm(LegendControl.Legend legend, Layer layer, ShapeDrawingOptions options, bool applyDisabled) { InitializeComponent(); if (options == null || layer == null) { throw new Exception("PolygonsForm: unexpected null parameter"); } else { _options = options; m_layer = layer; } m_legend = legend; btnApply.Visible = !applyDisabled; _initState = options.Serialize(); _noEvents = true; groupPicture.Parent = tabPage2; groupPicture.Top = groupGradient.Top; groupPicture.Left = groupGradient.Left; groupHatch.Parent = tabPage2; groupHatch.Top = groupGradient.Top; groupHatch.Left = groupGradient.Left; cboFillType.Items.Clear(); cboFillType.Items.Add("Solid"); cboFillType.Items.Add("Hatch"); cboFillType.Items.Add("Gradient"); cboFillType.Items.Add("Texture"); cboGradientType.Items.Clear(); cboGradientType.Items.Add("Linear"); cboGradientType.Items.Add("Rectangular"); cboGradientType.Items.Add("Circle"); cboGradientBounds.Items.Clear(); cboGradientBounds.Items.Add("Whole layer"); cboGradientBounds.Items.Add("Per-shape"); cboVerticesType.Items.Clear(); cboVerticesType.Items.Add("Square"); cboVerticesType.Items.Add("Circle"); icbHatchStyle.ComboStyle = ImageComboStyle.HatchStyle; icbLineType.ComboStyle = ImageComboStyle.LineStyle; icbLineWidth.ComboStyle = ImageComboStyle.LineWidth; // loading icons string path = Globals.GetTexturesPath(); if (System.IO.Directory.Exists(path)) { iconControl1.FilePath = path; iconControl1.Textures = true; SymbologySettings settings = Globals.get_LayerSettings(layer.Handle); iconControl1.SelectedIndex = settings.IconIndex; } else { udScaleX.Enabled = false; udScaleY.Enabled = false; } _noEvents = false; cboFillType.SelectedIndexChanged += new EventHandler(cboFillType_SelectedIndexChanged); Options2GUI(); // ----------------------------------------------------- // adding event handlers // ----------------------------------------------------- // fill chkFillVisible.CheckedChanged += new EventHandler(GUI2Options); clpFill.SelectedColorChanged += new EventHandler(GUI2Options); // hatch icbHatchStyle.SelectedIndexChanged += new EventHandler(GUI2Options); chkFillBgTransparent.CheckedChanged += new EventHandler(GUI2Options); clpHatchBack.SelectedColorChanged += new EventHandler(GUI2Options); // gradient clpGradient2.SelectedColorChanged += new EventHandler(GUI2Options); udGradientRotation.ValueChanged += new EventHandler(GUI2Options); cboGradientType.SelectedIndexChanged += new EventHandler(GUI2Options); cboGradientBounds.SelectedIndexChanged += new EventHandler(GUI2Options); // outline chkOutlineVisible.CheckedChanged += new EventHandler(GUI2Options); icbLineType.SelectedIndexChanged += new EventHandler(GUI2Options); icbLineWidth.SelectedIndexChanged += new EventHandler(GUI2Options); clpOutline.SelectedColorChanged += new EventHandler(GUI2Options); // vertices chkVerticesVisible.CheckedChanged += new EventHandler(GUI2Options); cboVerticesType.SelectedIndexChanged += new EventHandler(GUI2Options); clpVerticesColor.SelectedColorChanged += new EventHandler(GUI2Options); chkVerticesFillVisible.CheckedChanged += new EventHandler(GUI2Options); udVerticesSize.ValueChanged += new EventHandler(GUI2Options); udScaleX.ValueChanged += new EventHandler(GUI2Options); udScaleY.ValueChanged += new EventHandler(GUI2Options); iconControl1.SelectionChanged += new ListControl.SelectionChangedDel(iconControl1_SelectionChanged); DrawPreview(); tabControl1.SelectedIndex = _tabPage; }
/// <summary> /// Creates a new instance of PolygonsForm class /// </summary> public LinesForm(LegendControl.Legend legend, Layer layer, ShapeDrawingOptions options, bool applyDisabled) { InitializeComponent(); if (options == null || layer == null) { throw new Exception("PolygonsForm: unexpected null parameter"); } else { _options = options; m_layer = layer; } m_legend = legend; btnApply.Visible = !applyDisabled; _initState = options.Serialize(); icbLineType.ComboStyle = ImageComboStyle.LineStyle; icbLineWidth.ComboStyle = ImageComboStyle.LineWidth; groupMarker.Parent = tabLine; groupMarker.Top = groupLine.Top; groupMarker.Left = groupLine.Left; cboVerticesType.Items.Clear(); cboVerticesType.Items.Add("Square"); cboVerticesType.Items.Add("Circle"); cboOrientation.Items.Clear(); cboOrientation.Items.Add("Horizontal"); cboOrientation.Items.Add("Parallel"); cboOrientation.Items.Add("Perpendicular"); cboLineType.Items.Clear(); cboLineType.Items.Add("Line"); cboLineType.Items.Add("Marker"); cboLineType.SelectedIndexChanged += new EventHandler(cboLineType_SelectedIndexChanged); cboLineType.SelectedIndex = 0; // vertices chkVerticesVisible.CheckedChanged += new EventHandler(GUI2Options); cboVerticesType.SelectedIndexChanged += new EventHandler(GUI2Options); clpVerticesColor.SelectedColorChanged += new EventHandler(GUI2Options); chkVerticesFillVisible.CheckedChanged += new EventHandler(GUI2Options); udVerticesSize.ValueChanged += new EventHandler(GUI2Options); InitLinePattern(); Options2Grid(); Options2GUI(); linePatternControl1.LoadFromXML(); _noEvents = true; tabControl1.SelectedIndex = _tabIndex; _noEvents = false; }