Exemplo n.º 1
0
        /// <summary>
        /// Prompts a dialog to select a folder
        /// </summary>
        /// <param name="conn"></param>
        /// <returns></returns>
        public string PickFolder(IServerConnection conn)
        {
            Func <string> picker = () =>
            {
                using (var diag = new ResourcePicker(conn, ResourcePickerMode.OpenFolder))
                {
                    if (diag.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        return(diag.ResourceID);
                    }
                }
                return(null);
            };

            if (this.MainWindow.InvokeRequired)
            {
                var result = this.MainWindow.Invoke(picker);
                if (result != null)
                {
                    return(result.ToString());
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(picker());
            }
        }
Exemplo n.º 2
0
        private void addLayerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var map = this.Viewer.GetMap();

            if (map != null)
            {
                var node = legendCtrl.SelectedNode;
                if (node != null)
                {
                    var grp = node.Tag as GroupNodeMetadata;
                    if (grp != null)
                    {
                        using (var picker = new ResourcePicker(map.CurrentConnection, ResourceTypes.LayerDefinition.ToString(), ResourcePickerMode.OpenResource))
                        {
                            if (picker.ShowDialog() == DialogResult.OK)
                            {
                                var mapSvc = (IMappingService)map.CurrentConnection.GetService((int)ServiceType.Mapping);
                                var layer  = mapSvc.CreateMapLayer(map, ((ILayerDefinition)map.CurrentConnection.ResourceService.GetResource(picker.ResourceID)));
                                layer.Name         = GenerateUniqueName(ResourceIdentifier.GetName(picker.ResourceID), map.Layers);
                                layer.LegendLabel  = ResourceIdentifier.GetName(picker.ResourceID);
                                layer.Group        = grp.Name;
                                layer.Visible      = true;
                                layer.ShowInLegend = true;
                                map.Layers.Insert(0, layer);
                                legendCtrl.Viewer.RefreshMap();
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void btnAddFolder_Click(object sender, EventArgs e)
        {
            using (var picker = new ResourcePicker(_source, ResourcePickerMode.OpenFolder))
            {
                if (!string.IsNullOrEmpty(_lastSourceFolder))
                {
                    picker.SetStartingPoint(_lastSourceFolder);
                }

                if (picker.ShowDialog() == DialogResult.OK)
                {
                    var folderId = picker.ResourceID;
                    var list     = _source.ResourceService.GetRepositoryResources(folderId);

                    foreach (var item in list.Children)
                    {
                        if (!item.IsFolder && !lstResources.Items.Contains(item.ResourceId))
                        {
                            lstResources.Items.Add(item.ResourceId);
                        }
                    }

                    _lastSourceFolder = picker.SelectedFolder;

                    EvaluateCommandState();
                }
            }
        }
 private void btnAddBaseLayer_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_edSvc.CurrentConnection, ResourceTypes.LayerDefinition.ToString(), ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.SelectedFolder;
             string        layerId = picker.ResourceID;
             IBaseMapGroup grp     = null;
             var           group   = GetSelectedTiledLayerItem() as BaseLayerGroupItem;
             if (group != null)
             {
                 grp = group.Tag;
             }
             else
             {
                 grp = _tsd.GetFirstGroup();
                 if (grp == null)
                 {
                     grp = _tsd.AddBaseLayerGroup(GenerateBaseGroupName(_tsd));
                 }
             }
             var bl = grp.AddLayer(GenerateBaseLayerName(layerId, _tsd), layerId);
             _tiledLayerModel.Invalidate();
             RestoreBaseLayerSelection(bl);
         }
     }
 }
Exemplo n.º 5
0
        private void btnAddTileSet_Click(object sender, EventArgs e)
        {
            var conn = _edSvc.CurrentConnection;

            using (var picker = new ResourcePicker(conn, ResourcePickerMode.OpenResource, new[] { ResourceTypes.TileSetDefinition.ToString() }))
            {
                if (picker.ShowDialog() == DialogResult.OK)
                {
                    ITileSetDefinition tsd = (ITileSetDefinition)conn.ResourceService.GetResource(picker.ResourceID);
                    if (tsd.TileStoreParameters.TileProvider == "XYZ")
                    {
                        var baseGroup = tsd.BaseMapLayerGroups.FirstOrDefault();
                        var mapagent  = conn.GetCustomProperty("BaseUrl").ToString(); //NOXLATE
                        mapagent += "mapagent/mapagent.fcgi?OPERATION=GETTILEIMAGE&VERSION=1.2.0&CLIENTAGENT=OpenLayers&USERNAME=Anonymous&MAPDEFINITION=" + tsd.ResourceID + "&BASEMAPLAYERGROUPNAME=" + baseGroup.Name + "&TILECOL=${y}&TILEROW=${x}&SCALEINDEX=${z}";
                        _urls.Add(new ExternalUrl {
                            URL = mapagent
                        });
                        SyncCurrentUrls();
                    }
                    else
                    {
                        MessageBox.Show(Strings.InvalidTileSetForFusionXYZLayer);
                    }
                }
            }
        }
        internal void PopulatePropertyList()
        {
            //NOTE: This is being called before _vl is assigned in mono
            //so guard against it
            if (_vl == null || string.IsNullOrEmpty(_vl.FeatureName))
            {
                return;
            }

            if (_edsvc.CurrentConnection.ResourceService.ResourceExists(_vl.ResourceId))
            {
                ClassDefinition cls = null;
                try
                {
                    cls = _edsvc.CurrentConnection.FeatureService.GetClassDefinition(_vl.ResourceId, _vl.FeatureName);
                }
                catch
                {
                    //Do nothing, layer settings control does this check and should flag the feature class field as something requiring attention
                }
                if (cls != null)
                {
                    grdProperties.Rows.Clear();
                    RemoveInvalidMappings(cls);
                    foreach (var col in cls.Properties)
                    {
                        if (col.Type == OSGeo.MapGuide.MaestroAPI.Schema.PropertyDefinitionType.Data)
                        {
                            bool   visible = false;
                            string disp    = col.Name;
                            foreach (var item in _vl.PropertyMapping)
                            {
                                if (item.Name == col.Name)
                                {
                                    visible = true;
                                    disp    = item.Value;
                                }
                            }
                            grdProperties.Rows.Add(visible, col.Name, disp);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show(string.Format(Strings.PromptRepairBrokenFeatureSource, _vl.ResourceId));
                using (var picker = new ResourcePicker(_edsvc.CurrentConnection, ResourceTypes.FeatureSource.ToString(), ResourcePickerMode.OpenResource))
                {
                    if (picker.ShowDialog() == DialogResult.OK)
                    {
                        _vl.ResourceId = picker.ResourceID;
                        OnResourceChanged();
                    }
                }
            }
        }
Exemplo n.º 7
0
 private void btnBrowseRestorePath_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_conn, ResourcePickerMode.OpenFolder))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             this.FolderToPackage = picker.ResourceID;
         }
     }
 }
Exemplo n.º 8
0
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_edSvc.CurrentConnection, ResourceTypes.FeatureSource.ToString(), ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             this.FeatureSourceID = picker.ResourceID;
         }
     }
 }
Exemplo n.º 9
0
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_editor.CurrentConnection, ResourcePickerMode.OpenFolder))
     {
         if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             txtFolder.Text = picker.ResourceID;
         }
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Invokes a prompt to select a folder
        /// </summary>
        /// <returns></returns>
        public string SelectFolder()
        {
            var picker = new ResourcePicker(_conn, ResourcePickerMode.OpenFolder);

            if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                return(picker.ResourceID);
            }
            return(string.Empty);
        }
Exemplo n.º 11
0
 private void btnBrowseMdf_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_edSvc.CurrentConnection, ResourceTypes.MapDefinition.ToString(), ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             txtMapDefinition.Text = picker.ResourceID;
         }
     }
 }
 private void btnTarget_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_conn, ResourcePickerMode.OpenFolder))
     {
         if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             txtTargetFolder.Text = picker.SelectedFolder;
         }
     }
 }
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(SelectedConnection, ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             txtResourceId.Text = picker.ResourceID;
         }
     }
 }
Exemplo n.º 14
0
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_source, ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.SelectedFolder;
             txtResourceId.Text          = picker.ResourceID;
         }
     }
 }
Exemplo n.º 15
0
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_edSvc.CurrentConnection, ResourceTypes.WatermarkDefinition.ToString(), ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.SelectedFolder;
             txtResourceId.Text          = picker.ResourceID;
         }
     }
 }
Exemplo n.º 16
0
 private void btnFeatureSource_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_conn, ResourceTypes.FeatureSource.ToString(), ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             txtFeatureSource.Text = picker.ResourceID;
             LoadFeatureClassesAsync();
         }
     }
 }
Exemplo n.º 17
0
 private void btnCreateTarget_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_conn, ResourcePickerMode.OpenFolder))
     {
         if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             txtCreateTargetFolder.Text = picker.ResourceID;
             EvalButtonState();
         }
     }
 }
 private void btnAddMap_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_edsvc.CurrentConnection, ResourceTypes.MapDefinition.ToString(), ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.SelectedFolder;
             string resId = picker.ResourceID;
             AddMapDefinition(resId, ResourceIdentifier.GetName(resId));
         }
     }
 }
 private void referenceToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_edSvc.CurrentConnection, ResourceTypes.SymbolDefinition.ToString(), ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.SelectedFolder;
             var symRef = _comp.CreateSymbolReference(picker.ResourceID);
             AddInstance(symRef, true);
         }
     }
 }
Exemplo n.º 20
0
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_conn, ResourceTypes.SymbolLibrary.ToString(), ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.SelectedFolder;
             LoadSymbols(picker.ResourceID);
             txtSymbolLibrary.Text = picker.ResourceID;
         }
     }
 }
Exemplo n.º 21
0
 private void btnBrowseSymbolLibrary_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_conn, ResourceTypes.SymbolLibrary.ToString(), ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.SelectedFolder;
             this.SymbolLibraryID        = picker.ResourceID;
             this.SymbolName             = string.Empty;
         }
     }
 }
        public override void Run()
        {
            var wb   = Workbench.Instance;
            var exp  = wb.ActiveSiteExplorer;
            var omgr = ServiceRegistry.GetService <OpenResourceManager>();
            var ed   = wb.ActiveDocumentView as IEditorViewContent;
            var conn = ed.EditorService.CurrentConnection;

            if (ed != null)
            {
                using (var picker = new ResourcePicker(conn, ed.Resource.ResourceType, ResourcePickerMode.SaveResource))
                {
                    if (!string.IsNullOrEmpty(ed.EditorService.SuggestedSaveFolder))
                    {
                        picker.SetStartingPoint(ed.EditorService.SuggestedSaveFolder);
                    }

                    if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        if (omgr.IsOpen(picker.ResourceID, conn))
                        {
                            MessageService.ShowMessage(string.Format(Strings.CannotSaveToResourceAlreadyOpened, picker.ResourceID));
                            return;
                        }

                        using (new WaitCursor(wb))
                        {
                            var oldId = ed.EditorService.ResourceID;
                            ed.EditorService.SaveAs(picker.ResourceID);
                            if (oldId != ed.EditorService.ResourceID)
                            {
                                omgr.RenameResourceId(oldId, ed.EditorService.ResourceID, conn, exp);
                            }

                            try
                            {
                                var rid = new ResourceIdentifier(picker.ResourceID);
                                exp.RefreshModel(conn.DisplayName, rid.ParentFolder);
                            }
                            catch (NullReferenceException)
                            {
                                //HACK/FIXME: This can NRE if we created a new resource and
                                //we haven't expanded the Site Explorer for the first
                                //time. Muffling this NRE will just mean that the Site
                                //Explorer won't auto-expand to the folder where this
                                //resource was created. So nothing major.
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 23
0
 private void btnBrowseFeatureSource_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_edsvc.CurrentConnection, ResourceTypes.FeatureSource.ToString(), ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.SelectedFolder;
             txtFeatureSource.Text       = picker.ResourceID;
             //Invalidate
             _cachedFs = null;
         }
     }
 }
Exemplo n.º 24
0
 private void DoSaveAs()
 {
     using (var picker = new ResourcePicker(_conn, ResourceTypes.MapDefinition.ToString(), ResourcePickerMode.SaveResource))
     {
         if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             _mapEditor.SyncMap();                               //RuntimeMap to IMapDefinition
             _mapEditor.EditorService.SyncSessionCopy();         //IMapDefinition to session-copy
             _mapEditor.EditorService.SaveAs(picker.ResourceID); //Session-copy to specified resource
         }
     }
     EvaluateCommandStates();
 }
Exemplo n.º 25
0
        private void btnToOGR_Click(object sender, EventArgs e)
        {
            using (var picker = new ResourcePicker(_service.CurrentConnection, ResourcePickerMode.SaveResource, new[] { ResourceTypes.FeatureSource.ToString() }))
            {
                if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var conv = new OgrFeatureSourceConverter(_fs, _service.CurrentConnection.ResourceService, _service.CurrentConnection.FeatureService);
                    conv.Convert(picker.ResourceID);

                    System.Windows.Forms.MessageBox.Show(string.Format(Strings.ConvertedToOgrFeatureSource, picker.ResourceID));
                }
            }
        }
Exemplo n.º 26
0
        private void DoOpen()
        {
            ClearExistingEditor();

            using (var picker = new ResourcePicker(_conn, ResourceTypes.MapDefinition.ToString(), ResourcePickerMode.OpenResource))
            {
                if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var mdf = (IMapDefinition)_conn.ResourceService.GetResource(picker.ResourceID);
                    LoadMapDefinitionForEditing(mdf);
                }
            }
            EvaluateCommandStates();
        }
Exemplo n.º 27
0
 private void btnBrowseDs_Click(object sender, EventArgs e)
 {
     //The ResourcePicker class, functions like a file dialog allowing the user
     //to easily select a given resource. In our case, we want the user to select
     //a Drawing Source
     using (var picker = new ResourcePicker(_conn,
                                            ResourceTypes.DrawingSource.ToString(),
                                            ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             txtDrawingSource.Text = picker.ResourceID;
         }
     }
 }
Exemplo n.º 28
0
 public override IResource CreateItem(string startPoint, IServerConnection conn)
 {
     //This is to just ensure we have a functional WebLayout when it's created
     using (var picker = new ResourcePicker(conn, ResourceTypes.MapDefinition.ToString(), ResourcePickerMode.OpenResource))
     {
         picker.SetStartingPoint(startPoint);
         if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             var wl = ObjectFactory.CreateWebLayout(new Version(2, 4, 0), string.Empty);
             wl.Map.ResourceId = picker.ResourceID;
             return(wl);
         }
     }
     return(null);
 }
Exemplo n.º 29
0
 private void openMapDefinitionToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //The ResourcePicker class, functions like a file dialog allowing the user
     //to easily select a given resource. In our case, we want the user to select
     //a Map Definition
     using (var picker = new ResourcePicker(_conn,
                                            ResourceTypes.MapDefinition.ToString(),
                                            ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LoadMap(_conn, picker.ResourceID);
         }
     }
 }
        private void layerDefinitionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var picker = new ResourcePicker(_conn, ResourceTypes.LayerDefinition.ToString(), ResourcePickerMode.OpenResource))
            {
                if (picker.ShowDialog() == DialogResult.OK)
                {
                    dynamic conf   = GetConfigurationObject();
                    dynamic source = new ExpandoObject();
                    source.Type            = "MapGuide"; //NOXLATE
                    source.LayerDefinition = picker.ResourceID;
                    conf.Source            = source;

                    txtJson.Text = JsonConvert.SerializeObject(conf, Formatting.Indented);
                }
            }
        }