private static void InvokeRefreshPlugins(UIPluginManager uiPluginManager, RefreshArgs refreshArgs = null) { if (System.Windows.Application.Current != null && System.Windows.Application.Current.Dispatcher != null) { System.Windows.Application.Current.Dispatcher.BeginInvoke(() => { uiPluginManager.RefreshPlugins(refreshArgs); }); } }
/// <summary> /// Refreshes the plugins core. /// </summary> /// <param name="refreshArgs">The refresh args.</param> protected virtual void RefreshPluginsCore(RefreshArgs refreshArgs) { RefreshedPluginsUIPluginManagerEventArgs e = new RefreshedPluginsUIPluginManagerEventArgs(); foreach (UIPlugin plugin in GetActiveUIPlugins()) { Stopwatch stopwatch = Stopwatch.StartNew(); plugin.Refresh(refreshArgs); stopwatch.Stop(); e.RefreshingTimes[plugin] = stopwatch.Elapsed; } OnRefreshedPlugins(e); refreshingTime = e.TotalRefreshingTime; }
/// <summary> /// This method sychronizes status from map to controls in this plugin. /// For example, a map is changed by another plugin such as adding a new layer; /// we need to notice the shell that the map's status is changed; /// then shells send a message to all plugins that to synchronize status from map by their selfies. /// </summary> public void Refresh(RefreshArgs refreshArgs) { try { if (GisEditor.ActiveMap != null) { #if GISEditorUnitTest #else RefreshCore(GisEditor.ActiveMap, refreshArgs); #endif } } catch (TypeLoadException ex) { HandleTypeLoadException(ex); } }
private void ExportToShapeFile(Collection <Feature> resultFeatures, Collection <FeatureSourceColumn> columns, FeatureLayerPlugin sourceLayerPlugin, WellKnownType type) { int count = resultFeatures.Count; if (count > 0) { FeatureLayerPlugin targetLayerPlugin = (FeatureLayerPlugin)GisEditor.LayerManager.GetLayerPlugins(typeof(ShapeFileFeatureLayer)).FirstOrDefault(); FeatureLayer resultLayer = null; if (targetLayerPlugin != null) { GetLayersParameters getLayerParameters = new GetLayersParameters(); ConfigureFeatureLayerParameters parameters = targetLayerPlugin.GetCreateFeatureLayerParameters(columns); if (parameters != null && sourceLayerPlugin != null) { bool needColumns = false; Collection <string> tempColumns = new Collection <string>(); if (parameters.CustomData.ContainsKey("Columns")) { tempColumns = parameters.CustomData["Columns"] as Collection <string>; } else { needColumns = true; } var featureColumns = columns.Where(c => needColumns || tempColumns.Contains(c.ColumnName)); if (targetLayerPlugin.CanCreateFeatureLayerWithSourceColumns(sourceLayerPlugin)) { foreach (var item in featureColumns) { FeatureSourceColumn column = new FeatureSourceColumn(item.ColumnName, item.TypeName, item.MaxLength); if (column.TypeName.Equals("c", StringComparison.InvariantCultureIgnoreCase)) { column.TypeName = "Character"; } parameters.AddedColumns.Add(column); } } else { var geoColumns = sourceLayerPlugin.GetIntermediateColumns(featureColumns); foreach (var item in geoColumns) { if (item.TypeName.Equals("c", StringComparison.InvariantCultureIgnoreCase)) { item.TypeName = "Character"; } parameters.AddedColumns.Add(item); } } parameters.WellKnownType = type; //parameters.CustomData["SourceLayer"] = featureLayer; getLayerParameters.LayerUris.Add(parameters.LayerUri); foreach (var item in parameters.CustomData) { getLayerParameters.CustomData[item.Key] = item.Value; } Proj4Projection proj4 = new Proj4Projection(); proj4.InternalProjectionParametersString = parameters.Proj4ProjectionParametersString; proj4.ExternalProjectionParametersString = GisEditor.ActiveMap.DisplayProjectionParameters; proj4.SyncProjectionParametersString(); proj4.Open(); foreach (var item in resultFeatures) { Feature feature = proj4.ConvertToInternalProjection(item); parameters.AddedFeatures.Add(feature); } if (parameters.MemoColumnConvertMode == MemoColumnConvertMode.ToCharacter) { foreach (var item in parameters.AddedColumns.Where(c => c.TypeName.Equals("Memo", StringComparison.InvariantCultureIgnoreCase)).ToList()) { item.TypeName = "Character"; item.MaxLength = 254; DbfColumn tmpDbfColumn = item as DbfColumn; if (tmpDbfColumn != null) { tmpDbfColumn.ColumnType = DbfColumnType.Character; tmpDbfColumn.Length = 254; } } } resultLayer = targetLayerPlugin.CreateFeatureLayer(parameters); resultLayer.FeatureSource.Projection = proj4; resultLayer = targetLayerPlugin.GetLayers(getLayerParameters).FirstOrDefault() as FeatureLayer; } } if (resultLayer != null) { GisEditorMessageBox messageBox = new GisEditorMessageBox(MessageBoxButton.YesNo); messageBox.Owner = Application.Current.MainWindow; messageBox.WindowStartupLocation = WindowStartupLocation.CenterOwner; messageBox.Title = GisEditor.LanguageManager.GetStringResource("NavigatePluginAddToMap"); messageBox.Message = GisEditor.LanguageManager.GetStringResource("DoYouWantToAddToMap"); messageBox.ErrorMessage = string.Empty; if (messageBox.ShowDialog().Value) { GisEditor.ActiveMap.AddLayerToActiveOverlay(resultLayer); GisEditor.ActiveMap.RefreshActiveOverlay(); RefreshArgs refreshArgs = new RefreshArgs(this, "LoadToMapCore"); InvokeRefreshPlugins(GisEditor.UIManager, refreshArgs); GisEditor.ActiveMap.Refresh(); } } } else { System.Windows.Forms.MessageBox.Show("There is no features to export.", "Export"); } }
/// <summary> /// Refreshes the plugins. /// </summary> /// <param name="refreshArgs">The refresh args.</param> public void RefreshPlugins(RefreshArgs refreshArgs) { RefreshPluginsCore(refreshArgs); }
/// <summary> /// Refreshes the core. /// </summary> /// <param name="currentMap">The current map.</param> /// <param name="refreshArgs">The refresh args.</param> protected virtual void RefreshCore(GisEditorWpfMap currentMap, RefreshArgs refreshArgs) { }