Esempio n. 1
0
        private void edit(object sender, DataGridViewCellEventArgs e)
        {
            IParamCollection i = p.Groups[currentEntry[0]];

            if (i is ParamGroup)
            {
                ParamGroup pg = (ParamGroup)i;
                switch (pg.Values[pg.EntrySize * currentEntry[1] + e.RowIndex].Type)
                {
                case ParamType.str:
                    pg.Values[pg.EntrySize * currentEntry[1] + e.RowIndex].Value = tbl.Rows[e.RowIndex][1];
                    break;

                case ParamType.s8:
                    pg.Values[pg.EntrySize * currentEntry[1] + e.RowIndex].Value = Convert.ToByte(tbl.Rows[e.RowIndex][1]);
                    break;

                case ParamType.u8:
                    pg.Values[pg.EntrySize * currentEntry[1] + e.RowIndex].Value = Convert.ToByte(tbl.Rows[e.RowIndex][1]);
                    break;

                case ParamType.s16:
                    pg.Values[pg.EntrySize * currentEntry[1] + e.RowIndex].Value = Convert.ToInt16(tbl.Rows[e.RowIndex][1]);
                    break;

                case ParamType.u16:
                    pg.Values[pg.EntrySize * currentEntry[1] + e.RowIndex].Value = Convert.ToUInt16(tbl.Rows[e.RowIndex][1]);
                    break;

                case ParamType.s32:
                    pg.Values[pg.EntrySize * currentEntry[1] + e.RowIndex].Value = Convert.ToInt32(tbl.Rows[e.RowIndex][1]);
                    break;

                case ParamType.u32:
                    pg.Values[pg.EntrySize * currentEntry[1] + e.RowIndex].Value = Convert.ToUInt32(tbl.Rows[e.RowIndex][1]);
                    break;

                case ParamType.f32:
                    pg.Values[pg.EntrySize * currentEntry[1] + e.RowIndex].Value = Convert.ToSingle(tbl.Rows[e.RowIndex][1]);
                    break;
                }
                //pg.Values[pg.EntrySize * currentEntry[1] + e.RowIndex].Value = tbl.Rows[e.RowIndex][1];
            }
            else
            {
                switch (i.Values[e.RowIndex].Type)
                {
                case ParamType.str:
                    i.Values[e.RowIndex].Value = tbl.Rows[e.RowIndex][1];
                    break;

                case ParamType.s8:
                    i.Values[e.RowIndex].Value = Convert.ToByte(tbl.Rows[e.RowIndex][1]);
                    break;

                case ParamType.u8:
                    i.Values[e.RowIndex].Value = Convert.ToByte(tbl.Rows[e.RowIndex][1]);
                    break;

                case ParamType.s16:
                    i.Values[e.RowIndex].Value = Convert.ToInt16(tbl.Rows[e.RowIndex][1]);
                    break;

                case ParamType.u16:
                    i.Values[e.RowIndex].Value = Convert.ToUInt16(tbl.Rows[e.RowIndex][1]);
                    break;

                case ParamType.s32:
                    i.Values[e.RowIndex].Value = Convert.ToInt32(tbl.Rows[e.RowIndex][1]);
                    break;

                case ParamType.u32:
                    i.Values[e.RowIndex].Value = Convert.ToUInt32(tbl.Rows[e.RowIndex][1]);
                    break;

                case ParamType.f32:
                    i.Values[e.RowIndex].Value = Convert.ToSingle(tbl.Rows[e.RowIndex][1]);
                    break;
                }
                //i.Values[e.RowIndex].Value = tbl.Rows[e.RowIndex][1];
            }
            if (!notSaved)
            {
                Text    += "*";
                notSaved = true;
            }
        }
        private void edit(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                IParamCollection i = p.Groups[currentEntry[0]];
                int entrySize      = -1;
                if (i is ParamGroup)
                {
                    entrySize = ((ParamGroup)i).EntrySize;
                }
                else
                {
                    foreach (IniLabels.Label label in labels.labels)
                    {
                        if (label.Type == IniLabels.Label.type.Group && label.group == currentEntry[0] && label.entries != -1)
                        {
                            entrySize = (int)((p.Groups[currentEntry[0]].Values.ToArray().Length / label.entries) + 0.5);
                        }
                    }
                }
                if (entrySize != -1)
                {
                    IParamCollection pg = i;
                    switch (pg.Values[entrySize * currentEntry[1] + e.RowIndex].Type)
                    {
                    case ParamType.str:
                        pg.Values[entrySize * currentEntry[1] + e.RowIndex].Value = tbl.Rows[e.RowIndex][1];
                        break;

                    case ParamType.s8:
                        pg.Values[entrySize * currentEntry[1] + e.RowIndex].Value = Convert.ToByte(tbl.Rows[e.RowIndex][1]);
                        break;

                    case ParamType.u8:
                        pg.Values[entrySize * currentEntry[1] + e.RowIndex].Value = Convert.ToByte(tbl.Rows[e.RowIndex][1]);
                        break;

                    case ParamType.s16:
                        pg.Values[entrySize * currentEntry[1] + e.RowIndex].Value = Convert.ToInt16(tbl.Rows[e.RowIndex][1]);
                        break;

                    case ParamType.u16:
                        pg.Values[entrySize * currentEntry[1] + e.RowIndex].Value = Convert.ToUInt16(tbl.Rows[e.RowIndex][1]);
                        break;

                    case ParamType.s32:
                        pg.Values[entrySize * currentEntry[1] + e.RowIndex].Value = Convert.ToInt32(tbl.Rows[e.RowIndex][1]);
                        break;

                    case ParamType.u32:
                        pg.Values[entrySize * currentEntry[1] + e.RowIndex].Value = Convert.ToUInt32(tbl.Rows[e.RowIndex][1]);
                        break;

                    case ParamType.f32:
                        pg.Values[entrySize * currentEntry[1] + e.RowIndex].Value = Convert.ToSingle(tbl.Rows[e.RowIndex][1]);
                        break;
                    }
                    //pg.Values[pg.EntrySize * currentEntry[1] + e.RowIndex].Value = tbl.Rows[e.RowIndex][1];
                }
                else
                {
                    switch (i.Values[e.RowIndex].Type)
                    {
                    case ParamType.str:
                        i.Values[e.RowIndex].Value = tbl.Rows[e.RowIndex][1];
                        break;

                    case ParamType.s8:
                        i.Values[e.RowIndex].Value = Convert.ToByte(tbl.Rows[e.RowIndex][1]);
                        break;

                    case ParamType.u8:
                        i.Values[e.RowIndex].Value = Convert.ToByte(tbl.Rows[e.RowIndex][1]);
                        break;

                    case ParamType.s16:
                        i.Values[e.RowIndex].Value = Convert.ToInt16(tbl.Rows[e.RowIndex][1]);
                        break;

                    case ParamType.u16:
                        i.Values[e.RowIndex].Value = Convert.ToUInt16(tbl.Rows[e.RowIndex][1]);
                        break;

                    case ParamType.s32:
                        i.Values[e.RowIndex].Value = Convert.ToInt32(tbl.Rows[e.RowIndex][1]);
                        break;

                    case ParamType.u32:
                        i.Values[e.RowIndex].Value = Convert.ToUInt32(tbl.Rows[e.RowIndex][1]);
                        break;

                    case ParamType.f32:
                        i.Values[e.RowIndex].Value = Convert.ToSingle(tbl.Rows[e.RowIndex][1]);
                        break;
                    }
                    //i.Values[e.RowIndex].Value = tbl.Rows[e.RowIndex][1];
                }
                Edited = true;
            }
            catch (Exception)
            {
            }
        }