Exemple #1
0
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(resSvc, ResourceTypes.FeatureSource, ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             this.FeatureSourceID = picker.ResourceID;
         }
     }
 }
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_resSvc,
                                            ResourceTypes.SymbolDefinition,
                                            ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.ResourceID;
             txtResourceId.Text = picker.ResourceID;
         }
     }
 }
 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.ResourceService, ResourceTypes.MapDefinition, ResourcePickerMode.OpenResource))
     {
         picker.SetStartingPoint(startPoint);
         if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             var wl = ObjectFactory.CreateWebLayout(conn, new Version(2, 4, 0), string.Empty);
             wl.Map.ResourceId = picker.ResourceID;
             return wl;
         }
     }
     return null;
 }
        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.GetEditedResource().CurrentConnection;

            if (ed != null)
            {
                using (var picker = new ResourcePicker(conn.ResourceService, 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.
                            }
                        }
                    }
                }
            }
        }
Exemple #5
0
        public override void Run()
        {
            var wb = Workbench.Instance;
            var exp = wb.ActiveSiteExplorer;
            var mgr = ServiceRegistry.GetService<ServerConnectionManager>();
            var conn = mgr.GetConnection(exp.ConnectionName);

            var picker = new ResourcePicker(conn.ResourceService, ResourcePickerMode.OpenResource);
            if (picker.ShowDialog(wb) == System.Windows.Forms.DialogResult.OK)
            {
                MessageService.ShowMessage(picker.ResourceID);
            }
            else
            {
                MessageService.ShowMessage(Strings.Cancelled);
            }
        }
        public override IResource CreateItem(string startPoint, IServerConnection conn)
        {
            //This is to just ensure we have a functional template when it's created
            using (var picker = new ResourcePicker(conn.ResourceService, ResourceTypes.MapDefinition, ResourcePickerMode.OpenResource))
            {
                picker.SetStartingPoint(startPoint);
                if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var flex = ObjectFactory.CreateFlexibleLayout(conn, FusionTemplateNames.Slate);
                    var grp = flex.MapSet.GetGroupAt(0);
                    var map = grp.GetMapAt(0);

                    map.SetMapDefinition(picker.ResourceID);
                    return flex;
                }
            }
            return null;
        }
        public override IResource CreateItem(string startPoint, IServerConnection conn)
        {
            using (var picker = new ResourcePicker(conn.ResourceService, ResourceTypes.DrawingSource, ResourcePickerMode.OpenResource))
            {
                picker.SetStartingPoint(startPoint);
                if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var ldf = ObjectFactory.CreateDefaultLayer(conn, OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerType.Drawing, new Version(1, 0, 0));
                    ldf.SubLayer.ResourceId = picker.ResourceID;
                    var dl = ((IDrawingLayerDefinition)ldf.SubLayer);
                    dl.LayerFilter = string.Empty;
                    dl.MinScale = 0;

                    IDrawingService dwSvc = (IDrawingService)conn.GetService((int)ServiceType.Drawing);
                    var sheets = dwSvc.EnumerateDrawingSections(picker.ResourceID);
                    dl.Sheet = sheets.Section[0].Name;

                    return ldf;
                }
                return null;
            }
        }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_edSvc.ResourceService, ResourceTypes.WatermarkDefinition, ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.SelectedFolder;
             var wdf = (IWatermarkDefinition)_edSvc.ResourceService.GetResource(picker.ResourceID);
             //var wm = wdf.CreateInstance();
             var wm = _watermarks.AddWatermark(wdf);
             var diag = new WatermarkInstanceEditorDialog(_edSvc, wm);
             if (diag.ShowDialog() == DialogResult.OK)
             {
                 _list.Add(wm);
             }
             else //Undo
             {
                 _watermarks.RemoveWatermark(wm);
             }
         }
     }
 }
 public override OSGeo.MapGuide.MaestroAPI.Resource.IResource CreateItem(string startPoint, OSGeo.MapGuide.MaestroAPI.IServerConnection conn)
 {
     using (var picker = new ResourcePicker(conn.ResourceService, ResourceTypes.FeatureSource, ResourcePickerMode.OpenResource))
     {
         picker.SetStartingPoint(startPoint);
         if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             var lyr = ObjectFactory.CreateDefaultLayer(conn, OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerType.Vector, new Version(1, 1, 0));
             var vl = (IVectorLayerDefinition)lyr.SubLayer;
             vl.ResourceId = picker.ResourceID;
             //Stub these for now, validation will ensure this never makes it
             //into the session repository until all validation errors pass
             vl.FeatureName = string.Empty;
             vl.Geometry = string.Empty;
             return lyr;
         }
         else
         {
             return null;
         }
     }
 }
Exemple #10
0
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_conn.ResourceService, ResourceTypes.SymbolLibrary, ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.SelectedFolder;
             LoadSymbols(picker.ResourceID);
             txtSymbolLibrary.Text = picker.ResourceID;
         }
     }
 }
 private void btnBrowseFeatureSource_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_edsvc.ResourceService, ResourceTypes.FeatureSource, ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.SelectedFolder;
             txtFeatureSource.Text = picker.ResourceID;
             //Invalidate
             _cachedFs = null;
         }
     }
 }
Exemple #12
0
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(SelectedConnection.ResourceService, ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             txtResourceId.Text = picker.ResourceID;
         }
     }
 }
        private void btnBrowseTarget_Click(object sender, EventArgs e)
        {
            using (var picker = new ResourcePicker(_target.ResourceService, ResourcePickerMode.OpenFolder))
            {
                if (!string.IsNullOrEmpty(_lastTargetFolder))
                    picker.SetStartingPoint(_lastTargetFolder);

                if (picker.ShowDialog() == DialogResult.OK)
                {
                    _lastTargetFolder = picker.SelectedFolder;
                    txtTargetFolder.Text = picker.ResourceID;
                    EvaluateCommandState();
                }
            }
        }
Exemple #14
0
        private void DoOpen()
        {
            ClearExistingEditor();

            using (var picker = new ResourcePicker(_conn.ResourceService, ResourceTypes.MapDefinition, ResourcePickerMode.OpenResource))
            {
                if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var mdf = (IMapDefinition)_conn.ResourceService.GetResource(picker.ResourceID);
                    LoadMapDefinitionForEditing(mdf);
                }
            }
            EvaluateCommandStates();
        }
Exemple #15
0
 /// <summary>
 /// Displays a resource picker for saving
 /// </summary>
 /// <param name="conn"></param>
 /// <param name="resourceType"></param>
 /// <returns></returns>
 public string PickResourceSave(IServerConnection conn, string resourceType)
 {
     Func<string> picker = () =>
     {
         using (var diag = new ResourcePicker(conn.ResourceService, (ResourceTypes)Enum.Parse(typeof(ResourceTypes), resourceType), ResourcePickerMode.SaveResource))
         {
             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();
 }
Exemple #16
0
 private void toolStripButton1_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.ResourceService,
                                            ResourceTypes.MapDefinition,
                                            ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LoadMap(_conn, picker.ResourceID);
         }
     }
 }
 /// <summary>
 /// Invokes a prompt to select a folder
 /// </summary>
 /// <returns></returns>
 public string SelectFolder()
 {
     var picker = new ResourcePicker(_conn.ResourceService, ResourcePickerMode.OpenFolder);
     if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         return picker.ResourceID;
     }
     return string.Empty;
 }
Exemple #18
0
 private void openWebLayoutToolStripMenuItem_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 Feature Source
     using (var picker = new ResourcePicker(_conn.ResourceService,
                                            ResourceTypes.WebLayout,
                                            ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LoadWebLayoutEditor(picker.ResourceID);
         }
     }
 }
Exemple #19
0
 private void btnBrowseSymbolLibrary_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_conn.ResourceService, ResourceTypes.SymbolLibrary, ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.SelectedFolder;
             this.SymbolLibraryID = picker.ResourceID;
             this.SymbolName = string.Empty;
         }
     }
 }
Exemple #20
0
 private void btnAddLayer_Click(object sender, EventArgs e)
 {
     var map = this.Viewer.GetMap();
     if (map != null)
     {
         using (var picker = new ResourcePicker(map.CurrentConnection.ResourceService, ResourceTypes.LayerDefinition, 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.Visible = true;
                 layer.ShowInLegend = true;
                 map.Layers.Insert(0, layer);
                 legendCtrl.Viewer.RefreshMap();
             }
         }
     }
 }
Exemple #21
0
 private void DoSaveAs()
 {
     using (var picker = new ResourcePicker(_conn.ResourceService, ResourceTypes.MapDefinition, 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();
 }
Exemple #22
0
 private void btnBrowse_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 Feature Source
     using (var picker = new ResourcePicker(_conn.ResourceService,
                                            ResourceTypes.FeatureSource,
                                            ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             txtFeatureSource.Text = picker.ResourceID;
             LoadFeatureSource(picker.ResourceID);
         }
     }
 }
Exemple #23
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.ResourceService, 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();
 }
        private void btnAddResource_Click(object sender, EventArgs e)
        {
            using (var picker = new ResourcePicker(_source.ResourceService, ResourcePickerMode.OpenResource))
            {
                if (!string.IsNullOrEmpty(_lastSourceFolder))
                    picker.SetStartingPoint(_lastSourceFolder);

                if (picker.ShowDialog() == DialogResult.OK)
                {
                    if (!lstResources.Items.Contains(picker.ResourceID))
                        lstResources.Items.Add(picker.ResourceID);

                    _lastSourceFolder = picker.SelectedFolder;

                    EvaluateCommandState();
                }
            }
        }
 private void btnCreateTarget_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_conn.ResourceService, ResourcePickerMode.OpenFolder))
     {
         if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             txtCreateTargetFolder.Text = picker.ResourceID;
             EvalButtonState();
         }
     }
 }
        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.ResourceService.ResourceExists(_vl.ResourceId))
            {
                var cls = _edsvc.FeatureService.GetClassDefinition(_vl.ResourceId, _vl.FeatureName);
                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.ResourceService, ResourceTypes.FeatureSource, ResourcePickerMode.OpenResource))
                {
                    if (picker.ShowDialog() == DialogResult.OK)
                    {
                        _vl.ResourceId = picker.ResourceID;
                        OnResourceChanged();
                    }
                }
            }
        }
 /// <summary>
 /// Invokes a prompt to select a resource of the specified type
 /// </summary>
 /// <param name="resType"></param>
 /// <returns></returns>
 public string SelectResource(OSGeo.MapGuide.MaestroAPI.ResourceTypes resType)
 {
     var picker = new ResourcePicker(_conn.ResourceService, resType, ResourcePickerMode.OpenResource);
     if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         return picker.ResourceID;
     }
     return string.Empty;
 }
 private void btnFeatureSource_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_conn.ResourceService, ResourceTypes.FeatureSource, ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             txtFeatureSource.Text = picker.ResourceID;
             LoadFeatureClassesAsync();
         }
     }
 }
Exemple #29
0
 private void btnBrowseFeatureSource_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(m_editor.ResourceService, ResourceTypes.FeatureSource, ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             txtFeatureSource.Text = picker.ResourceID;
         }
     }
 }
        private void btnAddFolder_Click(object sender, EventArgs e)
        {
            using (var picker = new ResourcePicker(_source.ResourceService, 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();
                }
            }
        }