コード例 #1
0
ファイル: SdfFileCtrl.cs プロジェクト: kanbang/Colt
        public override void Bind(IEditorService service)
        {
            base.Bind(service);
            _service = service;
            _fs = _service.GetEditedResource() as IFeatureSource;
            Debug.Assert(_fs != null);

            MarkSelected();

            //HACK: Set ReadOnly property if not specified otherwise this will be an invalid feature source
            if (string.IsNullOrEmpty(_fs.GetConnectionProperty("ReadOnly"))) //NOXLATE
                _fs.SetConnectionProperty("ReadOnly", "FALSE"); //NOXLATE

            chkReadOnly.Checked = _fs.GetConnectionProperty("ReadOnly").ToUpper().Equals(true.ToString().ToUpper()); //NOXLATE
        }
コード例 #2
0
        public override void Bind(IEditorService service)
        {
            base.Bind(service);
            _service = service;
            _fs      = service.GetEditedResource() as IFeatureSource;
            Debug.Assert(_fs != null);

            MarkSelected();

            //HACK: Set UseFdoMetadata property if not specified otherwise this will be an invalid feature source
            if (string.IsNullOrEmpty(_fs.GetConnectionProperty("UseFdoMetadata")))                                               //NOXLATE
            {
                _fs.SetConnectionProperty("UseFdoMetadata", "FALSE");                                                            //NOXLATE
            }
            chkUseFdoMetadata.Checked = _fs.GetConnectionProperty("UseFdoMetadata").ToUpper().Equals(true.ToString().ToUpper()); //NOXLATE
        }
コード例 #3
0
        public WmsAdvancedConfigurationDialog(IEditorService service)
        {
            InitializeComponent();
            grdSpatialContexts.AutoGenerateColumns = false;
            _service = service;
            _fs      = (IFeatureSource)_service.GetEditedResource();
            txtFeatureServer.Text = _fs.GetConnectionProperty("FeatureServer"); //NOXLATE
            string xml = _fs.GetConfigurationContent(service.CurrentConnection);

            if (!string.IsNullOrEmpty(xml))
            {
                try
                {
                    _config = (WmsConfigurationDocument)ConfigurationDocument.LoadXml(xml);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format(Strings.ErrorLoadingWmsConfig, ex.Message), Strings.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MakeDefaultDocument();
                }
            }
            else
            {
                MakeDefaultDocument();
            }

            lstFeatureClasses.DataSource  = _config.RasterOverrides;
            grdSpatialContexts.DataSource = _config.SpatialContexts;
        }
コード例 #4
0
        public WmsAdvancedConfigurationDialog(IEditorService service)
        {
            InitializeComponent();
            grdSpatialContexts.AutoGenerateColumns = false;
            _service = service;
            _fs = (IFeatureSource)_service.GetEditedResource();
            txtFeatureServer.Text = _fs.GetConnectionProperty("FeatureServer"); //NOXLATE
            string xml = _fs.GetConfigurationContent();
            if (!string.IsNullOrEmpty(xml))
            {
                try
                {
                    _config = (WmsConfigurationDocument)ConfigurationDocument.LoadXml(xml);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format(Strings.ErrorLoadingWmsConfig, ex.Message), Strings.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MakeDefaultDocument();
                }
            }
            else
            {
                MakeDefaultDocument();
            }

            lstFeatureClasses.DataSource = _config.RasterOverrides;
            grdSpatialContexts.DataSource = _config.SpatialContexts;
        }
コード例 #5
0
ファイル: WmsProviderCtrl.cs プロジェクト: kanbang/Colt
        public override void Bind(IEditorService service)
        {
            _init = true;
            try
            {
                _service = service;
                _service.RegisterCustomNotifier(this);
                _fs = (IFeatureSource)_service.GetEditedResource();

                txtFeatureServer.Text = _fs.GetConnectionProperty("FeatureServer"); //NOXLATE
                txtUsername.Text = _fs.GetConnectionProperty("Username"); //NOXLATE
                txtPassword.Text = _fs.GetConnectionProperty("Password"); //NOXLATE
            }
            finally
            {
                _init = false;
            }
        }
コード例 #6
0
        private string GetPartialConnectionStringForDataStoreEnumeration()
        {
            var builder = new System.Data.Common.DbConnectionStringBuilder();

            builder["Service"]  = _fs.GetConnectionProperty("Service"); //NOXLATE
            builder["Username"] = txtUsername.Text;                     //_fs.GetConnectionProperty("Username"); //NOXLATE
            builder["Password"] = txtPassword.Text;                     //_fs.GetConnectionProperty("Password"); //NOXLATE
            return(builder.ToString());
        }
コード例 #7
0
        private void MarkSelected()
        {
            var file = _fs.GetConnectionProperty(this.FileFdoProperty);

            if (!string.IsNullOrEmpty(file))
            {
                if (_fs.UsesEmbeddedDataFiles)
                {
                    rdManaged.Checked = true;
                    var df = _fs.GetEmbeddedDataName();
                    resDataCtrl.MarkedFile = df;
                }
                else //if (_fs.UsesAliasedDataFiles)
                {
                    txtAlias.Text       = file;
                    rdUnmanaged.Checked = true;
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Gets a collection of connection properties
        /// </summary>
        /// <param name="fs"></param>
        /// <returns></returns>
        public static NameValueCollection GetConnectionProperties(this IFeatureSource fs)
        {
            Check.ArgumentNotNull(fs, nameof(fs));
            var values = new NameValueCollection();

            foreach (string name in fs.ConnectionPropertyNames)
            {
                values[name] = fs.GetConnectionProperty(name);
            }
            return(values);
        }
コード例 #9
0
        /// <summary>
        /// Gets a collection of connection properties
        /// </summary>
        /// <param name="fs"></param>
        /// <returns></returns>
        public static NameValueCollection GetConnectionProperties(this IFeatureSource fs)
        {
            Check.NotNull(fs, "fs"); //NOXLATE
            var values = new NameValueCollection();

            foreach (string name in fs.ConnectionPropertyNames)
            {
                values[name] = fs.GetConnectionProperty(name);
            }
            return(values);
        }
コード例 #10
0
        public override void Bind(IEditorService service)
        {
            try
            {
                _init = true;
                _bSupportsResample = false;
                _service           = service;
                _fs = (IFeatureSource)_service.GetEditedResource();

                var provInfo = _service.CurrentConnection.FeatureService.GetFeatureProvider("OSGeo.Gdal"); //NOXLATE
                foreach (var prop in provInfo.ConnectionProperties)
                {
                    if (prop.Name == "ResamplingMethod") //NOXLATE
                    {
                        chkResamplingMethod.Visible         =
                            cmbResamplingMethod.Visible     =
                                cmbResamplingMethod.Enabled = true;

                        cmbResamplingMethod.DataSource = new List <string>(prop.Value);
                        var method = _fs.GetConnectionProperty("ResamplingMethod"); //NOXLATE
                        if (!string.IsNullOrEmpty(method))
                        {
                            chkResamplingMethod.Checked      = true;
                            cmbResamplingMethod.SelectedItem = method;
                        }
                        else
                        {
                            cmbResamplingMethod.SelectedIndex = 0;
                            chkResamplingMethod.Checked       = false;
                        }
                        _bSupportsResample = true;
                        break;
                    }
                }

                cmbResamplingMethod.Enabled = chkResamplingMethod.Checked;

                _sing.Bind(service);
                _comp.Bind(service);
                if (!string.IsNullOrEmpty(_fs.GetConfigurationContent(service.CurrentConnection)))
                {
                    rdComposite.Checked = true;
                }
                else
                {
                    OnTypeCheckedChanged(null, null); //It is already checked by default
                }
            }
            finally
            {
                _init = false;
            }
        }
コード例 #11
0
ファイル: GdalProviderCtrl.cs プロジェクト: kanbang/Colt
        public override void Bind(IEditorService service)
        {
            try
            {
                _init = true;
                _bSupportsResample = false;
                _service = service;
                _fs = (IFeatureSource)_service.GetEditedResource();

                var provInfo = _service.FeatureService.GetFeatureProvider("OSGeo.Gdal"); //NOXLATE
                foreach (var prop in provInfo.ConnectionProperties)
                {
                    if (prop.Name == "ResamplingMethod") //NOXLATE
                    {
                        chkResamplingMethod.Visible =
                            cmbResamplingMethod.Visible =
                                cmbResamplingMethod.Enabled = true;

                        cmbResamplingMethod.DataSource = new List<string>(prop.Value);
                        var method = _fs.GetConnectionProperty("ResamplingMethod"); //NOXLATE
                        if (!string.IsNullOrEmpty(method))
                        {
                            chkResamplingMethod.Checked = true;
                            cmbResamplingMethod.SelectedItem = method;
                        }
                        else
                        {
                            cmbResamplingMethod.SelectedIndex = 0;
                            chkResamplingMethod.Checked = false;
                        }
                        _bSupportsResample = true;
                        break;
                    }
                }

                cmbResamplingMethod.Enabled = chkResamplingMethod.Checked;

                _sing.Bind(service);
                _comp.Bind(service);
                if (!string.IsNullOrEmpty(_fs.GetConfigurationContent()))
                    rdComposite.Checked = true;
                else
                    OnTypeCheckedChanged(null, null); //It is already checked by default
            }
            finally
            {
                _init = false;
            }
        }
コード例 #12
0
        public override void Bind(IEditorService service)
        {
            _init = true;
            try
            {
                _service = service;
                _service.RegisterCustomNotifier(this);
                _fs = (IFeatureSource)_service.GetEditedResource();

                txtFeatureServer.Text = _fs.GetConnectionProperty("FeatureServer"); //NOXLATE
                txtUsername.Text      = _fs.GetConnectionProperty("Username");      //NOXLATE
                txtPassword.Text      = _fs.GetConnectionProperty("Password");      //NOXLATE

                //A new WMS Feature Source will have no configuration document
                if (service.IsNew)
                {
                    errorProvider.SetError(btnAdvanced, Strings.WarningUnconfiguredWmsFeatureSource);
                }
            }
            finally
            {
                _init = false;
            }
        }
コード例 #13
0
        private void InitGrid()
        {
            grdConnectionParameters.Rows.Clear();
            grdConnectionParameters.Columns.Clear();
            var prov = _service.CurrentConnection.FeatureService.GetFeatureProvider(_fs.Provider);

            var colName = new DataGridViewColumn();

            colName.Name         = "COL_NAME"; //NOXLATE
            colName.HeaderText   = Strings.ColHeaderName;
            colName.ReadOnly     = true;
            colName.CellTemplate = new DataGridViewTextBoxCell();
            var colValue = new DataGridViewColumn();

            colValue.Name         = "COL_VALUE"; //NOXLATE
            colValue.HeaderText   = Strings.ColHeaderValue;
            colValue.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            colValue.CellTemplate = new DataGridViewTextBoxCell();

            grdConnectionParameters.Columns.Add(colName);
            grdConnectionParameters.Columns.Add(colValue);

            foreach (var p in prov.ConnectionProperties)
            {
                var row      = new DataGridViewRow();
                var nameCell = new DataGridViewTextBoxCell();
                nameCell.Value       = p.Name;
                nameCell.ToolTipText = p.LocalizedName;

                var currentValue           = _fs.GetConnectionProperty(p.Name);
                DataGridViewCell valueCell = null;
                if (p.Enumerable)
                {
                    valueCell       = new DataGridViewTextBoxCell();
                    valueCell.Tag   = p;
                    valueCell.Value = currentValue;
                }
                else
                {
                    valueCell       = new DataGridViewTextBoxCell();
                    valueCell.Tag   = p;
                    valueCell.Value = currentValue;
                }

                if (string.IsNullOrEmpty(currentValue) && !string.IsNullOrEmpty(p.DefaultValue))
                {
                    valueCell.Value = p.DefaultValue;
                    _fs.SetConnectionProperty(p.Name, p.DefaultValue);
                }

                row.Cells.Add(nameCell);
                row.Cells.Add(valueCell);

                if (p.Protected)
                {
                    pwdCells.Add(valueCell);
                }

                grdConnectionParameters.Rows.Add(row);
            }
        }
コード例 #14
0
        public override void Bind(IEditorService service)
        {
            _init    = true;
            _service = service;
            _fs      = (IFeatureSource)_service.GetEditedResource();

            resDataCtrl.Init(service);
            if (_fs.UsesEmbeddedDataFiles)
            {
                var df = _fs.GetEmbeddedDataName();
                resDataCtrl.MarkedFile = df;
            }

            var values = _fs.GetConnectionProperties();

            txtDataSource.Text  = values[P_DATASOURCE];
            chkReadOnly.Checked = values[P_READONLY] == "TRUE";                                   //NOXLATE

            var prov = _service.CurrentConnection.FeatureService.GetFeatureProvider("OSGeo.OGR"); //NOXLATE

            foreach (var p in prov.ConnectionProperties.Where(p => p.Name != P_DATASOURCE && p.Name != P_READONLY))
            {
                var row      = new DataGridViewRow();
                var nameCell = new DataGridViewTextBoxCell();
                nameCell.Value       = p.Name;
                nameCell.ToolTipText = p.LocalizedName;

                var currentValue           = _fs.GetConnectionProperty(p.Name);
                DataGridViewCell valueCell = null;
                if (p.Enumerable)
                {
                    valueCell       = new DataGridViewTextBoxCell();
                    valueCell.Tag   = p;
                    valueCell.Value = currentValue;
                }
                else
                {
                    valueCell       = new DataGridViewTextBoxCell();
                    valueCell.Tag   = p;
                    valueCell.Value = currentValue;
                }

                if (string.IsNullOrEmpty(currentValue) && !string.IsNullOrEmpty(p.DefaultValue))
                {
                    valueCell.Value = p.DefaultValue;
                    _fs.SetConnectionProperty(p.Name, p.DefaultValue);
                }

                row.Cells.Add(nameCell);
                row.Cells.Add(valueCell);

                if (p.Protected)
                {
                    pwdCells.Add(valueCell);
                }

                grdOtherProperties.Rows.Add(row);
            }

            _init = false;
        }
コード例 #15
0
        public override void Bind(IEditorService service)
        {
            _bChangedUsername       = false;
            _bChangedPassword       = false;
            _service                = service;
            _service.BeforeSave    += OnBeforeSave;
            _service.BeforePreview += OnBeforePreview;
            _service.RegisterCustomNotifier(this);
            _fs = _service.GetEditedResource() as IFeatureSource;

            //Set the field values
            txtService.Text = _fs.GetConnectionProperty("Service"); //NOXLATE

            //We're gonna follow MG Studio behaviour here which is: Never load the password
            //and auto trigger dirty state.
            if (!_service.IsNew)
            {
                txtUsername.Text = _fs.GetEncryptedUsername(_service.CurrentConnection) ?? _fs.GetConnectionProperty("Username"); //NOXLATE
                txtPassword.Text = GenerateRandomFakeString();
            }

            //Set initial value of data store if possible
            var dstore = _fs.GetConnectionProperty("DataStore"); //NOXLATE

            txtDataStore.Text = dstore;

            //As our connection properties are not CLR properties,
            //"manually" bind these fields
            txtService.TextChanged += (s, e) =>
            {
                _fs.SetConnectionProperty("Service", txtService.Text); //NOXLATE
            };

            txtUsername.TextChanged += (s, e) =>
            {
                _bChangedUsername = true;
                if (string.IsNullOrEmpty(txtUsername.Text))
                {
                    _fs.SetConnectionProperty("Username", null); //NOXLATE
                }
                else
                {
                    _fs.SetConnectionProperty("Username", txtUsername.Text); //NOXLATE
                }
            };

            txtPassword.TextChanged += (s, e) =>
            {
                _bChangedPassword = true;
                if (string.IsNullOrEmpty(txtPassword.Text))
                {
                    _fs.SetConnectionProperty("Password", null); //NOXLATE
                }
                else
                {
                    _fs.SetConnectionProperty("Password", txtPassword.Text); //NOXLATE
                }
            };

            txtDataStore.TextChanged += (s, e) =>
            {
                _fs.SetConnectionProperty("DataStore", txtDataStore.Text); //NOXLATE
            };
        }
コード例 #16
0
 internal void InitDefaults()
 {
     txtPath.Text = _fs.GetConnectionProperty("DefaultRasterFileLocation"); //NOXLATE
 }
コード例 #17
0
ファイル: RdbmsBaseCtrl.cs プロジェクト: kanbang/Colt
        public override void Bind(IEditorService service)
        {
            _bChangedUsername = false;
            _bChangedPassword = false;
            _service = service;
            _service.BeforeSave += OnBeforeSave;
            _service.BeforePreview += OnBeforePreview;
            _service.RegisterCustomNotifier(this);
            _fs = _service.GetEditedResource() as IFeatureSource;

            //Set the field values
            txtService.Text = _fs.GetConnectionProperty("Service"); //NOXLATE

            //We're gonna follow MG Studio behaviour here which is: Never load the password
            //and auto trigger dirty state.
            if (!_service.IsNew)
            {
                txtUsername.Text = _fs.GetEncryptedUsername() ?? _fs.GetConnectionProperty("Username"); //NOXLATE
                txtPassword.Text = GenerateRandomFakeString();
            }

            //Set initial value of data store if possible
            var dstore = _fs.GetConnectionProperty("DataStore"); //NOXLATE
            txtDataStore.Text = dstore;

            //As our connection properties are not CLR properties,
            //"manually" bind these fields
            txtService.TextChanged += (s, e) =>
            {
                _fs.SetConnectionProperty("Service", txtService.Text); //NOXLATE
            };

            txtUsername.TextChanged += (s, e) =>
            {
                _bChangedUsername = true;
                if (string.IsNullOrEmpty(txtUsername.Text))
                    _fs.SetConnectionProperty("Username", null); //NOXLATE
                else
                    _fs.SetConnectionProperty("Username", txtUsername.Text); //NOXLATE
            };

            txtPassword.TextChanged += (s, e) =>
            {
                _bChangedPassword = true;
                if (string.IsNullOrEmpty(txtPassword.Text))
                    _fs.SetConnectionProperty("Password", null); //NOXLATE
                else
                    _fs.SetConnectionProperty("Password", txtPassword.Text); //NOXLATE
            };

            txtDataStore.TextChanged += (s, e) =>
            {
                _fs.SetConnectionProperty("DataStore", txtDataStore.Text); //NOXLATE
            };
        }