public static DataGridTableStyle InitializeLogColumns(this ILogFieldProvider stratum, EditableDataGrid grid)
        {
            DataGridTableStyle tblStyle = new DataGridTableStyle();
            tblStyle.MappingName = "LogDO";

            foreach (LogFieldSetupDO field in stratum.LogFields)
            {
                CustomColumnBase col = MakeColumn(field.ColumnType);
                col.MappingName = field.Field;
                col.HeaderText = field.Heading;
                col.Format = field.Format; // 'C' = currency, 'N' = number (E.G. "N1" means one decimal place), #0.00
                col.FormatInfo = null;
                col.NullText = String.Empty;// <- look into this

                if (field.Width == 0.0)
                {
                    col.Width = MeasureTextWidth(grid, field.Heading.Trim()) + 18;//plus 18 to allow for padding
                }
                else
                {
                    col.Width = (int)field.Width;
                }

                tblStyle.GridColumnStyles.Add(col);
            }

            grid.TableStyles.Add(tblStyle);

            return tblStyle;
        }
Example #2
0
        private void TextBox_TextChanged(object sender, EventArgs e)
        {
            EditableDataGrid dg = this.Owner as EditableDataGrid;

            if (dg != null)
            {
                _textWidth = Win32.MeasureTextWidth(dg, this.TextBox.Text);
                if (this.GoToNextColumnWhenTextCompleate &&
                    this.TextBox.TextLength == this.TextBox.MaxLength)
                {
                    dg.SelectNextCell(true);
                }
            }
            else
            {
                _textWidth = -1;
            }
        }
 public static void InitializeGrid(EditableDataGrid grid)
 {
     // Default grid-level parameters
     grid.RowHeadersVisible = false;
     grid.HomeColumnIndex = 0;
     //preferredRowHeight = 20;
     grid.Font = new Font("Courier New", 12.0F, FontStyle.Regular);
     grid.ForeColor = Color.Black;
     grid.GridLineColor = Color.Black;
     grid.ErrorColor = Color.Red;
     grid.BackColor = Color.White; // background color of the actual grid cells
     grid.BackgroundColor = Color.Black; // background color of the control, but outside the grid.
     grid.HeaderBackColor = Color.DarkGray;
     grid.HeaderForeColor = Color.White;
     grid.SelectionBackColor = Color.Yellow;
     grid.SelectionForeColor = Color.Black;
     grid.AlternatingBackColor = Color.LightGray;
 }
Example #4
0
        private void PaintBoarder(Graphics g, Rectangle bounds, int rowNum)
        {
            System.Diagnostics.Debug.Assert(!(this._mouseDown && (this._mouseRowNum == -1)));

            EditableDataGrid grid = this.Owner as EditableDataGrid;

            if (grid == null)
            {
                return;
            }
            Pen boarderPen = grid.ForePen;

            bool isClicked = (this._mouseDown && (rowNum == this._mouseRowNum));

            if (isClicked)
            {
                this.DrawBorderClicked(g, bounds, boarderPen);
            }
            else
            {
                this.DrawBorderNormal(g, bounds, boarderPen);
            }
        }
Example #5
0
            private int _keyCounter = 0;//keeps track of the number of times the user hits enter on the control after it gains focus.
            //
            public virtual bool ProcessReturnKey()
            {
                if (this.DroppedDown == true)
                {
                    _keyCounter++;
                    EditableDataGrid dg = this.Parent as EditableDataGrid;

                    if (DeviceInfo.DevicePlatform == PlatformType.WinCE &&
                        (dg != null && _keyCounter == 3))
                    {
                        dg.MoveSeclection(Direction.Right);
                        return(true);
                    }

                    else if (dg != null && _keyCounter == 2)
                    {
                        dg.MoveSeclection(Direction.Right);
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    _keyCounter = 0;

                    IKeyPressProcessor p = this.Parent as IKeyPressProcessor;
                    if (p == null)
                    {
                        return(false);
                    }
                    return(p.ProcessReturnKey());
                }
            }
Example #6
0
            public new bool ProcessDialogKey(Keys keyVal)
#endif
            {
                switch (keyVal)
                {
                case (Keys.Left):
                {
                    if (this.SelectionStart == 0)
                    {
                        EditableDataGrid dg = this.Parent as EditableDataGrid;
                        if (dg != null)
                        {
                            return(dg.MoveSeclection(Direction.Left));
                        }
                    }
                    break;
                }

                case (Keys.Right):
                {
                    if (this.SelectionStart == this.Text.Length)
                    {
                        EditableDataGrid dg = this.Parent as EditableDataGrid;
                        if (dg != null)
                        {
                            return(dg.MoveSeclection(Direction.Right));
                        }
                    }
                    break;
                }

                case (Keys.Up):
                {
                    if (this.DroppedDown == false)
                    {
                        EditableDataGrid dg = this.Parent as EditableDataGrid;
                        if (dg != null)
                        {
                            return(dg.MoveSeclection(Direction.Up));
                        }
                    }
                    break;
                }

                case (Keys.Down):
                {
                    if (this.DroppedDown == false)
                    {
                        EditableDataGrid dg = this.Parent as EditableDataGrid;
                        if (dg != null)
                        {
                            return(dg.MoveSeclection(Direction.Down));
                        }
                    }
                    break;
                }

                default:
                {
                    IKeyPressProcessor p = this.Parent as IKeyPressProcessor;
                    if (p == null)
                    {
                        return(false);
                    }
                    return(p.ProcessDialogKey(keyVal));
                }
                }
                return(false);
            }
        public static DataGridTableStyle InitializeTreeColumns(this ITreeFieldProvider provider, EditableDataGrid grid)
        {
            DataGridTableStyle tblStyle = new System.Windows.Forms.DataGridTableStyle() { MappingName = "TreeVM" };

            int screenWidth = Screen.PrimaryScreen.WorkingArea.Width;
            int charWidth = MeasureTextWidth(grid, "0");

            // Loop through each item in the fields list,
            // set up a column style and add it to the table style.

            foreach (TreeFieldSetupDO field in provider.TreeFields)
            {
                CustomColumnBase col;

                switch (field.Field)
                {
                    case "CuttingUnit":
                        {
                            continue;
                        }
                    case "Species":
                        {
                            col = new FMSC.Controls.EditableComboBoxColumn();
                            ((EditableComboBoxColumn)col).DisplayMember = "Species";
                            //((EditableComboBoxColumn)col).ValueMember = "Self";
                            col.MappingName = "TreeDefaultValue";
                            col.Format = "[Species]";
                            break;
                        }
                    case "CountOrMeasure":
                        {
                            col = new FMSC.Controls.EditableComboBoxColumn();
                            //((EditableComboBoxColumn)col).DisplayMember = "CountOrMeasure";
                            //((EditableComboBoxColumn)col).ValueMember = "CountOrMeasure";
                            ((EditableComboBoxColumn)col).DataSource = new string[] { "C", "M", "I" };
                            break;
                        }
                    case "LiveDead":
                        {
                            col = new FMSC.Controls.EditableComboBoxColumn();
                            //((EditableComboBoxColumn)col).DisplayMember = "LiveDead";
                            //((EditableComboBoxColumn)col).ValueMember = "LiveDead";
                            ((EditableComboBoxColumn)col).DataSource = new string[] { "L", "D" };
                            break;
                        }

                    case "Stratum":
                        {
                            col = new FMSC.Controls.EditableComboBoxColumn();
                            ((EditableComboBoxColumn)col).DisplayMember = "Code";
                            //((EditableComboBoxColumn)col).ValueMember = "Code";
                            break;
                        }
                    case "SampleGroup":
                        {
                            col = new FMSC.Controls.EditableComboBoxColumn();
                            ((EditableComboBoxColumn)col).DisplayMember = "Code";
                            //((EditableComboBoxColumn)col).ValueMember = "Code";
                            break;
                        }
                    case "KPI":
                        {
                            col = MakeColumn(field.ColumnType);
                            //col.ReadOnly = true;
                            break;
                        }
                    case "Initials":
                        {
                            col = new FMSC.Controls.EditableComboBoxColumn();
                            ((EditableComboBoxColumn)col).DisplayMember = "Initials";
                            ((EditableComboBoxColumn)col).ValueMember = "Initials";
                            break;
                        }
                    default://all other columns
                        {
                            col = MakeColumn(field.ColumnType);
                            break;
                        }
                }

                // Set up width: autowidth or fixed width
                if (field.Width == 0.0)
                {
                    col.Width = MeasureTextWidth(grid, field.Heading.Trim()) + 18;//plus 18 to allow for padding
                }
                else
                {
                    int width1 = (int)field.Width;
                    if (width1 <= 10)
                    {
                        int width2 = (charWidth * width1) + 18;
                        col.Width = Math.Min(screenWidth, width2);
                    }
                    else
                    {
                        col.Width = Math.Min(screenWidth, width1);
                    }
                }

                if (String.IsNullOrEmpty(col.MappingName)) //see if we have already set the Mapping Name
                {
                    col.MappingName = field.Field;
                }
                if (String.IsNullOrEmpty(col.HeaderText))
                {
                    col.HeaderText = field.Heading;
                }
                if (string.IsNullOrEmpty(col.Format))
                {
                    col.Format = field.Format; // 'C' = currency, 'N' = number (E.G. "N1" means one decimal place), #0.00
                }
                col.FormatInfo = null;
                //this.myCustomColumnBase.Width = (int)myTreeFieldSetups[i].Width;
                col.NullText = String.Empty;// <- look into this

                // Add the column style to the table style
                tblStyle.GridColumnStyles.Add(col);
            }

            DataGridButtonColumn logsCol = new DataGridButtonColumn();
            logsCol.HeaderText = "Logs";
            logsCol.MappingName = "LogCountActual";
            tblStyle.GridColumnStyles.Add(logsCol);

            tblStyle.GridColumnStyles.Add(MakeErrorColumn(screenWidth));
            // Add the newly created DataGridTableStyle to the grid.
            grid.TableStyles.Add(tblStyle);

            return tblStyle;
        }
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this._plotNavPanel = new System.Windows.Forms.Panel();
            this._plotSelectCB = new System.Windows.Forms.ComboBox();
            this._nextPlotButton = new FMSC.Controls.ButtonPanel();

            this._gotoLastPlotButton = new FMSC.Controls.ButtonPanel();
            this._addPlotButton = new FMSC.Controls.ButtonPanel();
            this._deletePlotButton = new FMSC.Controls.ButtonPanel();
            this._plotInfoButton = new FMSC.Controls.ButtonPanel();
            this._prevPlotButton = new FMSC.Controls.ButtonPanel();
            this._gotoFirstPlotButton = new FMSC.Controls.ButtonPanel();
            this._dataGrid = new FMSC.Controls.EditableDataGrid();
            this._expandGridButton = new FMSC.Controls.ButtonPanel();
            this._tallyListPanel = new System.Windows.Forms.Panel();
            this._BS_TDV = new System.Windows.Forms.BindingSource(this.components);
            this._plotNavPanel.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this._dataGrid)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this._BS_TDV)).BeginInit();
            this.SuspendLayout();
            //
            // _plotNavPanel
            //
            this._plotNavPanel.Controls.Add(this._plotSelectCB);
            this._plotNavPanel.Controls.Add(this._nextPlotButton);
            this._plotNavPanel.Controls.Add(this._gotoLastPlotButton);
            this._plotNavPanel.Controls.Add(this._addPlotButton);
            this._plotNavPanel.Controls.Add(this._deletePlotButton);
            this._plotNavPanel.Controls.Add(this._plotInfoButton);
            this._plotNavPanel.Controls.Add(this._prevPlotButton);
            this._plotNavPanel.Controls.Add(this._gotoFirstPlotButton);
            this._plotNavPanel.Dock = System.Windows.Forms.DockStyle.Top;
            this._plotNavPanel.Location = new System.Drawing.Point(0, 0);
            this._plotNavPanel.Name = "_plotNavPanel";
            this._plotNavPanel.Size = new System.Drawing.Size(240, 22);
            //
            // _plotSelectCB
            //
            this._plotSelectCB.Dock = System.Windows.Forms.DockStyle.Fill;
            this._plotSelectCB.Location = new System.Drawing.Point(55, 0);
            this._plotSelectCB.Name = "_plotSelectCB";
            this._plotSelectCB.Size = new System.Drawing.Size(61, 23);
            this._plotSelectCB.TabIndex = 2;
            //
            // _nextPlotButton
            //
            this._nextPlotButton.Dock = System.Windows.Forms.DockStyle.Right;
            this._nextPlotButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular);

            this._nextPlotButton.Location = new System.Drawing.Point(116, 0);
            this._nextPlotButton.Name = "_nextPlotButton";
            this._nextPlotButton.Size = new System.Drawing.Size(27, 22);
            this._nextPlotButton.TabIndex = 6;
            this._nextPlotButton.Click += new System.EventHandler(this._nextPlotButton_Click);

            //
            // _gotoLastPlotButton
            //
            this._gotoLastPlotButton.Dock = System.Windows.Forms.DockStyle.Right;
            this._gotoLastPlotButton.Font = new System.Drawing.Font("Courier New", 14F, System.Drawing.FontStyle.Bold);

            this._gotoLastPlotButton.Location = new System.Drawing.Point(143, 0);
            this._gotoLastPlotButton.Name = "_gotoLastPlotButton";
            this._gotoLastPlotButton.Size = new System.Drawing.Size(28, 22);
            this._gotoLastPlotButton.TabIndex = 7;
            this._gotoLastPlotButton.Click += new System.EventHandler(this._gotoLastPlotButton_Click);
            //
            // _addPlotButton
            //
            this._addPlotButton.Dock = System.Windows.Forms.DockStyle.Right;
            this._addPlotButton.Font = new System.Drawing.Font("Courier New", 14F, System.Drawing.FontStyle.Bold);
            this._addPlotButton.ImageIndex = 0;
            this._addPlotButton.Location = new System.Drawing.Point(171, 0);
            this._addPlotButton.Name = "_addPlotButton";
            this._addPlotButton.Size = new System.Drawing.Size(32, 22);
            this._addPlotButton.TabIndex = 3;
            this._addPlotButton.Click += new System.EventHandler(this._addPlotButton_Click);
            //
            // _deletePlotButton
            //
            this._deletePlotButton.Dock = System.Windows.Forms.DockStyle.Right;
            this._deletePlotButton.Font = new System.Drawing.Font("Courier New", 14F, System.Drawing.FontStyle.Bold);
            this._deletePlotButton.ImageIndex = 0;
            this._deletePlotButton.Location = new System.Drawing.Point(203, 0);
            this._deletePlotButton.Name = "_deletePlotButton";
            this._deletePlotButton.Size = new System.Drawing.Size(20, 22);
            this._deletePlotButton.TabIndex = 4;
            this._deletePlotButton.Click += new System.EventHandler(this._deletePlotButton_Click);
            //
            // _plotInfoButton
            //
            this._plotInfoButton.Dock = System.Windows.Forms.DockStyle.Right;
            this._plotInfoButton.Font = new System.Drawing.Font("Courier New", 14F, System.Drawing.FontStyle.Bold);
            this._plotInfoButton.ImageIndex = 0;
            this._plotInfoButton.Location = new System.Drawing.Point(223, 0);
            this._plotInfoButton.Name = "_plotInfoButton";
            this._plotInfoButton.Size = new System.Drawing.Size(17, 22);
            this._plotInfoButton.TabIndex = 5;
            this._plotInfoButton.Click += new System.EventHandler(this._plotInfoButton_Click);
            //
            // _prevPlotButton
            //
            this._prevPlotButton.Dock = System.Windows.Forms.DockStyle.Left;
            this._prevPlotButton.Font = new System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Bold);

            this._prevPlotButton.Location = new System.Drawing.Point(28, 0);
            this._prevPlotButton.Name = "_prevPlotButton";
            this._prevPlotButton.Size = new System.Drawing.Size(27, 22);
            this._prevPlotButton.TabIndex = 1;
            this._prevPlotButton.Click += new System.EventHandler(this._prevPlotButton_Click);
            //
            // _gotoFirstPlotButton
            //
            this._gotoFirstPlotButton.Dock = System.Windows.Forms.DockStyle.Left;
            this._gotoFirstPlotButton.Font = new System.Drawing.Font("Courier New", 14F, System.Drawing.FontStyle.Bold);

            this._gotoFirstPlotButton.Location = new System.Drawing.Point(0, 0);
            this._gotoFirstPlotButton.Name = "_gotoFirstPlotButton";
            this._gotoFirstPlotButton.Size = new System.Drawing.Size(28, 22);
            this._gotoFirstPlotButton.TabIndex = 0;
            this._gotoFirstPlotButton.Click += new System.EventHandler(this._gotoFirstPlotButton_Click);
            //
            // _dataGrid
            //
            this._dataGrid.Dock = System.Windows.Forms.DockStyle.Fill;
            this._dataGrid.Location = new System.Drawing.Point(0, 22);
            this._dataGrid.Name = "_dataGrid";
            this._dataGrid.Size = new System.Drawing.Size(240, 148);
            this._dataGrid.TabIndex = 1;
            //
            // _expandGridButton
            //
            this._expandGridButton.Dock = System.Windows.Forms.DockStyle.Bottom;
            this._expandGridButton.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular);

            this._expandGridButton.Location = new System.Drawing.Point(0, 170);
            this._expandGridButton.Name = "_expandGridButton";
            this._expandGridButton.Size = new System.Drawing.Size(240, 15);
            this._expandGridButton.TabIndex = 2;
            this._expandGridButton.Click += new System.EventHandler(this._expandGridButton_Click);
            //
            // _tallyListPanel
            //
            this._tallyListPanel.AutoScroll = true;
            this._tallyListPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
            this._tallyListPanel.Location = new System.Drawing.Point(0, 185);
            this._tallyListPanel.Name = "_tallyListPanel";
            this._tallyListPanel.Size = new System.Drawing.Size(240, 60);
            //
            // _BS_TDV
            //
            this._BS_TDV.DataSource = typeof(CruiseDAL.DataObjects.TreeDefaultValueDO);
            //
            // LayoutPlot
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
            this.Controls.Add(this._dataGrid);
            this.Controls.Add(this._expandGridButton);
            this.Controls.Add(this._tallyListPanel);
            this.Controls.Add(this._plotNavPanel);
            this.Name = "LayoutPlot";
            this.Size = new System.Drawing.Size(240, 245);
            this._plotNavPanel.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this._dataGrid)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this._BS_TDV)).EndInit();
            this.ResumeLayout(false);
        }
        public void Init()
        {
            TtUtils.ShowWaitCursor();
            this.DialogResult = DialogResult.Cancel;

            #if (PocketPC || WindowsCE || Mobile)

            edg = new EditableDataGrid();
            edg.Left = 0;
            edg.Top = 0;
            edg.Dock = DockStyle.Top;

            if (Environment.OSVersion.Version.Major < 5)
            {
                edg.Size = new System.Drawing.Size(tablePanel.Width, tablePanel.Height - 55);
            }
            else
            {
                edg.Size = new System.Drawing.Size(tablePanel.Width, tablePanel.Height - 70);
            }

            /*
            //new not working with archer 2
            if (Environment.OSVersion.Version.Major < 5)
            {
                edg.Size = new System.Drawing.Size(this.Width, this.Height - 55);
                edg.Dock = DockStyle.Top;
            }
            else
            {
                edg.Size = new System.Drawing.Size(this.Width, this.Height - 25);
                edg.Dock = DockStyle.Top;
                if (Environment.Version.Minor > 1)
                {
                    edg.Dock = DockStyle.Fill;
                    btnCancel.Location = new Point(btnCancel.Location.X, btnCancel.Location.Y - 10);
                    btnSave.Location = new Point(btnSave.Location.X, btnSave.Location.Y - 10);
                }
            }
            */

            edg.Visible = true;
            edg.Enabled = true;
            edg.ColumnHeadersVisible = true;
            edg.RowHeadersVisible = false;
            edg.BackgroundColor = Color.Gray;
            edg.AlternatingBackColor = Color.LightGray;
            edg.ErrorColor = Color.Red;
            edg.Name = "Grid";
            edg.CellValueChanged += new EditableDataGridCellValueChangedEventHandler(edg_CellValueChanged);

            if (Environment.OSVersion.Platform != PlatformID.WinCE)
            {
                input = new Microsoft.WindowsCE.Forms.InputPanel();

                edg.SIP = input;
            }

            tablePanel.Controls.Add(edg);
            //this.Controls.Add(edg);
            #endif

            try
            {
                List<TtPoint> tmpPoints = DAL.GetPoints();

                tmpPoints.Sort();

                _Points = tmpPoints.ToDictionary(x => x.CN, x => x);
                _Polys = DAL.GetPolygons();
                _Meta = DAL.GetMetaData().ToDictionary(x=> x.CN, x => x);
                _MetaNames = new List<string>();
                _PolyNames = new List<string>();
                _PointNames = new List<string>();

                _PolyCNs = new List<string>();
                _PointEdited = new Dictionary<string, bool>();

                bs = new BindingSource();

                foreach (TtPolygon poly in _Polys)
                {
                    _PolyCNs.Add(poly.CN);
                    _PolyNames.Add(poly.Name);
                }

                foreach (TtMetaData meta in _Meta.Values)
                {
                    _MetaNames.Add(meta.Name);
                }

                if (SetupDataTable())
                {
                    AddDataToTable();
                }
                bs.DataSource = GridPoints;

                #if (PocketPC || WindowsCE || Mobile)
                edg.DataSource = bs;
                #endif
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "EditPointTableFormLogic:Init");
            }

            TtUtils.HideWaitCursor();
        }