/// <summary> /// �Ļ�վ��Ϣ����ͼ��Դ�ļ� /// </summary> /// <param name="f"></param> /// <param name="pointCode"></param> /// <param name="iType"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="pointname"></param> private void ModifyPoint(Feature f, string pointCode, int iType, double x, double y, string pointname, bool IsBusy) { MapInfo.Geometry.Point g = new MapInfo.Geometry.Point(GetCoordSys(), x, y); SimpleVectorPointStyle vs = null; MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable(strTempMapPointTable); //vs = new SimpleVectorPointStyle(34, System.Drawing.Color.Red, 12); //��ȡ��վ��ʾЧ�� vs = GetSimpleVectorPointStyleByiType(iType); SimpleLineStyle ls = new SimpleLineStyle(new LineWidth(1, LineWidthUnit.Pixel), 1, System.Drawing.Color.Red); SimpleInterior si = new SimpleInterior(1, System.Drawing.Color.Red, System.Drawing.Color.Red); AreaStyle a = new AreaStyle(ls, si); CompositeStyle cs = new CompositeStyle(a, null, null, vs); cs = GetCompositeStyleByIsBusy(IsBusy, iType); //Columns cols = new Columns(); //cols.Add(MapInfo.Data.ColumnFactory.CreateStringColumn("Caption", 50)); //Feature f = new Feature(g, cs, cols); f["Obj"] = g; f["MI_Style"] = cs; f["ID"] = pointCode; f["Caption"] = pointname; table.UpdateFeature(f); MapInfo.Data.TableInfo tableInfo = table.TableInfo; tableInfo.WriteTabFile(); //����Ϊ.tab�ļ� }
private void InitializeCommands() { applyCommand = new ObservedCommand(() => { if (stylePropertyContent != null) { StyleLayerListItem styleListItem = stylePropertyContent.StyleItem; LayerListItem componentLayerListItem = StylePropertyUIPlugin.GetSpecificLayerListItem <CompositeStyle>(styleListItem); if (componentLayerListItem != null) { CompositeStyle oldStyle = (CompositeStyle)componentLayerListItem.ConcreteObject; List <Style> innerStyles = oldStyle.Styles.ToList(); oldStyle.Styles.Clear(); foreach (var innerStyle in componentLayerListItem.Children.OfType <StyleLayerListItem>() .Select(item => item.ConcreteObject).OfType <Style>().Reverse()) { oldStyle.Styles.Add(innerStyle); } if (featureLayer != null) { //GisEditor.ActiveMap.GetOverlaysContaining(featureLayer).ForEach(o => o.Refresh()); GisEditor.ActiveMap.GetOverlaysContaining(featureLayer).ForEach(o => o.RefreshWithBufferSettings()); LayerListUIPlugin layerListUIPlugin = GisEditor.UIManager.GetActiveUIPlugins <LayerListUIPlugin>().FirstOrDefault(); if (layerListUIPlugin != null) { layerListUIPlugin.Refresh(new RefreshArgs(this, "StyleProperties Applied.")); } } } } }, () => stylePropertyContent != null); }
protected override void OnGottenLayers(GottenLayersLayerPluginEventArgs e) { base.OnGottenLayers(e); foreach (var tobinBasFeatureLayer in e.Layers.OfType <TobinBasFeatureLayer>()) { CompositeStyle compositeStyle = new CompositeStyle(); compositeStyle.Name = tobinBasFeatureLayer.Name; AreaStyle areaStyle = AreaStyles.CreateSimpleAreaStyle(new GeoColor(0, GeoColor.SimpleColors.Black), new GeoColor(250, GeoColor.SimpleColors.Black), 1); areaStyle.Name = "Area Style"; LineStyle lineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.Black, 0.5f, false); lineStyle.Name = "Line Style"; PointStyle pointStyle = PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.SimpleColors.Green, 3); pointStyle.Name = "Point Style"; compositeStyle.Styles.Add(areaStyle); compositeStyle.Styles.Add(lineStyle); compositeStyle.Styles.Add(pointStyle); foreach (var zoomLevel in tobinBasFeatureLayer.ZoomLevelSet.CustomZoomLevels) { zoomLevel.CustomStyles.Clear(); zoomLevel.CustomStyles.Add(compositeStyle); } } BuildIndexAdapter adapter = new TobinBasBuildIndexAdapter(this); adapter.BuildIndex(e.Layers.OfType <FeatureLayer>()); }
public static void AddStyle() { if (GisEditor.LayerListManager.SelectedLayerListItem == null) { return; } var featureLayer = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as FeatureLayer; if (featureLayer == null) { featureLayer = GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject as FeatureLayer; } if (featureLayer != null) { var styleArguments = new StyleBuilderArguments(); var featureLayerPlugin = GisEditor.LayerManager.GetLayerPlugins(featureLayer.GetType()).FirstOrDefault() as FeatureLayerPlugin; switch (featureLayerPlugin.GetFeatureSimpleShapeType(featureLayer)) { case SimpleShapeType.Point: styleArguments.AvailableStyleCategories = StyleCategories.Point | StyleCategories.Label | StyleCategories.Composite; break; case SimpleShapeType.Line: styleArguments.AvailableStyleCategories = StyleCategories.Line | StyleCategories.Label | StyleCategories.Composite; break; case SimpleShapeType.Area: styleArguments.AvailableStyleCategories = StyleCategories.Area | StyleCategories.Label | StyleCategories.Composite; break; } var componentStyle = new CompositeStyle(); styleArguments.StyleToEdit = componentStyle; styleArguments.FeatureLayer = featureLayer; styleArguments.FromZoomLevelIndex = 1; styleArguments.ToZoomLevelIndex = GisEditor.ActiveMap.ZoomLevelSet.GetZoomLevels().Where(z => z.GetType() == typeof(ZoomLevel)).Count(); styleArguments.AppliedCallback = new Action <StyleBuilderResult>((styleResult) => { if (!styleResult.Canceled) { foreach (var zoomLevel in featureLayer.ZoomLevelSet.CustomZoomLevels) { zoomLevel.CustomStyles.Remove(componentStyle); } for (int i = styleResult.FromZoomLevelIndex - 1; i < styleResult.ToZoomLevelIndex; i++) { featureLayer.ZoomLevelSet.CustomZoomLevels[i].CustomStyles.Add(styleResult.CompositeStyle); } LayerListHelper.InvalidateTileOverlay(); GisEditor.UIManager.InvokeRefreshPlugins(new RefreshArgs(featureLayer, RefreshArgsDescriptions.AddStyleCommandDescription)); componentStyle = styleResult.CompositeStyle as CompositeStyle; } }); styleArguments.FillRequiredColumnNames(); var styleResults = GisEditor.StyleManager.EditStyle(styleArguments); styleArguments.AppliedCallback(styleResults); } }
/// <summary> /// Handles the Loaded event of the StyleBuilderWindow control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> private void StyleBuilderWindow_Loaded(object sender, RoutedEventArgs e) { var styleToEdit = styleBuilderArguments.StyleToEdit; if (styleToEdit == null) { styleToEdit = new CompositeStyle(); } styleBuilderResult = new StyleBuilderResult(); styleBuilderViewModel = new StyleBuilderViewModel(styleToEdit, styleBuilderArguments); DataContext = styleBuilderViewModel; FromZoomLevelIndex = styleBuilderArguments.FromZoomLevelIndex; ToZoomLevelIndex = styleBuilderArguments.ToZoomLevelIndex; if (styleBuilderViewModel.RootStyleItem != null && styleBuilderViewModel.RootStyleItem.StyleItemViewModels.Count == 0) { if (Validate()) { styleBuilderViewModel.IsRootNodeSelected = true; RootNodePanel.Background = new SolidColorBrush(Color.FromRgb(173, 216, 230)); } } }
public SelectionAndQueryingRibbonGroupViewModel() { spatialQueryModeEntities = InitSpatialQueryModeEntities(); layers = new ObservableCollection <CheckableItemViewModel <FeatureLayer> >(); AreaStyle selectionAreaStyle = new AreaStyle(new GeoPen(GeoColor.StandardColors.Yellow, 3)); selectionAreaStyle.Name = "Selected Area Style"; LineStyle selectionLineStyle = new LineStyle(new GeoPen(GeoColor.StandardColors.Yellow, 5)); selectionLineStyle.Name = "Selected Line Style"; PointStyle selectionPointStyle = new PointStyle(); selectionPointStyle.Name = "Selected Point Style"; selectionPointStyle.SymbolPen = new GeoPen(GeoColor.StandardColors.Yellow, 3); IconTextStyle selectionTextStyle = new IconTextStyle(); selectionTextStyle.TextColumnName = SelectionUIPlugin.FeatureIdColumnName; selectionTextStyle.TextSolidBrush = new GeoSolidBrush(GeoColor.StandardColors.Yellow); selectionTextStyle.Font = new GeoFont("Arial", 7, DrawingFontStyles.Regular); selectionTextStyle.CustomTextStyles.Add(new TextStyle(SelectionUIPlugin.FeatureIdColumnName, new GeoFont("Arial", 7, DrawingFontStyles.Regular), new GeoSolidBrush(GeoColor.StandardColors.Yellow))); selectionTextStyle.Name = "Selected Text Style"; selectionCompositeStyle = new CompositeStyle(); selectionCompositeStyle.Styles.Add(selectionAreaStyle); selectionCompositeStyle.Styles.Add(selectionLineStyle); selectionCompositeStyle.Styles.Add(selectionPointStyle); selectionCompositeStyle.Styles.Add(selectionTextStyle); UpdateStylePreview(); }
public static CompositeStyle GetCurrentDrawingStyle(ZoomLevel zoomLevel) { var allNonComponentStyle = zoomLevel.CustomStyles.SelectMany(tmpStyle => { var componentStyle = tmpStyle as CompositeStyle; if (componentStyle != null) { return(componentStyle.Styles); } else { return new ObservableCollection <Style>() { tmpStyle } }; }); var currentDrawingStyle = allNonComponentStyle.Where(tmpStyle => !(tmpStyle is IconTextStyle || tmpStyle is TextFilterStyle)).LastOrDefault(); var currentDrawingTextStyle = allNonComponentStyle.Where(tmpStyle => tmpStyle is IconTextStyle || tmpStyle is TextFilterStyle).LastOrDefault(); var resultComponentStyle = new CompositeStyle(); if (currentDrawingStyle != null) { resultComponentStyle.Styles.Add(currentDrawingStyle); } if (currentDrawingTextStyle != null) { resultComponentStyle.Styles.Add(currentDrawingTextStyle); } return(resultComponentStyle); }
///// <summary> ///// starts from 1. ///// </summary> //private int FromZoomLevelIndex //{ // get { return styleBuilderViewModel.FromZoomLevelIndex; } // set { styleBuilderViewModel.FromZoomLevelIndex = value; } //} ///// <summary> ///// starts from 1. ///// </summary> //private int ToZoomLevelIndex //{ // get { return styleBuilderViewModel.ToZoomLevelIndex; } // set { styleBuilderViewModel.ToZoomLevelIndex = value; } //} /// <summary> /// Handles the Loaded event of the StyleBuilderWindow control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> private void StyleBuilderWindow_Loaded(object sender, RoutedEventArgs e) { multiStyleBuilderViewModel = new MultiStyleBuilderViewModel(); foreach (var item in styleBuilderArguments) { CompositeStyle tempStyle = item.StyleToEdit; if (tempStyle == null) { tempStyle = new CompositeStyle(); } StyleBuilderViewModel currentViewModel = new StyleBuilderViewModel(tempStyle, item); currentViewModel.FromZoomLevelIndex = item.FromZoomLevelIndex; currentViewModel.ToZoomLevelIndex = item.ToZoomLevelIndex; multiStyleBuilderViewModel.StyleBuilderViewModels.Add(currentViewModel); } multiStyleBuilderViewModel.SelectedStyleBuilderViewModel = multiStyleBuilderViewModel.StyleBuilderViewModels.FirstOrDefault(); DataContext = multiStyleBuilderViewModel; if (multiStyleBuilderViewModel.SelectedStyleBuilderViewModel != null && multiStyleBuilderViewModel.SelectedStyleBuilderViewModel.RootStyleItem != null && multiStyleBuilderViewModel.SelectedStyleBuilderViewModel.RootStyleItem.StyleItemViewModels.Count == 0) { if (Validate()) { multiStyleBuilderViewModel.SelectedStyleBuilderViewModel.IsRootNodeSelected = true; //RootNodePanel.Background = new SolidColorBrush(Color.FromRgb(173, 216, 230)); multiStyleBuilderViewModel.SelectedStyleBuilderViewModel.RootNodeBackground = defaultRootNodeBackground; } } }
/// <summary> /// Saves the style to library core. /// </summary> /// <param name="compositeStyle">The composite style.</param> /// <param name="lowerScale">The lower scale.</param> /// <param name="upperScale">The upper scale.</param> protected virtual void SaveStyleToLibraryCore(CompositeStyle compositeStyle, double lowerScale, double upperScale) { string savePath = StyleLibraryViewModel.StyleLibraryFolder; SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = savePath; saveFileDialog.FileName = compositeStyle.Name + fileFormat; saveFileDialog.Filter = "ThinkGeo style files (*.tgsty)|*.tgsty"; if (saveFileDialog.ShowDialog().GetValueOrDefault()) { var folder = Path.GetDirectoryName(saveFileDialog.FileName); if (!folder.StartsWith(StyleLibraryViewModel.BaseFolder, StringComparison.InvariantCultureIgnoreCase) && !GisEditor.StyleManager.Folders.Contains(folder)) { GisEditor.StyleManager.Folders.Add(folder); } var styleXml = GisEditor.Serializer.Serialize(compositeStyle); var rootXml = new XElement("Style" , new XElement("LowerScale", lowerScale) , new XElement("UpperScale", upperScale) , XElement.Parse(styleXml)); rootXml.Save(saveFileDialog.FileName); } }
public static CompositeStyle GetInitialCompositeStyle() { AreaStyle measurementAreaStyle = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Black, 2), new GeoSolidBrush(GeoColor.StandardColors.Transparent)); measurementAreaStyle.Name = "Measurement Area Style"; LineStyle measurementLineStyle = new LineStyle(new GeoPen(GeoColor.SimpleColors.Black, 2), new GeoPen(GeoColor.StandardColors.Transparent)); measurementLineStyle.Name = "Measurement Line Style"; IconTextStyle measurementPointStyle = new IconTextStyle(); measurementPointStyle.Name = "Measurement Text Style"; measurementPointStyle.TextColumnName = measureResultColumnName; measurementPointStyle.Font = new GeoFont("Arial", 12); measurementPointStyle.TextSolidBrush = new GeoSolidBrush(GeoColor.SimpleColors.Black); measurementPointStyle.HaloPen = new GeoPen(GeoColor.StandardColors.White, 3); measurementPointStyle.BestPlacement = false; measurementPointStyle.DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels; measurementPointStyle.OverlappingRule = LabelOverlappingRule.AllowOverlapping; measurementPointStyle.PolygonLabelingLocationMode = PolygonLabelingLocationMode.BoundingBoxCenter; measurementPointStyle.ForceLineCarriage = true; measurementPointStyle.SuppressPartialLabels = false; measurementPointStyle.SplineType = SplineType.StandardSplining; measurementPointStyle.TextLineSegmentRatio = 10000; measurementPointStyle.AllowLineCarriage = true; measurementPointStyle.IsHaloEnabled = true; CompositeStyle measurementStyle = new CompositeStyle(); measurementStyle.Styles.Add(measurementAreaStyle); measurementStyle.Styles.Add(measurementLineStyle); measurementStyle.Styles.Add(measurementPointStyle); return(measurementStyle); }
private static void AddStyle(StylePlugin styleProvider) { Style style = null; StyleBuilderArguments arguments = new StyleBuilderArguments(); FeatureLayer currentFeatureLayer = null; if (GisEditor.LayerListManager.SelectedLayerListItem == null) { return; } //add a new style by right-clicking on a layer node if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is FeatureLayer) { currentFeatureLayer = (FeatureLayer)GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject; } //add a new style by right-clicking on a zoomlevel node else if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is ZoomLevel) { ZoomLevel editingZoomLevel = (ZoomLevel)GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject; arguments.FromZoomLevelIndex = GisEditor.ActiveMap.GetSnappedZoomLevelIndex(editingZoomLevel.Scale) + 1; arguments.ToZoomLevelIndex = (int)editingZoomLevel.ApplyUntilZoomLevel; currentFeatureLayer = (FeatureLayer)GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject; } //replace an existing style else if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is Style) { Style currentStyle = (Style)GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject; currentFeatureLayer = LayerListHelper.FindMapElementInLayerList <FeatureLayer>(GisEditor.LayerListManager.SelectedLayerListItem); } arguments.AvailableStyleCategories = StylePluginHelper.GetStyleCategoriesByFeatureLayer(currentFeatureLayer); arguments.FeatureLayer = currentFeatureLayer; arguments.FillRequiredColumnNames(); arguments.AppliedCallback = args => { if (args.CompositeStyle != null) { ZoomLevelHelper.ApplyStyle(args.CompositeStyle, currentFeatureLayer, args.FromZoomLevelIndex, args.ToZoomLevelIndex); } }; style = styleProvider.GetDefaultStyle(); style.Name = styleProvider.Name; var componentStyle = new CompositeStyle(style) { Name = currentFeatureLayer.Name }; arguments.StyleToEdit = componentStyle; var styleResults = GisEditor.StyleManager.EditStyle(arguments); if (!styleResults.Canceled) { ZoomLevelHelper.ApplyStyle(styleResults.CompositeStyle, currentFeatureLayer, styleResults.FromZoomLevelIndex, styleResults.ToZoomLevelIndex); } }
public static StyleBuilderResult EditCompondStyle <T>(T style, StyleBuilderArguments styleArguments) where T : Style { CompositeStyle compositeStyle = new CompositeStyle(); compositeStyle.Styles.Add(style); styleArguments.StyleToEdit = compositeStyle; return(GisEditor.StyleManager.EditStyle(styleArguments)); }
public StylePreviewViewModel(CompositeStyle style) { if (style != null) { styleWrapper = new StyleWrapper(0, 1000000000, style); preview = style.GetPreview(32, 32); name = style.Name; } }
/// <summary> /// Initializes a new instance of the <see cref="StyleBuilderResult" /> class. /// </summary> /// <param name="compositeStyle">The composite style.</param> /// <param name="canceled">if set to <c>true</c> [canceled].</param> /// <param name="fromZoomLevelIndex">Index of from zoom level.</param> /// <param name="toZoomLevelIndex">Index of to zoom level.</param> public StyleBuilderResult(CompositeStyle compositeStyle, bool canceled, int fromZoomLevelIndex, int toZoomLevelIndex) { Canceled = canceled; CompositeStyle = compositeStyle; ToZoomLevelIndex = toZoomLevelIndex; FromZoomLevelIndex = fromZoomLevelIndex; //LowerScale = 0; //UpperScale = 10000000; }
protected override void UpdateConcreteObjectCore() { base.UpdateConcreteObjectCore(); CompositeStyle componentStyle = (CompositeStyle)ConcreteObject; componentStyle.Styles.Clear(); foreach (var style in Children.Select(i => i.ConcreteObject).OfType <Style>().Reverse()) { componentStyle.Styles.Add(style); } }
public ComponentStyleItem(CompositeStyle componentStyle) : base(componentStyle) { CanRename = true; CanAddInnerStyle = true; foreach (var innerStyle in componentStyle.Styles.Reverse()) { var innerStyleItem = GisEditor.StyleManager.GetStyleLayerListItem(innerStyle); Children.Add(innerStyleItem); } }
private static void SetDrawingLevelForStyle(Style style) { AreaStyle areaStyle = style as AreaStyle; LineStyle lineStyle = style as LineStyle; PointStyle pointStyle = style as PointStyle; CompositeStyle compositeStyle = style as CompositeStyle; FilterStyle filterStyle = style as FilterStyle; ValueStyle valueStyle = style as ValueStyle; ClassBreakStyle classBreakStyle = style as ClassBreakStyle; if (areaStyle != null) { areaStyle.SetDrawingLevel(); } else if (lineStyle != null) { lineStyle.SetDrawingLevel(); } else if (pointStyle != null) { pointStyle.SetDrawingLevel(); } else if (filterStyle != null) { foreach (var item in filterStyle.Styles) { SetDrawingLevelForStyle(item); } } else if (classBreakStyle != null) { foreach (var item in classBreakStyle.ClassBreaks.SelectMany(v => v.CustomStyles)) { SetDrawingLevelForStyle(item); } } else if (valueStyle != null) { foreach (var item in valueStyle.ValueItems.SelectMany(v => v.CustomStyles)) { SetDrawingLevelForStyle(item); } } else if (compositeStyle != null) { foreach (var subStyle in compositeStyle.Styles) { SetDrawingLevelForStyle(subStyle); } } }
public StyleBuilderViewModel(CompositeStyle editingStyle, StyleBuilderArguments styleArguments) { this.componentStyle = editingStyle; this.styleArguments = styleArguments; this.fromZoomLevelModels = new Collection <ZoomLevelModel>(); this.InitializeZoomLevels(fromZoomLevelModels); this.toZoomLevelModels = new Collection <ZoomLevelModel>(); this.InitializeZoomLevels(toZoomLevelModels); this.InitializeStyleItems(styleArguments.SelectedConcreteObject); this.InitializeUIItems(styleArguments.AvailableUIElements); this.InitializeCommands(); this.mainContextMenu = RootStyleItem.ContextMenu; }
private static T EditStyles <T>(StylePluginManager styleManager, StyleBuilderArguments styleArguments, T editingStyle, Func <T, Collection <T> > fetchInnerStyles) where T : Style, new() { CompositeStyle compositeStyle = new CompositeStyle(); compositeStyle.Name = editingStyle.Name; if (fetchInnerStyles(editingStyle).Count > 0) { foreach (var style in fetchInnerStyles(editingStyle)) { compositeStyle.Styles.Add(style); } } else { compositeStyle.Styles.Add(editingStyle); } styleArguments.StyleToEdit = compositeStyle; var result = styleManager.EditStyle(styleArguments); if (result.Canceled) { return(null); } else { T resultAreaStyle = new T(); resultAreaStyle.Name = compositeStyle.Name; PointStyle pointStyle = resultAreaStyle as PointStyle; if (pointStyle != null) { foreach (var tmpAreaStyle in compositeStyle.Styles.OfType <PointStyle>()) { pointStyle.CustomPointStyles.Add(tmpAreaStyle); } } else { foreach (var tmpAreaStyle in compositeStyle.Styles.OfType <T>()) { fetchInnerStyles(resultAreaStyle).Add(tmpAreaStyle); } } return(resultAreaStyle); } }
void Map_ViewChangedEvent(object sender, MapInfo.Mapping.ViewChangedEventArgs e) { // Display the zoom level Double dblZoom = System.Convert.ToDouble(String.Format("{0:E2}", mapControl1.Map.Zoom.Value)); if (statusStrip1.Items.Count > 0) { statusStrip1.Items[0].Text = "缩放: " + dblZoom.ToString() + " " + MapInfo.Geometry.CoordSys.DistanceUnitAbbreviation(mapControl1.Map.Zoom.Unit); } if (Session.Current.Catalog.GetTable("EagleEyeTemp") == null) { loadEagleLayer(); } Table tblTemp = Session.Current.Catalog.GetTable("EagleEyeTemp"); try { (tblTemp as ITableFeatureCollection).Clear(); } catch (Exception) { } try { // 主地图发生改变是对鹰眼地图进行相应的画框操作 if (mapControl2.Map.Layers["MyEagleEye"] != null) { mapControl2.Map.Layers.Remove(eagleEye); } DRect rect = mapControl1.Map.Bounds; FeatureGeometry fg = new MapInfo.Geometry.Rectangle(mapControl1.Map.GetDisplayCoordSys(), rect); SimpleLineStyle vLine = new SimpleLineStyle(new LineWidth(2, LineWidthUnit.Point), 2, Color.Red); SimpleInterior vInter = new SimpleInterior(9, Color.Yellow, Color.Yellow, true); CompositeStyle cStyle = new CompositeStyle(new AreaStyle(vLine, vInter), null, null, null); fRec = new Feature(fg, cStyle); tblTemp.InsertFeature(fRec); eagleEye = new FeatureLayer(tblTemp, "EagleEye ", "MyEagleEye"); mapControl2.Map.Layers.Insert(0, eagleEye); } catch (Exception) { } }
protected override Collection <Layer> GetLayersCore(GetLayersParameters getLayersParameters) { NoaaWeatherStationFeatureLayer noaaWeatherStationFeatureLayer = new NoaaWeatherStationFeatureLayer(); GisEditor.LayerManager.FeatureIdColumnNames[noaaWeatherStationFeatureLayer.FeatureSource.Id] = "StationId"; CompositeStyle compositeStyle = new CompositeStyle(new NoaaWeatherStationStyle()); foreach (ZoomLevel zoomLevel in GisEditor.ActiveMap.ZoomLevelSet.GetZoomLevels()) { ZoomLevel newZoomLevel = new ZoomLevel(zoomLevel.Scale); newZoomLevel.CustomStyles.Add(compositeStyle); noaaWeatherStationFeatureLayer.ZoomLevelSet.CustomZoomLevels.Add(newZoomLevel); } return(new Collection <Layer> { noaaWeatherStationFeatureLayer }); }
public EditorSetting() { IsAttributePrompted = true; AreaStyle editAreaStyle = new AreaStyle(new GeoPen(GeoColor.StandardColors.Pink, 3)); editAreaStyle.Name = "Edit Area Style"; LineStyle editLineStyle = new LineStyle(new GeoPen(GeoColor.FromArgb(255, 0, 0, 255), 3)); editLineStyle.Name = "Edit Line Style"; PointStyle editPointStyle = new PointStyle(); editPointStyle.Name = "Edit Point Style"; editPointStyle.SymbolPen = new GeoPen(GeoColor.FromArgb(255, 0, 0, 255), 5); editCompositeStyle = new CompositeStyle(); editCompositeStyle.Styles.Add(editAreaStyle); editCompositeStyle.Styles.Add(editLineStyle); editCompositeStyle.Styles.Add(editPointStyle); }
private void SetUpRasterLayer() { FeatureLayer myRasterLayer = _map.Layers["florida"] as FeatureLayer; _rasterTable = myRasterLayer.Table; RasterStyle rs = new RasterStyle(); rs.Contrast = 33; rs.Grayscale = true; // this composite style will affect the raster as intended CompositeStyle csRaster = new CompositeStyle(rs); FeatureOverrideStyleModifier fosm = new FeatureOverrideStyleModifier("Style Mod", csRaster); FeatureStyleModifiers modifiers = myRasterLayer.Modifiers; modifiers.Append(fosm); }
public static System.Windows.Controls.Image GetImageFromStyle(IEnumerable <Style> styles) { if (styles.Count() > 1) { CompositeStyle componentStyle = new CompositeStyle(styles) { Name = GisEditor.LanguageManager.GetStringResource("SampleStyleName") }; BitmapImage imageSource = componentStyle.GetPreviewImage(34, 34); System.Windows.Controls.Image image = new System.Windows.Controls.Image(); image.Source = imageSource; return(image); } else if (styles.Count() == 0) { return(new System.Windows.Controls.Image()); } else { return(GetImageFromStyle(styles.FirstOrDefault())); } }
private void StyleButton_Click(object sender, System.EventArgs e) { if (_mStyle == null) { MessageBox.Show("Please click GridInfo before clicking Style."); return; } GridStyle aStyle = _mStyle.Clone() as GridStyle; GridStyleForm f = new GridStyleForm(); f.AlphaTextBox.Text = aStyle.Alpha.ToString(); f.BrightnessBox.Text = aStyle.Brightness.ToString(); f.ContrastBox.Text = aStyle.Contrast.ToString(); f.GrayScale.CheckState = (aStyle.Grayscale) ? CheckState.Checked : CheckState.Unchecked; f.Transparency.CheckState = (aStyle.Transparent) ? CheckState.Checked : CheckState.Unchecked; f.DisplayHillshade.CheckState = (aStyle.DisplayHillshade) ? CheckState.Checked : CheckState.Unchecked; f.TransparentColor.BackColor = aStyle.TransparentColor; if (f.ShowDialog() == DialogResult.OK) { aStyle.Alpha = int.Parse(f.AlphaTextBox.Text); aStyle.Brightness = int.Parse(f.BrightnessBox.Text); aStyle.Contrast = int.Parse(f.ContrastBox.Text); aStyle.Grayscale = f.GrayScale.CheckState == CheckState.Checked ? true : false; aStyle.Transparent = (f.Transparency.CheckState == CheckState.Checked) ? true : false; aStyle.DisplayHillshade = (f.DisplayHillshade.CheckState == CheckState.Checked) ? true : false; aStyle.TransparentColor = f.TransparentColor.BackColor; // this composite style will affect the raster as intended CompositeStyle csRaster = new CompositeStyle(aStyle); FeatureOverrideStyleModifier fosm = new FeatureOverrideStyleModifier("Style Mod", csRaster); FeatureStyleModifiers modifiers = _lyr.Modifiers; modifiers.Clear(); modifiers.Append(fosm); } }
public void Parse(XElement styleXElement) { this.lowerScale = 0; this.upperScale = 1000000000; XElement upperScaleXElement = styleXElement.Element("UpperScale"); if (upperScaleXElement != null) { double.TryParse(upperScaleXElement.Value, out upperScale); } XElement lowerScaleXElement = styleXElement.Element("LowerScale"); if (lowerScaleXElement != null) { double.TryParse(lowerScaleXElement.Value, out lowerScale); } XElement compositeStyleXElement = styleXElement.Element("CompositeStyle"); if (compositeStyleXElement != null) { object styleObject = GisEditor.Serializer.Deserialize(compositeStyleXElement.ToString()); if (styleObject is CompositeStyle) { this.style = (CompositeStyle)styleObject; } else if (styleObject is Style) { Style currentStyle = (Style)styleObject; CompositeStyle compositeStyle = new CompositeStyle(); compositeStyle.Name = currentStyle.Name; compositeStyle.Styles.Add(currentStyle); this.style = compositeStyle; } } }
private void InitializeStyleIcons() { var styles = CurrentAnnotationOverlay.TrackShapeLayer.ZoomLevelSet .ZoomLevel01.CustomStyles.OfType <ValueStyle>().First() .ValueItems.Take(1).SelectMany(valueItem => { return(new Styles.Style[] { valueItem.DefaultAreaStyle, valueItem.DefaultLineStyle, valueItem.DefaultPointStyle, valueItem.DefaultTextStyle }); }); CompositeStyle style = new CompositeStyle(); foreach (var item in styles) { style.Styles.Add(item); } AnnotationPreview = style.GetPreviewImage(32, 32); }
public static bool AddMarker(Map oMap, string strLayer, string strUID, string strText, DPoint dPoint, string strBmpName, double dbSize, System.Drawing.Color color) { if (oMap == null) { return(false); } FeatureLayer layer = (FeatureLayer)oMap.Layers[strLayer]; if (layer == null) { return(false); } FeatureGeometry fg = new Point(oMap.GetDisplayCoordSys(), dPoint); CompositeStyle cs = new CompositeStyle(new BitmapPointStyle(strBmpName, BitmapStyles.None, color, dbSize)); Feature feature = new Feature(layer.Table.TableInfo.Columns); feature.Geometry = fg; feature.Style = cs; feature["uid"] = strUID; feature["name"] = strText; //feature.Geometry.GetGeometryEditor().Rotate(dPoint, 90); //feature.Geometry.EditingComplete (); layer.Table.InsertFeature(feature); return(true); }
private void InitializeCommands() { #region load from lib loadFromLibraryCommand = new RelayCommand(() => { StyleLibraryWindow libraryWindow = new StyleLibraryWindow(); if (libraryWindow.ShowDialog().Value) { var componentStyle = libraryWindow.Result.CompositeStyle; if (componentStyle != null) { FromZoomLevelIndex = libraryWindow.Result.FromZoomLevelIndex; ToZoomLevelIndex = libraryWindow.Result.ToZoomLevelIndex; RootStyleItem.StyleItem.Children.Clear(); componentStyle.Styles.Reverse().ForEach(s => LoadStyle(s)); RootStyleItem.StyleItem.Name = componentStyle.Name; RootStyleItem.StyleItem.UpdateConcreteObject(); UpdatePreviewSource(); SelectedStyleItem = RootStyleItem.StyleItemViewModels.FirstOrDefault(); if (SelectedStyleItem != null) { SelectedStyleItem.IsSelected = true; } } } }, () => !styleArguments.IsSubStyleReadonly); #endregion load from lib #region save to lib saveToLibraryCommand = new RelayCommand(() => { var innerStyles = StyleItems.Select(s => s.StyleItem.ConcreteObject).Reverse().OfType <Styles.Style>(); CompositeStyle componentStyle = new CompositeStyle(innerStyles) { Name = Name }; GisEditor.StyleManager.SaveStyleToLibrary(componentStyle, SelectedToZoomLevelModel.Scale, SelectedFromZoomLevelModel.Scale); }); #endregion save to lib #region clear styles clearStylesCommand = new RelayCommand(() => { System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show(GisEditor.LanguageManager.GetStringResource("StyleBuilderViewModelEraseAllStylesText") , GisEditor.LanguageManager.GetStringResource("StyleBuilderViewModelClearStylesCaption") , System.Windows.Forms.MessageBoxButtons.YesNo , System.Windows.Forms.MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.Yes) { RootStyleItem.StyleItem.Children.Clear(); RootStyleItem.StyleItem.UpdateConcreteObject(); UpdatePreviewSource(); SelectRootNodeIfEmpty(); } }, () => !styleArguments.IsSubStyleReadonly); #endregion clear styles #region duplicate style duplicateCommand = new RelayCommand(() => { StyleLayerListItem duplicateStyleItem = SelectedStyleItem.StyleItem.CloneDeep(); if (duplicateStyleItem != null) { var parent = SelectedStyleItem.StyleItem.Parent as StyleLayerListItem; if (parent != null) { parent.Children.Insert(0, duplicateStyleItem); parent.UpdateConcreteObject(); if (StyleItems.Count > 0) { StyleItems.FirstOrDefault().IsSelected = true; } UpdatePreviewSource(); } } }, () => !styleArguments.IsSubStyleReadonly && SelectedStyleItem != null && SelectedStyleItem.StyleItem.Parent != null); #endregion duplicate style #region delete style deleteStyleCommand = new RelayCommand(() => { var parentItem = SelectedStyleItem.StyleItem.Parent as StyleLayerListItem; if (parentItem != null && parentItem.Children.Contains(SelectedStyleItem.StyleItem)) { parentItem.Children.Remove(SelectedStyleItem.StyleItem); parentItem.UpdateConcreteObject(); UpdatePreviewSource(); SelectRootNodeIfEmpty(); } }, () => !styleArguments.IsSubStyleReadonly && SelectedStyleItem != null && SelectedStyleItem.StyleItem.Parent != null && SelectedStyleItem.StyleItem.ConcreteObject is Styles.Style); #endregion delete style #region rename renameCommand = new RelayCommand(() => { if (IsRootNodeSelected) { RootStyleItem.IsRenaming = true; } else { SelectedStyleItem.IsRenaming = true; } }, () => !styleArguments.IsSubStyleReadonly && (IsRootNodeSelected || (SelectedStyleItem != null && SelectedStyleItem.StyleItem.CanRename))); #endregion rename }
protected virtual ObservableCollection <MenuItem> GetLayerListContextMenuItemsCore(LayerListItem layerListItem) { ObservableCollection <MenuItem> menuItems = new ObservableCollection <MenuItem>(); var args = new GetLayerListItemContextMenuParameters(layerListItem); foreach (var item in layerListItem.ContextMenuItems) { menuItems.Add(item); } if (layerListItem.ConcreteObject is Layer) { var layerPlugin = GisEditor.LayerManager.GetLayerPlugins(layerListItem.ConcreteObject.GetType()).FirstOrDefault(); if (layerPlugin != null) { foreach (var item in layerPlugin.GetLayerListItemContextMenuItems(args)) { menuItems.Add(item); } } } else if (layerListItem.ConcreteObject is Styles.Style) { var stylePlugin = GisEditor.StyleManager.GetStylePluginByStyle((Styles.Style)layerListItem.ConcreteObject); if (stylePlugin != null) { foreach (var item in stylePlugin.GetLayerListItemContextMenuItems(args)) { menuItems.Add(item); } } Styles.Style style = (Styles.Style)layerListItem.ConcreteObject; if (style is CompositeStyle) { CompositeStyle compositeStyle = (CompositeStyle)style; if (compositeStyle.Styles.Count == 1 && !(compositeStyle.Styles[0] is FilterStyle) && compositeStyle.Styles[0].Filters != null && compositeStyle.Styles[0].Filters.Count > 0) { MenuItem menuItem = GetFilteredDataMenuItem(layerListItem); menuItems.Add(menuItem); MenuItem exportMenuItem = GetExportFilterMenuItem(layerListItem); menuItems.Add(exportMenuItem); MenuItem zoomtoMenuItem = GetZoomToFilteredDataMenuItem(layerListItem); menuItems.Add(zoomtoMenuItem); } } else if (!(style is FilterStyle) && style.Filters != null && style.Filters.Count > 0) { MenuItem menuItem = GetFilteredDataMenuItem(layerListItem); menuItems.Add(menuItem); MenuItem zoomtoMenuItem = GetZoomToFilteredDataMenuItem(layerListItem); menuItems.Add(zoomtoMenuItem); } } foreach (var uiPlugin in GisEditor.UIManager.GetActiveUIPlugins()) { var tmpItems = uiPlugin.GetLayerListItemContextMenuItems(args); if (tmpItems != null && tmpItems.Count > 0) { menuItems.Add(new MenuItem { Header = "--" }); foreach (var tmItem in tmpItems) { menuItems.Add(tmItem); } } } return(menuItems); }
public MapForm1() { // // Required for Windows Form Designer support // InitializeComponent(); // Set table search path to value sampledatasearch registry key string s = Environment.CurrentDirectory; Microsoft.Win32.RegistryKey keySamp = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\MapInfo\MapXtreme\6.6"); if ((keySamp != null) && (keySamp.GetValue("SampleDataSearchPath") != null)) { s = (string)keySamp.GetValue("SampleDataSearchPath"); if (s.EndsWith("\\") == false) { s += "\\"; } keySamp.Close(); } Session.Current.TableSearchPath.Path = s; // Add the USA table to the map mapControl1.Map.Load(new MapTableLoader("usa.tab")); // Listen to some map events mapControl1.Map.ViewChangedEvent += new ViewChangedEventHandler(Map_ViewChanged); mapControl1.Resize += new EventHandler(mapControl1_Resize); // Create a ranged theme on the USA layer. Map map = mapControl1.Map; FeatureLayer lyr = map.Layers["usa"] as MapInfo.Mapping.FeatureLayer; RangedTheme thm = new MapInfo.Mapping.Thematics.RangedTheme( lyr, "Round(MI_Area(Obj, 'sq mi', 'Spherical'), 1)", "Area (square miles)", 5, MapInfo.Mapping.Thematics.DistributionMethod.EqualCountPerRange); lyr.Modifiers.Append(thm); // Change the default fill colors from Red->Gray to White->Blue AreaStyle ars; // Get the style from our first bin CompositeStyle cs = thm.Bins[0].Style; // Get the region -- Area -- style ars = cs.AreaStyle; // Change the fill color ars.Interior = StockStyles.WhiteFillStyle(); // Update the CompositeStyle with the new region color cs.AreaStyle = ars; // Update the bin with the new CompositeStyle settings thm.Bins[0].Style = cs; // Change the style settings on the last bin int nLastBin = thm.Bins.Count - 1; cs = thm.Bins[nLastBin].Style; ars = cs.AreaStyle; ars.Interior = StockStyles.BlueFillStyle(); thm.Bins[nLastBin].Style = cs; // Tell the theme how to fill in the other bins thm.SpreadBy = SpreadByPart.Color; thm.ColorSpreadBy = ColorSpreadMethod.Rgb; thm.RecomputeStyles(); // Create a legend legend = map.Legends.CreateLegend(new Size(5, 5)); legend.Border = true; ThemeLegendFrame frame = LegendFrameFactory.CreateThemeLegendFrame("Area", "Area", thm); legend.Frames.Append(frame); frame.Title = "Area (sq. mi.)"; map.Adornments.Append(legend); // Set the initial legend location to be the lower right corner of the map control. System.Drawing.Point pt = new System.Drawing.Point(0, 0); pt.X = mapControl1.Size.Width - legend.Size.Width; pt.Y = mapControl1.Size.Height - legend.Size.Height; legend.Location = pt; }
/// <summary> /// �Ƿ�ӵ�� /// </summary> /// <param name="IsBusy">True Ϊӵ�£�False Ϊ��ӵ��</param> /// <param name="iType">վ����</param> /// <returns></returns> private CompositeStyle GetCompositeStyleByIsBusy(bool IsBusy, int iType) { CompositeStyle cs = new CompositeStyle(); BitmapPointStyle BitmapPoint = null; ////vs = new SimpleVectorPointStyle(34, System.Drawing.Color.Red, PointSize); ////��ȡ��վ��ʾЧ�� //vs = GetSimpleVectorPointStyleByiType(iType); //SimpleLineStyle ls = new SimpleLineStyle(new LineWidth(1, LineWidthUnit.Pixel), 1, System.Drawing.Color.Red); //SimpleInterior si = new SimpleInterior(1, System.Drawing.Color.Red, System.Drawing.Color.Red); //AreaStyle a = new AreaStyle(ls, si); //CompositeStyle cs = new CompositeStyle(a, null, null, vs); if (IsBusy) { BitmapPoint = new BitmapPointStyle("BUSY.BMP"); } else { switch (iType) { case 0: BitmapPoint = new BitmapPointStyle("TA-0.bmp"); break; case 1: BitmapPoint = new BitmapPointStyle("TA-1.bmp"); break; case 2: BitmapPoint = new BitmapPointStyle("TA-2.bmp"); break; case 3: BitmapPoint = new BitmapPointStyle("TA-3.bmp"); break; case 4: BitmapPoint = new BitmapPointStyle("TA-4.bmp"); break; case 5: BitmapPoint = new BitmapPointStyle("TA-5.bmp"); break; default: BitmapPoint = new BitmapPointStyle("TA-0.bmp"); break; } } BitmapPoint.PointSize = PointSize; BitmapPoint.ApplyColor = false; BitmapPoint.ShowWhiteBackground = false; BitmapPoint.Color = System.Drawing.Color.AliceBlue; cs.SymbolStyle = BitmapPoint; return cs; }