Ejemplo n.º 1
0
        private void btnResData_Click(object sender, EventArgs e)
        {
            string resourceId = txtResourceId.Text;

            if (string.IsNullOrEmpty(resourceId))
            {
                resourceId = _ssd.ResourceID;
            }

            if (!_conn.ResourceService.ResourceExists(resourceId))
            {
                MessageBox.Show(Strings.ResourceDoesntExist);
                return;
            }

            var resData = _conn.ResourceService.EnumerateResourceData(resourceId);
            var items   = new List <string>();

            foreach (var rd in resData.ResourceData)
            {
                items.Add(rd.Name);
            }

            var result = GenericItemSelectionDialog.SelectItem(null, null, items.ToArray());

            if (result != null)
            {
                txtResData.Text = $"'{result}'"; //To avoid Expression Engine invocation
            }
        }
Ejemplo n.º 2
0
        private void btnBrowseSchema_Click(object sender, EventArgs e)
        {
            var list = new List <ClassDefinition>();

            foreach (var cls in _cachedDesc.AllClasses)
            {
                bool hasRaster = false;
                foreach (var prop in cls.Properties)
                {
                    var rp = prop as RasterPropertyDefinition;
                    if (rp != null)
                    {
                        hasRaster = true;
                        break;
                    }
                }

                if (hasRaster)
                {
                    list.Add(cls);
                }
            }
            if (list.Count == 0)
            {
                MessageBox.Show(Strings.NoRasterClasses);
                return;
            }

            var item = GenericItemSelectionDialog.SelectItem(null, null, list.ToArray(), "QualifiedName", "QualifiedName"); //NOXLATE

            if (item != null)
            {
                SetFeatureClass(item);
            }
        }
Ejemplo n.º 3
0
        public override IResource CreateItem(string startPoint, OSGeo.MapGuide.MaestroAPI.IServerConnection conn)
        {
            var cmd       = (IGetTileProviders)conn.CreateCommand((int)CommandType.GetTileProviders);
            var providers = cmd.Execute();
            var item      = GenericItemSelectionDialog.SelectItem(Strings.SelectTileProvider, Strings.SelectTileProvider, providers.TileProvider, "DisplayName", "Name");

            if (item != null)
            {
                ITileSetDefinition tsd = ObjectFactory.CreateTileSetDefinition(new Version(3, 0, 0));
                switch (item.Name)
                {
                case "Default":
                    tsd.SetDefaultProviderParameters(300, 300, string.Empty, new double[0]);
                    break;

                case "XYZ":
                    tsd.SetXYZProviderParameters();
                    break;

                default:
                    return(null);
                }
                return(tsd);
            }
            return(null);
        }
        private void btnRemoveMap_Click(object sender, EventArgs e)
        {
            if (lstMaps.SelectedItems.Count == 1)
            {
                var item  = lstMaps.SelectedItems[0];
                var group = (IMapGroup)item.Tag;

                var mapWidget = _flexLayout.GetFirstWidgetSet().MapWidget;
                //The map group we removed is being referenced by the map widget
                if (group.id == mapWidget.MapId)
                {
                    if (_flexLayout.MapSet.MapGroupCount >= 2)
                    {
                        if (_flexLayout.MapSet.MapGroupCount == 2)
                        {
                            _flexLayout.MapSet.RemoveGroup(group);
                            lstMaps.Items.Remove(item);

                            mapWidget.MapId = _flexLayout.MapSet.GetGroupAt(0).id;
                            MessageBox.Show(string.Format(Strings.MapUpdatedToUseGroup, mapWidget.MapId));
                            OnResourceChanged();
                        }
                        else if (_flexLayout.MapSet.MapGroupCount > 2)
                        {
                            List <string> mapGroupIds = new List <string>();
                            for (int i = 0; i < _flexLayout.MapSet.MapGroupCount; i++)
                            {
                                mapGroupIds.Add(_flexLayout.MapSet.GetGroupAt(i).id);
                            }

                            mapGroupIds.Remove(group.id); //Remove the one to be removed from the list

                            string id = GenericItemSelectionDialog.SelectItem(Strings.PromptSelectMap, Strings.PromptUpdateMapWidgetReference, mapGroupIds.ToArray());
                            if (id != null) //A replacement has been selected, now we can remove
                            {
                                _flexLayout.MapSet.RemoveGroup(group);
                                lstMaps.Items.Remove(item);

                                mapWidget.MapId = id;

                                OnResourceChanged();
                            }
                        }
                    }
                }
                else
                {
                    _flexLayout.MapSet.RemoveGroup(group);
                    lstMaps.Items.Remove(item);
                    OnResourceChanged();
                }
            }
        }
        private void btnBrowseSchema_Click(object sender, EventArgs e)
        {
            var featSvc = _edsvc.CurrentConnection.FeatureService;
            var list    = featSvc.GetClassNames(txtFeatureSource.Text, null);
            var item    = GenericItemSelectionDialog.SelectItem(null, null, list);

            if (item != null)
            {
                var cls = featSvc.GetClassDefinition(txtFeatureSource.Text, item);
                SetFeatureClass(cls);
            }
        }
Ejemplo n.º 6
0
        private void btnSelectFormat_Click(object sender, EventArgs e)
        {
            string[] formats = { RasterWmsItem.WmsImageFormat.GIF,
                                 RasterWmsItem.WmsImageFormat.JPG,
                                 RasterWmsItem.WmsImageFormat.PNG,
                                 RasterWmsItem.WmsImageFormat.TIF };
            var      item = GenericItemSelectionDialog.SelectItem(null, null, formats);

            if (item != null)
            {
                txtImageFormat.Text = item;
            }
        }
Ejemplo n.º 7
0
        private void btnPasswordProperty_Click(object sender, EventArgs e)
        {
            var list = new List <string>(_propertyNames);

            list.Remove(txtUserProperty.Text);

            string item = GenericItemSelectionDialog.SelectItem(null, null, list.ToArray());

            if (item != null)
            {
                txtPasswordProperty.Text = item;
                CheckSubmissionState();
            }
        }
        private void btnSpatialContext_Click(object sender, EventArgs e)
        {
            if (!chkGeometry.Checked)
            {
                MessageBox.Show(Strings.CheckGeometryFirst);
                return;
            }

            var item = GenericItemSelectionDialog.SelectItem(Strings.SelectSpatialContext, Strings.SelectSpatialContext, _scNames);

            if (!string.IsNullOrEmpty(item))
            {
                txtSpatialContext.Text = item;
            }
        }
        private void btnZ_Click(object sender, EventArgs e)
        {
            if (!chkGeometry.Checked)
            {
                MessageBox.Show(Strings.CheckGeometryFirst);
                return;
            }

            var item = GenericItemSelectionDialog.SelectItem(Strings.SelectProperty, Strings.SelectProperty, GetNumericPropertyNames());

            if (!string.IsNullOrEmpty(item))
            {
                txtZ.Text = item;
            }
        }
        public override IResource CreateItem(string startPoint, IServerConnection conn)
        {
            var provider = GenericItemSelectionDialog.SelectItem(
                Strings.SelectFdoProvider,
                Strings.SelectFdoProvider,
                conn.FeatureService.FeatureProviders,
                "DisplayName", //NOXLATE
                "Name");       //NOXLATE

            if (provider != null)
            {
                return(ObjectFactory.CreateFeatureSource(Utility.StripVersionFromProviderName(provider.Name)));
            }
            return(null);
        }
Ejemplo n.º 11
0
        private void btnSelectCs_Click(object sender, EventArgs e)
        {
            List <string> names = new List <string>();

            foreach (var sn in _config.SpatialContexts)
            {
                names.Add(sn.Name);
            }

            var item = GenericItemSelectionDialog.SelectItem(null, null, names.ToArray());

            if (item != null)
            {
                txtEpsg.Text = item;
            }
        }
Ejemplo n.º 12
0
 private void btnBrowseDataStore_Click(object sender, EventArgs e)
 {
     try
     {
         var    dstore = _service.CurrentConnection.FeatureService.EnumerateDataStores(this.Provider, GetPartialConnectionStringForDataStoreEnumeration());
         var    values = ConvertToArray(dstore);
         string item   = GenericItemSelectionDialog.SelectItem(Strings.TextSelectDataStore, Strings.TextSelectDataStore, values);
         if (item != null)
         {
             txtDataStore.Text = item;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(string.Format(Strings.FailEnumDataStores, ex.Message));
     }
 }
Ejemplo n.º 13
0
        private void btnBrowseSecondaryClass_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFeatureSource.Text))
            {
                MessageBox.Show(Strings.SpecifySecondaryFeatureSource);
                return;
            }

            var selClass = GenericItemSelectionDialog.SelectItem(Strings.SelectFeatureClass, Strings.SelectFeatureClass, _secondaryClasses, "QualifiedName", "QualifiedName"); //NOXLATE

            if (selClass != null)
            {
                _secondaryClass        = selClass;
                txtSecondaryClass.Text = _secondaryClass;
                CheckAddStatus();
            }
        }
        private void btnKey_Click(object sender, EventArgs e)
        {
            var item = GenericItemSelectionDialog.SelectItem(Strings.SelectProperty, Strings.SelectProperty, GetPropertyNames());

            if (!string.IsNullOrEmpty(item))
            {
                txtKey.Text = item;

                //Change the mapped logical class
                var prop = _item.Class.FindProperty(item);
                if (prop != null && prop.Type == PropertyDefinitionType.Data)
                {
                    _item.Class.ClearIdentityProperties();
                    _item.Class.AddProperty((DataPropertyDefinition)prop, true);
                }
            }
        }
Ejemplo n.º 15
0
        private void btnBrowseDsn_Click(object sender, EventArgs e)
        {
            string dsn = GenericItemSelectionDialog.SelectItem(null, null, _dsnNames);

            if (dsn != null)
            {
                if (dsn != txtDSN.Text)
                {
                    bool reset = MessageBox.Show(Strings.PromptResetOdbcConfigDocument, Strings.TitleQuestion, MessageBoxButtons.YesNo) == DialogResult.Yes;
                    if (reset)
                    {
                        txtDSN.Text = dsn;
                        OnRequestDocumentReset();
                        OnConnectionChanged();
                    }
                }
            }
        }
Ejemplo n.º 16
0
        private void pickAValueToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (grdConnectionParameters.SelectedCells.Count != 1)
            {
                return;
            }

            var           cell   = grdConnectionParameters.SelectedCells[0];
            List <string> values = new List <string>();

            try
            {
                var prop = grdConnectionParameters.Rows[cell.RowIndex].Cells[0].Value.ToString();

                var p = cell.Tag as OSGeo.MapGuide.ObjectModels.Common.FeatureProviderRegistryFeatureProviderConnectionProperty;
                if (p != null)
                {
                    if (p.Enumerable && p.Value.Count > 0)
                    {
                        values.AddRange(p.Value);
                    }
                    else
                    {
                        values.AddRange(_service.CurrentConnection.FeatureService.GetConnectionPropertyValues(txtProvider.Text, prop, GetPartialConnectionString()));
                    }
                }
            }
            catch
            {
            }

            if (values.Count > 0)
            {
                var selected = GenericItemSelectionDialog.SelectItem(null, null, values.ToArray());
                if (!string.IsNullOrEmpty(selected))
                {
                    cell.Value = selected;
                }
            }
            else
            {
                MessageBox.Show(Strings.PropEnumNoValues);
            }
        }
Ejemplo n.º 17
0
        private void btnBrowseLayer_Click(object sender, EventArgs e)
        {
            var layers = new List <LayerItem>();

            foreach (var l in _layers)
            {
                layers.Add(new LayerItem()
                {
                    Name = l.Name, ResourceId = l.ResourceId
                });
            }
            var layer = GenericItemSelectionDialog.SelectItem(Strings.SelectLayer, Strings.SelectLayer, layers.ToArray(), "Name", "Name");

            if (layer != null)
            {
                txtLayer.Tag  = layer.ResourceId;
                txtLayer.Text = layer.Name;
            }
        }
        public override void Run()
        {
            var wb   = Workbench.Instance;
            var exp  = wb.ActiveSiteExplorer;
            var mgr  = ServiceRegistry.GetService <ServerConnectionManager>();
            var conn = mgr.GetConnection(exp.ConnectionName);

            var providers = conn.FeatureService.FeatureProviders;
            var provider  = GenericItemSelectionDialog.SelectItem(Strings.TitleSelectFdoProvider, Strings.PromptSelectFdoProvider, providers, "DisplayName", "Name");

            if (provider != null)
            {
                MessageService.ShowMessage(provider.DisplayName);
            }
            else
            {
                MessageService.ShowMessage(Strings.Cancelled);
            }
        }
        private void btnBrowseGeometry_Click(object sender, EventArgs e)
        {
            if (_selectedClass != null)
            {
                List <PropertyDefinition> geoms = new List <PropertyDefinition>();
                foreach (var col in _selectedClass.Properties)
                {
                    if (col.Type == PropertyDefinitionType.Geometry)
                    {
                        geoms.Add(col);
                    }
                }

                var item = GenericItemSelectionDialog.SelectItem(null, null, geoms.ToArray(), "Name", "Name");
                if (item != null)
                {
                    txtGeometry.Text = item.Name;
                }
            }
        }
        private void featureSourceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var picker = new ResourcePicker(_conn, ResourceTypes.FeatureSource.ToString(), ResourcePickerMode.OpenResource))
            {
                if (picker.ShowDialog() == DialogResult.OK)
                {
                    dynamic conf   = GetConfigurationObject();
                    dynamic source = new ExpandoObject();
                    source.Type          = "MapGuide"; //NOXLATE
                    source.FeatureSource = picker.ResourceID;

                    string[] classNames = _conn.FeatureService.GetClassNames(picker.ResourceID, null);
                    string   className  = GenericItemSelectionDialog.SelectItem(Strings.FdoClass, Strings.SelectClassName, classNames);
                    if (className != null)
                    {
                        source.FeatureClass = className;
                        conf.Source         = source;
                        txtJson.Text        = JsonConvert.SerializeObject(conf, Formatting.Indented);
                    }
                }
            }
        }
        private void widgetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var cnt = this.SelectedContainer;

            if (cnt != null)
            {
                string[] widgets = _context.GetDockableWidgetNames(_flexLayout);
                string   widget  = GenericItemSelectionDialog.SelectItem(
                    Strings.AddWidgetReference,
                    Strings.SelectWidget,
                    widgets);
                if (widget != null)
                {
                    //at end
                    var item = _flexLayout.CreateWidgetReference(widget);
                    cnt.Insert(item, cnt.ItemCount);
                    this.SelectedNode.Nodes.Add(CreateNode(item));
                }
            }
            else
            {
                var menu = this.SelectedNode.Tag as IMenu;
                if (menu != null)
                {
                    string[] widgets = _context.GetDockableWidgetNames(_flexLayout);
                    string   widget  = GenericItemSelectionDialog.SelectItem(
                        Strings.AddWidgetReference,
                        Strings.SelectWidget,
                        widgets);
                    if (widget != null)
                    {
                        //at end
                        var item = _flexLayout.CreateWidgetReference(widget);
                        menu.Insert(item, menu.ItemCount);
                        this.SelectedNode.Nodes.Add(CreateNode(item));
                    }
                }
            }
        }
Ejemplo n.º 22
0
        internal static void OnDragDrop(ISiteExplorer sender, DragEventArgs e, TreeNodeAdv droppedNode)
        {
            //If drop node specified, extract relevant folder, otherwise default to root (Library://)
            string            folderId = StringConstants.RootIdentifier;
            IServerConnection conn     = null;
            var mgr = ServiceRegistry.GetService <ServerConnectionManager>();

            if (droppedNode != null)
            {
                var ri = droppedNode.Tag as RepositoryItem;
                if (ri != null)
                {
                    if (ri.IsFolder)
                    {
                        folderId = ri.ResourceId;
                    }
                    else
                    {
                        folderId = ri.Parent != null ? ri.Parent.ResourceId : StringConstants.RootIdentifier;
                    }
                }
                conn = mgr.GetConnection(ri.ConnectionName);
            }
            else
            {
                return;
            }

            Array a       = e.Data.GetData(DataFormats.FileDrop) as Array;
            bool  refresh = false;

            if (a != null && a.Length > 0)
            {
                DragDropHandlerService handlerSvc = ServiceRegistry.GetService <DragDropHandlerService>();
                for (int i = 0; i < a.Length; i++)
                {
                    string file = a.GetValue(i).ToString();

                    IList <IDragDropHandler> handlers = handlerSvc.GetHandlersForFile(file);

                    if (handlers.Count == 0)
                    {
                        continue;
                    }

                    if (handlers.Count == 1)
                    {
                        using (new WaitCursor(Workbench.Instance))
                        {
                            if (handlers[0].HandleDrop(conn, file, folderId))
                            {
                                refresh = true;
                            }
                        }
                    }

                    if (handlers.Count > 1)
                    {
                        //Resolve which handler to use
                        var handler = GenericItemSelectionDialog.SelectItem <IDragDropHandler>(Strings.SelectFileHandler, Strings.SelectFileHandlerDesc, handlers.ToArray());
                        if (handler != null)
                        {
                            using (new WaitCursor(Workbench.Instance))
                            {
                                if (handler.HandleDrop(conn, file, folderId))
                                {
                                    refresh = true;
                                }
                            }
                        }
                    }
                }
            }
            if (refresh)
            {
                sender.RefreshModel(conn.DisplayName, folderId);
            }
        }