Ejemplo n.º 1
0
 private void InitGrid(RedComboBox[] comboboxes, RedContext context)
 {
     foreach(RedComboBox cb in comboboxes)
     {
         var row = new DataGridViewRow();
         var c1 = new DataGridViewTextBoxCell();
         c1.Value = cb.Name;
         DataGridViewCell c2;
         if (cb.query.ToLowerInvariant() == "textedit")
         {
             c2 = new DataGridViewTextBoxCell();
             c2.Value = "";
         }
         else
         {
             c2 = new DataGridViewComboBoxCell();
             var t = cb.GetValues(context);
             foreach (DataRow r in t.Rows)
             {
                 (c2 as DataGridViewComboBoxCell).Items.Add(r[0].ToString());
             }
             (c2 as DataGridViewComboBoxCell).Value = (c2 as DataGridViewComboBoxCell).Items[0];
         }
         c2.ReadOnly = false;
         row.Cells.Add(c1);
         row.Cells.Add(c2);
         dataGridView1.Rows.Add(row);
     }
 }
Ejemplo n.º 2
0
 //Grid View Combobox column
 public static void fillCatalogValueGridViewComboNew(System.Windows.Forms.DataGridViewComboBoxCell cmb, string catalogvalue)
 {
     try
     {
         cmb.Items.Clear();
         CatalogueValueDB      dbrecord                  = new CatalogueValueDB();
         List <cataloguevalue> CatalogueValues           = dbrecord.getCatalogueValues();
         List <Structures.GridViewComboBoxItem> ItemList =
             new List <Structures.GridViewComboBoxItem>();
         foreach (cataloguevalue catval in CatalogueValues)
         {
             if (catval.catalogueID.Equals(catalogvalue) && catval.status == 1)
             {
                 Structures.GridViewComboBoxItem ch =
                     new Structures.GridViewComboBoxItem(catval.description, catval.catalogueValueID);
                 cmb.Items.Add(ch);
             }
         }
         cmb.DisplayMember = "Name";  // Name Property will show(Editing)
         cmb.ValueMember   = "Value"; // Value Property will save(Saving)
     }
     catch (Exception ex)
     {
         MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
     }
 }
Ejemplo n.º 3
0
        private DataGridViewRow CreateRow(Item item)
        {
            var row = new DataGridViewRow();

            row.Cells.Add(new DataGridViewTextBoxCell { Value = item.Name });
            row.Cells.Add(new DataGridViewButtonCell { Value = "Delete" });

            var isInShoppingList = RecipeBooks.Current.IsInShoppingList(item, excludeIfInRecipe: true);
            row.Cells.Add(new DataGridViewTextBoxCell
            {
                Value = isInShoppingList
                    ? RecipeBooks.Current.ShoppingList
                        .Where(sli => sli.Item.Id == item.Id && sli.Recipe == null)
                        .Sum(sli => sli.Quantity)
                    : 1
            });

            var unitCell = new DataGridViewComboBoxCell { DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing };
            unitCell.Items.AddRange(item.UnitType.Units().Select(u => u.GuiInfo().DisplayText).ToArray());
            unitCell.Value = item.DefaultBuyUnit.GuiInfo().DisplayText;
            row.Cells.Add(unitCell);

            row.Cells.Add(new DataGridViewButtonCell { Value = isInShoppingList ? REMOVE_FROM_LIST : ADD_TO_LIST });
            row.Cells.Add(new DataGridViewTextBoxCell { Value = item.Id });

            return row;
        }
 private void AddItems(string[] panels, int sections)
 {
     foreach (string panel in panels)
     {
         DataGridViewComboBoxCell reff = new DataGridViewComboBoxCell();
         DataGridViewTextBoxCell txt2A = new DataGridViewTextBoxCell();
         DataGridViewRow dataGridRow = new DataGridViewRow();
         //ComboBox reff = new ComboBox();
         reff.MaxDropDownItems = sections;
         //reff.DataSource =
         txt2A.Value = panel;
         for (int i = 1; i <= sections; i++)
             reff.Items.Add(i);
         try
         {
             dataGridRow.Cells.Add(txt2A);
             dataGridRow.Cells.Add(reff);
             Grid.Rows.Add(dataGridRow);
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message, "Error");
         }
     }
 }
Ejemplo n.º 5
0
        private void InitDefaultValues()
        {
            List <string> finishingTypeNames = (from type in FinishingTypes select type.Name).ToList();

            finishingTypeNames.Insert(0, "");
            for (int i = 0; i < Rooms.Count; i++)
            {
                this.dataGridView1.Rows.Add();
                this.dataGridView1.Rows[i].Cells["RoomNumber"].Value = Rooms[i].LookupParameter("Номер").AsString();
                this.dataGridView1.Rows[i].Cells["RoomName"].Value   = Rooms[i].LookupParameter("Имя").AsString();
                this.dataGridView1.Rows[i].Cells["RoomId"].Value     = Rooms[i].Id.IntegerValue;
                /// Типы отделок
                WF.DataGridViewComboBoxCell cb = this.dataGridView1.Rows[i].Cells["FinishingType"] as WF.DataGridViewComboBoxCell;
                cb.DataSource = finishingTypeNames;
                Parameter p = Rooms[i].get_Parameter(FinishingRoomParameter);
                if (p != null && p.HasValue && cb.Items.Contains(p.AsString()))
                {
                    cb.Value = p.AsString();
                }
                /// связанный элемент
                Parameter pFloorId    = Rooms[i].LookupParameter(FinishingIdParameterName);
                int       floorId     = (pFloorId != null && pFloorId.HasValue) ? pFloorId.AsInteger() : ElementId.InvalidElementId.IntegerValue;
                Floor     linkedFloor = Rooms[i].Document.GetElement(new ElementId(floorId)) as Floor;
                if (linkedFloor != null)
                {
                    this.dataGridView1.Rows[i].Cells["FinishingId"].Value     = floorId;
                    this.dataGridView1.Rows[i].Cells["FinishingOffset"].Value = linkedFloor.get_Parameter(FinishingOffsetParameter).AsDouble() * 304.8;
                }
                else
                {
                    this.dataGridView1.Rows[i].Cells["FinishingId"].Value     = -1;
                    this.dataGridView1.Rows[i].Cells["FinishingOffset"].Value = 0f;
                }
            }
        }
Ejemplo n.º 6
0
        private void FilterPropertiesDlg_Load(object sender, EventArgs e)
        {
            // заполняем таблицу
            foreach (var item in filter.ColumnFilters.Values.ToList())
            {
                var row = new DataGridViewRow();

                row.Cells.Add(new DataGridViewTextBoxCell { Value = item.PropInfo.Name });
                row.Cells.Add(new DataGridViewTextBoxCell { Value = item.Title });

                if (item.EnabledValues.Length > 0)
                {
                    var valueCol = new DataGridViewComboBoxCell();
                    valueCol.Items.AddRange(item.EnabledValues.ToArray());
                    row.Cells.Add(valueCol);
                }
                else
                    row.Cells.Add(new DataGridViewTextBoxCell {Value = item.Value ?? string.Empty});

                var criteriasCol = new DataGridViewComboBoxCell();
                criteriasCol.Items.AddRange(item.GetStringCriterias());
                if (item.Criterias != ColumnFilterCriteria.Нет)
                    criteriasCol.Value = item.Criterias.ToString();
                else
                    criteriasCol.Value = criteriasCol.Items[0];
                row.Cells.Add(criteriasCol);
                grid.Rows.Add(row);
            }
        }
		public DataGridViewComboBoxColumn ()
		{
			CellTemplate = new DataGridViewComboBoxCell();
			((DataGridViewComboBoxCell) CellTemplate).OwningColumnTemplate = this;
			SortMode = DataGridViewColumnSortMode.NotSortable;
			autoComplete = true;
			displayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
			displayStyleForCurrentCellOnly = false;
		}
		void SelectElement(DataGridViewComboBoxCell box, string itemName)
		{
			if (box.Items.IndexOf(itemName) == -1) {
				if (itemName == "Any CPU" && box.Items.IndexOf("AnyCPU") >= 0) {
					box.Value = "AnyCPU";
				} else {
					box.Value = box.Items[0];
				}
			} else {
				box.Value = itemName;
			}
		}
        public void addRow(DataGridView view, FileDirectory fd, string config)
        {
            DirectoryDataGridViewRow directoryDataGridViewRow = new DirectoryDataGridViewRow(fd);

            string text = DirectoryHandler.getInstance().getPathFromParent(fd, fd.getPath());
            DirectoryDataGridViewTextBoxCell directories = new DirectoryDataGridViewTextBoxCell(text);
            DataGridViewComboBoxCell commands = new DataGridViewComboBoxCell();
            DataGridViewCheckBoxCell include = new DataGridViewCheckBoxCell();
            DataGridViewCheckBoxCell echo = new DataGridViewCheckBoxCell();
            DataGridViewCheckBoxCell display = new DataGridViewCheckBoxCell();
            DataGridViewCheckBoxCell autoExit = new DataGridViewCheckBoxCell();
            DataGridViewCheckBoxCell waitForExit = new DataGridViewCheckBoxCell();
            if (text.Length > 50)
            {
                int i = text.Length;
                int num = 20;
                while (i > 50)
                {
                    i--;
                    num++;
                }
                text = text.Substring(0, 5) + "....." + text.Substring(num);
            }
            directories.Value = text;

            foreach(Command c in PreloadedConfigurationGetterService.getInstance().getCommandsFromXMLConfiguration(config)){
                commands.Items.Add(c.getName());
            }
            if(commands.Items.Count == 0) return;
            commands.Value = commands.Items[0];

            include.Value = true;
            echo.Value = true;
            display.Value = true;
            autoExit.Value = true;
            waitForExit.Value = true;
            directoryDataGridViewRow.Cells.Add(directories);
            directoryDataGridViewRow.Cells.Add(commands);
            directoryDataGridViewRow.Cells.Add(include);
            directoryDataGridViewRow.Cells.Add(display);
            directoryDataGridViewRow.Cells.Add(autoExit);
            directoryDataGridViewRow.Cells.Add(waitForExit);

            directories.ReadOnly = true;
            commands.ReadOnly = false;
            include.ReadOnly = false;
            echo.ReadOnly = false;
            display.ReadOnly = false;
            autoExit.ReadOnly = false;
            view.Rows.Add(directoryDataGridViewRow);
        }
Ejemplo n.º 10
0
        public static void BindComboBoxCellDataSource(DataGridViewComboBoxCell cell, string[][] dataSource)
        {
            if (dataSource == null ||
                dataSource.Length.Equals(0))
            {
                cell.DataSource = null;
                return;
            }
            List<DataSourceNode> dataSourceNodeList = BindArrayDataHelper.GetDataSource(dataSource, 0, 1);

            cell.DataSource = dataSourceNodeList;
            cell.DisplayMember = "Text";
            cell.ValueMember = "Value";
        }
Ejemplo n.º 11
0
 private void AddGenerationParameterAsComboBox(String g, String v, Type t)
 {
     DataGridViewRow r = new DataGridViewRow();
     DataGridViewCell rColumn1 = new DataGridViewTextBoxCell();
     DataGridViewComboBoxCell rColumn2 = new DataGridViewComboBoxCell();
     rColumn2.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
     rColumn1.Value = g;
     rColumn2.Items.Clear();
     string[] mt = Enum.GetNames(t);
     rColumn2.Items.AddRange(mt);
     rColumn2.Value = v;
     r.Cells.Add(rColumn1);
     r.Cells.Add(rColumn2);
     generationParametersTable.Rows.Add(r);
 }
Ejemplo n.º 12
0
 public static void fillAcceptanceStatusGridViewCombo(System.Windows.Forms.DataGridViewComboBoxCell cmb)
 {
     try
     {
         cmb.Items.Clear();
         for (int i = 0; i < Main.AcceptanceStatus.GetLength(0); i++)
         {
             cmb.Items.Add(Main.AcceptanceStatus[i, 1]);
         }
     }
     catch (Exception)
     {
         MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
     }
 }
Ejemplo n.º 13
0
        private void FreshDG()
        {
            DataSet datasetAlg = new DataSet();

            DG_Forecast.Rows.Clear();
            dataset.Clear();
            dataset = ServiceContainer.GetService<IGasDAL>().QueryData("EquipName", "EquipTypeSlet");
            int j = 0;
            foreach (DataRow dr in dataset.Tables[0].Rows)
            {

                DataGridViewRow row = new DataGridViewRow();
                DataGridViewTextBoxCell txtboxcell0 = new DataGridViewTextBoxCell();
                txtboxcell0.Value = dataset.Tables[0].Rows[j]["EquipName"];
                row.Cells.Add(txtboxcell0);

                DataGridViewComboBoxCell comboxcell = new DataGridViewComboBoxCell();
                datasetAlg = ServiceContainer.GetService<IGasDAL>().QueryData("EquipAlgSlet", "EquipName", dataset.Tables[0].Rows[j]["EquipName"].ToString());
                int i = 0;
                foreach (DataRow dr2 in datasetAlg.Tables[0].Rows)
                {

                    comboxcell.Items.Add(datasetAlg.Tables[0].Rows[i]["AlgName"]);

                    i++;
                }
                row.Cells.Add(comboxcell);
                //comboxcell.DisplayMember=;

                DataGridViewComboBoxCell comboxcel2 = new DataGridViewComboBoxCell();
                comboxcel2.Items.Add("5");
                comboxcel2.Items.Add("10");
                row.Cells.Add(comboxcel2);
                comboxcel2.Value = "10";

                DataGridViewComboBoxCell comboxcel3 = new DataGridViewComboBoxCell();
                comboxcel3.Items.Add("15");
                comboxcel3.Items.Add("30");
                comboxcel3.Items.Add("60");
                row.Cells.Add(comboxcel3);
                comboxcel3.Value = "30";

                DG_Forecast.Rows.Add(row);

                j++;
            }
        }
Ejemplo n.º 14
0
 public void CreaColumna(string NameColumna,string HeaderColumna)
 {
     DataGridViewComboBoxColumn column = new DataGridViewComboBoxColumn();
     column.Name = NameColumna;
     column.HeaderText = HeaderColumna;
     //DataGridViewCell cell = new DataGridViewTextBoxCell();
     DataGridViewCell cell = new DataGridViewComboBoxCell();
     cell.Style.BackColor = Color.White;
     column.CellTemplate = cell;
     column.FlatStyle = FlatStyle.Popup;
     dataGridView1.Columns.Add(column);
     if (NameColumna == "NewPuesto")
         cargaPuestos(column);
     else if (NameColumna == "Rancho")
         cargaRancho(column);
     else
         column.Items.AddRange("P", "E", "J", "EX");
 }
Ejemplo n.º 15
0
        private void UpdateDisplay()
        {
            IVIHandler.Reset();
            IviHandler = IVIHandler.Instance;
            IviHandler.IviConfigStore.Deserialize(IviHandler.IviConfigStore.MasterLocation);

            AdapterConfigList.Rows.Clear();
            foreach (IIviSoftwareModule2 SoftwareModule in IviHandler.IviConfigStore.SoftwareModules)
            {
                if (!SoftwareModule.Name.StartsWith("nis"))
                {
                    DataGridViewRow Row = new DataGridViewRow();
                    DataGridViewCheckBoxCell UpdateCheckBox = new DataGridViewCheckBoxCell();
                    DataGridViewTextBoxCell SoftwareModuleTextBox = new DataGridViewTextBoxCell();
                    DataGridViewTextBoxCell CurrentAdapterClassTextBox = new DataGridViewTextBoxCell();
                    DataGridViewComboBoxCell NewAdapterClassComboBox = new DataGridViewComboBoxCell();

                    UpdateCheckBox.Value = false;
                    SoftwareModuleTextBox.Value = SoftwareModule.Name;
                    string className = SoftwareModule.AssemblyQualifiedClassName;

                    if (!className.Equals(string.Empty))
                    {
                        Type type = Type.GetType(SoftwareModule.AssemblyQualifiedClassName);
                        if (type != null)
                        {
                            CurrentAdapterClassTextBox.Value = type.Name;
                        }
                    }

                    NewAdapterClassComboBox.Items.Add(string.Empty);
                    NewAdapterClassComboBox.Items.AddRange(IviCAdapterList);
                    NewAdapterClassComboBox.Value = NewAdapterClassComboBox.Items[0];

                    Row.Cells.Add(UpdateCheckBox);
                    Row.Cells.Add(SoftwareModuleTextBox);
                    Row.Cells.Add(CurrentAdapterClassTextBox);
                    Row.Cells.Add(NewAdapterClassComboBox);

                    AdapterConfigList.Rows.Add(Row);
                }
            }
        }
Ejemplo n.º 16
0
        public void setData(oFunction functionBase, oSingleData measuredData)
        {
            this.functionBase = functionBase;
            this.measuredData = measuredData;
            if (functionBase == null)
            {
                this.Rows.Clear();
                return;
            }
            this.argumentClasses = functionBase.getArgumentList();

            // Cleanup this datagridview)
            this.Rows.Clear();

            // Build the combobox selection options
            string[] options = Enum.GetNames(typeof(DISPLAY_TYPE));

            // Fill out this datagridview based on the supplied data
            ARGUMENT_STRING_COLLECTION stringData = functionBase.getArgumentString(measuredData);
            DataGridViewRow[] newRows = new DataGridViewRow[argumentClasses.Count];
            for( int i = 0; i < argumentClasses.Count; i++ )
            {
                // Add this row
                newRows[i] = new DataGridViewRow();

                // Add the name cell
                newRows[i].Cells[newRows[i].Cells.Add(new DataGridViewTextBoxCell())].Value = stringData.names[i];

                // Add the type cell combobox
                DataGridViewComboBoxCell comboBox = new DataGridViewComboBoxCell();
                comboBox.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox;
                comboBox.Value = Enum.GetName(typeof(DISPLAY_TYPE), argumentClasses[i].displayMethod);
                comboBox.Items.AddRange(options);
                newRows[i].Cells.Add(comboBox);

                // Add the value cell
                newRows[i].Cells[newRows[i].Cells.Add(new DataGridViewTextBoxCell())].Value = stringData.values[i];
            }

            // Add the new rows
            this.Rows.AddRange(newRows);
        }
Ejemplo n.º 17
0
        public RowEditorDlg(MetaDataRow mdrow)
        {
            this.mdrow = mdrow;
            InitializeComponent();

            for (int i = 0; i < mdrow.Parts.Length; i++)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.Cells.Add(new DataGridViewTextBoxCell() { Value = i.ToString() });
                row.Cells.Add(new DataGridViewTextBoxCell() { Value = (Convert.ToUInt64(mdrow.Parts[i])).ToString("X" +(Marshal.SizeOf(mdrow.Parts[i]))*2)  });
                DataGridViewComboBoxCell cbox = new DataGridViewComboBoxCell();
                cbox.Items.Add("Byte");
                cbox.Items.Add("UInt16");
                cbox.Items.Add("UInt32");
                cbox.Items.Add("UInt64");
                cbox.Value = mdrow.Parts[i].GetType().Name;
                row.Cells.Add(cbox);
                dataGridView1.Rows.Add(row);
            }
        }
Ejemplo n.º 18
0
        public ParameterInputForm(
			IEnumerable<string[]> required,
			IEnumerable<string[]> optional
		)
            : this()
        {
            foreach (string[] a in required) grdParameters.Rows.Add(a[0], a[1]);
            foreach (string[] a in optional)
            {
                string[] options = a[2].Split('|');
                grdParameters.Rows.Add(a[0], a[1], a[2]);
                if (options.Length > 1)
                {
                    var cbb = new DataGridViewComboBoxCell();
                    foreach (string o in options) cbb.Items.Add(o);
                    string s = a[1] ?? "";
                    if (cbb.Items.Contains(s)) cbb.Value = s;
                    grdParameters[1, grdParameters.Rows.Count-1] = cbb;
                }
            }
        }
        public void Setup(string FirstHeader, IEnumerable<object> FirstList, string SecondHeader, IEnumerable<object> SecondList, DataTable sourceData)
        {
            this.InitializeComponent();
            this.FirstList = FirstList;
            this.SecondList = SecondList;

            this.AllowUserToAddRows = false;
            this.AllowUserToDeleteRows = false;

            this.Columns.Clear();
            var col1 = new DataGridViewTextBoxColumn();
            col1.ReadOnly = true;
            this.Columns.Add(col1);

            var data = sourceData != null
                    ? sourceData
                    : (from x in FirstList
                       from y in new object[] { null }
                       select new { x, y }).ToDataTable("Data");

            var secondCol = new DataGridViewComboBoxColumn();
            var secondTemplate = new DataGridViewComboBoxCell();
            secondTemplate.DataSource = SecondList.Select(i => new { i }).ToDataTable("Combo Items");
            secondTemplate.DisplayMember = "i";
            secondCol.CellTemplate = secondTemplate;

            this.Columns.Add(secondCol);

            this.Columns[0].Width = (int)(this.Width * 0.40);
            this.Columns[1].Width = (int)(this.Width * 0.40);
            this.Columns[0].HeaderText = FirstHeader;
            this.Columns[1].HeaderText = SecondHeader;
            this.Columns[0].DataPropertyName = "x";
            this.Columns[1].DataPropertyName = "y";

            this.DataSource = data;
            this.Data = data;

            // this.DataError += new DataGridViewDataErrorEventHandler(AssociationGridView_DataError);
        }
Ejemplo n.º 20
0
 private DataRow CreateNewRow(DataTable dt)
 {
     DataRow dr;
     List<object> items = new List<object>();
     dr = dt.NewRow();
     DataGridViewRow row;
     DataGridViewCell cell;
     DataColumn primaryKeyColumn = dt.PrimaryKey.Length == 0 ? null : dt.PrimaryKey[0];
     for (int i = 0; i < dt.Columns.Count; i++) {
         row = new DataGridViewRow();
         foreach (DataRelation dataRel in dt.ParentRelations) {
             if (dataRel.ChildColumns[0] == dt.Columns[i]) {
                 cell = new DataGridViewComboBoxCell();
                 foreach (DataRow drR in dbFile.Tables[dataRel.ParentColumns[0].Table.TableName].Rows) {
                     if (drR.RowState != DataRowState.Deleted) {
                         ((DataGridViewComboBoxCell)cell).Items.Add(drR.ItemArray[dataRel.ParentColumns[0].Ordinal]);
                     }
                     if (((DataGridViewComboBoxCell)cell).Items.Count > 0) {
                         break;
                     }
                 }
                 row.Cells.Add(cell);
                 break;
             }
         }
         if (row.Cells.Count == 0) {
             row.Cells.Clear();
             if (dt.Columns[i].DataType == typeof(bool)) {
                 cell = new DataGridViewCheckBoxCell();
                 row.Cells.Add(cell);
             } else if (dt.Columns[i].DataType == typeof(string)) {
                 cell = new DataGridViewTextBoxCell();
                 row.Cells.Add(cell);
             } else if (dt.Columns[i].DataType == typeof(int) || dt.Columns[i].DataType == typeof(float)) {
                 cell = new DataGridViewTextBoxCell();
                 row.Cells.Add(cell);
             } else {
                 cell = new DataGridViewTextBoxCell();
                 row.Cells.Add(cell);
             }
         }
         if (row.Cells[0] is DataGridViewComboBoxCell) {
             if (((DataGridViewComboBoxCell)row.Cells[0]).Items.Count > 0) {
                 ((DataGridViewComboBoxCell)row.Cells[0]).Value = ((DataGridViewComboBoxCell)row.Cells[0]).Items[0];
             } else {
                 ((DataGridViewComboBoxCell)row.Cells[0]).Items.Add(dt.Columns[i].DefaultValue);
                 ((DataGridViewComboBoxCell)row.Cells[0]).Value = dt.Columns[i].DefaultValue;
             }
         } else {
             row.Cells[0].Value = dt.Columns[i].DefaultValue;
         }
         row.Cells[0].ValueType = dt.Columns[i].DataType;
         // Set Up PrimaryKey Row Values for Validation
         if (dt.Columns[i] == primaryKeyColumn) {
             int largestIndex = 1;
             foreach (DataRow dRPK in dt.Rows) {
                 if (dRPK.RowState != DataRowState.Deleted) {
                     if (dRPK.ItemArray[i] is int) {
                         largestIndex = Math.Max(largestIndex, (int)dRPK.ItemArray[i]);
                     }
                 }
             }
             if (row.Cells[0].ValueType == typeof(int)) {
                 row.Cells[0].Value = largestIndex + 1;
             }
         }
         items.Add(row.Cells[0].Value);
     }
     // Finish
     dr.ItemArray = items.ToArray();
     return dr;
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Add the property to PropertyWindow.
        /// </summary>
        /// <param name="d">EcellData of property.</param>
        /// <param name="type">Type of property.</param>
        /// <returns>Row in DataGridView.</returns>
        DataGridViewRow AddProperty(EcellData d, string type)
        {
            DataGridViewRow row = new DataGridViewRow();
            DataGridViewTextBoxCell propNameCell = new DataGridViewTextBoxCell();
            DataGridViewCell propValueCell;
            propNameCell.Value = d.Name;
            row.Cells.Add(propNameCell);
            if (m_propDic == null || m_current.Type != Constants.xpathProcess
                || m_propDic.ContainsKey(d.Name))
            {
                propNameCell.Style.BackColor = Color.LightGray;
                propNameCell.Style.SelectionBackColor = Color.LightGray;
                propNameCell.ReadOnly = true;
            }
            else
            {
                propNameCell.ReadOnly = false;
                propNameCell.Style.BackColor = SystemColors.Window;
                propNameCell.Style.ForeColor = SystemColors.WindowText;
                propNameCell.Style.SelectionBackColor = SystemColors.Highlight;
                propNameCell.Style.SelectionForeColor = SystemColors.HighlightText;
            }

            if (d.Value == null) return null;

            if (d.Name == Constants.xpathExpression)
            {
                propValueCell = new DataGridViewOutOfPlaceEditableCell();
                propValueCell.Value = (string)d.Value;
                ((DataGridViewOutOfPlaceEditableCell)propValueCell).OnOutOfPlaceEditRequested =
                    delegate(DataGridViewOutOfPlaceEditableCell c)
                    {
                        string retval = ShowFormulatorDialog(c.Value == null ? "" : c.Value.ToString());
                        if (retval != null)
                        {
                            propValueCell.Value = retval;
                            UpdateExpression(retval);
                            return true;
                        }
                        return false;
                    };
            }
            else if (d.Name == Constants.xpathVRL)
            {
                propValueCell = new DataGridViewLinkCell();
                propValueCell.Value = MessageResources.LabelEdit;
            }
            else if (d.Name == Constants.xpathStepperID)
            {
                propValueCell = new DataGridViewComboBoxCell();
                bool isexist = false;
                string stepperName = d.Value.ToString();
                foreach (EcellObject obj in m_env.DataManager.GetStepper(m_current.ModelID))
                {
                    if (!string.IsNullOrEmpty(stepperName) &&
                        stepperName.Equals(obj.Key))
                    {
                        isexist = true;
                    }
                    ((DataGridViewComboBoxCell)propValueCell).Items.Add(obj.Key);
                }
                if (isexist)
                    propValueCell.Value = d.Value.ToString();
                m_stepperIDComboBox = (DataGridViewComboBoxCell)propValueCell;
            }
            else
            {
                propValueCell = new DataGridViewTextBoxCell();
                if (d.Value.IsDouble)
                {
                    propValueCell.Value = ((double)d.Value).ToString(m_env.DataManager.DisplayStringFormat);
                }
                else
                {
                    propValueCell.Value = (string)d.Value;
                }
            }
            row.Cells.Add(propValueCell);
            m_dgv.Rows.Add(row);

            if (d.Settable && !d.Name.Equals(Constants.xpathVRL))
            {
                propValueCell.ReadOnly = false;
            }
            else
            {
                propValueCell.ReadOnly = true;
                propValueCell.Style.ForeColor = SystemColors.GrayText;
            }
            propValueCell.Tag = d;

            return row;
        }
Ejemplo n.º 22
0
        public static void ParametersToDataGridView(DataGridView dg,
			IEcasParameterized p, IEcasObject objDefaults)
        {
            if(dg == null) throw new ArgumentNullException("dg");
            if(p == null) throw new ArgumentNullException("p");
            if(p.Parameters == null) throw new ArgumentException();
            if(objDefaults == null) throw new ArgumentNullException("objDefaults");
            if(objDefaults.Parameters == null) throw new ArgumentException();

            dg.Rows.Clear();
            dg.Columns.Clear();

            Color clrBack = dg.DefaultCellStyle.BackColor;
            Color clrValueBack = dg.DefaultCellStyle.BackColor;
            if(clrValueBack.GetBrightness() >= 0.5)
                clrValueBack = UIUtil.DarkenColor(clrValueBack, 0.075);
            else clrValueBack = UIUtil.LightenColor(clrValueBack, 0.075);

            dg.ColumnHeadersVisible = false;
            dg.RowHeadersVisible = false;
            dg.GridColor = clrBack;
            dg.BackgroundColor = clrBack;
            dg.DefaultCellStyle.SelectionBackColor = clrBack;
            dg.DefaultCellStyle.SelectionForeColor = dg.DefaultCellStyle.ForeColor;
            dg.EditMode = DataGridViewEditMode.EditOnEnter;
            dg.AllowDrop = false;
            dg.AllowUserToAddRows = false;
            dg.AllowUserToDeleteRows = false;
            dg.AllowUserToOrderColumns = false;
            dg.AllowUserToResizeColumns = false;
            dg.AllowUserToResizeRows = false;

            int nWidth = (dg.ClientSize.Width - UIUtil.GetVScrollBarWidth());
            dg.Columns.Add("Name", KPRes.FieldName);
            dg.Columns.Add("Value", KPRes.FieldValue);
            dg.Columns[0].Width = (nWidth / 2);
            dg.Columns[1].Width = (nWidth / 2);

            for(int i = 0; i < p.Parameters.Length; ++i)
            {
                EcasParameter ep = p.Parameters[i];

                dg.Rows.Add();
                DataGridViewRow row = dg.Rows[dg.Rows.Count - 1];
                DataGridViewCellCollection cc = row.Cells;

                Debug.Assert(cc.Count == 2);
                cc[0].Value = ep.Name;
                cc[0].ReadOnly = true;

                string strParam = EcasUtil.GetParamString(objDefaults.Parameters, i);
                DataGridViewCell c = null;

                switch(ep.Type)
                {
                    case EcasValueType.String:
                        c = new DataGridViewTextBoxCell();
                        c.Value = strParam;
                        break;

                    case EcasValueType.Bool:
                        c = new DataGridViewCheckBoxCell(false);
                        (c as DataGridViewCheckBoxCell).Value =
                            StrUtil.StringToBool(strParam);
                        break;

                    case EcasValueType.EnumStrings:
                        DataGridViewComboBoxCell cmb = new DataGridViewComboBoxCell();
                        cmb.Sorted = false;
                        cmb.DisplayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
                        int iFound = -1;
                        for(int e = 0; e < ep.EnumValues.ItemCount; ++e)
                        {
                            EcasEnumItem eei = ep.EnumValues.Items[e];
                            cmb.Items.Add(eei.Name);
                            if(eei.ID.ToString() == strParam) iFound = e;
                        }
                        if(iFound >= 0) cmb.Value = ep.EnumValues.Items[iFound].Name;
                        else if(ep.EnumValues.ItemCount > 0) cmb.Value = ep.EnumValues.Items[0].Name;
                        else { Debug.Assert(false); }
                        c = cmb;
                        break;

                    case EcasValueType.Int64:
                        c = new DataGridViewTextBoxCell();
                        c.Value = FilterTypeI64(strParam);
                        break;

                    case EcasValueType.UInt64:
                        c = new DataGridViewTextBoxCell();
                        c.Value = FilterTypeU64(strParam);
                        break;

                    default:
                        Debug.Assert(false);
                        break;
                }

                if(c != null) cc[1] = c;
                cc[1].ReadOnly = false;
                cc[1].Style.BackColor = clrValueBack;
                cc[1].Style.SelectionBackColor = clrValueBack;
            }
        }
        private void CarregaGridViewParametros()
        {
            dgParametros.Rows.Clear();
            foreach (var param in _parametros)
            {
                var row = new DataGridViewRow();

                var nome = new DataGridViewTextBoxCell { Value = param.ParameterName };
                var valor = new DataGridViewMaskedTextCell { Value = param.ParameterValue };
                var defineNull = new DataGridViewCheckBoxCell { Value = param.DefineNull };
                var lista = new DataGridViewComboBoxCell { DataSource = _tiposDadosParametros, DisplayMember = "Key", ValueMember = "Value", Value = "System.Object|" };
                row.Cells.Add(nome);
                row.Cells.Add(defineNull);
                row.Cells.Add(lista);
                row.Cells.Add(valor);

                dgParametros.Rows.Add(row);
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Add the non data property to DataGridView.
        /// </summary>
        /// <param name="propName">the property name.</param>
        /// <param name="propValue">the property value.</param>
        /// <param name="readOnly">the flag whether this property is readonly.</param>
        /// <returns>Added DataGridViewRow.</returns>
        DataGridViewRow AddNonDataProperty(string propName, string propValue, bool readOnly)
        {
            DataGridViewRow row = new DataGridViewRow();
            DataGridViewTextBoxCell propNameCell = new DataGridViewTextBoxCell();
            DataGridViewCell propValueCell = null;
            row.Cells.Add(propNameCell);
            propNameCell.Style.BackColor = Color.LightGray;
            propNameCell.Style.SelectionBackColor = Color.LightGray;
            propNameCell.ReadOnly = true;
            propNameCell.Value = propName;

            if (propName == Constants.xpathClassName)
            {
                if (m_current.Type == Constants.xpathSystem || m_current.Type == Constants.xpathVariable)
                {
                    propValueCell = new DataGridViewComboBoxCell();
                    ((DataGridViewComboBoxCell)propValueCell).Items.Add(propValue);
                    propValueCell.Value = propValue;
                }
                else if (m_current.Type == Constants.xpathText)
                {
                    propValueCell = new DataGridViewTextBoxCell();
                    propValueCell.Value = "Text";
                    readOnly = true; // forcefully marked as readonly
                }
                else if (m_current.Type == Constants.xpathStepper)
                {
                    propValueCell = new DataGridViewComboBoxCell();
                    bool isHit = false;
                    List<string> stepList = m_env.DMDescriptorKeeper.StepperDmList;
                    foreach (string sName in stepList)
                    {
                        ((DataGridViewComboBoxCell)propValueCell).Items.Add(sName);
                        if (sName == propValue)
                            isHit = true;
                    }

                    if (!isHit)
                    {
                        ((DataGridViewComboBoxCell)propValueCell).Items.Add(propValue);
                    }
                    propValueCell.Value = propValue;
                    DMDescriptor desc = m_env.DMDescriptorKeeper.GetDMDescriptor(Constants.xpathStepper, propValue);
                    if (desc != null)
                        propValueCell.ToolTipText = desc.Description;
                    else
                        propValueCell.ToolTipText = "";

                }
                else
                {
                    propValueCell = new DataGridViewComboBoxCell();
                    bool isHit = false;
                    List<string> procList = m_env.DMDescriptorKeeper.ProcessDmList;
                    foreach (string pName in procList)
                    {
                        ((DataGridViewComboBoxCell)propValueCell).Items.Add(pName);
                        if (pName == propValue)
                            isHit = true;
                    }

                    if (!isHit)
                    {
                        ((DataGridViewComboBoxCell)propValueCell).Items.Add(propValue);
                    }
                    propValueCell.Value = propValue;
                    DMDescriptor desc = m_env.DMDescriptorKeeper.GetDMDescriptor(Constants.xpathProcess, propValue);
                    if (desc != null)
                        propValueCell.ToolTipText = desc.Description;
                    else
                        propValueCell.ToolTipText = "";
                }
            }
            else
            {
                propValueCell = new DataGridViewTextBoxCell();
                propValueCell.Value = propValue;
            }
            row.Cells.Add(propValueCell);
            propValueCell.Tag = propName;
            propValueCell.ReadOnly = readOnly;
            if (readOnly)
                propValueCell.Style.ForeColor = SystemColors.GrayText;

            m_dgv.Rows.Add(row);
            m_nonDataProps.Add(propName);
            return row;
        }
Ejemplo n.º 25
0
    private void LoadRowsFromDatabase(int KategorieFilter, double pZuschlagProzent)
    {
      using (DataBaseDataContext dbContext = new DataBaseDataContext())
      {
        IQueryable<DB.Lager> x;

        if (KategorieFilter != 0)
        {
          x = dbContext.Lager.Where(l => l.Kategorie.Equals(KategorieFilter));
        }
        else
        {
          x = dbContext.Lager.Select(s => s);
        }

        foreach (var lager in x)
        {
          // Neue Zeile erzeugen
          var dataGridRow = new DataGridViewRow();

          // Zellen erzeugen
          var cellNr = new DataGridViewTextBoxCell();
          var cellBezeichnung = new DataGridViewTextBoxCell();
          var cellEinheit = new DataGridViewComboBoxCell();
          var cellKategorie = new DataGridViewComboBoxCell();
          var cellFaktor = new DataGridViewTextBoxCell();
          var cellAnzahl = new DataGridViewTextBoxCell();
          var cellEk = new DataGridViewTextBoxCell();
          var cellBetrag = new DataGridViewTextBoxCell();

          // Zellen in die Zeile einfeügen
          dataGridRow.Cells.Add(cellNr);
          dataGridRow.Cells.Add(cellBezeichnung);
          dataGridRow.Cells.Add(cellKategorie);
          dataGridRow.Cells.Add(cellEinheit);
          dataGridRow.Cells.Add(cellFaktor);
          dataGridRow.Cells.Add(cellAnzahl);
          dataGridRow.Cells.Add(cellEk);
          dataGridRow.Cells.Add(cellBetrag);

          // Zelle (Bezeichnung)
          cellBezeichnung.Value = lager.Bezeichnung;

          // Zelle (Einheit)
          cellEinheit.DataSource = lagereinheitBindingSource;
          cellEinheit.DisplayMember = "Bezeichnung";
          cellEinheit.ValueMember = "ID";
          cellEinheit.Value = lager.Einheit;

          // Zelle (Faktor)
          cellFaktor.Value = lager.Faktor;

          // Zelle (Kategorie)
          cellKategorie.DataSource = lagerkategorieBindingSource;
          cellKategorie.DisplayMember = "Bezeichnung";
          cellKategorie.ValueMember = "ID";
          cellKategorie.Value = lager.Kategorie;
     

          // Zelle (Stk)
          cellAnzahl.Value = lager.Stk;

          // Zelle (Ek)
          if (zuschlagProzent == 0.0)
          {
            cellEk.Value = lager.EK;
          }
          else
          {
            // EK um eingegebenen Prozentsatz erhöhen
            cellEk.Value = lager.EK + (lager.EK / 100) * pZuschlagProzent;
          }

          // Zelle (Betrag)
          cellBetrag.Value = lager.Stk * (Convert.ToDouble(cellEk.Value)/ Convert.ToDouble(cellFaktor.Value));

          // Zeile ins Grid einfügen
          dgrLager.Rows.Add(dataGridRow);

          // Neue Positonsnummern vergeben
          ReNumberPos();
        }
      }
    }
Ejemplo n.º 26
0
 public ItemComparer(DataGridViewComboBoxCell dataGridViewComboBoxCell)
 {
     this.dataGridViewComboBoxCell = dataGridViewComboBoxCell;
 }
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            string cellValueString = String.Empty;

            if (e.ColumnIndex == -1 || e.RowIndex == -1)
            {
                return;
            }


            try
            {
                // handle the event when the value in the first column changed
                // -- if an existing tag key was selected populate the 2nd column and the info 3rd column
                // -- add a new last row with the remaining tag key entries
                if (e.ColumnIndex == 0)
                {
                    Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey> localTags = new Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey>();
                    foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tagkey tagKey in m_editTags.Values)
                    {
                        localTags.Add(tagKey.name, tagKey);
                    }

                    string keyValue = string.Empty;
                    // remove the once already used
                    for (int rowIndex = 0; rowIndex < dataGridView1.Rows.Count; rowIndex++)
                    {
                        keyValue = dataGridView1[0, rowIndex].Value as string;
                        if (!String.IsNullOrEmpty(keyValue))
                        {
                            if (localTags.ContainsKey(keyValue))
                            {
                                localTags.Remove(keyValue);
                            }
                        }
                    }


                    keyValue = dataGridView1[e.ColumnIndex, e.RowIndex].Value as string;
                    int deletedRow = -1;

                    // if the 
                    if (string.IsNullOrEmpty(keyValue))
                    {
                        if (!string.IsNullOrEmpty(m_ChangeTagString))
                        {
                            keyValue = m_ChangeTagString;
                            m_ChangeTagString = string.Empty;
                        }
                    }
                    else
                    {
                        try
                        {
                            deletedRow = e.RowIndex;
                            dataGridView1.Rows.RemoveAt(e.RowIndex);
                        }
                        catch
                        {

                        }
                    }

                    if (!string.IsNullOrEmpty(keyValue))
                    {
                        DataGridViewRow newRow = new DataGridViewRow();

                        // name of the tag - tag type
                        DataGridViewCell currentTagCell = new DataGridViewTextBoxCell();
                        currentTagCell.Value = keyValue;

                        // for localization include the translated language into a tooltip
                        if (m_editTags.ContainsKey(keyValue))
                        {
                            if (!String.IsNullOrEmpty(m_editTags[keyValue].displayname))
                            {
                                currentTagCell.ToolTipText = m_editTags[keyValue].displayname;
                            }
                        }

                        newRow.Cells.Insert(0, currentTagCell);

                        // the default case is not to allow the user change the key field
                        bool canEdit = false;

                        if (m_editTags.ContainsKey(keyValue))
                        {
                            if (m_editTags[keyValue].editableSpecified)
                            {
                                canEdit = m_editTags[keyValue].editable;
                            }
                        }

                        newRow.Cells[0].ReadOnly = !canEdit;


                        if (m_editTags.ContainsKey(keyValue))
                        {
                            DataGridViewCell currentValueCell = null;
                            switch (m_editTags[keyValue].tagtype)
                            {
                                case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_list:
                                    currentValueCell = new DataGridViewComboBoxCell();
                                    try
                                    {
                                        foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue value in m_editTags[keyValue].tagvalue)
                                        {
                                            ((DataGridViewComboBoxCell)currentValueCell).Items.Add(value.name);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        System.Diagnostics.Debug.WriteLine(ex.Message);
                                    }
                                    break;
                                case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_integer:
                                    currentValueCell = new DataGridViewTextBoxCell();
                                    break;
                                case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_double:
                                    currentValueCell = new DataGridViewTextBoxCell();
                                    break;
                                case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_string:
                                    currentValueCell = new DataGridViewTextBoxCell();
                                    break;
                                default:
                                    currentValueCell = new DataGridViewTextBoxCell();
                                    break;
                            }
                            try
                            {
                                newRow.Cells.Insert(1, currentValueCell);
                            }
                            catch
                            {

                            }

                            DataGridViewLinkCell currentInfoCell = new DataGridViewLinkCell();
                            currentInfoCell.LinkBehavior = LinkBehavior.SystemDefault;

                            if (m_editTags.ContainsKey(keyValue))
                            {
                                if (String.IsNullOrEmpty(m_editTags[keyValue].infoURL))
                                {
                                    currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + keyValue));
                                }
                                else
                                {
                                    currentInfoCell.Value = new Uri(m_editTags[keyValue].infoURL);
                                }
                            }
                            else
                            {
                                currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + keyValue));
                            }

                            try
                            {
                                newRow.Cells.Insert(2, currentInfoCell);
                            }
                            catch
                            {
                            }
                        }

                        dataGridView1.Rows.Add(newRow);

                        // add a new last row
                        DataGridViewRow lastRow = new DataGridViewRow();
                        DataGridViewComboBoxCell currentKeyCell = new DataGridViewComboBoxCell();
                        try
                        {
                            // show a sorted list of tags to the user
                            IEnumerable<string> sortedKeys = localTags.Keys.OrderBy(myKey => myKey);

                            foreach (string currentKey in sortedKeys)
                            {
                                currentKeyCell.Items.Add(currentKey);
                            }
                        }
                        catch { }

                        lastRow.Cells.Insert(0, currentKeyCell);

                        dataGridView1.Rows.Add(lastRow);

                        dataGridView1.FirstDisplayedScrollingRowIndex = e.RowIndex;
                        dataGridView1.Refresh();
                        dataGridView1.CurrentCell = dataGridView1.Rows[e.RowIndex].Cells[1];
                    }

                    return;
                }


                // ensure that we have values in the first and the second column before we commit an edit operation
                if (e.ColumnIndex == 0)
                {
                    cellValueString = dataGridView1[1, e.RowIndex].Value as string;
                }
                else if (e.ColumnIndex == 1)
                {
                    cellValueString = dataGridView1[0, e.RowIndex].Value as string;
                }

                if (String.IsNullOrEmpty(cellValueString))
                {
                    return;
                }

                if (m_editor == null)
                {
                    return;
                }

                if (((IWorkspaceEdit2)m_editor.EditWorkspace).IsInEditOperation)
                {
                }
                else
                //MessageBox.Show(resourceManager.GetString("OSMEditor_FeatureInspector_operationwarningcaption"), resourceManager.GetString("OSMClassExtension_FeatureInspector_operationwarningcaption"));
                {

                    m_editor.StartOperation();
                }

                ESRI.ArcGIS.OSM.OSMClassExtension.tag newTag = null;

                string tagString = dataGridView1[0, e.RowIndex].Value as string;
                string valueString = dataGridView1[1, e.RowIndex].Value as string;

                if (String.IsNullOrEmpty(tagString) || String.IsNullOrEmpty(valueString))
                {
                }
                else
                {
                    newTag = new ESRI.ArcGIS.OSM.OSMClassExtension.tag();
                    newTag.k = tagString;
                    newTag.v = valueString;
                }


                if (m_enumRow != null)
                {
                    m_enumRow.Reset();

                    // persist the collection in the blob/xml field
                    IFeature currentFeature = null;

                    while ((currentFeature = m_enumRow.Next() as IFeature) != null)
                    {
                        int tagCollectionFieldIndex = currentFeature.Fields.FindField("osmTags");

                        if (tagCollectionFieldIndex != -1)
                        {

                            ESRI.ArcGIS.OSM.OSMClassExtension.tag[] existingTags = _osmUtility.retrieveOSMTags((IRow)currentFeature, tagCollectionFieldIndex, m_editor.EditWorkspace);

                            if (existingTags != null)
                            {
                                // let's rebuild the tags from scratch based on the items that we found in the UI and the existing feature
                                Dictionary<string, string> existingTagsList = new Dictionary<string, string>();
                                for (int index = 0; index < existingTags.Length; index++)
                                {
                                    if (String.IsNullOrEmpty(existingTags[index].k) == false && String.IsNullOrEmpty(existingTags[index].v) == false)
                                    {
                                        existingTagsList.Add(existingTags[index].k, existingTags[index].v);
                                    }
                                }

                                if (newTag != null)
                                {
                                    if (existingTagsList.ContainsKey(newTag.k))
                                    {
                                        existingTagsList[newTag.k] = newTag.v;
                                    }
                                    else
                                    {
                                        if (!String.IsNullOrEmpty(newTag.v))
                                        {
                                            existingTagsList.Add(newTag.k, newTag.v);
                                        }
                                    }
                                }


                                int tagIndex = 0;

                                // convert the newly assembled tag list into a tag array that can be serialized into the osmtag field
                                existingTags = new ESRI.ArcGIS.OSM.OSMClassExtension.tag[existingTagsList.Count];
                                foreach (KeyValuePair<string, string> item in existingTagsList)
                                {
                                    if (!String.IsNullOrEmpty(item.Key) && !String.IsNullOrEmpty(item.Value))
                                    {
                                        ESRI.ArcGIS.OSM.OSMClassExtension.tag insertTag = new ESRI.ArcGIS.OSM.OSMClassExtension.tag();
                                        insertTag.k = item.Key;
                                        insertTag.v = item.Value;

                                        existingTags[tagIndex] = insertTag;
                                        tagIndex = tagIndex + 1;
                                    }
                                }

                                _osmUtility.insertOSMTags(tagCollectionFieldIndex, (IRow)currentFeature, existingTags, m_editor.EditWorkspace);

                                currentFeature.Store();
                            }
                        }
                    }
                }

                m_editor.StopOperation(resourceManager.GetString("OSMClassExtension_FeatureInspector_operationmenu"));

            }
            catch
            {
            }
        }
        public void prepareGrid4Features(IEnumRow currentFeatures)
        {
            if (m_inspector == null)
            {
                //this is the default inspector shipped with the editor
                m_inspector = new FeatureInspector();

                SetParent(dataGridView1.Handle.ToInt32(), this.Handle.ToInt32());
            }


            DataGridView featureGridView = this.dataGridView1;

            // reset the feature grid
            featureGridView.Rows.Clear();


            if (currentFeatures == null)
            {
                return;
            }

            currentFeatures.Reset();

            IFeature currentFeature = currentFeatures.Next() as IFeature;

            Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey> potentialTags = new Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey>();


            // determine a unique collection of proposed and existing tags
            List<string> uniqueListofTags = new List<string>();
            Dictionary<string, string> commonTags = new Dictionary<string, string>();
            Geometry.esriGeometryType currentGeometryType = esriGeometryType.esriGeometryNull;
            IEnumerable<ESRI.ArcGIS.OSM.OSMClassExtension.tag> sameTags = null;

            while (currentFeature != null)
            {
                int osmTagsFieldIndex = currentFeature.Fields.FindField("osmTags");
                currentGeometryType = currentFeature.Shape.GeometryType;

                if (osmTagsFieldIndex != -1)
                {
                    ESRI.ArcGIS.OSM.OSMClassExtension.tag[] tagsOnCurrentFeature = _osmUtility.retrieveOSMTags((IRow)currentFeature, osmTagsFieldIndex, m_editor.EditWorkspace);

                    if (sameTags == null && tagsOnCurrentFeature != null)
                    {
                        sameTags = tagsOnCurrentFeature.ToArray<ESRI.ArcGIS.OSM.OSMClassExtension.tag>();
                    }
                    else if (sameTags != null && tagsOnCurrentFeature != null)
                    {
                        IEnumerable<ESRI.ArcGIS.OSM.OSMClassExtension.tag> both = tagsOnCurrentFeature.Intersect(sameTags, new ESRI.ArcGIS.OSM.OSMClassExtension.TagKeyComparer());
                        sameTags = both.ToArray<ESRI.ArcGIS.OSM.OSMClassExtension.tag>();
                    }

                    if (tagsOnCurrentFeature != null)
                    {
                        for (int index = 0; index < tagsOnCurrentFeature.Length; index++)
                        {
                            if (uniqueListofTags.Contains(tagsOnCurrentFeature[index].k) == false)
                            {
                                uniqueListofTags.Add(tagsOnCurrentFeature[index].k);
                            }

                            // check if the tag key already exists
                            if (commonTags.ContainsKey(tagsOnCurrentFeature[index].k) == true)
                            {
                                if (commonTags[tagsOnCurrentFeature[index].k] == tagsOnCurrentFeature[index].v)
                                {
                                    // the tag values still match - don't do anything
                                }
                                else
                                {
                                    // the values are different - purge the existing value
                                    commonTags[tagsOnCurrentFeature[index].k] = String.Empty;
                                }
                            }
                            else
                            {
                                // the tag doesn't exist yet in the overall collection, 
                                // add the first entry
                                commonTags.Add(tagsOnCurrentFeature[index].k, tagsOnCurrentFeature[index].v);
                            }
                        }
                    }
                }

                // determine potential tag candidates based on the osmfeature schema
                string featureString = String.Empty;

                //let's get the first domain entry and use it as the main feature theme

                for (int fieldIndex = 0; fieldIndex < currentFeature.Fields.FieldCount; fieldIndex++)
                {
                    if (String.IsNullOrEmpty(featureString))
                    {
                        if (currentFeature.Fields.get_Field(fieldIndex).Type == esriFieldType.esriFieldTypeString)
                        {
                            System.Object attributeValue = currentFeature.get_Value(fieldIndex);

                            if (attributeValue != System.DBNull.Value)
                            {
                                foreach (string lookingforDomain in m_domainDictionary.Keys)
                                {
                                    if (currentFeature.Fields.get_Field(fieldIndex).Name == lookingforDomain)
                                    {
                                        featureString = lookingforDomain + "=" + attributeValue.ToString();
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                ESRI.ArcGIS.OSM.OSMClassExtension.osmfeature OSMInspectorFeatureType = null;

                if (m_editFeatures.Keys.Contains(featureString))
                {
                    OSMInspectorFeatureType = m_editFeatures[featureString];
                }

                if (OSMInspectorFeatureType != null)
                {
                    if (OSMInspectorFeatureType.tag != null)
                    {
                        for (int index = 0; index < OSMInspectorFeatureType.tag.Length; index++)
                        {
                            if (commonTags.ContainsKey(OSMInspectorFeatureType.tag[index].@ref) == false)
                            {
                                commonTags.Add(OSMInspectorFeatureType.tag[index].@ref, String.Empty);
                            }
                        }
                    }
                }

                currentFeature = currentFeatures.Next() as IFeature;
            }


            // get a listing of all possible tags
            Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey> localTags = new Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey>();

            foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tagkey tagKeyItem in m_editTags.Values)
            {
                localTags.Add(tagKeyItem.name, tagKeyItem);
            }


            // now let's go through our unique list of proposed and existing tags
            // and fill the grid accordingly

            DataGridViewRow currentRow = null;

            foreach (KeyValuePair<string, string> osmTagValuePair in commonTags)
            {
                currentRow = new DataGridViewRow();

                // name of the tag - tag type
                DataGridViewCell currentTagCell = new DataGridViewTextBoxCell();
                currentTagCell.Value = osmTagValuePair.Key;

                // for localization include the translated language into a tooltip
                if (m_editTags.ContainsKey(osmTagValuePair.Key))
                {
                    if (!String.IsNullOrEmpty(m_editTags[osmTagValuePair.Key].displayname))
                    {
                        currentTagCell.ToolTipText = m_editTags[osmTagValuePair.Key].displayname;
                    }
                }


                currentRow.Cells.Insert(0, currentTagCell);

                // the default case is not to allow the user change the key field
                bool canEdit = false;

                if (m_editTags.ContainsKey(osmTagValuePair.Key))
                {
                    if (m_editTags[osmTagValuePair.Key].editableSpecified)
                    {
                        canEdit = m_editTags[osmTagValuePair.Key].editable;
                    }
                }

                currentRow.Cells[0].ReadOnly = !canEdit;

                // value of the tag
                // depending on the tag type we'll need to create a different cell type
                DataGridViewCell currentValueCell = null;

                if (m_editTags.ContainsKey(osmTagValuePair.Key))
                {
                    switch (m_editTags[osmTagValuePair.Key].tagtype)
                    {
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_list:
                            currentValueCell = new DataGridViewComboBoxCell();
                            try
                            {
                                foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue value in m_editTags[osmTagValuePair.Key].tagvalue)
                                {
                                    ((DataGridViewComboBoxCell)currentValueCell).Items.Add(value.name);
                                }
                            }
                            catch (Exception ex)
                            {
                                System.Diagnostics.Debug.WriteLine(ex.Message);
                            }
                            break;
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_integer:
                            currentValueCell = new DataGridViewTextBoxCell();
                            break;
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_double:
                            currentValueCell = new DataGridViewTextBoxCell();
                            break;
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_string:
                            currentValueCell = new DataGridViewTextBoxCell();
                            break;
                        default:
                            currentValueCell = new DataGridViewTextBoxCell();
                            break;
                    }
                }
                else if (m_domainDictionary.ContainsKey(osmTagValuePair.Key))
                {
                    currentValueCell = new DataGridViewComboBoxCell();
                    ESRI.ArcGIS.OSM.OSMClassExtension.domain currentDomain = null;

                    switch (currentGeometryType)
                    {
                        case esriGeometryType.esriGeometryAny:
                            break;
                        case esriGeometryType.esriGeometryBag:
                            break;
                        case esriGeometryType.esriGeometryBezier3Curve:
                            break;
                        case esriGeometryType.esriGeometryCircularArc:
                            break;
                        case esriGeometryType.esriGeometryEllipticArc:
                            break;
                        case esriGeometryType.esriGeometryEnvelope:
                            break;
                        case esriGeometryType.esriGeometryLine:
                            break;
                        case esriGeometryType.esriGeometryMultiPatch:
                            break;
                        case esriGeometryType.esriGeometryMultipoint:
                            break;
                        case esriGeometryType.esriGeometryNull:
                            break;
                        case esriGeometryType.esriGeometryPath:
                            break;
                        case esriGeometryType.esriGeometryPoint:
                            currentDomain = m_domainDictionary[osmTagValuePair.Key];

                            foreach (ESRI.ArcGIS.OSM.OSMClassExtension.domainvalue item in currentDomain.domainvalue)
                            {
                                for (int geometryIndex = 0; geometryIndex < item.geometrytype.Length; geometryIndex++)
                                {
                                    if (item.geometrytype[geometryIndex] == ESRI.ArcGIS.OSM.OSMClassExtension.geometrytype.point)
                                    {
                                        try
                                        {
                                            ((DataGridViewComboBoxCell)currentValueCell).Items.Add(item.value);
                                        }
                                        catch (Exception ex)
                                        {
                                            System.Diagnostics.Debug.WriteLine(ex.Message);
                                        }
                                    }
                                }
                            }
                            break;
                        case esriGeometryType.esriGeometryPolygon:
                            currentDomain = m_domainDictionary[osmTagValuePair.Key];

                            foreach (ESRI.ArcGIS.OSM.OSMClassExtension.domainvalue item in currentDomain.domainvalue)
                            {
                                for (int geometryIndex = 0; geometryIndex < item.geometrytype.Length; geometryIndex++)
                                {
                                    if (item.geometrytype[geometryIndex] == ESRI.ArcGIS.OSM.OSMClassExtension.geometrytype.polygon)
                                    {
                                        try
                                        {
                                            ((DataGridViewComboBoxCell)currentValueCell).Items.Add(item.value);
                                        }
                                        catch (Exception ex)
                                        {
                                            System.Diagnostics.Debug.WriteLine(ex.Message);
                                        }
                                    }
                                }
                            }
                            break;
                        case esriGeometryType.esriGeometryPolyline:
                            currentDomain = m_domainDictionary[osmTagValuePair.Key];

                            foreach (ESRI.ArcGIS.OSM.OSMClassExtension.domainvalue item in currentDomain.domainvalue)
                            {
                                for (int geometryIndex = 0; geometryIndex < item.geometrytype.Length; geometryIndex++)
                                {
                                    if (item.geometrytype[geometryIndex] == ESRI.ArcGIS.OSM.OSMClassExtension.geometrytype.line)
                                    {
                                        try
                                        {
                                            ((DataGridViewComboBoxCell)currentValueCell).Items.Add(item.value);
                                        }
                                        catch (Exception ex)
                                        {
                                            System.Diagnostics.Debug.WriteLine(ex.Message);
                                        }
                                    }
                                }
                            }
                            break;
                        case esriGeometryType.esriGeometryRay:
                            break;
                        case esriGeometryType.esriGeometryRing:
                            break;
                        case esriGeometryType.esriGeometrySphere:
                            break;
                        case esriGeometryType.esriGeometryTriangleFan:
                            break;
                        case esriGeometryType.esriGeometryTriangleStrip:
                            break;
                        case esriGeometryType.esriGeometryTriangles:
                            break;
                        default:
                            break;
                    }
                }
                else
                { // unkown keys are treated as strings
                    currentValueCell = new DataGridViewTextBoxCell();
                }

                // add the value only we have a value and if the tag is common among all features
                if (String.IsNullOrEmpty(osmTagValuePair.Value) == false)
                {
                    ESRI.ArcGIS.OSM.OSMClassExtension.tag compareTag = new ESRI.ArcGIS.OSM.OSMClassExtension.tag();
                    compareTag.k = osmTagValuePair.Key;

                    if (sameTags.Contains(compareTag, new ESRI.ArcGIS.OSM.OSMClassExtension.TagKeyComparer()))
                    {
                        currentValueCell.Value = osmTagValuePair.Value;
                    }
                }

                // for localization include the translated language into a tooltip
                if (m_editTags.ContainsKey((string)currentTagCell.Value))
                {
                    if (!String.IsNullOrEmpty((string)currentValueCell.Value))
                    {
                        ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue[] possibleValues = m_editTags[(string)currentTagCell.Value].tagvalue;

                        if (possibleValues != null)
                        {
                            for (int valueIndex = 0; valueIndex < possibleValues.Length; valueIndex++)
                            {
                                if (currentValueCell.Value.Equals(possibleValues[valueIndex].name) == true)
                                {
                                    if (!String.IsNullOrEmpty(possibleValues[valueIndex].displayname))
                                    {
                                        currentValueCell.ToolTipText = possibleValues[valueIndex].displayname;
                                    }
                                }
                            }
                        }
                    }
                }

                currentRow.Cells.Insert(1, currentValueCell);

                // the assumption here is that values are usually open to user edits
                canEdit = true;
                currentRow.Cells[1].ReadOnly = !canEdit;

                DataGridViewLinkCell currentInfoCell = new DataGridViewLinkCell();
                currentInfoCell.LinkBehavior = LinkBehavior.SystemDefault;

                if (m_editTags.ContainsKey(osmTagValuePair.Key))
                {
                    if (String.IsNullOrEmpty(m_editTags[osmTagValuePair.Key].infoURL))
                    {
                        currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + osmTagValuePair.Key));
                    }
                    else
                    {
                        currentInfoCell.Value = new Uri(m_editTags[osmTagValuePair.Key].infoURL);
                    }
                    currentRow.Cells.Insert(2, currentInfoCell);
                }
                else
                {
                    currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + osmTagValuePair.Key));
                }

                featureGridView.Rows.Add(currentRow);

                if (localTags.ContainsKey(osmTagValuePair.Key))
                {
                    localTags.Remove(osmTagValuePair.Key);
                }
            }

            // add the list in the first column of the last row
            DataGridViewRow lastRow = new DataGridViewRow();
            DataGridViewComboBoxCell currentKeyCell = new DataGridViewComboBoxCell();
            try
            {
                // show a sorted list of tags to the user
                IEnumerable<string> sortedKeys = localTags.Keys.OrderBy(myKey => myKey);

                foreach (string currentKey in sortedKeys)
                {
                    currentKeyCell.Items.Add(currentKey);
                }
            }
            catch { }

            lastRow.Cells.Insert(0, currentKeyCell);

            featureGridView.Rows.Add(lastRow);

        }
Ejemplo n.º 29
0
		private void FillColumnizerList()
		{
			this.columnizerDataGridView.Rows.Clear();

			DataGridViewComboBoxColumn comboColumn = (DataGridViewComboBoxColumn)this.columnizerDataGridView.Columns[1];
			comboColumn.Items.Clear();

			DataGridViewTextBoxColumn textColumn = (DataGridViewTextBoxColumn)this.columnizerDataGridView.Columns[0];

			IList<ILogLineColumnizer> columnizers = PluginRegistry.GetInstance().RegisteredColumnizers;
			foreach (ILogLineColumnizer columnizer in columnizers)
			{
				int index = comboColumn.Items.Add(columnizer.GetName());
			}
			//comboColumn.DisplayMember = "Name";
			//comboColumn.ValueMember = "Columnizer";

			foreach (ColumnizerMaskEntry maskEntry in this.Preferences.columnizerMaskList)
			{
				DataGridViewRow row = new DataGridViewRow();
				row.Cells.Add(new DataGridViewTextBoxCell());
				DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell();

				foreach (ILogLineColumnizer logColumnizer in columnizers)
				{
					int index = cell.Items.Add(logColumnizer.GetName());
				}
        
				row.Cells.Add(cell);
				row.Cells[0].Value = maskEntry.mask;
				ILogLineColumnizer columnizer = Util.FindColumnizerByName(maskEntry.columnizerName, PluginRegistry.GetInstance().RegisteredColumnizers);
				if (columnizer == null)
					columnizer = PluginRegistry.GetInstance().RegisteredColumnizers[0];
				row.Cells[1].Value = columnizer.GetName();
				this.columnizerDataGridView.Rows.Add(row);
			}
			int count = this.columnizerDataGridView.RowCount;
			if (count > 0 && !this.columnizerDataGridView.Rows[count - 1].IsNewRow)
			{
				DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)this.columnizerDataGridView.Rows[count - 1].Cells[1];
				comboCell.Value = comboCell.Items[0];
			}
		}
Ejemplo n.º 30
0
		private void FillHighlightMaskList()
		{
			this.highlightMaskGridView.Rows.Clear();

			DataGridViewComboBoxColumn comboColumn = (DataGridViewComboBoxColumn)this.highlightMaskGridView.Columns[1];
			comboColumn.Items.Clear();

			DataGridViewTextBoxColumn textColumn = (DataGridViewTextBoxColumn)this.highlightMaskGridView.Columns[0];

			IList<HilightGroup> groups = this.logTabWin.HilightGroupList;
			foreach (HilightGroup group in groups)
			{
				int index = comboColumn.Items.Add(group.GroupName);
			}

			foreach (HighlightMaskEntry maskEntry in this.Preferences.highlightMaskList)
			{
				DataGridViewRow row = new DataGridViewRow();
				row.Cells.Add(new DataGridViewTextBoxCell());
				DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell();

				foreach (HilightGroup group in groups)
				{
					int index = cell.Items.Add(group.GroupName);
				}

				row.Cells.Add(cell);
				row.Cells[0].Value = maskEntry.mask;
				HilightGroup currentGroup = this.logTabWin.FindHighlightGroup(maskEntry.highlightGroupName);
				if (currentGroup == null)
					currentGroup = groups[0];
				if (currentGroup == null)
					currentGroup = new HilightGroup();
				row.Cells[1].Value = currentGroup.GroupName;
				this.highlightMaskGridView.Rows.Add(row);
			}
			int count = this.highlightMaskGridView.RowCount;
			if (count > 0 && !this.highlightMaskGridView.Rows[count - 1].IsNewRow)
			{
				DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)this.highlightMaskGridView.Rows[count - 1].Cells[1];
				comboCell.Value = comboCell.Items[0];
			}
		}
Ejemplo n.º 31
0
 public ObjectCollection(DataGridViewComboBoxCell owner)
 {
     this.owner = owner;
     list       = new ArrayList();
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Assegna un datasource ad una combo box
 /// </summary>
 /// <param name="combo">ComboBox in oggetto</param>
 /// <param name="DataSource">DataSource da asseggnare</param>
 /// <param name="display">Nome DisplayMember</param>
 /// <param name="value">Nome Value Member</param>
 public static void BindDataGridComboBox(System.Windows.Forms.DataGridViewComboBoxCell combo, object DataSource, string display, string value)
 {
     combo.DataSource    = DataSource;
     combo.DisplayMember = display;
     combo.ValueMember   = value;
 }
Ejemplo n.º 33
0
        public void ComboBoxTest()
        {
            SWF.DataGridViewComboBoxColumn column = new SWF.DataGridViewComboBoxColumn();
            column.HeaderText = "CheckBox Column";
            column.Items.AddRange("1", "2", "3", "4", "5");

            SWF.DataGridViewComboBoxCell cell    = new SWF.DataGridViewComboBoxCell();
            SWF.DataGridViewComboBoxCell newCell = new SWF.DataGridViewComboBoxCell();

            IRawElementProviderFragmentRoot provider
                = ColumnCellTest(column,
                                 cell,
                                 true,
                                 newCell);

            // Lets test navigation.

            IRawElementProviderFragment child = provider.Navigate(NavigateDirection.FirstChild);

            while (child != null)
            {
                if ((int)child.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id)
                    == ControlType.DataItem.Id)
                {
                    break;
                }
                child = child.Navigate(NavigateDirection.NextSibling);
            }

            // Lets search our ComboBox
            child = child.Navigate(NavigateDirection.FirstChild);
            while (child != null)
            {
                if ((int)child.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id)
                    == ControlType.ComboBox.Id)
                {
                    break;
                }
                child = child.Navigate(NavigateDirection.NextSibling);
            }

            // ComboBox should have 2 children. Button and ListBox
            int children = 0;

            IRawElementProviderFragmentRoot comboboxProvider = child as IRawElementProviderFragmentRoot;

            child = child.Navigate(NavigateDirection.FirstChild);
            while (child != null)
            {
                children++;
                child = child.Navigate(NavigateDirection.NextSibling);
            }
            Assert.AreEqual(2, children, "ComboBox.Children");

            // Exposes #493520
            // cell should be the first combobox
            cell.Value = "1";
            ISelectionProvider selectionProvider
                = (ISelectionProvider)comboboxProvider.GetPatternProvider(SelectionPatternIdentifiers.Pattern.Id);

            Assert.IsNotNull(selectionProvider, "Selection Provider missing");
            IRawElementProviderSimple [] selection = selectionProvider.GetSelection();
            Assert.IsNotNull(selection, "Selection is null");

            foreach (IRawElementProviderSimple selected in selection)
            {
                Assert.IsNotNull(selected, "Selected is null");
            }

            cell.Value = null;
            selection  = selectionProvider.GetSelection();
            Assert.IsNotNull(selection, "Selection is null");

            foreach (IRawElementProviderSimple selected in selection)
            {
                Assert.IsNotNull(selected, "Selected is null");
            }
        }
Ejemplo n.º 34
0
        /// <summary> 为每一行的配件信息绑定下拉框信息
        /// </summary>
        /// <param name="parts_code"></param>
        /// <param name="rowsindex"></param>
        /// <param name="dgcombox"></param>
        public void BindDataGridViewComboBoxCell(string data_source, string parts_code, int rowsindex, ref DataGridViewComboBoxCell dgcombox, ref string default_unit_id, ref string default_price)
        {
            dgcombox = (DataGridViewComboBoxCell)gvPurchaseList.Rows[rowsindex].Cells["unit_id"];

            List<ListItem> list = new List<ListItem>();
            list.Add(new ListItem("", "请选择"));
            string wherestr = string.Format(@" parts_id=(select parts_id from tb_parts where ser_parts_code='{0}') and enable_flag=1", parts_code);
            DataTable dt = DBHelper.GetTable("", "tb_parts_price", "*", wherestr, "", "");
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    list.Add(new ListItem(dt.Rows[i]["pp_id"].ToString(), dt.Rows[i]["unit"].ToString()));

                    partunitprice model = new partunitprice();
                    model.parts_id = dt.Rows[i]["parts_id"].ToString();
                    model.unitid = dt.Rows[i]["pp_id"].ToString();
                    model.unitname = dt.Rows[i]["unit"].ToString();
                    model.rate = Convert.ToDecimal(dt.Rows[i]["rate"] == null ? "0" : string.IsNullOrEmpty(dt.Rows[i]["rate"].ToString()) ? "0" : dt.Rows[i]["rate"].ToString());
                    //model.price = Convert.ToDecimal(dt.Rows[i]["into_price_two"] == null ? "0" : string.IsNullOrEmpty(dt.Rows[i]["into_price_two"].ToString()) ? "0" : dt.Rows[i]["into_price_two"].ToString());

                    //根据配件数据来源,判断给什么单价(采购业务时:自建的配件信息用参考进价,宇通的配件用销售2A价)
                    if (data_source == "1")//自建配件
                    {
                        model.price = Convert.ToDecimal(dt.Rows[i]["ref_in_price"] == null ? "0" : string.IsNullOrEmpty(dt.Rows[i]["ref_in_price"].ToString()) ? "0" : dt.Rows[i]["ref_in_price"].ToString());
                    }
                    else if (data_source == "2")//宇通配件
                    {
                        model.price = Convert.ToDecimal(dt.Rows[i]["out_price_two"] == null ? "0" : string.IsNullOrEmpty(dt.Rows[i]["out_price_two"].ToString()) ? "0" : dt.Rows[i]["out_price_two"].ToString());
                    }
                    //采购业务中,判断单位是否是采购单位
                    if (dt.Rows[i]["is_sale"].ToString() == "1")
                    {
                        default_unit_id = dt.Rows[i]["pp_id"].ToString();
                        default_price = model.price.ToString();
                    }
                    
                    if (list_partunitprice.Count > 0)
                    {
                        if (!list_partunitprice.Exists(p => p.unitid == dt.Rows[i]["pp_id"].ToString()))
                        {
                            list_partunitprice.Add(model);
                        }
                    }
                    else
                    {
                        list_partunitprice.Add(model);
                    }
                }
            }
            dgcombox.DataSource = list;
            dgcombox.ValueMember = "Value";
            dgcombox.DisplayMember = "Text";
        }
        public void prepareGrid4Feature(IFeature currentFeature)
        {
            if (m_inspector == null)
            {
                //this is the default inspector shipped with the editor
                m_inspector = new FeatureInspector();

                SetParent(dataGridView1.Handle.ToInt32(), this.Handle.ToInt32());
            }

            DataGridView featureGridView = this.dataGridView1;

            string featureString = String.Empty;

            //let's get the first domain entry and use it as the main feature theme

            for (int fieldIndex = 0; fieldIndex < currentFeature.Fields.FieldCount; fieldIndex++)
            {
                if (String.IsNullOrEmpty(featureString))
                {
                    if (currentFeature.Fields.get_Field(fieldIndex).Type == esriFieldType.esriFieldTypeString)
                    {
                        System.Object attributeValue = currentFeature.get_Value(fieldIndex);

                        if (attributeValue != System.DBNull.Value)
                        {
                            foreach (string lookingforDomain in m_domainDictionary.Keys)
                            {
                                if (currentFeature.Fields.get_Field(fieldIndex).Name == lookingforDomain)
                                {
                                    featureString = lookingforDomain + "=" + attributeValue.ToString();
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    break;
                }
            }

            ESRI.ArcGIS.OSM.OSMClassExtension.osmfeature currentFeatureType = null;

            if (m_editFeatures.Keys.Contains(featureString))
            {
                currentFeatureType = m_editFeatures[featureString];
            }


            // reset the feature grid
            featureGridView.Rows.Clear();


            // rehydrate the tag from the container field
            Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tag> tagList = new Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tag>();
            ESRI.ArcGIS.OSM.OSMClassExtension.tag[] storedTags = null;

            Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey> localTags = new Dictionary<string, ESRI.ArcGIS.OSM.OSMClassExtension.tagkey>();

            foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tagkey tagKeyItem in m_editTags.Values)
            {
                localTags.Add(tagKeyItem.name, tagKeyItem);
            }

            int tagCollectionFieldIndex = currentFeature.Fields.FindField("osmTags");

            storedTags = _osmUtility.retrieveOSMTags((IRow)currentFeature, tagCollectionFieldIndex, m_editor.EditWorkspace);

            if (storedTags != null)
            {
                foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tag currenttag in storedTags)
                {
                    tagList.Add(currenttag.k, currenttag);
                }
            }

            // if we have a known entity of tag - OSM map feature that is
            if (currentFeatureType != null)
            {
                DataGridViewRow currentRow = new DataGridViewRow();

                // the feature itself is the main osm key value pair
                string[] osmkeyvalue = null;

                try
                {
                    osmkeyvalue = currentFeatureType.name.Split("=".ToCharArray());
                }
                catch { }


                if (osmkeyvalue != null && osmkeyvalue.Length > 1)
                {
                    // name of the tag - tag type
                    DataGridViewCell currentTagCell = new DataGridViewTextBoxCell();
                    currentTagCell.Value = osmkeyvalue[0];

                    // for localization include the translated language into a tooltip
                    if (m_editTags.ContainsKey(osmkeyvalue[0]))
                    {
                        if (!String.IsNullOrEmpty(m_editTags[osmkeyvalue[0]].displayname))
                        {
                            currentTagCell.ToolTipText = m_editTags[osmkeyvalue[0]].displayname;
                        }
                    }

                    currentRow.Cells.Insert(0, currentTagCell);
                    currentRow.Cells[0].ReadOnly = true;

                    // value of the tag
                    DataGridViewCell currentValueCell = null;
                    currentValueCell = new DataGridViewComboBoxCell();
                    foreach (var domainvalue in m_domainDictionary[osmkeyvalue[0]].domainvalue)
                    {
                        if (IsGeometryTypeEqual(currentFeature.Shape.GeometryType, domainvalue.geometrytype))
                        {
                            ((DataGridViewComboBoxCell)currentValueCell).Items.Add(domainvalue.value);
                        }
                    }
                    currentValueCell.Value = osmkeyvalue[1];

                    // for localization include the translated language into a tooltip
                    if (m_editTags.ContainsKey(osmkeyvalue[0]))
                    {
                        ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue[] possibleValues = m_editTags[osmkeyvalue[0]].tagvalue;

                        if (possibleValues != null)
                        {
                            for (int valueIndex = 0; valueIndex < possibleValues.Length; valueIndex++)
                            {
                                if (osmkeyvalue[1].Equals(possibleValues[valueIndex].name) == true)
                                {
                                    if (!String.IsNullOrEmpty(possibleValues[valueIndex].displayname))
                                    {
                                        currentValueCell.ToolTipText = possibleValues[valueIndex].displayname;
                                    }
                                }
                            }
                        }
                    }

                    currentRow.Cells.Insert(1, currentValueCell);
                    currentRow.Cells[1].ReadOnly = false;


                    DataGridViewLinkCell currentInfoCell = new DataGridViewLinkCell();
                    currentInfoCell.LinkBehavior = LinkBehavior.SystemDefault;
                    currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Tag:" + currentFeatureType.name));
                    currentRow.Cells.Insert(2, currentInfoCell);

                    featureGridView.Rows.Add(currentRow);

                    if (tagList.Keys.Contains(osmkeyvalue[0]))
                    {
                        tagList.Remove(osmkeyvalue[0]);
                    }

                    if (localTags.ContainsKey(osmkeyvalue[0]))
                    {
                        localTags.Remove(osmkeyvalue[0]);
                    }
                }

                if (currentFeatureType.tag != null)
                {
                    foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tag osmTagValuePair in currentFeatureType.tag)
                    {
                        try
                        {
                            currentRow = new DataGridViewRow();

                            // name of the tag - tag type
                            DataGridViewCell currentTagCell = new DataGridViewTextBoxCell();
                            currentTagCell.Value = osmTagValuePair.@ref;

                            // for localization include the translated language into a tooltip
                            if (m_editTags.ContainsKey(osmTagValuePair.@ref))
                            {
                                if (!String.IsNullOrEmpty(m_editTags[osmTagValuePair.@ref].displayname))
                                {
                                    currentTagCell.ToolTipText = m_editTags[osmTagValuePair.@ref].displayname;
                                }
                            }

                            currentRow.Cells.Insert(0, currentTagCell);

                            // the default case is not to allow the user change the key field
                            bool canEdit = false;

                            if (m_editTags.ContainsKey(osmTagValuePair.@ref))
                            {
                                if (m_editTags[osmTagValuePair.@ref].editableSpecified)
                                {
                                    canEdit = m_editTags[osmTagValuePair.@ref].editable;
                                }
                            }

                            currentRow.Cells[0].ReadOnly = !canEdit;

                            // value of the tag
                            // depending on the tag type we'll need to create a different cell type
                            DataGridViewCell currentValueCell = null;

                            if (m_editTags.ContainsKey(osmTagValuePair.@ref))
                            {
                                switch (m_editTags[osmTagValuePair.@ref].tagtype)
                                {
                                    case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_list:
                                        currentValueCell = new DataGridViewComboBoxCell();
                                        try
                                        {
                                            foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue value in m_editTags[osmTagValuePair.@ref].tagvalue)
                                            {
                                                ((DataGridViewComboBoxCell)currentValueCell).Items.Add(value.name);
                                            }
                                        }

                                        catch (Exception ex)
                                        {
                                            System.Diagnostics.Debug.WriteLine(ex.Message);
                                        }
                                        break;
                                    case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_integer:
                                        currentValueCell = new DataGridViewTextBoxCell();
                                        break;
                                    case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_double:
                                        currentValueCell = new DataGridViewTextBoxCell();
                                        break;
                                    case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_string:
                                        currentValueCell = new DataGridViewTextBoxCell();
                                        break;
                                    default:
                                        currentValueCell = new DataGridViewTextBoxCell();
                                        break;
                                }
                            }
                            else
                            { // unkown keys are treated as strings
                                currentValueCell = new DataGridViewTextBoxCell();
                            }

                            if (tagList.Keys.Contains(osmTagValuePair.@ref))
                            {
                                currentValueCell.Value = tagList[osmTagValuePair.@ref].v;
                            }
                            else
                            {
                                if (osmTagValuePair.value != null)
                                {
                                    currentValueCell.Value = osmTagValuePair.value;
                                }
                            }

                            // for localization include the translated language into a tooltip
                            if (m_editTags.ContainsKey((string)currentTagCell.Value))
                            {
                                if (!String.IsNullOrEmpty((string)currentValueCell.Value))
                                {
                                    ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue[] possibleValues = m_editTags[(string)currentTagCell.Value].tagvalue;

                                    if (possibleValues != null)
                                    {
                                        for (int valueIndex = 0; valueIndex < possibleValues.Length; valueIndex++)
                                        {
                                            if (currentValueCell.Value.Equals(possibleValues[valueIndex].name) == true)
                                            {
                                                if (!String.IsNullOrEmpty(possibleValues[valueIndex].displayname))
                                                {
                                                    currentValueCell.ToolTipText = possibleValues[valueIndex].displayname;
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            currentRow.Cells.Insert(1, currentValueCell);

                            // the assumption here is that values are usually open to user edits
                            canEdit = true;
                            currentRow.Cells[1].ReadOnly = !canEdit;

                            DataGridViewLinkCell currentInfoCell = new DataGridViewLinkCell();
                            currentInfoCell.LinkBehavior = LinkBehavior.SystemDefault;

                            if (m_editTags.ContainsKey(osmTagValuePair.@ref))
                            {
                                if (String.IsNullOrEmpty(m_editTags[osmTagValuePair.@ref].infoURL))
                                {
                                    currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + osmTagValuePair.@ref));
                                }
                                else
                                {
                                    currentInfoCell.Value = new Uri(m_editTags[osmTagValuePair.@ref].infoURL);
                                }
                                currentRow.Cells.Insert(2, currentInfoCell);
                            }
                            else
                            {
                                currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + osmTagValuePair.@ref));
                            }

                            featureGridView.Rows.Add(currentRow);

                            tagList.Remove(osmTagValuePair.@ref);

                            if (localTags.ContainsKey(osmTagValuePair.@ref))
                            {
                                localTags.Remove(osmTagValuePair.@ref);
                            }
                        }
                        catch { }
                    }
                }
            }


            // for all the remaining tags of whatever is passed into this function - known or unkown
            // list the remaining tag key/value pairs
            foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tag currentTag in tagList.Values)
            {
                DataGridViewRow currentRow = new DataGridViewRow();

                DataGridViewCell currentTagCell = new DataGridViewTextBoxCell();
                currentTagCell.Value = currentTag.k;


                // for localization include the translated language into a tooltip
                if (m_editTags.ContainsKey(currentTag.k))
                {
                    if (!String.IsNullOrEmpty(m_editTags[currentTag.k].displayname))
                    {
                        currentTagCell.ToolTipText = m_editTags[currentTag.k].displayname;
                    }
                }


                currentRow.Cells.Insert(0, currentTagCell);

                DataGridViewCell currentValueCell = null;
                if (m_editTags.ContainsKey(currentTag.k))
                {
                    switch (m_editTags[currentTag.k].tagtype)
                    {
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_list:
                            currentValueCell = new DataGridViewComboBoxCell();
                            try
                            {
                                foreach (ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue value in m_editTags[currentTag.k].tagvalue)
                                {
                                    ((DataGridViewComboBoxCell)currentValueCell).Items.Add(value.name);
                                }

                                currentValueCell.Value = currentTag.v;
                            }
                            catch (Exception ex)
                            {
                                System.Diagnostics.Debug.WriteLine(ex.Message);
                            }
                            break;
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_integer:
                            currentValueCell = new DataGridViewTextBoxCell();
                            currentValueCell.Value = Convert.ToInt32(currentTag.v);
                            break;
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_double:
                            currentValueCell = new DataGridViewTextBoxCell();
                            currentValueCell.Value = Convert.ToDouble(currentTag.v);
                            break;
                        case ESRI.ArcGIS.OSM.OSMClassExtension.tagkeyTagtype.tag_string:
                            currentValueCell = new DataGridViewTextBoxCell();
                            currentValueCell.Value = Convert.ToString(currentTag.v);
                            break;
                        default:
                            currentValueCell = new DataGridViewTextBoxCell();
                            break;
                    }
                }
                else
                {
                    currentValueCell = new DataGridViewTextBoxCell();
                    currentValueCell.Value = Convert.ToString(currentTag.v);
                }

                try
                {
                    // for localization include the translated language into a tooltip
                    if (m_editTags.ContainsKey(currentTag.k))
                    {
                        if (!String.IsNullOrEmpty(Convert.ToString(currentValueCell.Value)))
                        {
                            ESRI.ArcGIS.OSM.OSMClassExtension.tagvalue[] possibleValues = m_editTags[currentTag.k].tagvalue;

                            if (possibleValues != null)
                            {
                                for (int valueIndex = 0; valueIndex < possibleValues.Length; valueIndex++)
                                {
                                    if (currentTag.v.Equals(possibleValues[valueIndex].name) == true)
                                    {
                                        if (!String.IsNullOrEmpty(possibleValues[valueIndex].displayname))
                                        {
                                            currentValueCell.ToolTipText = possibleValues[valueIndex].displayname;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch { }

                currentRow.Cells.Insert(1, currentValueCell);

                DataGridViewLinkCell currentInfoCell = new DataGridViewLinkCell();
                currentInfoCell.LinkBehavior = LinkBehavior.SystemDefault;

                if (m_editTags.ContainsKey(currentTag.k))
                {
                    if (String.IsNullOrEmpty(m_editTags[currentTag.k].infoURL))
                    {
                        currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + currentTag.k));
                    }
                    else
                    {
                        currentInfoCell.Value = new Uri(m_editTags[currentTag.k].infoURL);
                    }
                    currentRow.Cells.Insert(2, currentInfoCell);
                }
                else
                {
                    currentInfoCell.Value = new Uri(m_baseInfoURI + HttpUtility.UrlEncode("Key:" + currentTag.k));
                }

                featureGridView.Rows.Add(currentRow);

                if (localTags.ContainsKey(currentTag.k))
                {
                    localTags.Remove(currentTag.k);
                }
            }

            // add the list of remaning known tags in the first column of the last row in ascending order
            DataGridViewRow lastRow = new DataGridViewRow();
            DataGridViewComboBoxCell currentKeyCell = new DataGridViewComboBoxCell();
            try
            {
                // show a sorted list of tags to the user
                IEnumerable<string> sortedKeys = localTags.Keys.OrderBy(myKey => myKey);

                foreach (string currentKey in sortedKeys)
                {
                    currentKeyCell.Items.Add(currentKey);
                }

            }
            catch { }

            lastRow.Cells.Insert(0, currentKeyCell);

            featureGridView.Rows.Add(lastRow);

        }
Ejemplo n.º 36
0
        private void Agregar_Click(object sender, EventArgs e)
        {
            DataGridViewComboBoxCell cbc = new DataGridViewComboBoxCell();
            cbc.Items.Add("Vigilante");
            cbc.Items.Add("Vigilante Auxiliar");
            cbc.Items.Add("Vigilante Armado");
            cbc.Items.Add("Supervisor");
            

            // Se crea una fila seteandole a la primer columna el combobox
            DataGridViewRow dgvr = new DataGridViewRow();
            dgvHoras.Rows.Add(dgvr);
            dgvr.Cells[0] = cbc;

            for (int i = 2; i < 9; i++)
            {
                if (diasNL[i] == 1)
                {
                    DataGridViewTextBoxCell dgvtc = new DataGridViewTextBoxCell();
                    dgvtc.Value = "N/T";
                    dgvr.Cells[i] = dgvtc;
                    //dgvtc.ReadOnly = true;
                }
            }

            // Se crea otra fila en blando.
            DataGridViewTextBoxCell dgvtbc = new DataGridViewTextBoxCell();
            DataGridViewTextBoxCell dgvtbc2 = new DataGridViewTextBoxCell();
            dgvr = new DataGridViewRow();
            dgvHoras.Rows.Add(dgvr);
            dgvr.Cells[0] = dgvtbc;
            dgvr.Cells[0].Style.BackColor = System.Drawing.Color.Gray;
            dgvr.Cells[1] = dgvtbc2;
            dgvr.Cells[1].Style.BackColor = System.Drawing.Color.Gray; 
            //dgvtbc.ReadOnly = true;
            //dgvtbc2.ReadOnly = true;

            for (int i = 2; i < 9; i++)
            {
                if (diasNL[i] == 1)
                {
                    DataGridViewTextBoxCell dgvtc = new DataGridViewTextBoxCell();
                    dgvtc.Value = "N/T";
                    dgvr.Cells[i] = dgvtc;
                    //dgvtc.ReadOnly = true;
                }
            }
        }
Ejemplo n.º 37
0
 public ObjectCollection(DataGridViewComboBoxCell owner)
 {
     throw null;
 }
Ejemplo n.º 38
0
        void LoadXmlFile()
        {
            if (string.IsNullOrEmpty(this.XmlFileName) == true)
                return;

            string strError = "";
            XmlDocument dom = new XmlDocument();
            try
            {
                dom.Load(this.XmlFileName);
            }
            catch (FileNotFoundException)
            {
                dom.LoadXml("<root />");
            }
            catch (Exception ex)
            {
                strError = "文件 '"+this.XmlFileName+"' 装入 XMLDOM 时出错: " + ex.Message;
                goto ERROR1;
            }

            XmlNodeList nodes = dom.DocumentElement.SelectNodes("item");
            foreach (XmlElement item in nodes)
            {
                string strName = item.GetAttribute("name");
                string strValue = item.InnerText.Trim();

                int index = this.dataGridView1.Rows.Add();
                DataGridViewRow row = this.dataGridView1.Rows[index];

                row.Cells[0].Value = strName;
                row.Cells[1].Value = strValue;

#if NO
                DataGridViewRow row = new DataGridViewRow();

                var nameCell = new DataGridViewComboBoxCell();
                // nameCell.Items.Add(strName);
                nameCell.Value = strName;

                var incStyleCell = new DataGridViewComboBoxCell();
                // incStyleCell.Items.Add("test");
                incStyleCell.Value = "test";

                var valueCell = new DataGridViewTextBoxCell();
                valueCell.Value = strValue;

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

                this.dataGridView1.Rows.Add(row);
#endif

            }

            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
Ejemplo n.º 39
0
 public ObjectCollection(DataGridViewComboBoxCell owner)
 {
     Debug.Assert(owner is not null);
     this.owner = owner;
 }