Ejemplo n.º 1
0
        public void InitMonthCells(int mt)
        {
            var pos = GetMTFirstCell(mt);

            SourceGrid.Cells.Editors.TextBox editor = null;
            grid[pos.Y, pos.X] = new SourceGrid.Cells.Cell("", editor);
            var cell = grid[pos.Y, pos.X];

            cell.ColumnSpan = 7;
            cell.View       = grid.gridViewModel.captionModel;
            cell.Value      = MonthNames[mt];
            for (int i = 1; i <= 6; i++)
            {
                for (int j = 0; j <= 6; j++)
                {
                    cell = new SourceGrid.Cells.Cell("", editor);
                    grid[pos.Y + i, pos.X + j] = cell;
                    SourceGrid.Cells.Views.Cell vm = null;
                    if (j == 0)
                    {
                        vm = grid.gridViewModel.dayCellModelLeft;
                    }
                    else if (j > 4)
                    {
                        vm = grid.gridViewModel.dayCellModelWeekend;
                    }
                    else
                    {
                        vm = grid.gridViewModel.dayCellModel;
                    }
                    cell.View = vm;
                }
            }
        }
Ejemplo n.º 2
0
        private static void Fill2(Grid a, object[] data, Color warna, int kolom)
        {
            SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
            view.BackColor = Color.Snow;

            //Editor (IDataModel) shared between all the cells
            SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string));

            editor.Control.Multiline = true;

            string nol = "";

            for (int i = 0; i < GlobalConfiguration.Digit; i++)
            {
                nol += "#";
            }

            for (int r = a.FixedRows; r < a.RowsCount; r++)
            {
                a[r, kolom]        = new SourceGrid.Cells.Cell(((double)data[r]).ToString("0." + nol));
                a[r, kolom].Editor = editor;
                a[r, kolom].View   = view;
            }

            a.Update();
            a.Selection.Focus(new SourceGrid.Position(0, 0), true);
            a.AutoSizeCells();
        }
Ejemplo n.º 3
0
        private static void Fill2(Grid a, object[,] data, Color warna, bool multiline = true)
        {
            SourceGrid.Cells.Views.Cell      view   = new SourceGrid.Cells.Views.Cell();
            SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(double));

            string nol = "";

            for (int i = 0; i < GlobalConfiguration.Digit; i++)
            {
                nol += "#";
            }

            view.BackColor           = warna;
            editor.Control.Multiline = multiline;

            for (int r = a.FixedRows; r < a.RowsCount; r++)
            {
                for (int c = a.FixedRows; c < a.ColumnsCount; c++)
                {
                    a[r, c]        = new SourceGrid.Cells.Cell(((double)data[r - 1, c - 1]).ToString("0." + nol));
                    a[r, c].Editor = editor;
                    a[r, c].View   = view;
                }
            }

            a.Update();
            a.Selection.Focus(new SourceGrid.Position(0, 0), true);
            a.AutoSizeCells();
        }
Ejemplo n.º 4
0
        internal void PopulateRetractionStops()
        {
            //List<string> retractionStartLines = bfbObject.generateRetractionStartList();

            SourceGrid.Cells.Editors.TextBox retractCountEditor = new SourceGrid.Cells.Editors.TextBox(typeof(int));
            retractCountEditor.EditableMode = SourceGrid.EditableMode.None;


            int gridRow = 1;
            RetractionStopChangedEvent valueChangedController = new RetractionStopChangedEvent(this);


            foreach (string keyLine in bfbObject.RetractionStopLineList.Keys)
            {
                int        index      = bfbObject.RetractionStopLineList[keyLine][0];
                Retraction retraction = bfbObject.RetractionStopDictionary[index];

                gridRetractionStop.Rows.Insert(gridRow);
                gridRetractionStop[gridRow, 0] = new SourceGrid.Cells.Cell(retraction.P, typeof(int));
                gridRetractionStop[gridRow, 0].AddController(valueChangedController);
                gridRetractionStop[gridRow, 1] = new SourceGrid.Cells.Cell(retraction.S, typeof(int));
                gridRetractionStop[gridRow, 1].AddController(valueChangedController);
                gridRetractionStop[gridRow, 2] = new SourceGrid.Cells.Cell(index, retractCountEditor);

                gridRow++;
            }
        }
Ejemplo n.º 5
0
        public void AddEmptyRow()
        {
            int newRowIndex = Rows.Count;

            Rows.Insert(newRowIndex);

            SuplementTypeCellValueChangedController suplementController = new SuplementTypeCellValueChangedController(this, entry);
            var lookupEditor = new LookupEditEditor(typeof(Guid));

            this[newRowIndex, SuplementTypeColumn] = new SourceGrid.Cells.Cell(null, lookupEditor);
            SourceGrid.Cells.Views.Cell readOnlyView = new SourceGrid.Cells.Views.Cell();
            this[newRowIndex, SuplementTypeColumn].View           = readOnlyView;
            this[newRowIndex, SuplementTypeColumn].View.ForeColor = ApplicationColors.FGNullText;
            this[newRowIndex, SuplementTypeColumn].AddController(suplementController);
            this[newRowIndex, SuplementTypeColumn].Editor.NullDisplayString = SuplementsEntryStrings.SelectSuplementType;

            readOnlyView = new SourceGrid.Cells.Views.Cell();
            var textBox = new SourceGrid.Cells.Editors.TextBox(typeof(string));

            textBox.Control.MaxLength = Constants.NameColumnLength;
            this[newRowIndex, SuplementNameColumn]      = new SourceGrid.Cells.Cell(null, textBox);
            this[newRowIndex, SuplementNameColumn].View = readOnlyView;
            readOnlyView = new SourceGrid.Cells.Views.Cell();
            ////grid1[newRowIndex, 1].AddController(ee);
            this[newRowIndex, InfoColumn]      = new SourceGrid.Cells.Cell(null, new MemoExEditEditor());
            this[newRowIndex, InfoColumn].View = readOnlyView;
            this[newRowIndex, InfoColumn].AddController(commentableCellController);
            this[newRowIndex, InfoColumn].Column.Width = 80;

            var maskEditor = new MaskEditEditor();

            maskEditor.MaskRegEx                 = string.Format("[0-9]*{0}?[0-9]*", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
            this[newRowIndex, DosageColumn]      = new SourceGrid.Cells.Cell(null, maskEditor);
            this[newRowIndex, DosageColumn].View = readOnlyView;

            SourceGrid.Cells.Editors.ComboBox cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(ComboBoxItem));
            //cbEditor.StandardValues = Enum.GetValues(typeof (DosageType));
            foreach (DosageType type in Enum.GetValues(typeof(DosageType)))
            {
                cbEditor.Control.Items.Add(new BodyArchitect.Controls.ComboBoxItem(type, EnumLocalizer.Default.Translate(type)));
            }

            cbEditor.Control.DropDownStyle = ComboBoxStyle.DropDownList;

            this[newRowIndex, DosageTypeColumn]              = new SourceGrid.Cells.Cell(null, cbEditor);
            this[newRowIndex, DosageTypeColumn].View         = readOnlyView;
            this[newRowIndex, DosageTypeColumn].Column.Width = 80;

            var timeEditor = new TimeEditEditor();

            this[newRowIndex, TimeColumn]      = new SourceGrid.Cells.Cell(null, timeEditor);
            this[newRowIndex, TimeColumn].View = new TimeEditView();

            UpdateCellsReadOnlyMode(Rows[newRowIndex]);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Translate all Pending Ressources with Google Translator
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AutoTranslateAll(object sender, EventArgs e)
        {
            progressBar.Maximum = grid1.Rows.Count;
            progressBar.Minimum = 0;

            progressBar.Value = 0;

            Cursor = Cursors.WaitCursor;

            for (int i = 0; i < grid1.Rows.Count; i++)
            {
                progressBar.Value = i;

                if (grid1[i, 2].Editor == null)
                {
                    continue;
                }

                SourceGrid.Cells.Editors.TextBox tbx = (SourceGrid.Cells.Editors.TextBox)grid1[i, 2].Editor;

                TextBoxTranslation tbt = (TextBoxTranslation)tbx.Control.Tag;

                if (!tbx.Control.ForeColor.Equals(Color.Red))
                {
                    continue;
                }

                tbx.Control.Text = Translator.TranslateText(tbx.Control.Text,
                                                            string.Format("{0}|{1}", sLangCodeSrc, sLangCodeDest));

                tbx.Control.ForeColor = tbt.srcResourceValue.Equals(tbx.Control.Text, StringComparison.OrdinalIgnoreCase)
                                            ? Color.Red
                                            : Color.Black;

                // Update Translations List
                translations.Find(check =>
                                  check.sPageName.Equals(tbt.pageName) &&
                                  check.sResourceName.Equals(tbt.resourceName)).
                sLocalizedValue = tbx.Control.Text;


                grid1[i, 2].View = tbt.srcResourceValue.Equals(tbx.Control.Text, StringComparison.OrdinalIgnoreCase)
                                       ? cellLocalResourceRed
                                       : cellLocalResource;

                grid1[i, 2].Value = tbx.Control.Text;
            }

            grid1.Update();


            Cursor = Cursors.Default;
        }
Ejemplo n.º 7
0
            public EditableColumnHeader(string caption) : base(caption)
            {
                //Set the editor
                SourceGrid.Cells.Editors.TextBox headerEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string));
                headerEditor.EditableMode = SourceGrid.EditableMode.None;
                Editor = headerEditor;

                //Add the right click editing support
                AddController(rightClickEditing);

                //Remove the unselectable Controllers
                RemoveController(SourceGrid.Cells.Controllers.Unselectable.Default);
            }
Ejemplo n.º 8
0
        private void btLoad_Click(object sender, System.EventArgs e)
        {
            grid.Redim(0, 0);
            //Visual properties shared between all the cells
            SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
            view.BackColor = Color.Snow;

            //Editor (IDataModel) shared between all the cells
            SourceGrid.Cells.Editors.TextBox editor = new
                                                      SourceGrid.Cells.Editors.TextBox(typeof(string));

            grid.Redim(int.Parse(txtRows.Text), int.Parse(txtCols.Text));

            if (chkAddHeaders.Checked && grid.RowsCount > 0 &&
                grid.ColumnsCount > 0)
            {
                grid.FixedRows    = 1;
                grid.FixedColumns = 1;

                for (int r = grid.FixedRows; r < grid.RowsCount; r++)
                {
                    grid[r, 0] = new SourceGrid.Cells.RowHeader(r);
                }
                for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++)
                {
                    SourceGrid.Cells.ColumnHeader header = new
                                                           SourceGrid.Cells.ColumnHeader(c);
                    header.AutomaticSortEnabled = false;
                    grid[0, c] = header;
                }
                grid[0, 0] = new SourceGrid.Cells.Header();
            }
            else
            {
                grid.FixedRows    = 0;
                grid.FixedColumns = 0;
            }

            for (int r = grid.FixedRows; r < grid.RowsCount; r++)
            {
                for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++)
                {
                    grid[r, c] = new SourceGrid.Cells.Cell(r.ToString() + "," +
                                                           c.ToString());
                    grid[r, c].Editor = editor;
                    grid[r, c].View   = view;
                }
            }
            grid.Selection.Focus(new SourceGrid.Position(0, 0), true);
        }
Ejemplo n.º 9
0
        public override SourceGrid.Cells.Cell MakeDataCell()
        {
            SourceGrid.Cells.Cell            textcell     = null;
            SourceGrid.Cells.Editors.TextBox sharededitor = null;

            var sharededitor1 = GetSharedEditor();

            if (sharededitor1 != null)
            {
                sharededitor = sharededitor1 as SourceGrid.Cells.Editors.TextBox;
                if (sharededitor1 == null)
                {
                    throw new Exception("Wrong shared editor type.");
                }
            }

            if (sharededitor != null)
            {
                textcell        = new SourceGrid.Cells.Cell(GetDefaultValue());
                textcell.Editor = sharededitor;
            }
            else
            {
                textcell = new SourceGrid.Cells.Cell(GetDefaultValue(), GetValueType());
                var editor = new SourceGrid.Cells.Editors.TextBox(GetValueType());
                textcell.Editor              = editor;
                editor.Control.Multiline     = true;
                editor.Control.WordWrap      = true;
                editor.Control.AcceptsReturn = true;
                editor.Control.ScrollBars    = System.Windows.Forms.ScrollBars.Vertical;

                var tc = GetMyTypeConverter();
                if (tc != null)
                {
                    textcell.Editor.TypeConverter = tc;
                }

                //if (CustomConversions)
                ValueMapping = new ValueMappingB(textcell.Editor, this);
            }

            textcell.RowSpan = RowSpan;
            textcell.View    = Grid.gridViewModel.dataCellMultiLineModel;


            return(textcell);
        }
Ejemplo n.º 10
0
        internal void PopulateTemperatures(string tempCmdStr, Grid gridTemps)
        {
            Dictionary <int, int> tempDict = new Dictionary <int, int>();

            List <string> tempLines = bfbObject.getTemperatures(tempCmdStr);

            for (int i = 0; i < tempLines.Count; i++)
            {
                int temperature = bfbObject.GetTemperatureFromString(tempLines[i]);
                if (tempDict.ContainsKey(temperature))
                {
                    tempDict[temperature]++;
                }
                else
                {
                    tempDict.Add(temperature, 1);
                }
            }

            SourceGrid.Cells.Editors.ComboBox tempModEditor;
            String[] tempModType = { "Percentage", "Additive", "Replace" };
            tempModEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(String));
            tempModEditor.StandardValues = tempModType;
            tempModEditor.EditableMode   = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;

            SourceGrid.Cells.Editors.TextBox tempCountEditor = new SourceGrid.Cells.Editors.TextBox(typeof(int));
            tempCountEditor.EditableMode = SourceGrid.EditableMode.None;

            int gridRow = 1;
            TemperatureChangedEvent valueChangedController = new TemperatureChangedEvent(this);

            foreach (int temp in tempDict.Keys)
            {
                gridTemps.Rows.Insert(gridRow);
                gridTemps[gridRow, 0] = new SourceGrid.Cells.Cell(temp, tempCountEditor);
                gridTemps[gridRow, 1] = new SourceGrid.Cells.Cell(tempDict[temp], tempCountEditor);
                gridTemps[gridRow, 2] = new SourceGrid.Cells.Cell(null, typeof(int));
                gridTemps[gridRow, 2].AddController(valueChangedController);
                gridTemps[gridRow, 3]      = new SourceGrid.Cells.Cell("Replace", tempModEditor);
                gridTemps[gridRow, 3].View = SourceGrid.Cells.Views.ComboBox.Default;
                gridTemps[gridRow, 3].AddController(valueChangedController);
                gridTemps[gridRow, 4] = new SourceGrid.Cells.Cell(0, tempCountEditor);

                //gridLeftTemps[gridRow, 1] = new SourceGrid.Cells.CellControl();
                gridRow++;
            }
        }
Ejemplo n.º 11
0
        internal void PopulateRetractionStarts()
        {
            //List<string> retractionStartLines = bfbObject.generateRetractionStartList();

            SourceGrid.Cells.Editors.TextBox retractCountEditor = new SourceGrid.Cells.Editors.TextBox(typeof(int));
            retractCountEditor.EditableMode = SourceGrid.EditableMode.None;


            int gridRow = 1;
            RetractionStartChangedEvent valueChangedController = new RetractionStartChangedEvent(this);


            foreach (string keyLine in bfbObject.RetractionStartLineList.Keys)
            {
                int        index      = bfbObject.RetractionStartLineList[keyLine][0];
                Retraction retraction = bfbObject.RetractionStartDictionary[index];

                gridRetractionStart.Rows.Insert(gridRow);
                gridRetractionStart[gridRow, 0] = new SourceGrid.Cells.Cell(retraction.P, typeof(int));
                gridRetractionStart[gridRow, 0].AddController(valueChangedController);
                gridRetractionStart[gridRow, 1] = new SourceGrid.Cells.Cell(retraction.S, typeof(int));
                gridRetractionStart[gridRow, 1].AddController(valueChangedController);
                if (retraction.G != -1)
                {
                    gridRetractionStart[gridRow, 2] = new SourceGrid.Cells.Cell(retraction.G, typeof(int));
                    gridRetractionStart[gridRow, 2].AddController(valueChangedController);
                }
                else
                {
                    gridRetractionStart[gridRow, 2] = new SourceGrid.Cells.Cell(" ", retractCountEditor);
                }
                if (retraction.F != -1)
                {
                    gridRetractionStart[gridRow, 3] = new SourceGrid.Cells.Cell(retraction.F, typeof(int));
                    gridRetractionStart[gridRow, 3].AddController(valueChangedController);
                }
                else
                {
                    gridRetractionStart[gridRow, 3] = new SourceGrid.Cells.Cell(" ", retractCountEditor);
                }
                gridRetractionStart[gridRow, 4] = new SourceGrid.Cells.Cell(index, retractCountEditor);

                //gridLeftTemps[gridRow, 1] = new SourceGrid.Cells.CellControl();
                gridRow++;
            }
        }
Ejemplo n.º 12
0
        public static void FillRandom(Grid a, int rounddigit = 4, int minrnd = -1, int maxrnd = 1)
        {
            SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
            view.BackColor = Color.Snow;
            SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string));

            Random rnd = new Random();

            for (int r = a.FixedRows; r < a.RowsCount; r++)
            {
                for (int c = a.FixedColumns; c < a.ColumnsCount; c++)
                {
                    a[r, c]        = new SourceGrid.Cells.Cell(rnd.NextDouble(minrnd, maxrnd).Rounding(rounddigit));
                    a[r, c].Editor = editor;
                    a[r, c].View   = view;
                }
            }
            a.Update();
            a.Selection.Focus(new SourceGrid.Position(0, 0), true);
            a.AutoSizeCells();
        }
Ejemplo n.º 13
0
        private static void Fill(Grid a, object[] data, Color warna, int kolom)
        {
            SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
            view.BackColor = Color.Snow;

            //Editor (IDataModel) shared between all the cells
            SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string));

            editor.Control.Multiline = true;

            for (int r = a.FixedRows; r < a.RowsCount; r++)
            {
                a[r, kolom]        = new SourceGrid.Cells.Cell(data[r]);
                a[r, kolom].Editor = editor;
                a[r, kolom].View   = view;
            }

            a.Update();
            a.Selection.Focus(new SourceGrid.Position(0, 0), true);
            a.AutoSizeCells();
        }
Ejemplo n.º 14
0
        private void btLoad_Click(object sender, System.EventArgs e)
        {
            //Visual properties shared between all the cells
            SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
            view.BackColor = Color.Snow;

            //Editor (IDataModel) shared between all the cells
            SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string));

            grid.Redim(int.Parse(txtRows.Text), int.Parse(txtCols.Text));

            for (int r = 0; r < grid.RowsCount; r++)
            {
                for (int c = 0; c < grid.ColumnsCount; c++)
                {
                    grid[r, c]        = new SourceGrid.Cells.Cell(r.ToString() + "," + c.ToString());
                    grid[r, c].Editor = editor;
                    grid[r, c].View   = view;
                }
            }
        }
Ejemplo n.º 15
0
        private static void Fill(Grid a, object[,] data, Color warna, bool multiline = true)
        {
            SourceGrid.Cells.Views.Cell      view   = new SourceGrid.Cells.Views.Cell();
            SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            view.BackColor           = warna;
            editor.Control.Multiline = multiline;

            for (int r = a.FixedRows; r < a.RowsCount; r++)
            {
                for (int c = a.FixedRows; c < a.ColumnsCount; c++)
                {
                    a[r, c]        = new SourceGrid.Cells.Cell(data[r - 1, c - 1]);
                    a[r, c].Editor = editor;
                    a[r, c].View   = view;
                }
            }

            a.Update();
            a.Selection.Focus(new SourceGrid.Position(0, 0), true);
            a.AutoSizeCells();
        }
Ejemplo n.º 16
0
        private static void Fill(Grid a, object[,] data, bool multiline = true)
        {
            SourceGrid.Cells.Views.Cell      view   = new SourceGrid.Cells.Views.Cell();
            SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            view.BackColor           = Color.White;
            editor.Control.Multiline = multiline;

            for (int r = a.FixedRows; r < a.RowsCount; r++)
            {
                a[r, 1]      = new SourceGrid.Cells.Cell(data[r - 1, 0]);
                a[r, 2]      = new SourceGrid.Cells.Cell(data[r - 1, 1]);
                a[r, 3]      = new SourceGrid.Cells.Cell(data[r - 1, 2]);
                a[r, 4]      = new SourceGrid.Cells.Cell(data[r - 1, 3]);
                a[r, 5]      = new SourceGrid.Cells.Cell(data[r - 1, 4]);
                a[r, 6]      = new SourceGrid.Cells.Cell(data[r - 1, 5]);
                a[r, 7]      = new SourceGrid.Cells.Cell(data[r - 1, 6]);
                a[r, 8]      = new SourceGrid.Cells.Cell(data[r - 1, 7]);
                a[r, 9]      = new SourceGrid.Cells.Cell(data[r - 1, 8]);
                a[r, 1].View = view;
                a[r, 2].View = view;
                a[r, 3].View = view;
                a[r, 4].View = view;
                a[r, 5].View = view;
                a[r, 6].View = view;
                a[r, 7].View = view;
                a[r, 8].View = view;
                a[r, 9].View = view;
            }

            a.Update();
            try
            {
                a.Selection.Focus(new SourceGrid.Position(1, 1), true);
            }
            catch
            {
            }
            a.AutoSizeCells();
        }
Ejemplo n.º 17
0
        internal void PopulatePressures()
        {
            SourceGrid.Cells.Editors.TextBox pressureEditor = new SourceGrid.Cells.Editors.TextBox(typeof(Double));
            pressureEditor.EditableMode = SourceGrid.EditableMode.None;


            int gridRow = 1;
            PressureChangedEvent valueChangedController = new PressureChangedEvent(this);

            foreach (String keyLine in bfbObject.PressureLineList.Keys)
            {
                int    index    = bfbObject.PressureLineList[keyLine][0];
                Double pressure = bfbObject.PressureDictionary[index];

                gridPressure.Rows.Insert(gridRow);
                gridPressure[gridRow, 0] = new SourceGrid.Cells.Cell(pressure, typeof(double));
                gridPressure[gridRow, 0].AddController(valueChangedController);
                gridPressure[gridRow, 1] = new SourceGrid.Cells.Cell(index, pressureEditor);

                gridRow++;
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Creates controls for column 1 (Resource tag) and column 2 (Resource value).
        /// </summary>
        /// <param name="pageName"></param>
        /// <param name="resourceName"></param>
        /// <param name="srcResourceValue"></param>
        /// <param name="dstResourceValue"></param>
        private void CreatePageResourceControl(string pageName, string resourceName, string srcResourceValue, string dstResourceValue)
        {
            SourceGrid.Cells.Editors.TextBox tbx = new SourceGrid.Cells.Editors.TextBox(typeof(string));

            tbx.Control.Text      = dstResourceValue;
            tbx.Control.Multiline = true;

            if (tbx.Control.Text.Length > 30)
            {
                int height = 60 * (tbx.Control.Text.Length / 60);
                tbx.Control.Height = height;
            }


            Translation translation = new Translation
            {
                sPageName       = pageName,
                sResourceName   = resourceName,
                sResourceValue  = srcResourceValue,
                sLocalizedValue = dstResourceValue
            };

            translations.Add(translation);


            if (srcResourceValue.Equals(dstResourceValue, StringComparison.OrdinalIgnoreCase))
            {
                tbx.Control.ForeColor = Color.Red;
            }
            else
            {
                // Show only not translated
                if (checkPendingOnly.Checked)
                {
                    return;
                }
            }

            tbx.Control.LostFocus   += TbxLostFocus;
            tbx.Control.TextChanged += TbxTextChanged;

            MenuItem menuItem = new MenuItem {
                Text = "Auto Translate"
            };

            menuItem.Click += MenuItemClick;

            ContextMenu contextMenu = new ContextMenu();

            contextMenu.MenuItems.Add(menuItem);

            tbx.Control.ContextMenu = contextMenu;

            DevAge.Drawing.BorderLine      border     = new DevAge.Drawing.BorderLine(Color.Black, 1);
            DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

            tbx.Control.Tag = new TextBoxTranslation
            {
                pageName         = pageName,
                resourceName     = resourceName,
                srcResourceValue = srcResourceValue
            };


            Cell cellResourceValue = new Cell
            {
                Font          = ResourceHeaderFont,
                TextAlignment =
                    DevAge.Drawing.ContentAlignment.TopLeft,
                WordWrap  = true,
                Border    = cellBorder,
                BackColor = Color.LightGray
            };

            Cell cellResourceName = new Cell
            {
                Font          = ResourceHeaderFont,
                TextAlignment =
                    DevAge.Drawing.ContentAlignment.TopCenter,
                WordWrap  = true,
                Border    = cellBorder,
                BackColor = Color.LightGray
            };


            grid1.Rows.Insert(RowCount);
            grid1[RowCount, 0] = new SourceGrid.Cells.Cell(srcResourceValue, typeof(string))
            {
                View = cellResourceValue
            };
            grid1[RowCount, 0].AddController(new SourceGrid.Cells.Controllers.Unselectable());

            grid1[RowCount, 1] = new SourceGrid.Cells.Cell(resourceName, typeof(string))
            {
                View = cellResourceName
            };
            grid1[RowCount, 1].AddController(new SourceGrid.Cells.Controllers.Unselectable());

            if (tbx.Control.ForeColor.Equals(Color.Red))
            {
                grid1[RowCount, 2] = new SourceGrid.Cells.Cell(tbx.Control.Text)
                {
                    View = cellLocalResourceRed, Editor = tbx
                };
            }
            else
            {
                grid1[RowCount, 2] = new SourceGrid.Cells.Cell(tbx.Control.Text)
                {
                    View = cellLocalResource, Editor = tbx
                };
            }



            if (tbx.Control.Text.Length > 30)
            {
                int height = 60 * (tbx.Control.Text.Length / 60);

                grid1.Rows[RowCount].Height = height;
            }


            RowCount++;
        }
Ejemplo n.º 19
0
        private void btLoad_Click(object sender, System.EventArgs e)
        {
            grid.Redim(0, 0);
            //Visual properties shared between all the cells
            SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
            view.BackColor = Color.Snow;

            //Editor (IDataModel) shared between all the cells
            SourceGrid.Cells.Editors.TextBox editor = new
            SourceGrid.Cells.Editors.TextBox(typeof(string));

            grid.Redim(int.Parse(txtRows.Text), int.Parse(txtCols.Text));

            if (chkAddHeaders.Checked && grid.RowsCount > 0 &&
                        grid.ColumnsCount > 0)
            {
                grid.FixedRows = 1;
                grid.FixedColumns = 1;

                for (int r = grid.FixedRows; r < grid.RowsCount; r++)
                    grid[r, 0] = new SourceGrid.Cells.RowHeader(r);
                for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++)
                {
                    SourceGrid.Cells.ColumnHeader header = new
                    SourceGrid.Cells.ColumnHeader(c);
                    header.AutomaticSortEnabled = false;
                    grid[0, c] = header;
                }
                grid[0, 0] = new SourceGrid.Cells.Header();
            }
            else
            {
                grid.FixedRows = 0;
                grid.FixedColumns = 0;
            }

            for (int r = grid.FixedRows; r < grid.RowsCount; r++)
                for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++)
                {
                    grid[r, c] = new SourceGrid.Cells.Cell(r.ToString() + "," +
                    c.ToString());
                    grid[r, c].Editor = editor;
                    grid[r, c].View = view;
                }
            grid.Selection.Focus(new SourceGrid.Position(0, 0), true);
        }
Ejemplo n.º 20
0
		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad (e);

			//Border
			DevAge.Drawing.BorderLine border = new DevAge.Drawing.BorderLine(Color.DarkKhaki, 1);
			DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

			//Views
            CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.Khaki, Color.DarkKhaki);
            viewNormal.Border = cellBorder;
            CheckBoxBackColorAlternate viewCheckBox = new CheckBoxBackColorAlternate(Color.Khaki, Color.DarkKhaki);
            viewCheckBox.Border = cellBorder;

			//ColumnHeader view
			SourceGrid.Cells.Views.ColumnHeader viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
            DevAge.Drawing.VisualElements.ColumnHeader backHeader = new DevAge.Drawing.VisualElements.ColumnHeader();
            backHeader.BackColor = Color.Maroon;
            backHeader.Border = DevAge.Drawing.RectangleBorder.NoBorder;
            viewColumnHeader.Background = backHeader;
            viewColumnHeader.ForeColor = Color.White;
            viewColumnHeader.Font = new Font("Comic Sans MS", 10, FontStyle.Underline);

			//Editors
			SourceGrid.Cells.Editors.TextBox editorString = new SourceGrid.Cells.Editors.TextBox(typeof(string));
			SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDateTime = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime));


			//Create the grid
			grid1.BorderStyle = BorderStyle.FixedSingle;

			grid1.ColumnsCount = 3;
			grid1.FixedRows = 1;
			grid1.Rows.Insert(0);

			SourceGrid.Cells.ColumnHeader columnHeader;

			columnHeader = new SourceGrid.Cells.ColumnHeader("String");
			columnHeader.View = viewColumnHeader;
			grid1[0,0] = columnHeader;

			columnHeader = new SourceGrid.Cells.ColumnHeader("DateTime");
			columnHeader.View = viewColumnHeader;
			grid1[0,1] = columnHeader;

			columnHeader = new SourceGrid.Cells.ColumnHeader("CheckBox");
			columnHeader.View = viewColumnHeader;
			grid1[0,2] = columnHeader;

			for (int r = 1; r < 10; r++)
			{
				grid1.Rows.Insert(r);

				grid1[r,0] = new SourceGrid.Cells.Cell("Hello " + r.ToString());
				grid1[r,0].Editor = editorString;

				grid1[r,1] = new SourceGrid.Cells.Cell(DateTime.Today);
				grid1[r,1].Editor = editorDateTime;

				grid1[r,2] = new SourceGrid.Cells.CheckBox(null, true);

				grid1[r,0].View = viewNormal;
				grid1[r,1].View = viewNormal;
				grid1[r,2].View = viewCheckBox;
			}

            grid1.AutoSizeCells();
		}
Ejemplo n.º 21
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            grid.Redim(62, 3);

            SourceGrid.Cells.Views.Cell titleModel = new SourceGrid.Cells.Views.Cell();
            titleModel.BackColor     = Color.SteelBlue;
            titleModel.ForeColor     = Color.White;
            titleModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            SourceGrid.Cells.Views.Cell captionModel = new SourceGrid.Cells.Views.Cell();
            captionModel.BackColor = grid.BackColor;

            int currentRow = 0;

            #region Base Types
            grid[currentRow, 0]            = new SourceGrid.Cells.Cell("Base Types");
            grid[currentRow, 0].View       = titleModel;
            grid[currentRow, 0].ColumnSpan = 3;
            currentRow++;

            //string
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("String");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell("String Value", typeof(string));

            currentRow++;

            //double
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Double");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(1.5, typeof(double));

            currentRow++;

            //int
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Int");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(5, typeof(int));

            currentRow++;

            //DateTime
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("DateTime");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime));

            currentRow++;

            //Boolean
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Boolean");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(true, typeof(Boolean));

            currentRow++;
            #endregion

            #region Complex Types
            grid[currentRow, 0]            = new SourceGrid.Cells.Cell("Complex Types");
            grid[currentRow, 0].View       = titleModel;
            grid[currentRow, 0].ColumnSpan = 3;
            currentRow++;

            //Font
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Font");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(this.Font, typeof(Font));

            currentRow++;

            //Cursor
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Cursor");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(Cursors.Arrow, typeof(Cursor));

            currentRow++;

            //Point
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Point");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(new Point(2, 3), typeof(Point));

            currentRow++;

            //Rectangle
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Rectangle");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(new Rectangle(100, 100, 200, 200), typeof(Rectangle));

            currentRow++;

            //Image
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Image");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Image(Properties.Resources.CalcioSmall);

            currentRow++;

            //Enum AnchorStyle
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("AnchorStyle");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(AnchorStyles.Bottom, typeof(AnchorStyles));

            currentRow++;

            //Enum
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Enum");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(System.Windows.Forms.BorderStyle.Fixed3D, typeof(System.Windows.Forms.BorderStyle));

            currentRow++;

            //String[]
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("String Array");
            grid[currentRow, 0].View = captionModel;
            string[] strArray = new string[] { "Value 1", "Value 2" };
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(strArray, typeof(string[]));

            currentRow++;

            //Double[]
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Double Array");
            grid[currentRow, 0].View = captionModel;
            double[] dblArray = new double[] { 1, 0.5, 0.1 };
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(dblArray, typeof(double[]));

            currentRow++;
            #endregion

            #region Special Editors
            grid[currentRow, 0]            = new SourceGrid.Cells.Cell("Special Editors");
            grid[currentRow, 0].View       = titleModel;
            grid[currentRow, 0].ColumnSpan = 3;
            currentRow++;

            //Time
            grid[currentRow, 0]        = new SourceGrid.Cells.Cell("Time");
            grid[currentRow, 0].View   = captionModel;
            grid[currentRow, 1]        = new SourceGrid.Cells.Cell(DateTime.Now);
            grid[currentRow, 1].Editor = new SourceGrid.Cells.Editors.TimePicker();

            currentRow++;

            //Double Chars Validation
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Double Chars Validation");
            grid[currentRow, 0].View = captionModel;
            SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double));
            numericEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs)
            {
                bool isValid = char.IsNumber(keyArgs.KeyChar) ||
                               keyArgs.KeyChar == System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0];

                keyArgs.Handled = !isValid;
            };
            grid[currentRow, 1]        = new SourceGrid.Cells.Cell(0.5);
            grid[currentRow, 1].Editor = numericEditor;

            currentRow++;

            //String Chars (ABC)
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Chars Validation(only ABC)");
            grid[currentRow, 0].View = captionModel;
            SourceGrid.Cells.Editors.TextBox stringEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            stringEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs)
            {
                keyArgs.KeyChar = char.ToUpper(keyArgs.KeyChar);
                bool isValid = keyArgs.KeyChar == 'A' || keyArgs.KeyChar == 'B' || keyArgs.KeyChar == 'C';

                keyArgs.Handled = !isValid;
            };
            grid[currentRow, 1]        = new SourceGrid.Cells.Cell("AABB");
            grid[currentRow, 1].Editor = stringEditor;

            currentRow++;

            //String Validating
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("String validating(min 6 chars)");
            grid[currentRow, 0].View = captionModel;
            SourceGrid.Cells.Editors.TextBox stringEditorValidating = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            stringEditorValidating.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent)
            {
                string val = ((TextBox)sender).Text;
                if (val == null || val.Length < 6)
                {
                    cancelEvent.Cancel = true;
                }
            };
            grid[currentRow, 1]        = new SourceGrid.Cells.Cell("test string");
            grid[currentRow, 1].Editor = stringEditorValidating;

            currentRow++;

            //Int 0-100 or null
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Int 0-100 or null");
            grid[currentRow, 0].View = captionModel;
            SourceGrid.Cells.Editors.TextBoxNumeric numericEditor0_100 = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(int));
            numericEditor0_100.MinimumValue = 0;
            numericEditor0_100.MaximumValue = 100;
            numericEditor0_100.AllowNull    = true;
            grid[currentRow, 1]             = new SourceGrid.Cells.Cell(7);
            grid[currentRow, 1].Editor      = numericEditor0_100;

            currentRow++;

            //Double Custom Conversion
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Dbl custom conversion");
            grid[currentRow, 0].View = captionModel;
            SourceGrid.Cells.Editors.TextBox dblCustomConversion = new SourceGrid.Cells.Editors.TextBox(typeof(double));
            dblCustomConversion.ConvertingObjectToValue += delegate(object sender,
                                                                    DevAge.ComponentModel.ConvertingObjectEventArgs conv)
            {
                if (conv.Value is string)
                {
                    //Here you can add any custom code
                    double val;
                    if (double.TryParse((string)conv.Value, out val))
                    {
                        conv.Value            = val;
                        conv.ConvertingStatus = DevAge.ComponentModel.ConvertingStatus.Completed;
                    }
                }
            };
            grid[currentRow, 1]        = new SourceGrid.Cells.Cell(73.839);
            grid[currentRow, 1].Editor = dblCustomConversion;

            currentRow++;

            //Enum Custom Display
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Enum Custom Display");
            grid[currentRow, 0].View = captionModel;
            SourceGrid.Cells.Editors.ComboBox keysCombo = new SourceGrid.Cells.Editors.ComboBox(typeof(Keys));
            keysCombo.Control.FormattingEnabled       = true;
            keysCombo.ConvertingValueToDisplayString += delegate(object sender, DevAge.ComponentModel.ConvertingObjectEventArgs convArgs)
            {
                if (convArgs.Value is Keys)
                {
                    convArgs.Value = (int)((Keys)convArgs.Value) + " - " + convArgs.Value.ToString();
                }
            };
            grid[currentRow, 1]        = new SourceGrid.Cells.Cell(Keys.Enter);
            grid[currentRow, 1].Editor = keysCombo;

            currentRow++;

            string[] arraySample = new string[] { "Value 1", "Value 2", "Value 3" };
            //ComboBox 1
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("ComboBox String");
            grid[currentRow, 0].View = captionModel;
            SourceGrid.Cells.Editors.ComboBox comboStandard = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false);
            comboStandard.Control.MaxLength = 10;
            grid[currentRow, 1]             = new SourceGrid.Cells.Cell(arraySample[0], comboStandard);

            currentRow++;

            //ComboBox exclusive
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("ComboBox String Exclusive");
            grid[currentRow, 0].View = captionModel;
            SourceGrid.Cells.Editors.ComboBox comboExclusive = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true);
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboExclusive);

            currentRow++;

            //ComboBox AutoComplete
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("ComboBox AutoComplete");
            grid[currentRow, 0].View = captionModel;
            SourceGrid.Cells.Editors.ComboBox comboAutoComplete =
                new SourceGrid.Cells.Editors.ComboBox(typeof(string),
                                                      new string[] { "AAA", "ABC", "AZA", "BAA", "ZAA" },
                                                      true);
            comboAutoComplete.Control.AutoCompleteSource = AutoCompleteSource.ListItems;
            comboAutoComplete.Control.AutoCompleteMode   = AutoCompleteMode.Append;
            grid[currentRow, 1] = new SourceGrid.Cells.Cell("AAA", comboAutoComplete);

            currentRow++;

            //ComboBox DropDownList
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("ComboBox DropDownList");
            grid[currentRow, 0].View = captionModel;
            SourceGrid.Cells.Editors.ComboBox comboNoText = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true);
            grid[currentRow, 1]               = new SourceGrid.Cells.Cell(arraySample[0]);
            grid[currentRow, 1].Editor        = comboNoText;
            comboNoText.Control.DropDownStyle = ComboBoxStyle.DropDownList;

            currentRow++;

            //ComboBox DateTime Editable
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("ComboBox DateTime");
            grid[currentRow, 0].View = captionModel;
            DateTime[] arrayDt = new DateTime[] { new DateTime(1981, 10, 6), new DateTime(1991, 10, 6), new DateTime(2001, 10, 6) };
            SourceGrid.Cells.Editors.ComboBox comboDateTime = new SourceGrid.Cells.Editors.ComboBox(typeof(DateTime), arrayDt, false);
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(arrayDt[0], comboDateTime);

            currentRow++;

            //ComboBox Custom Display (create a datamodel that has a custom display string)
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("ComboBox Custom Display");
            grid[currentRow, 0].View = captionModel;
            int[]    arrInt = new int[] { 0, 1, 2, 3, 4 };
            string[] arrStr = new string[] { "0 - Zero", "1 - One", "2 - Two", "3 - Three", "4- Four" };
            SourceGrid.Cells.Editors.ComboBox editorComboCustomDisplay = new SourceGrid.Cells.Editors.ComboBox(typeof(int), arrInt, true);
            editorComboCustomDisplay.Control.FormattingEnabled = true;
            DevAge.ComponentModel.Validator.ValueMapping comboMapping = new DevAge.ComponentModel.Validator.ValueMapping();
            comboMapping.DisplayStringList = arrStr;
            comboMapping.ValueList         = arrInt;
            comboMapping.SpecialList       = arrStr;
            comboMapping.SpecialType       = typeof(string);
            comboMapping.BindValidator(editorComboCustomDisplay);
            grid[currentRow, 1]        = new SourceGrid.Cells.Cell(0);
            grid[currentRow, 1].Editor = editorComboCustomDisplay;

            SourceGrid.Cells.Cell l_CellComboRealValue = new SourceGrid.Cells.Cell(grid[currentRow, 1].Value);
            l_CellComboRealValue.View = captionModel;
            SourceGrid.Cells.Controllers.BindProperty l_ComboBindProperty = new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Cell).GetProperty("Value"), l_CellComboRealValue);
            grid[currentRow, 1].AddController(l_ComboBindProperty);
            grid[currentRow, 2] = l_CellComboRealValue;

            currentRow++;

            //ComboBox with inline View
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("ComboBox Inline View");
            grid[currentRow, 0].View = captionModel;
            SourceGrid.Cells.Editors.ComboBox cbInline = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false);
            cbInline.EditableMode    = SourceGrid.EditableMode.Default | SourceGrid.EditableMode.Focus;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(arraySample[0], cbInline);
            grid[currentRow, 1].View = SourceGrid.Cells.Views.ComboBox.Default;

            currentRow++;

            //Numeric Up Down Editor
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("NumericUpDown");
            grid[currentRow, 0].View = captionModel;

            grid[currentRow, 1] = new SourceGrid.Cells.Cell(0);
            SourceGrid.Cells.Editors.NumericUpDown l_NumericUpDownEditor = new SourceGrid.Cells.Editors.NumericUpDown(typeof(int), 50, -50, 1);
            grid[currentRow, 1].Editor = l_NumericUpDownEditor;

            currentRow++;

            //Multiline Textbox
            grid[currentRow, 0]            = new SourceGrid.Cells.Cell("Multiline Textbox");
            grid[currentRow, 0].View       = captionModel;
            grid[currentRow, 0].ColumnSpan = 1;
            grid[currentRow, 0].RowSpan    = 2;

            grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello\r\nWorld");
            SourceGrid.Cells.Editors.TextBox l_MultilineEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            l_MultilineEditor.Control.Multiline = true;
            grid[currentRow, 1].Editor          = l_MultilineEditor;
            grid[currentRow, 1].RowSpan         = 2;

            currentRow++;
            currentRow++;

            //Boolean (CheckBox)
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Boolean (CheckBox)");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.CheckBox(null, true);
            grid[currentRow, 1].FindController <SourceGrid.Cells.Controllers.CheckBox>().CheckedChanged += InvertDisabledCheckBox(currentRow);


            SourceGrid.Cells.CheckBox l_DisabledCheckBox = new SourceGrid.Cells.CheckBox("Disabled Checkbox", true);
            l_DisabledCheckBox.Editor.EnableEdit = false;
            grid[currentRow, 2] = l_DisabledCheckBox;

            currentRow++;

            //DateTime with DateTimePicker Editor
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("DateTimePicker");
            grid[currentRow, 0].View = captionModel;
            SourceGrid.Cells.Editors.DateTimePicker editorDtPicker = new SourceGrid.Cells.Editors.DateTimePicker();
            grid[currentRow, 1]        = new SourceGrid.Cells.Cell(DateTime.Today);
            grid[currentRow, 1].Editor = editorDtPicker;

            currentRow++;

            //DateTime with DateTimePicker nullable Editor
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("DateTimePicker nullable");
            grid[currentRow, 0].View = captionModel;
            SourceGrid.Cells.Editors.DateTimePicker editorDtPickerNull = new SourceGrid.Cells.Editors.DateTimePicker();
            editorDtPickerNull.AllowNull = true;
            grid[currentRow, 1]          = new SourceGrid.Cells.Cell(null);
            grid[currentRow, 1].Editor   = editorDtPickerNull;

            currentRow++;

            //File editor
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("File editor");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell("c:\\windows\\System32\\user32.dll", new EditorFileDialog());

            currentRow++;

            // Richtext box
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("RichTextBox editor");
            grid[currentRow, 0].View = captionModel;
            string rtf = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0" +
                         "Microsoft Sans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17 Only a \\b " +
                         "Test\\b0.\\par\r\n}\r\n";
            var richTextBox = new SourceGrid.Cells.RichTextBox(new RichText(rtf));
            grid[currentRow, 1] = richTextBox;

            currentRow++;

            #endregion

            #region Special Cells
            grid[currentRow, 0]            = new SourceGrid.Cells.Cell("Special Cells");
            grid[currentRow, 0].View       = titleModel;
            grid[currentRow, 0].ColumnSpan = 3;
            currentRow++;

            //Cell Button
            grid[currentRow, 0]       = new SourceGrid.Cells.Cell("Cell Button");
            grid[currentRow, 0].View  = captionModel;
            grid[currentRow, 1]       = new SourceGrid.Cells.Button("CellButton");
            grid[currentRow, 1].Image = Properties.Resources.FACE02.ToBitmap();
            SourceGrid.Cells.Controllers.Button buttonClickEvent = new SourceGrid.Cells.Controllers.Button();
            buttonClickEvent.Executed += new EventHandler(CellButton_Click);
            grid[currentRow, 1].Controller.AddController(buttonClickEvent);

            currentRow++;

            //Cell Link
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Cell Link");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Link("CellLink");
            SourceGrid.Cells.Controllers.Button linkClickEvent = new SourceGrid.Cells.Controllers.Button();
            linkClickEvent.Executed += new EventHandler(CellLink_Click);
            grid[currentRow, 1].Controller.AddController(linkClickEvent);

            currentRow++;

            //Custom draw cell
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Custom draw cell");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell("CustomView");
            grid[currentRow, 1].View = new RoundView();

            currentRow++;

            //Control Cell
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Control Cell");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell("control cell");
            ProgressBar progressBar = new ProgressBar();
            progressBar.Value = 50;
            grid.LinkedControls.Add(new SourceGrid.LinkedControlValue(progressBar, new SourceGrid.Position(currentRow, 1)));

            currentRow++;

            //Custom Border Cell
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Custom Border");
            grid[currentRow, 0].View = captionModel;

            SourceGrid.Cells.Views.Cell viewCustomBorder = new SourceGrid.Cells.Views.Cell();
            viewCustomBorder.Border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.Red, 1),
                                                                         new DevAge.Drawing.BorderLine(Color.Blue, 1),
                                                                         new DevAge.Drawing.BorderLine(Color.Violet, 1),
                                                                         new DevAge.Drawing.BorderLine(Color.Green, 1));
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell("Custom Border");
            grid[currentRow, 1].View = viewCustomBorder;

            currentRow++;
            #endregion

            #region Custom Formatting
            grid[currentRow, 0]            = new SourceGrid.Cells.Cell("Custom Formatting");
            grid[currentRow, 0].View       = titleModel;
            grid[currentRow, 0].ColumnSpan = 3;
            currentRow++;

            //Format
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Default Format");
            grid[currentRow, 0].View = captionModel;

            grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246);
            SourceGrid.Cells.Editors.TextBox editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double));
            editorCustom.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(double));
            DevAge.ComponentModel.Converter.NumberTypeConverter numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double));
            editorCustom.TypeConverter = numberFormatCustom;
            grid[currentRow, 1].Editor = editorCustom;

            currentRow++;

            //Percent Editor
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Percent Format");
            grid[currentRow, 0].View = captionModel;

            grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246);
            SourceGrid.Cells.Editors.TextBox l_PercentEditor = new SourceGrid.Cells.Editors.TextBox(typeof(double));
            l_PercentEditor.TypeConverter = new DevAge.ComponentModel.Converter.PercentTypeConverter(typeof(double));
            grid[currentRow, 1].Editor    = l_PercentEditor;

            currentRow++;

            //Currency Editor
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Currency Format");
            grid[currentRow, 0].View = captionModel;

            grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246M);
            SourceGrid.Cells.Editors.TextBox l_CurrencyEditor = new SourceGrid.Cells.Editors.TextBox(typeof(decimal));
            l_CurrencyEditor.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(decimal));
            grid[currentRow, 1].Editor     = l_CurrencyEditor;

            currentRow++;

            //Format (#.00)
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Format #.00");
            grid[currentRow, 0].View = captionModel;

            grid[currentRow, 1]        = new SourceGrid.Cells.Cell(88.5246);
            editorCustom               = new SourceGrid.Cells.Editors.TextBox(typeof(double));
            numberFormatCustom         = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double));
            numberFormatCustom.Format  = "#.00";
            editorCustom.TypeConverter = numberFormatCustom;
            grid[currentRow, 1].Editor = editorCustom;

            currentRow++;

            //Format ("0000.0000")
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Format 0000.0000");
            grid[currentRow, 0].View = captionModel;

            grid[currentRow, 1]        = new SourceGrid.Cells.Cell(88.5246);
            editorCustom               = new SourceGrid.Cells.Editors.TextBox(typeof(double));
            numberFormatCustom         = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double));
            numberFormatCustom.Format  = "0000.0000";
            editorCustom.TypeConverter = numberFormatCustom;
            grid[currentRow, 1].Editor = editorCustom;

            currentRow++;

            //Format ("Scientific (exponential)")
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Format Scientific");
            grid[currentRow, 0].View = captionModel;

            grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.0006);
            SourceGrid.Cells.Editors.TextBoxNumeric             editorExponential    = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double));
            DevAge.ComponentModel.Converter.NumberTypeConverter exponentialConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double), "e");
            exponentialConverter.NumberStyles = System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowExponent;
            editorExponential.TypeConverter   = exponentialConverter;
            grid[currentRow, 1].Editor        = editorExponential;

            currentRow++;

            //DateTime 2 (using custom formatting)
            string dtFormat2 = "yyyy MM dd";
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Date(" + dtFormat2 + ")");
            grid[currentRow, 0].View = captionModel;

            string[] dtParseFormats = new string[] { dtFormat2 };
            System.Globalization.DateTimeStyles dtStyles = System.Globalization.DateTimeStyles.AllowInnerWhite | System.Globalization.DateTimeStyles.AllowLeadingWhite | System.Globalization.DateTimeStyles.AllowTrailingWhite | System.Globalization.DateTimeStyles.AllowWhiteSpaces;
            TypeConverter dtConverter = new DevAge.ComponentModel.Converter.DateTimeTypeConverter(dtFormat2, dtParseFormats, dtStyles);
            SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDt2 = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime));
            editorDt2.TypeConverter = dtConverter;

            grid[currentRow, 1]        = new SourceGrid.Cells.Cell(DateTime.Today);
            grid[currentRow, 1].Editor = editorDt2;

            currentRow++;


            //Text Ellipses
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Text Ellipses");
            grid[currentRow, 0].View = captionModel;

            grid[currentRow, 1] = new SourceGrid.Cells.Cell("This text is very very long and shows how to trim and add ellipses", typeof(string));
            SourceGrid.Cells.Views.Cell ellipsesView = new SourceGrid.Cells.Views.Cell();
            ellipsesView.TrimmingMode = SourceGrid.TrimmingMode.Word;
            grid[currentRow, 1].View  = ellipsesView;

            currentRow++;

            #endregion

            #region Image And Text Properties
            grid[currentRow, 0]            = new SourceGrid.Cells.Cell("Image And Text Properties");
            grid[currentRow, 0].View       = titleModel;
            grid[currentRow, 0].ColumnSpan = 3;
            currentRow++;

            //Cell Image
            SourceGrid.Cells.Cell       cellImage1 = new SourceGrid.Cells.Cell("Single Image");
            SourceGrid.Cells.Views.Cell viewImage  = new SourceGrid.Cells.Views.Cell(captionModel);
            cellImage1.View     = viewImage;
            grid[currentRow, 2] = cellImage1;
            cellImage1.RowSpan  = 4;
            cellImage1.Image    = Properties.Resources.FACE02.ToBitmap();

            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Image Alignment");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(viewImage.ImageAlignment, typeof(DevAge.Drawing.ContentAlignment));
            grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageAlignment"), viewImage));

            currentRow++;

            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Stretch Image");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(viewImage.ImageStretch, typeof(bool));
            grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageStretch"), viewImage));

            currentRow++;

            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Text Alignment");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(viewImage.TextAlignment, typeof(DevAge.Drawing.ContentAlignment));
            grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("TextAlignment"), viewImage));

            currentRow++;

            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("DrawMode");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell(viewImage.ElementsDrawMode, typeof(DevAge.Drawing.ElementsDrawMode));
            grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ElementsDrawMode"), viewImage));

            currentRow++;


            // Cell VisualModelMultiImages
            grid[currentRow, 1] = new SourceGrid.Cells.Cell("Multi Images");
            SourceGrid.Cells.Views.MultiImages modelMultiImages = new SourceGrid.Cells.Views.MultiImages();
            modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE00.ToBitmap()));
            modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE01.ToBitmap()));
            modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE02.ToBitmap()));
            modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE04.ToBitmap()));
            modelMultiImages.SubImages[0].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopLeft, false);
            modelMultiImages.SubImages[1].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopRight, false);
            modelMultiImages.SubImages[2].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomLeft, false);
            modelMultiImages.SubImages[3].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomRight, false);
            modelMultiImages.TextAlignment           = DevAge.Drawing.ContentAlignment.MiddleCenter;
            grid[currentRow, 1].View           = modelMultiImages;
            grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize;
            grid.Rows[currentRow].Height       = 50;

            currentRow++;


            // Cell Rotated Text
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("Rotated by angle");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell("Rotated Text", typeof(string));
            SourceGrid.Cells.Views.Cell rotateView = new SourceGrid.Cells.Views.Cell();
            rotateView.ElementText             = new RotatedText(45);
            grid[currentRow, 1].View           = rotateView;
            grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize;
            grid.Rows[currentRow].Height       = 50;

            currentRow++;

            // GDI+ Text
            grid[currentRow, 0]      = new SourceGrid.Cells.Cell("GDI+ Text");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1]      = new SourceGrid.Cells.Cell("Hello from GDI+", typeof(string));
            GDITextView gdiTextView = new GDITextView();
            gdiTextView.FormatFlags  = StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap;
            grid[currentRow, 1].View = gdiTextView;

            currentRow++;
            #endregion


            grid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default;
            grid.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default;
            grid.Columns[2].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default;
            grid.MinimumWidth            = 50;
            grid.AutoSizeCells();
            grid.AutoStretchColumnsToFitWidth = true;
            grid.Columns.StretchToFit();
        }
Ejemplo n.º 22
0
        private void btLoad_Click(object sender, System.EventArgs e)
        {
            using (var counter = new PerformanceCounter())
            {
                grid.Redim(0, 0);
                //Visual properties shared between all the cells
                SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
                view.BackColor = Color.Snow;

                //Editor (IDataModel) shared between all the cells
                SourceGrid.Cells.Editors.TextBox editor = new
                                                          SourceGrid.Cells.Editors.TextBox(typeof(string));

                grid.Redim(int.Parse(txtRows.Text), int.Parse(txtCols.Text));

                if (chkAddHeaders.Checked && grid.RowsCount > 0 &&
                    grid.ColumnsCount > 0)
                {
                    grid.FixedRows    = 1;
                    grid.FixedColumns = 1;

                    for (int r = grid.FixedRows; r < grid.RowsCount; r++)
                    {
                        grid[r, 0] = new SourceGrid.Cells.RowHeader(r);
                    }

                    for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++)
                    {
                        SourceGrid.Cells.ColumnHeader header = new
                                                               SourceGrid.Cells.ColumnHeader(c);
                        header.AutomaticSortEnabled = false;
                        grid[0, c] = header;
                    }
                    grid[0, 0] = new SourceGrid.Cells.Header();
                }
                else
                {
                    grid.FixedRows    = 0;
                    grid.FixedColumns = 0;
                }

                for (int r = grid.FixedRows; r < grid.RowsCount; r++)
                {
                    for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++)
                    {
                        grid[r, c] = new SourceGrid.Cells.Cell(r.ToString() + "," +
                                                               c.ToString());
                        grid[r, c].Editor = editor;
                        grid[r, c].View   = view;
                        var span = 3;
                        if (chkAddColspan.Checked && (c + span < grid.ColumnsCount))
                        {
                            if (r % 2 == 0)
                            {
                                grid[r, c].ColumnSpan = span;
                                c += span;
                            }
                        }
                    }
                }
                grid.Selection.Focus(new SourceGrid.Position(0, 0), true);
                this.toolStripStatusLabelBuildTime.Text = string.Format(
                    "Rows added in {0} ms", counter.GetMilisec());
            }
        }
Ejemplo n.º 23
0
        public static void CreateSample(ref Grid grid1)
        {
            //Border
            DevAge.Drawing.BorderLine      border     = new DevAge.Drawing.BorderLine(Color.DarkKhaki, 1);
            DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

            //Views
            CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.Khaki, Color.DarkKhaki);

            viewNormal.Border = cellBorder;
            CheckBoxBackColorAlternate viewCheckBox = new CheckBoxBackColorAlternate(Color.Khaki, Color.DarkKhaki);

            viewCheckBox.Border = cellBorder;

            //ColumnHeader view
            SourceGrid.Cells.Views.ColumnHeader        viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
            DevAge.Drawing.VisualElements.ColumnHeader backHeader       = new DevAge.Drawing.VisualElements.ColumnHeader();
            backHeader.BackColor        = Color.Maroon;
            backHeader.Border           = DevAge.Drawing.RectangleBorder.NoBorder;
            viewColumnHeader.Background = backHeader;
            viewColumnHeader.ForeColor  = Color.White;
            viewColumnHeader.Font       = new Font("Comic Sans MS", 10, FontStyle.Underline);

            //Editors
            SourceGrid.Cells.Editors.TextBox             editorString   = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDateTime = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime));


            //Create the grid
            grid1.BorderStyle = BorderStyle.FixedSingle;

            grid1.ColumnsCount = 3;
            grid1.FixedRows    = 1;
            grid1.Rows.Insert(0);

            SourceGrid.Cells.ColumnHeader columnHeader;

            columnHeader      = new SourceGrid.Cells.ColumnHeader("String");
            columnHeader.View = viewColumnHeader;
            grid1[0, 0]       = columnHeader;

            columnHeader      = new SourceGrid.Cells.ColumnHeader("DateTime");
            columnHeader.View = viewColumnHeader;
            grid1[0, 1]       = columnHeader;

            columnHeader      = new SourceGrid.Cells.ColumnHeader("CheckBox");
            columnHeader.View = viewColumnHeader;
            grid1[0, 2]       = columnHeader;

            for (int r = 1; r < 10; r++)
            {
                grid1.Rows.Insert(r);

                grid1[r, 0]        = new SourceGrid.Cells.Cell("Hello " + r.ToString());
                grid1[r, 0].Editor = editorString;

                grid1[r, 1]        = new SourceGrid.Cells.Cell(DateTime.Today);
                grid1[r, 1].Editor = editorDateTime;

                grid1[r, 2] = new SourceGrid.Cells.CheckBox(null, true);

                grid1[r, 0].View = viewNormal;
                grid1[r, 1].View = viewNormal;
                grid1[r, 2].View = viewCheckBox;
            }

            grid1.AutoSizeCells();
        }
Ejemplo n.º 24
0
        private static void Build(Grid a, int m, int n, Color warna, HeaderColumnsHeader headerstate = HeaderColumnsHeader.both, ResizeColumns autoresize = ResizeColumns.autocell, string pointzero = "#", string[] headername = null, int positionx = 0, int positiony = 0, SorterColumns sortable = SorterColumns.sort)
        {
            try
            {
                MakeGrid.Reset(a, m, n, headerstate);

                SourceGrid.Cells.Views.Cell      view   = new SourceGrid.Cells.Views.Cell();
                SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string));
                view.BackColor = warna;

                if (headerstate == HeaderColumnsHeader.both || headerstate == HeaderColumnsHeader.rows)
                {
                    for (int r = a.FixedRows; r < a.RowsCount; r++)
                    {
                        a[r, 0] = new SourceGrid.Cells.RowHeader(r);
                    }
                }

                if (headerstate == HeaderColumnsHeader.both || headerstate == HeaderColumnsHeader.columns)
                {
                    try
                    {
                        for (int c = a.FixedColumns; c < a.ColumnsCount; c++)
                        {
                            SourceGrid.Cells.ColumnHeader header = new
                                                                   SourceGrid.Cells.ColumnHeader(headername[c - 1]);
                            header.AutomaticSortEnabled = true;
                            header.View.TextAlignment   = ContentAlignment.MiddleCenter;
                            a[0, c] = header;
                        }
                    }
                    catch
                    {
                    }
                }

                SourceGrid.Cells.ColumnHeader header1 = new SourceGrid.Cells.ColumnHeader(pointzero);

                if (sortable == SorterColumns.sort)
                {
                    header1.SortComparer = new SourceGrid.MultiColumnsComparer(1, 2, 3, 4);
                }

                a[0, 0] = header1;

                for (int r = a.FixedRows; r < a.RowsCount; r++)
                {
                    for (int c = a.FixedColumns; c < a.ColumnsCount; c++)
                    {
                        a[r, c]        = new SourceGrid.Cells.Cell("");
                        a[r, c].Editor = editor;
                        a[r, c].View   = view;
                    }
                }

                a.Update();
                a.Selection.Focus(new SourceGrid.Position(positionx, positiony), true);

                if (autoresize == ResizeColumns.autocell)
                {
                    a.AutoSizeCells();
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 25
0
		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);

			grid.Redim(62, 3);

			SourceGrid.Cells.Views.Cell titleModel = new SourceGrid.Cells.Views.Cell();
			titleModel.BackColor = Color.SteelBlue;
			titleModel.ForeColor = Color.White;
			titleModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
			SourceGrid.Cells.Views.Cell captionModel = new SourceGrid.Cells.Views.Cell();
			captionModel.BackColor = grid.BackColor;

			int currentRow = 0;

			#region Base Types
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Base Types");
			grid[currentRow, 0].View = titleModel;
			grid[currentRow, 0].ColumnSpan = 3;
			currentRow++;

			//string
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("String");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell("String Value", typeof(string));

			currentRow++;

			//double
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(1.5, typeof(double));

			currentRow++;

			//int
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(5, typeof(int));

			currentRow++;

			//DateTime
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTime");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime));

			currentRow++;

			//Boolean
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(true, typeof(Boolean));

			currentRow++;
			#endregion

			#region Complex Types
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Complex Types");
			grid[currentRow, 0].View = titleModel;
			grid[currentRow, 0].ColumnSpan = 3;
			currentRow++;

			//Font
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Font");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(this.Font, typeof(Font));

			currentRow++;

			//Cursor
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cursor");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(Cursors.Arrow, typeof(Cursor));

			currentRow++;

			//Point
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Point");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Point(2, 3), typeof(Point));

			currentRow++;

			//Rectangle
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rectangle");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Rectangle(100, 100, 200, 200), typeof(Rectangle));

			currentRow++;

			//Image
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Image(Properties.Resources.CalcioSmall);

			currentRow++;

			//Enum AnchorStyle
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("AnchorStyle");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(AnchorStyles.Bottom, typeof(AnchorStyles));

			currentRow++;

			//Enum
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(System.Windows.Forms.BorderStyle.Fixed3D, typeof(System.Windows.Forms.BorderStyle));

			currentRow++;

			//String[]
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("String Array");
			grid[currentRow, 0].View = captionModel;
			string[] strArray = new string[] { "Value 1", "Value 2" };
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(strArray, typeof(string[]));

			currentRow++;

			//Double[]
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Array");
			grid[currentRow, 0].View = captionModel;
			double[] dblArray = new double[] { 1, 0.5, 0.1 };
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(dblArray, typeof(double[]));

			currentRow++;
			#endregion

			#region Special Editors
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Editors");
			grid[currentRow, 0].View = titleModel;
			grid[currentRow, 0].ColumnSpan = 3;
			currentRow++;

			//Time
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Time");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now);
			grid[currentRow, 1].Editor = new SourceGrid.Cells.Editors.TimePicker();

			currentRow++;

			//Double Chars Validation
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Chars Validation");
			grid[currentRow, 0].View = captionModel;
			SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double));
			numericEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs)
			{
				bool isValid = char.IsNumber(keyArgs.KeyChar) ||
					keyArgs.KeyChar == System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0];

				keyArgs.Handled = !isValid;
			};
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.5);
			grid[currentRow, 1].Editor = numericEditor;

			currentRow++;

			//String Chars (ABC)
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Chars Validation(only ABC)");
			grid[currentRow, 0].View = captionModel;
			SourceGrid.Cells.Editors.TextBox stringEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string));
			stringEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs)
			{
				keyArgs.KeyChar = char.ToUpper(keyArgs.KeyChar);
				bool isValid = keyArgs.KeyChar == 'A' || keyArgs.KeyChar == 'B' || keyArgs.KeyChar == 'C';

				keyArgs.Handled = !isValid;
			};
			grid[currentRow, 1] = new SourceGrid.Cells.Cell("AABB");
			grid[currentRow, 1].Editor = stringEditor;

			currentRow++;

			//String Validating
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("String validating(min 6 chars)");
			grid[currentRow, 0].View = captionModel;
			SourceGrid.Cells.Editors.TextBox stringEditorValidating = new SourceGrid.Cells.Editors.TextBox(typeof(string));
			stringEditorValidating.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent)
			{
				string val = ((TextBox)sender).Text;
				if (val == null || val.Length < 6)
					cancelEvent.Cancel = true;
			};
			grid[currentRow, 1] = new SourceGrid.Cells.Cell("test string");
			grid[currentRow, 1].Editor = stringEditorValidating;

			currentRow++;

			//Int 0-100 or null
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int 0-100 or null");
			grid[currentRow, 0].View = captionModel;
			SourceGrid.Cells.Editors.TextBoxNumeric numericEditor0_100 = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(int));
			numericEditor0_100.MinimumValue = 0;
			numericEditor0_100.MaximumValue = 100;
			numericEditor0_100.AllowNull = true;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(7);
			grid[currentRow, 1].Editor = numericEditor0_100;

			currentRow++;

			//Double Custom Conversion
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Dbl custom conversion");
			grid[currentRow, 0].View = captionModel;
			SourceGrid.Cells.Editors.TextBox dblCustomConversion = new SourceGrid.Cells.Editors.TextBox(typeof(double));
			dblCustomConversion.ConvertingObjectToValue += delegate(object sender,
			                                                        DevAge.ComponentModel.ConvertingObjectEventArgs conv)
			{
				if (conv.Value is string)
				{
					//Here you can add any custom code
					double val;
					if (double.TryParse((string)conv.Value, out val))
					{
						conv.Value = val;
						conv.ConvertingStatus = DevAge.ComponentModel.ConvertingStatus.Completed;
					}
				}
			};
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(73.839);
			grid[currentRow, 1].Editor = dblCustomConversion;

			currentRow++;

			//Enum Custom Display
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum Custom Display");
			grid[currentRow, 0].View = captionModel;
			SourceGrid.Cells.Editors.ComboBox keysCombo = new SourceGrid.Cells.Editors.ComboBox(typeof(Keys));
			keysCombo.Control.FormattingEnabled = true;
			keysCombo.ConvertingValueToDisplayString += delegate(object sender, DevAge.ComponentModel.ConvertingObjectEventArgs convArgs)
			{
				if (convArgs.Value is Keys)
					convArgs.Value = (int)((Keys)convArgs.Value) + " - " + convArgs.Value.ToString();
			};
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(Keys.Enter);
			grid[currentRow, 1].Editor = keysCombo;

			currentRow++;

			string[] arraySample = new string[] { "Value 1", "Value 2", "Value 3" };
			//ComboBox 1
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox String");
			grid[currentRow, 0].View = captionModel;
			SourceGrid.Cells.Editors.ComboBox comboStandard = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false);
			comboStandard.Control.MaxLength = 10;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboStandard);

			currentRow++;

			//ComboBox exclusive
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox String Exclusive");
			grid[currentRow, 0].View = captionModel;
			SourceGrid.Cells.Editors.ComboBox comboExclusive = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true);
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboExclusive);

			currentRow++;

			//ComboBox AutoComplete
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox AutoComplete");
			grid[currentRow, 0].View = captionModel;
			SourceGrid.Cells.Editors.ComboBox comboAutoComplete =
				new SourceGrid.Cells.Editors.ComboBox(typeof(string),
				                                      new string[] { "AAA", "ABC", "AZA", "BAA", "ZAA" },
				                                      true);
			comboAutoComplete.Control.AutoCompleteSource = AutoCompleteSource.ListItems;
			comboAutoComplete.Control.AutoCompleteMode = AutoCompleteMode.Append;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell("AAA", comboAutoComplete);

			currentRow++;

			//ComboBox DropDownList
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox DropDownList");
			grid[currentRow, 0].View = captionModel;
			SourceGrid.Cells.Editors.ComboBox comboNoText = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true);
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0]);
			grid[currentRow, 1].Editor = comboNoText;
			comboNoText.Control.DropDownStyle = ComboBoxStyle.DropDownList;

			currentRow++;

			//ComboBox DateTime Editable
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox DateTime");
			grid[currentRow, 0].View = captionModel;
			DateTime[] arrayDt = new DateTime[] { new DateTime(1981, 10, 6), new DateTime(1991, 10, 6), new DateTime(2001, 10, 6) };
			SourceGrid.Cells.Editors.ComboBox comboDateTime = new SourceGrid.Cells.Editors.ComboBox(typeof(DateTime), arrayDt, false);
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(arrayDt[0], comboDateTime);

			currentRow++;

			//ComboBox Custom Display (create a datamodel that has a custom display string)
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox Custom Display");
			grid[currentRow, 0].View = captionModel;
			int[] arrInt = new int[] { 0, 1, 2, 3, 4 };
			string[] arrStr = new string[] { "0 - Zero", "1 - One", "2 - Two", "3 - Three", "4- Four" };
			SourceGrid.Cells.Editors.ComboBox editorComboCustomDisplay = new SourceGrid.Cells.Editors.ComboBox(typeof(int), arrInt, true);
			editorComboCustomDisplay.Control.FormattingEnabled = true;
			DevAge.ComponentModel.Validator.ValueMapping comboMapping = new DevAge.ComponentModel.Validator.ValueMapping();
			comboMapping.DisplayStringList = arrStr;
			comboMapping.ValueList = arrInt;
			comboMapping.SpecialList = arrStr;
			comboMapping.SpecialType = typeof(string);
			comboMapping.BindValidator(editorComboCustomDisplay);
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(0);
			grid[currentRow, 1].Editor = editorComboCustomDisplay;

			SourceGrid.Cells.Cell l_CellComboRealValue = new SourceGrid.Cells.Cell(grid[currentRow, 1].Value);
			l_CellComboRealValue.View = captionModel;
			SourceGrid.Cells.Controllers.BindProperty l_ComboBindProperty = new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Cell).GetProperty("Value"), l_CellComboRealValue);
			grid[currentRow, 1].AddController(l_ComboBindProperty);
			grid[currentRow, 2] = l_CellComboRealValue;

			currentRow++;

			//ComboBox with inline View
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox Inline View");
			grid[currentRow, 0].View = captionModel;
			SourceGrid.Cells.Editors.ComboBox cbInline = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false);
			cbInline.EditableMode = SourceGrid.EditableMode.Default | SourceGrid.EditableMode.Focus;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], cbInline);
			grid[currentRow, 1].View = SourceGrid.Cells.Views.ComboBox.Default;

			currentRow++;

			//Numeric Up Down Editor
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("NumericUpDown");
			grid[currentRow, 0].View = captionModel;

			grid[currentRow, 1] = new SourceGrid.Cells.Cell(0);
			SourceGrid.Cells.Editors.NumericUpDown l_NumericUpDownEditor = new SourceGrid.Cells.Editors.NumericUpDown(typeof(int), 50, -50, 1);
			grid[currentRow, 1].Editor = l_NumericUpDownEditor;

			currentRow++;

			//Multiline Textbox
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Multiline Textbox");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 0].ColumnSpan = 1;
			grid[currentRow, 0].RowSpan = 2;

			grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello\r\nWorld");
			SourceGrid.Cells.Editors.TextBox l_MultilineEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string));
			l_MultilineEditor.Control.Multiline = true;
			grid[currentRow, 1].Editor = l_MultilineEditor;
			grid[currentRow, 1].RowSpan = 2;

			currentRow++;
			currentRow++;

			//Boolean (CheckBox)
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean (CheckBox)");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.CheckBox(null, true);
			grid[currentRow, 1].FindController<SourceGrid.Cells.Controllers.CheckBox>().CheckedChanged += InvertDisabledCheckBox(currentRow);
			

			SourceGrid.Cells.CheckBox l_DisabledCheckBox = new SourceGrid.Cells.CheckBox("Disabled Checkbox", true);
			l_DisabledCheckBox.Editor.EnableEdit = false;
			grid[currentRow, 2] = l_DisabledCheckBox;

			currentRow++;

			//DateTime with DateTimePicker Editor
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTimePicker");
			grid[currentRow, 0].View = captionModel;
			SourceGrid.Cells.Editors.DateTimePicker editorDtPicker = new SourceGrid.Cells.Editors.DateTimePicker();
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Today);
			grid[currentRow, 1].Editor = editorDtPicker;

			currentRow++;

			//DateTime with DateTimePicker nullable Editor
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTimePicker nullable");
			grid[currentRow, 0].View = captionModel;
			SourceGrid.Cells.Editors.DateTimePicker editorDtPickerNull = new SourceGrid.Cells.Editors.DateTimePicker();
			editorDtPickerNull.AllowNull = true;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(null);
			grid[currentRow, 1].Editor = editorDtPickerNull;

			currentRow++;

			//File editor
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("File editor");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell("c:\\windows\\System32\\user32.dll", new EditorFileDialog());

			currentRow++;
			
			// Richtext box
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("RichTextBox editor");
            grid[currentRow, 0].View = captionModel;
            string rtf = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0" +
                    "Microsoft Sans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17 Only a \\b " +
                    "Test\\b0.\\par\r\n}\r\n";
			var richTextBox = new SourceGrid.Cells.RichTextBox(new RichText(rtf));
			grid[currentRow, 1] = richTextBox;

			currentRow++;

			#endregion

			#region Special Cells
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Cells");
			grid[currentRow, 0].View = titleModel;
			grid[currentRow, 0].ColumnSpan = 3;
			currentRow++;

			//Cell Button
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cell Button");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Button("CellButton");
			grid[currentRow, 1].Image = Properties.Resources.FACE02.ToBitmap();
			SourceGrid.Cells.Controllers.Button buttonClickEvent = new SourceGrid.Cells.Controllers.Button();
			buttonClickEvent.Executed += new EventHandler(CellButton_Click);
			grid[currentRow, 1].Controller.AddController(buttonClickEvent);

			currentRow++;

			//Cell Link
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cell Link");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Link("CellLink");
			SourceGrid.Cells.Controllers.Button linkClickEvent = new SourceGrid.Cells.Controllers.Button();
			linkClickEvent.Executed += new EventHandler(CellLink_Click);
			grid[currentRow, 1].Controller.AddController(linkClickEvent);

			currentRow++;

			//Custom draw cell
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom draw cell");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell("CustomView");
			grid[currentRow, 1].View = new RoundView();

			currentRow++;

			//Control Cell
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Control Cell");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell("control cell");
			ProgressBar progressBar = new ProgressBar();
			progressBar.Value = 50;
			grid.LinkedControls.Add(new SourceGrid.LinkedControlValue(progressBar, new SourceGrid.Position(currentRow, 1)));

			currentRow++;

			//Custom Border Cell
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom Border");
			grid[currentRow, 0].View = captionModel;

			SourceGrid.Cells.Views.Cell viewCustomBorder = new SourceGrid.Cells.Views.Cell();
			viewCustomBorder.Border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.Red, 1),
			                                                             new DevAge.Drawing.BorderLine(Color.Blue, 1),
			                                                             new DevAge.Drawing.BorderLine(Color.Violet, 1),
			                                                             new DevAge.Drawing.BorderLine(Color.Green, 1));
			grid[currentRow, 1] = new SourceGrid.Cells.Cell("Custom Border");
			grid[currentRow, 1].View = viewCustomBorder;

			currentRow++;
			#endregion

			#region Custom Formatting
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom Formatting");
			grid[currentRow, 0].View = titleModel;
			grid[currentRow, 0].ColumnSpan = 3;
			currentRow++;

			//Format
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Default Format");
			grid[currentRow, 0].View = captionModel;

			grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246);
			SourceGrid.Cells.Editors.TextBox editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double));
			editorCustom.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(double));
			DevAge.ComponentModel.Converter.NumberTypeConverter numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double));
			editorCustom.TypeConverter = numberFormatCustom;
			grid[currentRow, 1].Editor = editorCustom;

			currentRow++;

			//Percent Editor
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Percent Format");
			grid[currentRow, 0].View = captionModel;

			grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246);
			SourceGrid.Cells.Editors.TextBox l_PercentEditor = new SourceGrid.Cells.Editors.TextBox(typeof(double));
			l_PercentEditor.TypeConverter = new DevAge.ComponentModel.Converter.PercentTypeConverter(typeof(double));
			grid[currentRow, 1].Editor = l_PercentEditor;

			currentRow++;

			//Currency Editor
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Currency Format");
			grid[currentRow, 0].View = captionModel;

			grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246M);
			SourceGrid.Cells.Editors.TextBox l_CurrencyEditor = new SourceGrid.Cells.Editors.TextBox(typeof(decimal));
			l_CurrencyEditor.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(decimal));
			grid[currentRow, 1].Editor = l_CurrencyEditor;

			currentRow++;

			//Format (#.00)
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format #.00");
			grid[currentRow, 0].View = captionModel;

			grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246);
			editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double));
			numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double));
			numberFormatCustom.Format = "#.00";
			editorCustom.TypeConverter = numberFormatCustom;
			grid[currentRow, 1].Editor = editorCustom;

			currentRow++;

			//Format ("0000.0000")
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format 0000.0000");
			grid[currentRow, 0].View = captionModel;

			grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246);
			editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double));
			numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double));
			numberFormatCustom.Format = "0000.0000";
			editorCustom.TypeConverter = numberFormatCustom;
			grid[currentRow, 1].Editor = editorCustom;

			currentRow++;

			//Format ("Scientific (exponential)")
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format Scientific");
			grid[currentRow, 0].View = captionModel;

			grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.0006);
			SourceGrid.Cells.Editors.TextBoxNumeric editorExponential = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double));
			DevAge.ComponentModel.Converter.NumberTypeConverter exponentialConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double), "e");
			exponentialConverter.NumberStyles = System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowExponent;
			editorExponential.TypeConverter = exponentialConverter;
			grid[currentRow, 1].Editor = editorExponential;

			currentRow++;

			//DateTime 2 (using custom formatting)
			string dtFormat2 = "yyyy MM dd";
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Date(" + dtFormat2 + ")");
			grid[currentRow, 0].View = captionModel;

			string[] dtParseFormats = new string[] { dtFormat2 };
			System.Globalization.DateTimeStyles dtStyles = System.Globalization.DateTimeStyles.AllowInnerWhite | System.Globalization.DateTimeStyles.AllowLeadingWhite | System.Globalization.DateTimeStyles.AllowTrailingWhite | System.Globalization.DateTimeStyles.AllowWhiteSpaces;
			TypeConverter dtConverter = new DevAge.ComponentModel.Converter.DateTimeTypeConverter(dtFormat2, dtParseFormats, dtStyles);
			SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDt2 = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime));
			editorDt2.TypeConverter = dtConverter;

			grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Today);
			grid[currentRow, 1].Editor = editorDt2;

			currentRow++;


			//Text Ellipses
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Text Ellipses");
			grid[currentRow, 0].View = captionModel;

			grid[currentRow, 1] = new SourceGrid.Cells.Cell("This text is very very long and shows how to trim and add ellipses", typeof(string));
			SourceGrid.Cells.Views.Cell ellipsesView = new SourceGrid.Cells.Views.Cell();
			ellipsesView.TrimmingMode = SourceGrid.TrimmingMode.Word;
			grid[currentRow, 1].View = ellipsesView;

			currentRow++;

			#endregion

			#region Image And Text Properties
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image And Text Properties");
			grid[currentRow, 0].View = titleModel;
			grid[currentRow, 0].ColumnSpan = 3;
			currentRow++;

			//Cell Image
			SourceGrid.Cells.Cell cellImage1 = new SourceGrid.Cells.Cell("Single Image");
			SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(captionModel);
			cellImage1.View = viewImage;
			grid[currentRow, 2] = cellImage1;
			cellImage1.RowSpan = 4;
			cellImage1.Image = Properties.Resources.FACE02.ToBitmap();

			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image Alignment");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ImageAlignment, typeof(DevAge.Drawing.ContentAlignment));
			grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageAlignment"), viewImage));

			currentRow++;

			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Stretch Image");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ImageStretch, typeof(bool));
			grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageStretch"), viewImage));

			currentRow++;

			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Text Alignment");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.TextAlignment, typeof(DevAge.Drawing.ContentAlignment));
			grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("TextAlignment"), viewImage));

			currentRow++;

			grid[currentRow, 0] = new SourceGrid.Cells.Cell("DrawMode");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ElementsDrawMode, typeof(DevAge.Drawing.ElementsDrawMode));
			grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ElementsDrawMode"), viewImage));

			currentRow++;


			// Cell VisualModelMultiImages
			grid[currentRow, 1] = new SourceGrid.Cells.Cell("Multi Images");
			SourceGrid.Cells.Views.MultiImages modelMultiImages = new SourceGrid.Cells.Views.MultiImages();
			modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE00.ToBitmap()));
			modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE01.ToBitmap()));
			modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE02.ToBitmap()));
			modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE04.ToBitmap()));
			modelMultiImages.SubImages[0].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopLeft, false);
			modelMultiImages.SubImages[1].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopRight, false);
			modelMultiImages.SubImages[2].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomLeft, false);
			modelMultiImages.SubImages[3].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomRight, false);
			modelMultiImages.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
			grid[currentRow, 1].View = modelMultiImages;
			grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize;
			grid.Rows[currentRow].Height = 50;

			currentRow++;


			// Cell Rotated Text
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rotated by angle");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell("Rotated Text", typeof(string));
			SourceGrid.Cells.Views.Cell rotateView = new SourceGrid.Cells.Views.Cell();
			rotateView.ElementText = new RotatedText(45);
			grid[currentRow, 1].View = rotateView;
			grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize;
			grid.Rows[currentRow].Height = 50;

			currentRow++;

			// GDI+ Text
			grid[currentRow, 0] = new SourceGrid.Cells.Cell("GDI+ Text");
			grid[currentRow, 0].View = captionModel;
			grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello from GDI+", typeof(string));
			GDITextView gdiTextView = new GDITextView();
			gdiTextView.FormatFlags = StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap;
			grid[currentRow, 1].View = gdiTextView;

			currentRow++;
			#endregion


			grid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default;
			grid.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default;
			grid.Columns[2].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default;
			grid.MinimumWidth = 50;
			grid.AutoSizeCells();
			grid.AutoStretchColumnsToFitWidth = true;
			grid.Columns.StretchToFit();
		}
        private void GridForm_Load(object sender, EventArgs e)
        {
            string[] headers = { "Session", "Course ID", "Course Section", "Course Name", "Days", "Start Time", "End Time", "Instructor", "Credits", "Max Enrollment", "Room" };
            GetData(ref course);
            //Border
            DevAge.Drawing.BorderLine      border     = new DevAge.Drawing.BorderLine(Color.DarkKhaki, 1);
            DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

            /* //Views
             * CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.Khaki, Color.DarkKhaki);
             * viewNormal.Border = cellBorder;
             * CheckBoxBackColorAlternate viewCheckBox = new CheckBoxBackColorAlternate(Color.Khaki, Color.DarkKhaki);
             * viewCheckBox.Border = cellBorder;*/

            //ColumnHeader view
            SourceGrid.Cells.Views.ColumnHeader        viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
            DevAge.Drawing.VisualElements.ColumnHeader backHeader       = new DevAge.Drawing.VisualElements.ColumnHeader();
            backHeader.BackColor        = Color.Maroon;
            backHeader.Border           = DevAge.Drawing.RectangleBorder.NoBorder;
            viewColumnHeader.Background = backHeader;
            viewColumnHeader.ForeColor  = Color.White;
            viewColumnHeader.Font       = new Font("Comic Sans MS", 10, FontStyle.Underline);

            //Editors
            SourceGrid.Cells.Editors.TextBox             editorString   = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDateTime = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime));


            //Create the grid
            grid1.BorderStyle = BorderStyle.FixedSingle;


            grid1.ColumnsCount = headers.Length;
            //grid1.FixedRows = 1;
            grid1.Rows.Insert(0);

            /*   SourceGrid.Cells.ColumnHeader columnHeader;
             *
             * columnHeader = new SourceGrid.Cells.ColumnHeader("String");
             * columnHeader.View = viewColumnHeader;
             * grid1[0, 0] = columnHeader;
             *
             * columnHeader = new SourceGrid.Cells.ColumnHeader("DateTime");
             * columnHeader.View = viewColumnHeader;
             * grid1[0, 1] = columnHeader;
             *
             * columnHeader = new SourceGrid.Cells.ColumnHeader("CheckBox");
             * columnHeader.View = viewColumnHeader;
             * grid1[0, 2] = columnHeader;*/

            // columnHeader.ResizeEnabled = false;
            SourceGrid.Cells.ColumnHeader columnHeader;

            for (int i = 0; i < headers.Length; i++)
            {
                columnHeader = new SourceGrid.Cells.ColumnHeader(headers[i]);
                columnHeader.ResizeEnabled = false;
                columnHeader.View          = viewColumnHeader;
                grid1[0, i] = columnHeader;


                /* inputGrid[1, i] = new SourceGrid.Cells.Cell("");
                 * inputGrid[1, i].Editor = editorString;*/
            }

            MessageBox.Show(course.Count.ToString());
            grid1.RowsCount = course.Count + 10;

            int row = 1;

            foreach (Course c in course)
            {
                grid1.Rows.Insert(row);
                Type f   = course[row - 1].GetType();
                int  col = 0;
                foreach (PropertyInfo propertyInfo in f.GetProperties())
                {
                    grid1[row, col] = new SourceGrid.Cells.Cell(propertyInfo.GetValue(c));
                    // Console.WriteLine(propertyInfo.GetValue(obj));
                    col++;
                }

                row++;
                if (row >= course.Count + 1)
                {
                    break;
                }
            }



            /*    grid1[r, 0] = new SourceGrid.Cells.Cell("Hello " + r.ToString());
             *  grid1[r, 0].Editor = editorString;
             *
             *  grid1[r, 1] = new SourceGrid.Cells.Cell(DateTime.Today);
             *  grid1[r, 1].Editor = editorDateTime;
             *
             *  grid1[r, 2] = new SourceGrid.Cells.CheckBox(null, true);
             *
             * /*   grid1[r, 0].View = viewNormal;
             *  grid1[r, 1].View = viewNormal;
             *  grid1[r, 2].View = viewCheckBox;*/


            grid1.AutoSizeCells();

            // grid1.Height = grid1.Rows.GetHeight(0) + grid1.Rows.GetHeight(1) + ((int)border.Width * 2);
        }
Ejemplo n.º 27
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //Border
            DevAge.Drawing.Border          border     = new DevAge.Drawing.Border(Color.DarkKhaki, 1);
            DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

            //Views Odd
            SourceGrid.Cells.Views.Cell viewOddNormal = new SourceGrid.Cells.Views.Cell();
            viewOddNormal.BackColor = Color.Khaki;
            viewOddNormal.Border    = cellBorder;
            SourceGrid.Cells.Views.CheckBox viewOddCheckBox = new SourceGrid.Cells.Views.CheckBox();
            viewOddCheckBox.BackColor = Color.Khaki;
            viewOddCheckBox.Border    = cellBorder;

            //Views Even
            SourceGrid.Cells.Views.Cell viewEvenNormal = new SourceGrid.Cells.Views.Cell(viewOddNormal);
            viewEvenNormal.BackColor = Color.DarkKhaki;
            SourceGrid.Cells.Views.CheckBox viewEvenCheckBox = new SourceGrid.Cells.Views.CheckBox(viewOddCheckBox);
            viewEvenCheckBox.BackColor = Color.DarkKhaki;

            //ColumnHeader view
            SourceGrid.Cells.Views.ColumnHeader viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
            viewColumnHeader.ForeColor = Color.White;
            viewColumnHeader.Font      = new Font("Comic Sans MS", 10, FontStyle.Underline);

            DevAge.Drawing.VisualElements.ColumnHeader backgroundColHeader = new DevAge.Drawing.VisualElements.ColumnHeader();
            backgroundColHeader.BackColor = Color.Maroon;
            viewColumnHeader.Background   = backgroundColHeader;

            //Editors
            SourceGrid.Cells.Editors.TextBox             editorString   = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDateTime = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime));


            //Create the grid
            grid1.BorderStyle = BorderStyle.FixedSingle;

            grid1.ColumnsCount = 3;
            grid1.FixedRows    = 1;
            grid1.Rows.Insert(0);

            SourceGrid.Cells.ColumnHeader columnHeader;

            columnHeader      = new SourceGrid.Cells.ColumnHeader("String");
            columnHeader.View = viewColumnHeader;
            columnHeader.AutomaticSortEnabled = false;
            grid1[0, 0] = columnHeader;

            columnHeader      = new SourceGrid.Cells.ColumnHeader("DateTime");
            columnHeader.View = viewColumnHeader;
            columnHeader.AutomaticSortEnabled = false;
            grid1[0, 1] = columnHeader;

            columnHeader      = new SourceGrid.Cells.ColumnHeader("CheckBox");
            columnHeader.View = viewColumnHeader;
            columnHeader.AutomaticSortEnabled = false;
            grid1[0, 2] = columnHeader;

            for (int r = 1; r < 10; r++)
            {
                grid1.Rows.Insert(r);

                grid1[r, 0]        = new SourceGrid.Cells.Cell("Hello " + r.ToString());
                grid1[r, 0].Editor = editorString;

                grid1[r, 1]        = new SourceGrid.Cells.Cell(DateTime.Today);
                grid1[r, 1].Editor = editorDateTime;

                grid1[r, 2] = new SourceGrid.Cells.CheckBox(null, true);

                if (Math.IEEERemainder(r, 2) == 0)
                {
                    grid1[r, 0].View = viewOddNormal;
                    grid1[r, 1].View = viewOddNormal;
                    grid1[r, 2].View = viewOddCheckBox;
                }
                else
                {
                    grid1[r, 0].View = viewEvenNormal;
                    grid1[r, 1].View = viewEvenNormal;
                    grid1[r, 2].View = viewEvenCheckBox;
                }
            }

            grid1.AutoSizeCells();
        }
Ejemplo n.º 28
0
        public void InitArtGrid()
        {
            _editorsArt = new List <SourceGrid.Cells.Editors.EditorBase>();

            var editStr5 = new SourceGrid.Cells.Editors.TextBox(typeof(string));

            editStr5.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent) { StringMaxLen((TextBox)sender, cancelEvent, 5); };

            var editStr50 = new SourceGrid.Cells.Editors.TextBox(typeof(string));

            editStr50.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent) { StringMaxLen((TextBox)sender, cancelEvent, 50); };

            var editStr100 = new SourceGrid.Cells.Editors.TextBox(typeof(string));

            editStr100.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent) { StringMaxLen((TextBox)sender, cancelEvent, 100); };

            var editInt = SourceGrid.Cells.Editors.Factory.Create(typeof(int));

            var editIntNull = SourceGrid.Cells.Editors.Factory.Create(typeof(int));

            editIntNull.AllowNull = true;

            _editArt = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
            _editArt.Control.AutoCompleteSource = AutoCompleteSource.ListItems;
            _editArt.Control.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            _editArt.Control.Validating        += delegate(object sender, CancelEventArgs cancelEvent) {
                var text = ((ComboBox)sender).Text;
                if (!string.IsNullOrEmpty(text) && _arts.All(x => x.Name != text))
                {
                    cancelEvent.Cancel = true;
                }
            };

            _editorsArt.Add(null);
            _editorsArt.Add(editStr5);
            _editorsArt.Add(editInt);
            _editorsArt.Add(editStr5);
            _editorsArt.Add(editStr50);
            _editorsArt.Add(editStr100);
            _editorsArt.Add(editIntNull);
            _editorsArt.Add(editStr50);
            _editorsArt.Add(null);
            _editorsArt.Add(null);

            gridArt.ColumnsCount = 10;
            gridArt.RowsCount    = 1;
            gridArt.FixedRows    = 1;

            gridArt[0, 0] = new SourceGrid.Cells.ColumnHeader("ArtId");
            gridArt.Columns[0].Visible = false;
            gridArt[0, 1] = new SourceGrid.Cells.ColumnHeader("Mag");
            gridArt[0, 2] = new SourceGrid.Cells.ColumnHeader("IYear");
            gridArt[0, 3] = new SourceGrid.Cells.ColumnHeader("IMonth");
            gridArt[0, 4] = new SourceGrid.Cells.ColumnHeader("Author");
            gridArt[0, 5] = new SourceGrid.Cells.ColumnHeader("Name");
            gridArt[0, 6] = new SourceGrid.Cells.ColumnHeader("NN");
            gridArt[0, 7] = new SourceGrid.Cells.ColumnHeader("Serie");
            gridArt[0, 8] = new SourceGrid.Cells.ColumnHeader("Pics");
            gridArt[0, 9] = new SourceGrid.Cells.ColumnHeader("Art");

            for (var i = 1; i < gridArt.ColumnsCount; i++)
            {
                var key = $"gridArt:ColumnWidth:{i}";
                if (_config.ContainsKey(key))
                {
                    gridArt.Columns[i].Width = int.Parse(_config[key]);
                }
            }

            _gridArtController = new GridArtController(this);

            gridArt.Selection.CellGotFocus     += ArtCellGotFocus;
            gridArt.Columns.ColumnWidthChanged += ArtColumnWidthChanged;
        }
Ejemplo n.º 29
0
        private static void CreateColumns(SourceGrid.DataGridColumns columns, DataTable sourceTable)
        {
            SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(decimal));
            numericEditor.TypeConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(decimal), "N");
            numericEditor.AllowNull     = true;          //the database value can be null (System.DbNull)
            SourceGrid.Cells.Editors.TextBox  stringEditor     = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            SourceGrid.Cells.Editors.ComboBox externalIdEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(int));
            externalIdEditor.StandardValues          = new int[] { 1, 2, 3, 4 };
            externalIdEditor.StandardValuesExclusive = true;
            DevAge.ComponentModel.Validator.ValueMapping mapping = new DevAge.ComponentModel.Validator.ValueMapping();
            mapping.ValueList            = new int[] { 1, 2, 3, 4 };
            mapping.SpecialType          = typeof(string);
            mapping.SpecialList          = new string[] { "Reference 1", "Reference 2", "Reference 3", "Reference 4" };
            mapping.ThrowErrorIfNotFound = false;
            mapping.BindValidator(externalIdEditor);


            DataColumn dataColumn;

            SourceGrid.DataGridColumn     gridColumn;
            SourceGrid.Cells.ICellVirtual dataCell;

            //Create columns

            dataColumn = sourceTable.Columns["Selected"];
            dataCell   = new SourceGrid.Cells.DataGrid.CheckBox(dataColumn);
            gridColumn = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell);
            columns.Insert(columns.Count, gridColumn);

            dataColumn      = sourceTable.Columns["Country"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.Editor = stringEditor;
            gridColumn      = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell);
            columns.Insert(columns.Count, gridColumn);

            dataColumn = sourceTable.Columns["Uniform"];
            dataCell   = new SourceGrid.Cells.DataGrid.Image(dataColumn);
            gridColumn = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell);
            columns.Insert(columns.Count, gridColumn);

            dataColumn      = sourceTable.Columns["Population"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.Editor = numericEditor;
            gridColumn      = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell);
            columns.Insert(columns.Count, gridColumn);

            dataColumn      = sourceTable.Columns["Surface"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.Editor = numericEditor;
            gridColumn      = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell);
            columns.Insert(columns.Count, gridColumn);

            dataColumn      = sourceTable.Columns["ExternalID"];
            dataCell        = new SourceGrid.Cells.DataGrid.Cell(dataColumn);
            dataCell.Editor = externalIdEditor;
            gridColumn      = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell);
            columns.Insert(columns.Count, gridColumn);

            gridColumn = new MyDataGridColumnStar(columns.Grid, "Star");
            columns.Insert(columns.Count, gridColumn);
        }
Ejemplo n.º 30
0
		private void btLoad_Click(object sender, System.EventArgs e)
		{
			using (var counter = new PerformanceCounter())
			{
				grid.Redim(0, 0);
				//Visual properties shared between all the cells
				SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
				view.BackColor = Color.Snow;

				//Editor (IDataModel) shared between all the cells
				SourceGrid.Cells.Editors.TextBox editor = new
					SourceGrid.Cells.Editors.TextBox(typeof(string));

				grid.Redim(int.Parse(txtRows.Text), int.Parse(txtCols.Text));

				if (chkAddHeaders.Checked && grid.RowsCount > 0 &&
				    grid.ColumnsCount > 0)
				{
					grid.FixedRows = 1;
					grid.FixedColumns = 1;

					for (int r = grid.FixedRows; r < grid.RowsCount; r++)
						grid[r, 0] = new SourceGrid.Cells.RowHeader(r);

					for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++)
					{
						SourceGrid.Cells.ColumnHeader header = new
							SourceGrid.Cells.ColumnHeader(c);
						header.AutomaticSortEnabled = false;
						grid[0, c] = header;
					}
					grid[0, 0] = new SourceGrid.Cells.Header();
				}
				else
				{
					grid.FixedRows = 0;
					grid.FixedColumns = 0;
				}

				for (int r = grid.FixedRows; r < grid.RowsCount; r++)
					for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++)
				{
					grid[r, c] = new SourceGrid.Cells.Cell(r.ToString() + "," +
					                                       c.ToString());
					grid[r, c].Editor = editor;
					grid[r, c].View = view;
					var span = 3;
					if (chkAddColspan.Checked && (c + span < grid.ColumnsCount))
					{
						if (r % 2 == 0)
						{
							grid[r, c].ColumnSpan = span;
							c += span;
						}
					}
				}
				grid.Selection.Focus(new SourceGrid.Position(0, 0), true);
				this.toolStripStatusLabelBuildTime.Text = string.Format(
					"Rows added in {0} ms", counter.GetMilisec());
			}
		}
Ejemplo n.º 31
0
        public static void Populate(ref Grid grid1, string[] cols, string[] colTyeNames, List <Hashtable> htList_WithKey
                                    , Color HeaderBackColor, Color cellBackColor, Color cellBackColorAlternate)
        {
            //Border
            DevAge.Drawing.BorderLine      border     = new DevAge.Drawing.BorderLine(Color.DarkKhaki, 1);
            DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

            //Views
            CellBackColorAlternate viewNormal = new CellBackColorAlternate(cellBackColor, cellBackColorAlternate);

            viewNormal.Border = cellBorder;
            CheckBoxBackColorAlternate viewCheckBox = new CheckBoxBackColorAlternate(cellBackColor, cellBackColorAlternate);

            viewCheckBox.Border = cellBorder;

            //ColumnHeader view
            SourceGrid.Cells.Views.ColumnHeader        viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
            DevAge.Drawing.VisualElements.ColumnHeader backHeader       = new DevAge.Drawing.VisualElements.ColumnHeader();

            backHeader.BackColor        = HeaderBackColor;
            backHeader.Border           = DevAge.Drawing.RectangleBorder.NoBorder;
            viewColumnHeader.Background = backHeader;
            viewColumnHeader.ForeColor  = Color.White;
            viewColumnHeader.Font       = new Font("Comic Sans MS", 10, FontStyle.Underline);

            //Editors
            SourceGrid.Cells.Editors.TextBox             editorString   = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDateTime = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime));
            int colsLen = cols.Count();
            int rowsLen = htList_WithKey.Count;

            //Create the grid
            grid1.BorderStyle = BorderStyle.FixedSingle;

            grid1.ColumnsCount = colsLen;
            grid1.FixedRows    = 1;
            grid1.Rows.Clear();
            grid1.Rows.Insert(0);

            SourceGrid.Cells.ColumnHeader columnHeader;
            //header:
            for (int i = 0; i < colsLen; i++)
            {
                columnHeader      = new SourceGrid.Cells.ColumnHeader(cols[i]);
                columnHeader.View = viewColumnHeader;
                grid1[0, i]       = columnHeader;
            }
            //rows:
            for (int r = 1; r <= rowsLen; r++)
            {
                grid1.Rows.Insert(r);

                for (int c = 0; c < colsLen; c++)
                {
                    switch (colTyeNames[c])
                    {
                    case "CheckBox":
                        if (htList_WithKey[r - 1][cols[c]] != null)
                        {
                            if (htList_WithKey[r - 1][cols[c]].ToString() != "")
                            {
                                bool b = bool.Parse(htList_WithKey[r - 1][cols[c]].ToString());
                                grid1[r, c] = new SourceGrid.Cells.CheckBox(null, b);

                                grid1[r, c].View = viewCheckBox;
                            }
                        }
                        break;

                    case "CheckBoxVirtual":
                        if (htList_WithKey[r - 1][cols[c]] != null)
                        {
                            if (htList_WithKey[r - 1][cols[c]].ToString() != "")
                            {
                                bool b = false;
                                if (htList_WithKey[r - 1][cols[c]].ToString() == "11")
                                {
                                    b = true;
                                }

                                grid1[r, c] = new SourceGrid.Cells.CheckBox(null, b);

                                grid1[r, c].View = viewCheckBox;
                            }
                        }
                        break;

                    default:
                        if (htList_WithKey[r - 1][cols[c]] != null)
                        {
                            grid1[r, c] = new SourceGrid.Cells.Cell(htList_WithKey[r - 1][cols[c]].ToString());
                        }
                        else
                        {
                            grid1[r, c] = new SourceGrid.Cells.Cell("");
                        }

                        grid1[r, c].View = viewNormal;
                        break;
                    }
                }
            }
            grid1.AutoSizeCells();
        }
Ejemplo n.º 32
0
        void ExecuteWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            mnuExecute.Text           = "Execute";
            mnuExecute.ForeColor      = SystemColors.ControlText;
            mnuRun.Enabled            = true;
            mnuSchema.Enabled         = true;
            this.Cursor               = Cursors.Default;
            textEditorControl1.Cursor = Cursors.Default;
            timer.Stop();

            if (e.Cancelled)
            {
                lblCurrentStatus.Text = string.Format("Query cancelled");
            }
            else if (e.Error != null)
            {
                this.Cursor = Cursors.Default;
                Program.logger.ErrorException("Execute", e.Error);
                lblCurrentStatus.Text = "Error: " + e.Error.Message;
                MessageBox.Show("An error occurred executing sql statement data:\n" + e.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (e.Result != null && e.Result is IList <IList <object> > )
            {
                IList <IList <object> > result = (IList <IList <object> >)e.Result;

                grid1.ClipboardMode = SourceGrid.ClipboardMode.All;
                grid1.Rows.Clear();
                grid1.FixedRows    = 1;
                grid1.FixedColumns = 1;
                SourceGrid.Cells.Editors.EditorBase editor = new SourceGrid.Cells.Editors.TextBox(typeof(string));
                editor.EnableEdit = false;

                // Set the column count
                int colCount = result[0].Count;
                grid1.ColumnsCount = colCount + 1; // Extra one for header

                // Write the header
                grid1.Rows.Insert(0);
                grid1[0, 0] = new SourceGrid.Cells.ColumnHeader("");
                for (int c = 0; c < colCount; c++)
                {
                    grid1[0, c + 1] = new SourceGrid.Cells.ColumnHeader(result[0][c]);
                }

                int i = 0;

                // Write the values
                foreach (List <object> row in result.Skip(1))
                {
                    i++;
                    grid1.Rows.Insert(i);
                    grid1[i, 0] = new SourceGrid.Cells.RowHeader(i.ToString());
                    for (int c = 0; c < colCount; c++)
                    {
                        if (row[c] == null)
                        {
                            grid1[i, c + 1] = new SourceGrid.Cells.Cell("", typeof(string));
                        }
                        else if (row[c] == typeof(DateTime))
                        {
                            grid1[i, c + 1] = new SourceGrid.Cells.Cell(((DateTime)row[c]).ToString("yyyy-MM-dd HH:mm:ss"), typeof(string));
                        }
                        else if (row[c] == typeof(string))
                        {
                            grid1[i, c + 1] = new SourceGrid.Cells.Cell(row[c].ToString().Trim(), typeof(string));
                        }
                        else
                        {
                            grid1[i, c + 1] = new SourceGrid.Cells.Cell(row[c], typeof(double));
                        }

                        grid1[i, c + 1].Editor = editor;
                    }
                }

                grid1.AutoSizeCells();
                grid1.Visible         = true;
                lblCurrentStatus.Text = string.Format("Query completed in {0}s", DateTime.Now.Subtract(start).TotalSeconds);
            }
        }
Ejemplo n.º 33
0
        private void Fill(Grid a, object[,] data, bool multiline = true)
        {
            SourceGrid.Cells.Views.Cell      view   = new SourceGrid.Cells.Views.Cell();
            SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            view.BackColor           = Color.White;
            editor.Control.Multiline = multiline;

            for (int r = a.FixedRows; r < a.RowsCount; r++)
            {
                a[r, 1] = new SourceGrid.Cells.Cell(pkmnamecom[int.Parse(data[r - 1, 0].ToString())]);
                a[r, 2] = new SourceGrid.Cells.Cell(methodname[int.Parse(data[r - 1, 1].ToString())]);
                switch (gameformat)
                {
                case vEnum.GameFormat.gen4:
                    switch (int.Parse(data[r - 1, 1].ToString()))
                    {
                    case 4:
                    case 22:
                    case 23:
                    case 15:
                        a[r, 3] = new SourceGrid.Cells.Cell(data[r - 1, 2]);
                        break;

                    case 6:
                    case 7:
                    case 16:
                    case 17:
                    case 18:
                    case 19:
                        a[r, 3] = new SourceGrid.Cells.Cell(itemname[int.Parse(data[r - 1, 2].ToString())]);
                        break;

                    case 20:
                        a[r, 3] = new SourceGrid.Cells.Cell(movename[int.Parse(data[r - 1, 2].ToString())]);
                        break;

                    case 21:
                        a[r, 3] = new SourceGrid.Cells.Cell(pkmname[int.Parse(data[r - 1, 2].ToString())]);
                        break;

                    default:
                        a[r, 3] = new SourceGrid.Cells.Cell("None");
                        break;
                    }
                    break;

                case vEnum.GameFormat.gen5:
                    switch (int.Parse(data[r - 1, 1].ToString()))
                    {
                    case 4:
                    case 23:
                    case 24:
                    case 16:
                        a[r, 3] = new SourceGrid.Cells.Cell(data[r - 1, 2]);
                        break;

                    case 6:
                    case 8:
                    case 17:
                    case 18:
                    case 19:
                    case 20:
                        a[r, 3] = new SourceGrid.Cells.Cell(itemname[int.Parse(data[r - 1, 2].ToString())]);
                        break;

                    case 21:
                        a[r, 3] = new SourceGrid.Cells.Cell(movename[int.Parse(data[r - 1, 2].ToString())]);
                        break;

                    case 22:
                        a[r, 3] = new SourceGrid.Cells.Cell(pkmname[int.Parse(data[r - 1, 2].ToString())]);
                        break;

                    default:
                        a[r, 3] = new SourceGrid.Cells.Cell("None");
                        break;
                    }
                    break;
                }

                a[r, 1].View = view;
                a[r, 2].View = view;
                a[r, 3].View = view;
            }

            a.Update();
            a.Selection.Focus(new SourceGrid.Position(1, 1), true);
            a.AutoSizeCells();
        }
Ejemplo n.º 34
0
        public override SourceGrid.Cells.Cell MakeDataCell()
        {
            SourceGrid.Cells.Cell            textcell     = null;
            SourceGrid.Cells.Editors.TextBox sharededitor = null;

            var sharededitor1 = GetSharedEditor();

            if (sharededitor1 != null)
            {
                sharededitor = sharededitor1 as SourceGrid.Cells.Editors.TextBox;
                if (sharededitor1 == null)
                {
                    throw new Exception("Wrong shared editor type.");
                }
            }

            if (sharededitor != null)
            {
                textcell = new SourceGrid.Cells.Cell(GetDefaultValue(), sharededitor);
            }
            else
            {
                var valuetype = GetValueType();
                textcell = new SourceGrid.Cells.Cell(GetDefaultValue(), valuetype);
                var tc = GetMyTypeConverter();
                if (tc != null)
                {
                    textcell.Editor.TypeConverter = tc;
                }
                textcell.Editor.AllowNull = AllowNull;
                if (ReadOnly)
                {
                    textcell.Editor.EditableMode = EditableMode.None;
                }

                //if (CustomConversions)
                ValueMapping = new ValueMappingB(textcell.Editor, this);

                /*
                 * var dted = textcell.Editor as SourceGrid.Cells.Editors.DateTimePicker;
                 * if (dted != null)
                 * {
                 *  dted.Control.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
                 *  dted.Control.CustomFormat = string.IsNullOrEmpty(FormatString) ? "dd.MM.yyyy" : FormatString;
                 * }*/
            }

            if (RowValueType == EMyGridRowValueType.String)
            {
                textcell.AddController(KlonsLIB.MySourceGrid.MyToolTipText.Default);
                textcell.Model.AddModel(new KlonsLIB.MySourceGrid.MyToolTipModel());
            }

            if (rowSpan > 1 && RowValueType == EMyGridRowValueType.String)
            {
                textcell.View = Grid.gridViewModel.dataCellMultiLineModel;
            }
            else if (TextAllign == ECellTextAllign.NotSet)
            {
                switch (RowValueType)
                {
                case EMyGridRowValueType.Single:
                case EMyGridRowValueType.Double:
                case EMyGridRowValueType.ShortInt:
                case EMyGridRowValueType.Integer:
                case EMyGridRowValueType.Decimal:
                    textcell.View = Grid.gridViewModel.dataCellModelAllignRight;
                    break;

                default:
                    textcell.View = Grid.gridViewModel.dataCellModel;
                    break;
                }
            }
            else if (TextAllign == ECellTextAllign.Left)
            {
                textcell.View = Grid.gridViewModel.dataCellModel;
            }
            else
            {
                textcell.View = Grid.gridViewModel.dataCellModelAllignRight;
            }

            return(textcell);
        }
Ejemplo n.º 35
0
			public EditableColumnHeader(string caption):base(caption)
			{
				//Set the editor
				SourceGrid.Cells.Editors.TextBox headerEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string));
				headerEditor.EditableMode = SourceGrid.EditableMode.None;
				Editor = headerEditor;

				//Add the right click editing support
				AddController(rightClickEditing);

				//Remove the unselectable Controllers
				RemoveController(SourceGrid.Cells.Controllers.Unselectable.Default);
			}
        public void setSmsAppGrid()
        {
            List<SmsModel> smsList = ApplicationManager.getDummySmsList();
            DevAge.Drawing.BorderLine border = new DevAge.Drawing.BorderLine(Color.Black, 1);
            DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

            PopupMenu menuController = new PopupMenu();

            //Views
            CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.FromArgb(255, 210, 210, 210), Color.FromArgb(255, 240, 240, 240));
            viewNormal.Border = cellBorder;
            viewNormal.Font = new Font("돋음", 8, FontStyle.Regular);
            CheckBoxBackColorAlternate viewCheckBox = new CheckBoxBackColorAlternate(Color.Khaki, Color.DarkKhaki);
            viewCheckBox.Border = cellBorder;

            //ColumnHeader view
            SourceGrid.Cells.Views.ColumnHeader viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
            DevAge.Drawing.VisualElements.ColumnHeader backHeader = new DevAge.Drawing.VisualElements.ColumnHeader();
            backHeader.BackColor = Color.DimGray;
            //backHeader.Border = DevAge.Drawing.RectangleBorder.NoBorder;
            viewColumnHeader.Background = backHeader;
            viewColumnHeader.ForeColor = Color.White;
            viewColumnHeader.Font = new Font("맑은 고딕", 10, FontStyle.Bold);

            SourceGrid.Cells.Views.ColumnHeader viewColumnHeader1 = new SourceGrid.Cells.Views.ColumnHeader();
            DevAge.Drawing.VisualElements.ColumnHeader backHeader1 = new DevAge.Drawing.VisualElements.ColumnHeader();
            backHeader1.BackColor = Color.DarkSlateGray;
            viewColumnHeader1.Background = backHeader1;
            //viewColumnHeader1.Border = cellBorder;
            viewColumnHeader1.ForeColor = Color.White;
            viewColumnHeader1.Font = new Font("굴림", 8, FontStyle.Regular);
            viewColumnHeader1.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;

            //Editors
            SourceGrid.Cells.Editors.TextBox editorString = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDateTime = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime));

            //Create the grid
            smsAppGrid.BorderStyle = BorderStyle.FixedSingle;

            smsAppGrid.ColumnsCount = 8;
            smsAppGrid.FixedRows = 1;
            smsAppGrid.Rows.Insert(0);

            SourceGrid.Cells.ColumnHeader columnHeader;
            for (int i = 0; i < smsAppColumns.Length; i++)
            {
                columnHeader = new SourceGrid.Cells.ColumnHeader(smsAppColumns[i]);
                columnHeader.View = viewColumnHeader1;
                smsAppGrid[0, i] = columnHeader;
            }
            int length = smsList.Count;
            Random random = new Random();
            CellClickEvent clickController = new CellClickEvent(this);
            for (int r = 1; r < smsList.Count; r++)
            {
                smsAppGrid.Rows.Insert(r);
                SourceGrid.Cells.Views.ColumnHeader nameHeaderView1 = new SourceGrid.Cells.Views.ColumnHeader();
                DevAge.Drawing.VisualElements.ColumnHeader namebackHeader1 = new DevAge.Drawing.VisualElements.ColumnHeader();
                namebackHeader1.BackColor = Color.DarkSlateGray;
                nameHeaderView1.Background = namebackHeader1;
                nameHeaderView1.Border = cellBorder;
                nameHeaderView1.ForeColor = Color.White;
                nameHeaderView1.Font = new Font("굴림", 8, FontStyle.Regular);
                nameHeaderView1.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;

                SmsModel smsModel = smsList[r - 1];
                smsAppGrid[r, 0] = new SourceGrid.Cells.Cell(smsModel.Name);
                smsAppGrid[r, 0].View = viewNormal;
                smsAppGrid[r, 0].AddController(menuController);
                smsAppGrid[r, 0].AddController(clickController);

                smsAppGrid[r, 1] = new SourceGrid.Cells.Cell(smsModel.Description);
                smsAppGrid[r, 1].View = viewNormal;
                smsAppGrid[r, 1].AddController(menuController);
                smsAppGrid[r, 1].AddController(clickController);

                smsAppGrid[r, 2] = new SourceGrid.Cells.Cell(smsModel.Group);
                smsAppGrid[r, 2].View = viewNormal;
                smsAppGrid[r, 2].AddController(menuController);
                smsAppGrid[r, 2].AddController(clickController);

                smsAppGrid[r, 3] = new SourceGrid.Cells.Cell(smsModel.Number);
                smsAppGrid[r, 3].View = viewNormal;
                smsAppGrid[r, 3].AddController(menuController);
                smsAppGrid[r, 3].AddController(clickController);

                smsAppGrid[r, 4] = new SourceGrid.Cells.Cell(smsModel.RouterIp);
                smsAppGrid[r, 4].View = viewNormal;
                smsAppGrid[r, 4].AddController(menuController);
                smsAppGrid[r, 4].AddController(clickController);

                smsAppGrid[r, 5] = new SourceGrid.Cells.Cell(smsModel.Receive);
                smsAppGrid[r, 5].View = viewNormal;
                smsAppGrid[r, 5].AddController(menuController);
                smsAppGrid[r, 5].AddController(clickController);

                smsAppGrid[r, 6] = new SourceGrid.Cells.Cell(smsModel.Send);
                smsAppGrid[r, 6].View = viewNormal;
                smsAppGrid[r, 6].AddController(menuController);
                smsAppGrid[r, 6].AddController(clickController);

                smsAppGrid[r, 7] = new SourceGrid.Cells.Cell(smsModel.Status);
                smsAppGrid[r, 7].View = viewNormal;
                smsAppGrid[r, 7].AddController(menuController);
                smsAppGrid[r, 7].AddController(clickController);
            }
        }