Ejemplo n.º 1
0
        private void plugin_LayerAdded(IMuteLegend legend, LayerEventArgs e)
        {
            var layer = _context.Legend.Layers.ItemByHandle(e.LayerHandle);

            if (layer != null)
            {
                LayerSerializationHelper.LoadSettings(layer, _broadcaster, true);
            }
        }
Ejemplo n.º 2
0
        public override void RunCommand(VectorStyleCommand command)
        {
            switch (command)
            {
            case VectorStyleCommand.ClearVisibilityExpression:
                FeatureSet.VisibilityExpression = "";
                View.UpdateView();
                break;

            case VectorStyleCommand.ChangeVisibilityExpression:
                string s = FeatureSet.VisibilityExpression;
                if (FormHelper.ShowQueryBuilder(_context, Model, ViewAsParent, ref s, false))
                {
                    FeatureSet.VisibilityExpression = s;
                    View.UpdateView();
                }
                break;

            case VectorStyleCommand.ClearLabels:
                if (MessageService.Current.Ask("Do you want to remove labels?"))
                {
                    FeatureSet.Labels.Items.Clear();
                    FeatureSet.Labels.Expression = "";
                }
                View.RefreshLabels();
                break;

            case VectorStyleCommand.LabelAppearance:
                using (var form = new LabelStyleForm(_context, Model))
                {
                    _context.View.ShowChildView(form, ViewAsParent);
                }
                View.RefreshLabels();
                break;

            case VectorStyleCommand.ClearCharts:
                if (MessageService.Current.Ask("Do you want to remove charts?"))
                {
                    FeatureSet.Diagrams.Fields.Clear();
                    FeatureSet.Diagrams.Clear();
                }
                View.RefreshCharts();
                break;

            case VectorStyleCommand.OpenLocation:
                string filename = Model.Filename;
                if (!string.IsNullOrWhiteSpace(filename))
                {
                    PathHelper.OpenFolderWithExplorer(filename);
                }
                else
                {
                    MessageService.Current.Info("Can't find the datasource.");
                }
                break;

            case VectorStyleCommand.SaveStyle:
                LayerSerializationHelper.SaveSettings(Model);
                break;

            case VectorStyleCommand.RemoveStyle:
                LayerSerializationHelper.RemoveSettings(Model, false);
                break;

            case VectorStyleCommand.ProjectionDetails:
                _context.ShowProjectionProperties(Model.Projection, View as IWin32Window);
                break;

            case VectorStyleCommand.ChartsEditColorScheme:
                FormHelper.EditColorSchemes(_context, SchemeTarget.Charts, ViewAsParent);
                break;

            case VectorStyleCommand.ChartAppearance:
                using (var form = new ChartStyleForm(_context, Model))
                {
                    _context.View.ShowChildView(form, ViewAsParent);
                }
                View.RefreshCharts();
                break;

            default:
                throw new ArgumentOutOfRangeException("command");
            }
        }
Ejemplo n.º 3
0
        public override void RunCommand(RasterCommand command)
        {
            switch (command)
            {
            case RasterCommand.OpenFolder:
                string filename = Model.Filename;
                if (!string.IsNullOrWhiteSpace(filename))
                {
                    PathHelper.OpenFolderWithExplorer(filename);
                }
                else
                {
                    MessageService.Current.Info("Can't find the datasource.");
                }
                break;

            case RasterCommand.ProjectionDetails:
                _context.ShowProjectionProperties(Model.Projection, View as IWin32Window);
                break;

            case RasterCommand.ClearColorAdjustments:
                View.ClearColorAdjustments();
                break;

            case RasterCommand.Apply:
                Apply();
                break;

            case RasterCommand.RemoveStyle:
                LayerSerializationHelper.RemoveSettings(Model, false);
                break;

            case RasterCommand.LoadStyle:
            {
                bool result = LayerSerializationHelper.LoadSettings(Model, _broadcaster, false);

                if (result)
                {
                    View.Initialize();
                    Apply();
                }

                MessageService.Current.Info(result ? "Layer options are loaded." : "Failed to load layer options.");
            }
            break;

            case RasterCommand.SaveStyle:
                LayerSerializationHelper.SaveSettings(Model);
                break;

            case RasterCommand.ShowDriverInfo:
                if (_raster == null)
                {
                    return;
                }
                var manager = new DriverManager {
                    SelectedDriver = _raster.Driver
                };
                _context.Container.Run <DriversPresenter, DriverManager>(manager);
                break;

            default:
                throw new ArgumentOutOfRangeException("command");
            }
        }
Ejemplo n.º 4
0
        public override void RunCommand(LegendCommand command)
        {
            switch (command)
            {
            case LegendCommand.AddGroup:
                Legend.Groups.Add();
                break;

            case LegendCommand.AddLayer:
            {
                int groupHandle = _legendDockPanel.SelectedGroupHandle;
                if (_layerService.AddLayer(DataSourceType.All) && groupHandle != -1)
                {
                    int layerHandle = _layerService.LastLayerHandle;
                    Legend.Layers.MoveLayer(layerHandle, groupHandle);
                }
                break;
            }

            case LegendCommand.GroupProperties:
            {
                int groupHandle = _legendDockPanel.SelectedGroupHandle;
                var group       = Legend.Groups.ItemByHandle(groupHandle);
                if (group != null)
                {
                    if (_context.Container.Run <LegendGroupPresenter, ILegendGroup>(group))
                    {
                        Legend.Redraw();
                    }
                }
                break;
            }

            case LegendCommand.ZoomToGroup:
            {
                var group = Legend.Groups.ItemByHandle(_legendDockPanel.SelectedGroupHandle);
                if (group != null)
                {
                    var box = group.Envelope;
                    _context.Map.ZoomToExtents(box);
                }
                break;
            }

            case LegendCommand.RemoveGroup:
            {
                var group = Legend.Groups.ItemByHandle(_legendDockPanel.SelectedGroupHandle);
                if (group != null)
                {
                    if (MessageService.Current.Ask("Do you want to remove group: " + group.Text + "?"))
                    {
                        Legend.Groups.Remove(group.Handle);
                    }
                }
                break;
            }

            case LegendCommand.Labels:
            {
                var layer = _context.Legend.Layers.Current;
                if (layer != null && layer.IsVector)
                {
                    _broadcaster.BroadcastEvent(p => p.LayerLabelsClicked_, _context.Legend, new LayerEventArgs(layer.Handle));
                }
            }
            break;

            case LegendCommand.TableEditor:
            {
                var layer = _context.Legend.Layers.Current;
                if (layer != null && layer.IsVector)
                {
                    var args = new PluginMessageEventArgs(PluginMessages.ShowAttributeTable);
                    _broadcaster.BroadcastEvent(t => t.MessageBroadcasted_, _context.Legend, args);
                }
            }
            break;

            case LegendCommand.ZoomToLayer:
                _context.Map.ZoomToLayer(_context.Legend.SelectedLayerHandle);
                break;

            case LegendCommand.RemoveLayer:
                _layerService.RemoveSelectedLayer();
                break;

            case LegendCommand.Properties:
                _broadcaster.BroadcastEvent(p => p.LayerDoubleClicked_, Legend,
                                            new LayerEventArgs(Legend.SelectedLayerHandle));
                break;

            case LegendCommand.SaveStyle:
            {
                var layer = Legend.Layers.Current;

                if (layer != null)
                {
                    if (!LayerSerializationHelper.CheckFilename(layer.Filename))
                    {
                        MessageService.Current.Info("Can not save settings for a non-disk based layer.");
                        return;
                    }

                    LayerSerializationHelper.SaveSettings(layer);
                }
                break;
            }

            case LegendCommand.LoadStyle:
            {
                var layer = Legend.Layers.Current;

                if (layer != null)
                {
                    if (!LayerSerializationHelper.CheckFilename(layer.Filename))
                    {
                        MessageService.Current.Info("Can not load settings for a non-disk based layer.");
                        return;
                    }

                    LayerSerializationHelper.LoadSettings(layer, _broadcaster, false);
                }

                _context.Legend.Redraw(LegendRedraw.LegendAndMap);
            }
            break;

            case LegendCommand.OpenFileLocation:
            {
                var layer = Legend.Layers.Current;
                if (layer != null && File.Exists(layer.Filename))
                {
                    Shared.PathHelper.OpenFolderWithExplorer(layer.Filename);
                }
                else
                {
                    MessageService.Current.Warn("Failed to find file for the layer.");
                }
                break;
            }
            }
        }