Пример #1
0
        public QueryThemeTable(ILayer layer, string name) : this()
        {
            if (layer == null)
            {
                return;
            }

            base.Text = name;

            _layerID     = layer.ID;
            _datasetID   = layer.DatasetID;
            _queryFields = new QueryThemeQueryFieldDef();
            _visFields   = new QueryThemeVisibleFieldDef();
        }
Пример #2
0
        public void Load(IPersistStream stream)
        {
            base.Text  = (string)stream.Load("Text", "");
            _layerID   = (int)stream.Load("LayerID", -1);
            _datasetID = (int)stream.Load("DatasetID", -1);

            _queryFields = stream.Load("FieldDefs", null, new QueryThemeQueryFieldDef()) as QueryThemeQueryFieldDef;
            if (_queryFields == null)
            {
                _queryFields = new QueryThemeQueryFieldDef();
            }
            _visFields = stream.Load("VisibleFieldDefs", null, new QueryThemeVisibleFieldDef()) as QueryThemeVisibleFieldDef;
            if (_visFields == null)
            {
                _visFields = new QueryThemeVisibleFieldDef();
            }
        }
Пример #3
0
        private void treeQueries_AfterSelect(object sender, TreeViewEventArgs e)
        {
            btnAddTable.Enabled      = treeQueries.SelectedNode is QueryTheme && ((QueryTheme)treeQueries.SelectedNode).Type == QueryTheme.NodeType.query;
            tabControlLayers.Visible = treeQueries.SelectedNode is QueryThemeTable;
            dgQueries.Visible        = treeQueries.SelectedNode is QueryTheme;

            TreeNode node = treeQueries.SelectedNode;

            if (node is QueryTheme)
            {
                StoreFieldDefs();
                DataTable tab = ((QueryTheme)node).PromptDef;

                dgQueries.DataSource = tab;
            }
            else if (node is QueryThemeTable)
            {
                #region Query Fields
                StoreFieldDefs();
                dgLayers.Rows.Clear();

                IFeatureLayer layer = ((QueryThemeTable)node).GetLayer(_doc) as IFeatureLayer;
                if (layer != null)
                {
                    colField.Items.Clear();
                    if (layer.Fields != null)
                    {
                        foreach (IField field in layer.Fields.ToEnumerable())
                        {
                            colField.Items.Add(field.name);
                        }
                    }
                }
                QueryTheme theme = node.Parent as QueryTheme;
                if (theme == null && theme.PromptDef == null)
                {
                    return;
                }

                colPrompt.Items.Clear();
                foreach (DataRow row in theme.PromptDef.Select())
                {
                    colPrompt.Items.Add(row["Prompt"].ToString());
                }

                foreach (DataRow row in ((QueryThemeTable)node).QueryFieldDef.Rows)
                {
                    try
                    {
                        string field    = row["Field"].ToString();
                        string op       = row["Operator"].ToString();
                        int    promptID = (int)row["Prompt"];

                        if (colField.Items.IndexOf(field) == -1)
                        {
                            field = "";
                        }
                        if (colOperator.Items.IndexOf(op) == -1)
                        {
                            op = "";
                        }
                        DataRow[] rows = theme.PromptDef.Select("ID=" + promptID);
                        if (rows.Length == 0)
                        {
                            continue;
                        }

                        dgLayers.Rows.Add(
                            new object[] { field, rows[0]["Prompt"], op });
                    }
                    catch { }
                }
                #endregion

                #region Visible Fields
                if (((QueryThemeTable)node).VisibleFieldDef != null && layer != null && layer.Fields != null)
                {
                    QueryThemeVisibleFieldDef visFields = ((QueryThemeTable)node).VisibleFieldDef;

                    chkUseStandard.Checked = visFields.UseDefault;

                    cmbPrimaryField.Items.Clear();
                    dgVisibleFields.Rows.Clear();

                    foreach (IField field in layer.Fields.ToEnumerable())
                    {
                        cmbPrimaryField.Items.Add(field.name);
                        if (field.name == visFields.PrimaryDisplayField ||
                            (visFields.PrimaryDisplayField == "" &&
                             layer.Fields.PrimaryDisplayField != null &&
                             field.name == layer.Fields.PrimaryDisplayField.name))
                        {
                            cmbPrimaryField.SelectedIndex = cmbPrimaryField.Items.Count - 1;
                        }

                        DataRow[] r = visFields.Select("Name='" + field.name + "'");
                        if (r.Length == 1)
                        {
                            dgVisibleFields.Rows.Add(new object[] { (bool)r[0]["Visible"], field.name, (string)r[0]["Alias"], field.type.ToString() });
                        }
                        else
                        {
                            dgVisibleFields.Rows.Add(new object[] { false, field.name, field.aliasname, field.type.ToString() });
                        }
                    }
                }
                #endregion

                _actTableNode = node as QueryThemeTable;
            }
        }