private void SynchronizeTargetLayersComboBox(RefreshArgs synchronizeArgs)
        {
            var selectionOverlay = SelectionOverlay;

            if (selectionOverlay != null)
            {
                selectionOverlay.TargetFeatureLayers.Clear();
                GisEditor.ActiveMap.GetFeatureLayers(true).ForEach(tmpLayer => selectionOverlay.TargetFeatureLayers.Add(tmpLayer));

                if (synchronizeArgs != null &&
                    synchronizeArgs.Description == RefreshArgsDescription.DockManagerActiveDocumentChangedDescription)
                {
                    selectionOverlay.FilteredLayers.Clear();
                }

                selectionOverlay.TargetFeatureLayers.Where(tmpLayer
                                                           => !viewModel.Layers.Select(tmpLayerModel
                                                                                       => tmpLayerModel.Value).Contains(tmpLayer))
                .ForEach(tmpLayer => selectionOverlay.FilteredLayers.Add(tmpLayer));

                viewModel.Layers.Clear();
                selectionOverlay.TargetFeatureLayers.ForEach(tmpLayer =>
                                                             viewModel.Layers.Add(new CheckableItemViewModel <FeatureLayer>(tmpLayer, selectionOverlay.FilteredLayers.Contains(tmpLayer), generateNameFunc))
                                                             );
            }
            else
            {
                viewModel.Layers.Clear();
            }

            viewModel.RaiseDisplayTextPropertyChanged();
        }
 public void Synchronize(GisEditorWpfMap wpfMap, RefreshArgs synchronizeArgs)
 {
     RemoveConditionsLayerNotExist(wpfMap);
     SynchronizeTargetLayersComboBox(synchronizeArgs);
     SynchronizeSpatialQueryMode();
     SynchronizeButtonStatus();
 }
        //private MenuItem GetRelateMenuItem(FeatureLayer featureLayer)
        //{
        //    MenuItem rootMenuItem = new MenuItem();
        //    rootMenuItem.Header = GisEditor.LanguageManager.GetStringResource("LayerListUIPluginRelateText");
        //    rootMenuItem.Icon = new Image() { Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/relation.png", UriKind.RelativeOrAbsolute)), Width = 16, Height = 16 };
        //    rootMenuItem.Click += new RoutedEventHandler(RelateMenuItem_Click);
        //    rootMenuItem.Tag = featureLayer;

        //    PluginHelper.ApplyReadonlyMode(rootMenuItem);
        //    return rootMenuItem;
        //}

        //private void RelateMenuItem_Click(object sender, RoutedEventArgs e)
        //{
        //    MenuItem menuItem = (MenuItem)sender;
        //    FeatureLayer sourceFeatureLayer = (FeatureLayer)menuItem.Tag;

        //    LinkSourceWindow window = new LinkSourceWindow(sourceFeatureLayer);
        //    window.Owner = Application.Current.MainWindow;
        //    window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
        //    if (window.ShowDialog().GetValueOrDefault())
        //    {
        //        LinkSourceItem resultItem = window.ResultLinkSource;
        //        sourceFeatureLayer.FeatureSource.LinkSources.Clear();
        //        sourceFeatureLayer.FeatureSource.LinkExpressions.Clear();
        //        ApplyLinkSourceItems(sourceFeatureLayer, resultItem.LinkSourceItems);
        //        sourceFeatureLayer.FeatureSource.RefreshColumns();
        //        GisEditor.ActiveMap.RefreshActiveOverlay();
        //        GisEditor.ActiveMap.Refresh();
        //    }
        //}

        //private void ApplyLinkSourceItems(FeatureLayer featureLayer, Collection<LinkSourceItem> linkSourceItems)
        //{
        //    LinkSource linkSource = new LinkSource();
        //    FillLinkSource(linkSource, linkSourceItems);

        //    foreach (var item in linkSource.LinkSources)
        //    {
        //        featureLayer.FeatureSource.LinkSources.Add(item);
        //    }

        //    foreach (var item in linkSource.LinkExpressions)
        //    {
        //        if (item.Split(new[] { featureLayer.Name }, StringSplitOptions.RemoveEmptyEntries).Length >= 2)
        //        {
        //            string[] results = item.Split('.');
        //            if (results.Length == 3)
        //            {
        //                string expressions = "feature";
        //                foreach (var result in results.Skip(1))
        //                {
        //                    expressions += "." + result;
        //                }
        //                featureLayer.FeatureSource.LinkExpressions.Add(expressions);
        //            }
        //            else
        //            {
        //                string expressions = item.Replace(featureLayer.Name, "feature");
        //                featureLayer.FeatureSource.LinkExpressions.Add(expressions);
        //            }
        //        }
        //        else
        //        {
        //            string expressions = item.Replace(featureLayer.Name, "feature");
        //            featureLayer.FeatureSource.LinkExpressions.Add(expressions);
        //        }
        //    }
        //}

        //private void FillLinkSource(LinkSource linkSource, Collection<LinkSourceItem> linkSourceItems)
        //{
        //    foreach (var item in linkSourceItems)
        //    {
        //        LinkSourcePlugin plugin = LinkSourcePluginManager.Instance.GetLinkSourcePlugin(item.Source.GetType());
        //        LinkSource newlinkSource = plugin.GetLinkSource(item);
        //        linkSource.LinkSources.Add(newlinkSource);
        //        linkSource.LinkExpressions.Add(item.LinkExpression);
        //        if (item.LinkSourceItems.Count > 0)
        //        {
        //            FillLinkSource(newlinkSource, item.LinkSourceItems);
        //        }
        //    }
        //}

        protected override void RefreshCore(GisEditorWpfMap currentMap, RefreshArgs refreshArgs)
        {
            // RefreshInternal(currentMap, refreshArgs);
            if (dispatcherTimer == null)
            {
                dispatcherTimer          = new DispatcherTimer();
                dispatcherTimer.Interval = TimeSpan.FromMilliseconds(200);
                dispatcherTimer.Tick    += (s, e) =>
                {
                    DispatcherTimer currentTimer = (DispatcherTimer)s;
                    currentTimer.Stop();

                    Tuple <GisEditorWpfMap, RefreshArgs> currentTimerTag = currentTimer.Tag as Tuple <GisEditorWpfMap, RefreshArgs>;
                    RefreshInternal(currentTimerTag.Item1, currentTimerTag.Item2);
                };
            }

            if (dispatcherTimer.IsEnabled)
            {
                dispatcherTimer.Stop();
            }

            Tuple <GisEditorWpfMap, RefreshArgs> timerTag = new Tuple <GisEditorWpfMap, RefreshArgs>(currentMap, refreshArgs);

            dispatcherTimer.Tag = timerTag;
            dispatcherTimer.Start();
        }
        private void bgRefreshing_DoWork(object sender, DoWorkEventArgs e)
        {
            RefreshArgs args = (RefreshArgs)e.Argument;

            e.Result = MaterialPermit.LoadList(args.Database, args.Unit,
                                               DateTime.MinValue, DateTime.MaxValue, args.User);
        }
Exemplo n.º 5
0
 protected override void RefreshCore(GisEditorWpfMap currentMap, RefreshArgs refreshArgs)
 {
     base.RefreshCore(currentMap, refreshArgs);
     viewModel.SyncUIState();
     viewModel.SyncStylePreview();
     viewModel.Refresh();
 }
Exemplo n.º 6
0
        protected override void RefreshCore(GisEditorWpfMap currentMap, RefreshArgs refreshArgs)
        {
            measureGroup.SynchronizeState(currentMap);
            MeasureTrackInteractiveOverlay measurementOverlay = null;

            if (GisEditor.ActiveMap != null && GisEditor.ActiveMap.InteractiveOverlays.Contains("MeasurementOverlay"))
            {
                measurementOverlay = GisEditor.ActiveMap.InteractiveOverlays["MeasurementOverlay"] as MeasureTrackInteractiveOverlay;
                if (measurementOverlay != null)
                {
                    RenderMode renderMode = MeasureSetting.Instance.UseGdiPlusInsteadOfDrawingVisual ? RenderMode.GdiPlus : RenderMode.DrawingVisual;
                    if (measurementOverlay.RenderMode != renderMode)
                    {
                        measurementOverlay.RenderMode = renderMode;
                    }
                    switch (measurementOverlay.TrackMode)
                    {
                    case TrackMode.Point:
                        GisEditor.ActiveMap.Cursor = GisEditorCursors.DrawPoint;
                        break;

                    case TrackMode.Rectangle:
                        GisEditor.ActiveMap.Cursor = GisEditorCursors.DrawRectangle;
                        break;

                    case TrackMode.Square:
                        GisEditor.ActiveMap.Cursor = GisEditorCursors.DrawSqure;
                        break;

                    case TrackMode.Ellipse:
                        GisEditor.ActiveMap.Cursor = GisEditorCursors.DrawEllipse;
                        break;

                    case TrackMode.Circle:
                        GisEditor.ActiveMap.Cursor = GisEditorCursors.DrawCircle;
                        break;

                    case TrackMode.Polygon:
                        GisEditor.ActiveMap.Cursor = GisEditorCursors.DrawPolygon;
                        break;

                    case TrackMode.Line:
                        GisEditor.ActiveMap.Cursor = GisEditorCursors.DrawLine;
                        break;

                    case TrackMode.Custom:
                        GisEditor.ActiveMap.Cursor = GisEditorCursors.Normal;
                        break;
                    }

                    if (measurementOverlay.MeasureCustomeMode == MeasureCustomeMode.Move &&
                        measurementOverlay.TrackMode == TrackMode.Custom)
                    {
                        GisEditor.ActiveMap.Cursor = GisEditorCursors.Cross;
                    }
                }
            }
        }
 protected override void RefreshCore(GisEditorWpfMap currentMap, RefreshArgs refreshArgs)
 {
     if (!(refreshArgs != null && refreshArgs.Description.Equals(RefreshArgsDescription.EditLayerChangedDescription)))
     {
         base.RefreshCore(currentMap, refreshArgs);
         EditingToolsViewModel.Instance.Refresh(currentMap);
         snappingToolsRibbonGroup.ViewModel.EditOverlay = EditingToolsViewModel.Instance.EditOverlay;
         snappingToolsRibbonGroup.ViewModel.Refresh(currentMap);
     }
 }
 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);
         });
     }
 }
 public static void BeginRefreshPlugins(this UIPluginManager uiPluginManager, RefreshArgs refreshArgs = null)
 {
     if (Application.Current != null && Application.Current.Dispatcher != null)
     {
         Application.Current.Dispatcher.BeginInvoke(() =>
         {
             uiPluginManager.RefreshPlugins(refreshArgs);
         });
     }
 }
Exemplo n.º 10
0
        protected override void RefreshCore(GisEditorWpfMap currentMap, RefreshArgs refreshArgs)
        {
            base.RefreshCore(currentMap, refreshArgs);
            if (lastMap != currentMap && bookmarkGroup != null)
            {
                ((BookmarkRibbonGroupViewModel)bookmarkGroup.DataContext).SyncBookmarkMenuItems();
            }

            lastMap = currentMap;
        }
Exemplo n.º 11
0
        private void ForceRefreshing()
        {
            RefreshArgs args = new RefreshArgs();

            args.Database = Database;
            args.DateFrom = periodPicker.DateFrom;
            args.DateTo   = periodPicker.DateTo;

            refreshLabel.Text = "обновление...";
            bckRefresh.RunWorkerAsync(args);
        }
        private void ForceRefreshing()
        {
            RefreshArgs args = new RefreshArgs();

            args.Database = Database;
            args.DateFrom = DateTime.Now.AddDays(-10);
            args.DateTo   = DateTime.Now;

            refreshLabel.Text = "обновление...";
            bckRefresh.RunWorkerAsync(args);
        }
Exemplo n.º 13
0
 protected override void RefreshCore(GisEditorWpfMap currentMap, RefreshArgs refreshArgs)
 {
     base.RefreshCore(currentMap, refreshArgs);
     if (currentMap != null)
     {
         if (previousMap != currentMap)
         {
             viewGroup.viewModel.SelectedBackground = currentMap.BackgroundOverlay.BackgroundBrush;
             previousMap = currentMap;
         }
     }
 }
Exemplo n.º 14
0
        protected override void RefreshCore(GisEditorWpfMap currentMap, RefreshArgs refreshArgs)
        {
            foreach (var map in GisEditor.GetMaps())
            {
                foreach (var overlay in map.Overlays.OfType <TileOverlay>())
                {
                    overlay.DrawingException -= Overlay_DrawingException;
                    overlay.DrawingException += Overlay_DrawingException;
                }
            }

            base.RefreshCore(currentMap, refreshArgs);
        }
Exemplo n.º 15
0
        protected override void RefreshCore(GisEditorWpfMap currentMap, RefreshArgs refreshArgs)
        {
            var allFeatureLayers      = GisEditor.ActiveMap.GetFeatureLayers(true);
            var featureLayersToRemove = GisEditor.ActiveMap.SelectionOverlay.FilteredLayers.Where(l => !allFeatureLayers.Contains(l)).ToList();

            foreach (var item in featureLayersToRemove)
            {
                GisEditor.ActiveMap.SelectionOverlay.FilteredLayers.Remove(item);
            }

            selectionAndQueryingGroup.Synchronize(currentMap, refreshArgs);
            CommandHelper.CloseFindFeaturesWindow();
        }
Exemplo n.º 16
0
        protected override void RefreshCore(GisEditorWpfMap currentMap, RefreshArgs refreshArgs)
        {
            if (lastMap != null && lastMap != currentMap)
            {
                var boundingBoxSelectTool = lastMap.MapTools.OfType <BoundingBoxSelectorMapTool>().FirstOrDefault();
                if (boundingBoxSelectTool != null)
                {
                    lastMap.MapTools.Remove(boundingBoxSelectTool);
                    currentMap.MapTools.Add(boundingBoxSelectTool);
                }
            }

            lastMap = currentMap;
        }
        private void ForceRefresh()
        {
            RefreshArgs args = new RefreshArgs();

            args.Database = Database;
            args.User     = User;
            args.Unit     = (Unit)cboxUnit.SelectedItem;

            if (!bgRefreshing.IsBusy)
            {
                bgRefreshing.RunWorkerAsync(args);
            }

            refreshingLabel.Text = "обновляем...";
            refreshTimer.Stop();
        }
Exemplo n.º 18
0
 protected override void RefreshCore(GisEditorWpfMap currentMap, RefreshArgs refreshArgs)
 {
     if (refreshArgs is DataRepositoryUIRefreshArgs)
     {
         foreach (var dataRepositoryPlugin in ((DataRepositoryUIRefreshArgs)refreshArgs).RefreshPlugins)
         {
             Type type = dataRepositoryPlugin.GetType();
             DataRepositoryPlugin resultDataRepositoryPlugin = GisEditor.DataRepositoryManager.GetActiveDataRepositoryPlugins().FirstOrDefault(d => d.GetType() == type);
             var treeViewItem = DataRepositoryContentViewModel.Current.Children.FirstOrDefault(t => t.SourcePlugin == resultDataRepositoryPlugin);
             treeViewItem.Children.Clear();
             foreach (var dataRepositoryItem in resultDataRepositoryPlugin.RootDataRepositoryItem.Children)
             {
                 treeViewItem.Children.Add(dataRepositoryItem);
             }
         }
     }
 }
        private void RefreshInternal(GisEditorWpfMap currentMap, RefreshArgs refreshArgs)
        {
            if (currentMap != null && !GetRefreshArgsToSkip().Any(func => func(refreshArgs)))
            {
                var viewModel = GisEditor.LayerListManager.GetRootLayerListItem(currentMap);
                currentMap.Dispatcher.BeginInvoke(() =>
                {
                    RefreshExpandedStates(currentMap.Name, viewModel);

                    if (states != null && states.ContainsKey(currentMap.Name))
                    {
                        foreach (var overlayEntity in viewModel.Children)
                        {
                            if (states[currentMap.Name].ContainsKey(overlayEntity.Name))
                            {
                                overlayEntity.ChildrenContainerVisibility = states[currentMap.Name][overlayEntity.Name];
                            }
                            foreach (var layerEntity in overlayEntity.Children)
                            {
                                if (states[currentMap.Name].ContainsKey(layerEntity.Name))
                                {
                                    layerEntity.ChildrenContainerVisibility = states[currentMap.Name][layerEntity.Name];
                                }
                            }
                        }
                        if (viewModel.Children.Count > 0)
                        {
                            states.Remove(currentMap.Name);
                        }
                    }
                    else if (allMapElementsEntity.ContainsKey(currentMap.Name))
                    {
                        //LoadVisibilityFromMapElementEntity(allMapElementsEntity[currentMap.Name], viewModel);
                        UpdateNewEntityVisibility(allMapElementsEntity[currentMap.Name], viewModel);
                        allMapElementsEntity[currentMap.Name] = viewModel;
                    }
                    else if (!string.IsNullOrEmpty(currentMap.Name))
                    {
                        allMapElementsEntity.Add(currentMap.Name, viewModel);
                    }
                    layerListUserControl.DataContext = viewModel;
                }, DispatcherPriority.Background);
            }
        }
Exemplo n.º 20
0
        protected override void RefreshCore(GisEditorWpfMap currentMap, RefreshArgs refreshArgs)
        {
            base.RefreshCore(currentMap, refreshArgs);
            var dockManager = GetDockingManager();

            if (dockManager != null)
            {
                var dataControls = dockManager.DockableContents.Select(d => d.Content).OfType <DataViewerUserControl>().ToArray();
                foreach (var dataControl in dataControls)
                {
                    if (!dockManager.Documents.Any(d => d.Content == dataControl.Tag))
                    {
                        var removingDataControl = GisEditor.DockWindowManager.DockWindows.FirstOrDefault(d => d.Content == dataControl);
                        if (removingDataControl != null)
                        {
                            GisEditor.DockWindowManager.DockWindows.Remove(removingDataControl);
                        }
                    }
                }
            }
        }
        public static void CopyToNewLayer(Collection <FeatureLayer> selectedFeaturesLayers)
        {
            Collection <FeatureLayer> existLayers = new Collection <FeatureLayer>();

            foreach (var item in GisEditor.ActiveMap.GetFeatureLayers().OfType <InMemoryFeatureLayer>())
            {
                existLayers.Add(item);
            }

            GetLayersParameters parameters = new GetLayersParameters();

            parameters.LayerUris.Add(new Uri("mem:Newlayer"));
            InMemoryFeatureLayerPlugin plugin = GisEditor.LayerManager.GetActiveLayerPlugins <InMemoryFeatureLayerPlugin>().FirstOrDefault();
            InMemoryFeatureLayer       inMemoryFeatureLayer = null;

            if (plugin != null)
            {
                inMemoryFeatureLayer      = plugin.GetLayers(parameters).OfType <InMemoryFeatureLayer>().FirstOrDefault();
                inMemoryFeatureLayer.Name = "New layer";
                existLayers.Insert(0, inMemoryFeatureLayer);
            }
            if (selectedFeaturesLayers.Count > 1)
            {
                AddFeaturesToSelectedLayer(selectedFeaturesLayers, existLayers);
                GisEditor.ActiveMap.Refresh(GisEditor.ActiveMap.ActiveOverlay);
                RefreshArgs refreshArgs = new RefreshArgs(GisEditor.ActiveMap, RefreshArgsDescription.AddLayerGroupCommandDescription);
                GisEditor.UIManager.BeginRefreshPlugins(refreshArgs);
                LayerOverlay overlay = GisEditor.ActiveMap.ActiveOverlay as LayerOverlay;
                if (overlay != null)
                {
                    overlay.Invalidate();
                }
            }
            else if (selectedFeaturesLayers.Count == 1)
            {
                AddFeatureToInMemoryFeatureLayer(null, selectedFeaturesLayers[0]);
            }
        }
 public static void CopyToExistingLayer(Collection <FeatureLayer>
                                        selectedFeaturesLayers, InMemoryFeatureLayer inMemoryFeatureLayer)
 {
     if (selectedFeaturesLayers.Count > 1)
     {
         var targetLayers = new Collection <FeatureLayer>()
         {
             inMemoryFeatureLayer
         };
         AddFeaturesToSelectedLayer(selectedFeaturesLayers, targetLayers);
         GisEditor.ActiveMap.Refresh(GisEditor.ActiveMap.ActiveOverlay);
         RefreshArgs refreshArgs = new RefreshArgs(GisEditor.ActiveMap, RefreshArgsDescription.AddLayerGroupCommandDescription);
         GisEditor.UIManager.BeginRefreshPlugins(refreshArgs);
         LayerOverlay overlay = GisEditor.ActiveMap.ActiveOverlay as LayerOverlay;
         if (overlay != null)
         {
             overlay.Invalidate();
         }
     }
     else if (selectedFeaturesLayers.Count == 1)
     {
         AddFeatureToInMemoryFeatureLayer(inMemoryFeatureLayer, selectedFeaturesLayers[0]);
     }
 }
        private static void ExportToShapeFile(Collection <Feature> resultFeatures, Collection <FeatureSourceColumn> columns, FeatureLayerPlugin sourceLayerPlugin, WellKnownType type)
        {
            int count = resultFeatures.Count;

            if (count > 0)
            {
                ShapeFileFeatureLayerPlugin targetLayerPlugin = GisEditor.LayerManager.GetActiveLayerPlugins <ShapeFileFeatureLayerPlugin>().FirstOrDefault();
                FeatureLayer        resultLayer        = null;
                GetLayersParameters getLayerParameters = new GetLayersParameters();

                if (targetLayerPlugin != null)
                {
                    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())
                            {
                                //parameters.AddedColumns.Remove(item);
                                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(null, "LoadToMapCore");
                        InvokeRefreshPlugins(GisEditor.UIManager, refreshArgs);
                        GisEditor.ActiveMap.Refresh();
                    }
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("There's no features in this layer.", "Export File");
            }
        }
        private void bckRefresh_DoWork(object sender, DoWorkEventArgs e)
        {
            RefreshArgs args = (RefreshArgs)e.Argument;

            e.Result = MaterialPermit.LoadList(args.Database, args.DateFrom, args.DateTo);
        }
        protected override void RefreshCore(WpfDesktop.Extension.GisEditorWpfMap currentMap, RefreshArgs refreshArgs)
        {
            base.RefreshCore(currentMap, refreshArgs);

            GoogleEarthRibbonGroupViewModel viewModel = googleEarthRibbonGroup.DataContext as GoogleEarthRibbonGroupViewModel;

            if (viewModel != null)
            {
                viewModel.RaisePropertyChanged();
            }
        }
        private static void AddFeatureToInMemoryFeatureLayer(InMemoryFeatureLayer inMemoryFeatureLayer, FeatureLayer sourceLayer)
        {
            if (inMemoryFeatureLayer == null)
            {
                string name         = "ExportResults";
                string existingName = string.Empty;
                InMemoryFeatureLayer existingLayer = GisEditor.ActiveMap.Overlays.OfType <LayerOverlay>()
                                                     .SelectMany(o => o.Layers).OfType <InMemoryFeatureLayer>()
                                                     .FirstOrDefault(l => l.Name.Equals(name, System.StringComparison.Ordinal));
                if (existingLayer != null)
                {
                    existingName = existingLayer.Name;
                }

                int index = 0;
                while (name.Equals(existingName))
                {
                    index++;
                    name          = "ExportResults" + index;
                    existingLayer = GisEditor.ActiveMap.Overlays.OfType <LayerOverlay>()
                                    .SelectMany(o => o.Layers).OfType <InMemoryFeatureLayer>()
                                    .FirstOrDefault(l => l.Name.Equals(name, System.StringComparison.Ordinal));
                    existingName = existingLayer != null ? existingLayer.Name : string.Empty;
                }

                GetLayersParameters parameters = new GetLayersParameters();
                parameters.LayerUris.Add(new Uri("mem:" + name));
                InMemoryFeatureLayerPlugin plugin = GisEditor.LayerManager.GetActiveLayerPlugins <InMemoryFeatureLayerPlugin>().FirstOrDefault();
                if (plugin != null)
                {
                    inMemoryFeatureLayer = plugin.GetLayers(parameters).OfType <InMemoryFeatureLayer>().FirstOrDefault();
                }
                GisEditor.ActiveMap.AddLayerToActiveOverlay(inMemoryFeatureLayer, TargetLayerOverlayType.Dynamic);
            }

            //if (sourceLayer != null)
            //{
            //    foreach (var item in sourceLayer.FeatureSource.LinkExpressions)
            //    {
            //        inMemoryFeatureLayer.FeatureSource.LinkExpressions.Add(item);
            //    }
            //    foreach (var item in sourceLayer.FeatureSource.LinkSources)
            //    {
            //        inMemoryFeatureLayer.FeatureSource.LinkSources.Add(item);
            //    }
            //}

            Collection <Feature> features = GisEditor.SelectionManager.GetSelectedFeatures();

            AddFeaturesToInMemoryFeatureLayer(inMemoryFeatureLayer, features);

            GisEditor.ActiveMap.Refresh(GisEditor.ActiveMap.ActiveOverlay);
            RefreshArgs refreshArgs = new RefreshArgs(GisEditor.ActiveMap, RefreshArgsDescription.AddLayerGroupCommandDescription);

            GisEditor.UIManager.BeginRefreshPlugins(refreshArgs);
            LayerOverlay overlay = GisEditor.ActiveMap.ActiveOverlay as LayerOverlay;

            if (overlay != null)
            {
                overlay.Invalidate();
            }
        }