Inheritance: ViewBase
コード例 #1
0
ファイル: IBGridForm.cs プロジェクト: vslee/daemaged.ibnet
        private void SetupCommonGridResources()
        {
            _columnHeaderView             = new SourceGrid.Cells.Views.ColumnHeader();
            _columnHeaderView.ElementText = new RotatedText(-60);
            _columnHeaderView.BackColor   = Color.LightYellow;

            _textRenderer = new DevAge.Drawing.VisualElements.TextRenderer();

            _defaultView = new SourceGrid.Cells.Views.Cell();
            _defaultView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;

            _defaultViewClearType             = new SourceGrid.Cells.Views.Cell();
            _defaultViewClearType.ElementText = _textRenderer;

            _yellowView             = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
            _yellowView.BackColor   = Color.LightYellow;
            _yellowView.ElementText = _defaultView.ElementText;

            _lightGray             = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
            _lightGray.BackColor   = Color.LightGray;
            _lightGray.ElementText = _defaultView.ElementText;

            _whiteView             = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
            _whiteView.BackColor   = Color.White;
            _whiteView.ElementText = _defaultView.ElementText;

            _lightGreen             = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
            _lightGreen.BackColor   = Color.LightGreen;
            _lightGreen.ElementText = _defaultView.ElementText;

            _darkGreen             = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
            _darkGreen.BackColor   = Color.DarkGreen;
            _darkGreen.ForeColor   = Color.White;
            _darkGreen.ElementText = _defaultView.ElementText;

            _highlightView               = new SourceGrid.Cells.Views.Cell();
            _highlightView.BackColor     = Color.LightPink;
            _highlightView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            _highlightView.ElementText   = _defaultView.ElementText;
        }
コード例 #2
0
        private void LlenarGrillaSegmentos(List<TCPSegmentSOA> mensajesSegmentos)
        {


            int c = 0;
            ConfigurarGrillaSegmentos();

            foreach (TCPSegmentSOA mensaje in mensajesSegmentos)
            {
                Grid.Rows.Insert(1);
                Grid.Rows[1].Tag = mensaje;
                Grid[1, 0] = new SourceGrid.Cells.Cell(c++.ToString());
                Grid[1, 1] = new SourceGrid.Cells.Cell(mensaje.Fecha.ToString());
                if (mensaje.EsEnviado)
                {
                    Grid[1, 2] = new SourceGrid.Cells.Cell("1");
                    Grid[1, 3] = new SourceGrid.Cells.Cell("0");

                }
                else
                {
                    Grid[1, 2] = new SourceGrid.Cells.Cell("0");
                    Grid[1, 3] = new SourceGrid.Cells.Cell("1");
                }

                Grid[1, 4] = new SourceGrid.Cells.Cell(mensaje.Paquete.IpOrigen);
                Grid[1, 5] = new SourceGrid.Cells.Cell(mensaje.Paquete.IpDestino);
                Grid[1, 6] = new SourceGrid.Cells.Cell(mensaje.SourcePort.ToString());
                Grid[1, 7] = new SourceGrid.Cells.Cell(mensaje.DestinationPort.ToString());
                Grid[1, 8] = new SourceGrid.Cells.Cell(mensaje.SEQ_Number.ToString());
                Grid[1, 9] = new SourceGrid.Cells.Cell(mensaje.ACK_Number.ToString());
                Grid[1, 10] = new SourceGrid.Cells.Cell(ConvertirValor(mensaje.SYN_Flag));
                Grid[1, 11] = new SourceGrid.Cells.Cell(ConvertirValor(mensaje.ACK_Flag));
                Grid[1, 12] = new SourceGrid.Cells.Cell(ConvertirValor(mensaje.FIN_Flag));
                Grid[1, 13] = new SourceGrid.Cells.Cell(mensaje.DataLength.ToString());
                for (int i = 0; i < 14; i++)
                {
                    if (mensaje.EsEnviado)
                    {
                        Cell cell = new Cell();
                        cell.BackColor = Color.LightBlue;
                        Grid[1, i].View = cell;
                    }
                    else
                    {
                        Cell cell = new Cell();
                        cell.BackColor = Color.White;
                        Grid[1, i].View = cell;
                    }
                }

            }
            Grid.Columns.AutoSizeView();
        }
コード例 #3
0
ファイル: Cell.cs プロジェクト: zhuangyy/Motion
 /// <summary>
 /// Copy constructor.  This method duplicate all the reference field (Image, Font, StringFormat) creating a new instance.
 /// </summary>
 /// <param name="p_Source"></param>
 public Cell(Cell p_Source)
     : base(p_Source)
 {
     ElementImage = (DevAge.Drawing.VisualElements.IImage)p_Source.ElementImage.Clone();
     ElementText = (DevAge.Drawing.VisualElements.IText)p_Source.ElementText.Clone();
 }
コード例 #4
0
        /// <summary>
        /// Sets up the columns and rows of the Grid.
        ///
        /// </summary>
        /// <returns>void</returns>
        private void SetupGridColumnsAndRows()
        {
            Int32 GroupHeaderCount;
            Int32 Counter;
            Int32 CurrentRow;

            SourceGrid.Cells.Views.Cell LabelModel;
            SourceGrid.Cells.Views.Cell TitleModel;
            String CurrentGroup;
            String LastGroup = "";
            String LabelUse;
            PDataLabelRow DataLabelRow;
            DataColumn ForeignTableColumn;

            // Create class that hooks up Grid Cell Enter event notification
            FEnterNotificationController = new TCellEventNotificationController();
            FEnterNotificationController.Initialize(this);
            FLabelUseDV = new DataView(FLocalDataDS.DataLabelUseList);

            // Create DataColumns that contain data from the DataLabel DataTable
            // add column: group of the data label
            ForeignTableColumn = new DataColumn();
            ForeignTableColumn.DataType = System.Type.GetType("System.String");
            ForeignTableColumn.ColumnName = "Parent_" + PDataLabelTable.GetGroupDBName();
            ForeignTableColumn.Expression = "Parent." + PDataLabelTable.GetGroupDBName();
            FLocalDataDS.DataLabelUseList.Columns.Add(ForeignTableColumn);

            // add column: is this label to be displayed
            ForeignTableColumn = new DataColumn();
            ForeignTableColumn.DataType = System.Type.GetType("System.Boolean");
            ForeignTableColumn.ColumnName = "Parent_" + PDataLabelTable.GetDisplayedDBName();
            ForeignTableColumn.Expression = "Parent." + PDataLabelTable.GetDisplayedDBName();
            FLocalDataDS.DataLabelUseList.Columns.Add(ForeignTableColumn);
            LabelUse = Enum.GetName(typeof(TOfficeSpecificDataLabelUseEnum), FOfficeSpecificDataLabelUse);

            // Sort by Index
            FLabelUseDV.Sort = PDataLabelUseTable.GetIdx1DBName() + " ASC";

            // Show only Labels that should get displayed and are of the type that this UserControl is for
            FLabelUseDV.RowFilter = PDataLabelUseTable.GetUseDBName() + " = '" + LabelUse + "' AND Parent_" + PDataLabelTable.GetDisplayedDBName() +
                                    " = 1";

            // MessageBox.Show('FLabelUseDV.RowFilter: ' + FLabelUseDV.RowFilter);
            // MessageBox.Show('FLabelUseDV.Count: ' + FLabelUseDV.Count.ToString);
            GroupHeaderCount = CalculateGroupHeaderCount();

            // Set up Grid focus style
            // FLocalDataLabelValuesGrid.Selection.FocusStyle := SourceGrid.FocusStyle.RemoveSelectionOnLeave;
            // Set up Grid size
            FLocalDataLabelValuesGrid.Redim((FLabelUseDV.Count) + GroupHeaderCount, 3);

            // Initialize Size of Helper Object GridRowInfo (mapping between data and grid rows)
            FGridRowInfo = new TGridRowInfo();
            FGridRowInfo.Initialize(FLabelUseDV.Count + GroupHeaderCount);
            TitleModel = new SourceGrid.Cells.Views.Cell();
            TitleModel.BackColor = Color.SteelBlue;
            TitleModel.ForeColor = Color.White;
            TitleModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            LabelModel = new SourceGrid.Cells.Views.Cell();
            LabelModel.BackColor = FLocalDataLabelValuesGrid.BackColor;
            LabelModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight;
            CurrentRow = 0;

            for (Counter = 0; Counter <= FLabelUseDV.Count - 1; Counter += 1)
            {
                // Find the corresponding DataLabel Row
                DataLabelRow = (PDataLabelRow)FLocalDataDS.DataLabelList.Rows.Find(FLabelUseDV[Counter][PDataLabelUseTable.GetDataLabelKeyDBName()]);
                CurrentGroup = DataLabelRow.Group;

                if (CurrentGroup != LastGroup)
                {
                    // Create group header if Group changed
                    FLocalDataLabelValuesGrid.Rows.SetHeight(CurrentRow, 23);
                    FLocalDataLabelValuesGrid[CurrentRow, 0] = new SourceGrid.Cells.Cell(CurrentGroup);
                    FLocalDataLabelValuesGrid[CurrentRow, 0].View = TitleModel;
                    FLocalDataLabelValuesGrid[CurrentRow, 0].ColumnSpan = 3;
                    FLocalDataLabelValuesGrid[CurrentRow, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
                    CurrentRow = CurrentRow + 1;
                }

                // Create label (left of the field)
                FLocalDataLabelValuesGrid.Rows.SetHeight(CurrentRow, 23);
                FLocalDataLabelValuesGrid[CurrentRow, 0] = new SourceGrid.Cells.Cell(DataLabelRow.Text + ':');
                FLocalDataLabelValuesGrid[CurrentRow, 0].View = LabelModel;
                FLocalDataLabelValuesGrid[CurrentRow, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);

                // MessageBox.Show('Counter: ' + Counter.ToString);
                // MessageBox.Show('FPartnerKey: ' + FPartnerKey.ToString + '; FLocalDataDS.DataLabelList.Row[Counter].Key: ' + FLocalDataDS.DataLabelList.Row[Counter].Key.ToString);
                // set up the value cell(s) for the current row
                SetupGridValueCell(CurrentRow, DataLabelRow);

                // Some TODOs
                // Check for the p_editable_l flag and make column 1 readonly if true
                // should go like this: FLocalDataLabelValuesGrid[CurrentRow, 1].Editor.EnableEdit := false;
                // Check the value of p_char_length_i and limit the length of the editable value
                // see commentedout line above 'TextBoxEditor.Control.MaxLength := '
                // Check the value of p_num_decimal_places_i build the corresponding format for the cell
                // see 'Editor' section on webpage
                // Implement currency (take p_currency_code_c into consideration), boolean and PartnerKey types
                // Implement cmbAutoComplete ComboBox (in Ict_Common_Controls.dll) for Labels where p_lookup_category_code_c is set
                // see file AutoTranslatedCSExampleWinForm, lines 465470 for a basic example of how to host an arbitraty control in a Cell of the Grid
                // MessageBox.Show('CurrentRow: ' + CurrentRow.ToString);
                // Hook up Grid Cell Enter event notification (for displaying Help text in the Status Bar)
                FLocalDataLabelValuesGrid[CurrentRow, 1].AddController(FEnterNotificationController);

                // Store the mapping of the current Grid Row to the PDataLabel Row that holds the Cell's Label information
                FGridRowInfo.SetDataRowKey(CurrentRow, (int)DataLabelRow.Key);
                CurrentRow = CurrentRow + 1;
                LastGroup = CurrentGroup;
            }

            // FLocalDataLabelValuesGrid.Columns[0].AutoSizeMode := (SourceGrid.AutoSizeMode.EnableAutoSize);   or SourceGrid.AutoSizeMode.Default
            // FLocalDataLabelValuesGrid.Columns[1].AutoSizeMode := (SourceGrid.AutoSizeMode.EnableAutoSize);   or SourceGrid.AutoSizeMode.Default
            // FLocalDataLabelValuesGrid.Columns[2].AutoSizeMode := (SourceGrid.AutoSizeMode.EnableAutoSize);   or SourceGrid.AutoSizeMode.Default
            FLocalDataLabelValuesGrid.Columns[0].AutoSizeMode = (SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default);
            FLocalDataLabelValuesGrid.Columns[1].AutoSizeMode = (SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default);
            FLocalDataLabelValuesGrid.Columns[2].AutoSizeMode = (SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default);

            // This grid does not work the same way as our 'normal' grids, so we need to modify the keyboard handling
            FLocalDataLabelValuesGrid.SpecialKeys = FLocalDataLabelValuesGrid.SpecialKeys | GridSpecialKeys.SimplifiedTabEnter;

            // FLocalDataLabelValuesGrid.AutoSize;
            FLocalDataLabelValuesGrid.AutoStretchColumnsToFitWidth = true;
            FLocalDataLabelValuesGrid.Columns.StretchToFit();
            ApplySecurity();
            FGridIsSetUp = true;

            // set width for controls (comboboxes and buttons)
            ActUponGridSizeChanged();
        }
コード例 #5
0
        /// <summary>
        /// Sets up the value cell(s) for a specific data label
        ///
        /// </summary>
        /// <returns>void</returns>
        private void SetupGridValueCell(Int32 ARowIndex, PDataLabelRow ADataLabelRow)
        {
            Control cellControl;

            System.Windows.Forms.TextBox TextBoxEditor;
            TtxtPetraDate DateEditor;
            System.Windows.Forms.CheckBox CheckBoxEditor;
            TTxtNumericTextBox TextBoxNumericEditor;
            TTxtCurrencyTextBox TextBoxCurrencyEditor;
            TCmbAutoPopulated LookupValueEditor;
            TtxtAutoPopulatedButtonLabel PartnerKeyEditor;
            SourceGrid.Cells.Views.Cell ValueModel;
            SourceGrid.Cells.Views.Cell SuffixModel;
            PDataLabelValuePartnerRow DataLabelValuePartnerRow;
            PDataLabelValueApplicationRow DataLabelValueApplicationRow;

            // prepare model for the value cells
            ValueModel = new SourceGrid.Cells.Views.Cell();
            ValueModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft;
            ValueModel.Font = new Font(FLocalDataLabelValuesGrid.Font.FontFamily.Name, FLocalDataLabelValuesGrid.Font.Size, FontStyle.Bold);

            // prepare model for suffix cells (e.g. for currency)
            SuffixModel = new SourceGrid.Cells.Views.Cell();
            SuffixModel.BackColor = FLocalDataLabelValuesGrid.BackColor;
            SuffixModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft;

            // In this case the data value rows will only be created once a value is entered
            GetOrCreateDataLabelValueRow(false, ADataLabelRow, out DataLabelValuePartnerRow, out DataLabelValueApplicationRow);

            // initialize cell control
            cellControl = null;

            // Create field, according to specified data type
            // Create character field
            if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_CHAR)
            {
                TextBoxEditor = new System.Windows.Forms.TextBox();
                cellControl = TextBoxEditor;

                if (DataLabelValuePartnerRow != null)
                {
                    TextBoxEditor.Text = DataLabelValuePartnerRow.ValueChar;
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    TextBoxEditor.Text = DataLabelValueApplicationRow.ValueChar;
                }
                else
                {
                    // Default value if no Label data exists for the Partner
                    TextBoxEditor.Text = "";
                }

                // enable save button in editor when cell contents have changed
                TextBoxEditor.TextChanged += new EventHandler(this.ControlValueHasChanged);

                FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell();
                FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)TextBoxEditor, new Position(ARowIndex, 1)));
                FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = TextBoxEditor;
            }
            // Create float field
            else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_FLOAT)
            {
                TextBoxNumericEditor = new TTxtNumericTextBox();

                if (ADataLabelRow.NumDecimalPlaces == 0)
                {
                    TextBoxNumericEditor.ControlMode = TTxtNumericTextBox.TNumericTextBoxMode.LongInteger;
                    TextBoxNumericEditor.MaxLength = 14;
                }
                else
                {
                    TextBoxNumericEditor.ControlMode = TTxtNumericTextBox.TNumericTextBoxMode.Decimal;
                    TextBoxNumericEditor.DecimalPlaces = ADataLabelRow.NumDecimalPlaces;

                    // limit text length. 14 for number of digits, 5 for decimal and thousands separators
                    TextBoxNumericEditor.MaxLength = 14 + 5 + ADataLabelRow.NumDecimalPlaces;
                }

                TextBoxNumericEditor.NullValueAllowed = true;
                cellControl = TextBoxNumericEditor;

                if (ADataLabelRow.NumDecimalPlaces == 0)
                {
                    if (DataLabelValuePartnerRow != null)
                    {
                        TextBoxNumericEditor.NumberValueLongInt = (long)DataLabelValuePartnerRow.ValueNum;
                    }
                    else if (DataLabelValueApplicationRow != null)
                    {
                        TextBoxNumericEditor.NumberValueLongInt = (long)DataLabelValueApplicationRow.ValueNum;
                    }
                    else
                    {
                        // Default value if no Label data exists for the Partner
                        TextBoxNumericEditor.NumberValueLongInt = null;
                    }
                }
                else
                {
                    if (DataLabelValuePartnerRow != null)
                    {
                        TextBoxNumericEditor.NumberValueDecimal = DataLabelValuePartnerRow.ValueNum;
                    }
                    else if (DataLabelValueApplicationRow != null)
                    {
                        TextBoxNumericEditor.NumberValueDecimal = DataLabelValueApplicationRow.ValueNum;
                    }
                    else
                    {
                        // Default value if no Label data exists for the Partner
                        TextBoxNumericEditor.NumberValueDecimal = null;
                    }
                }

                // enable save button in editor when cell contents have changed
                TextBoxNumericEditor.TextChanged += new EventHandler(this.ControlValueHasChanged);

                FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell();
                FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)TextBoxNumericEditor, new Position(ARowIndex, 1)));
                FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = TextBoxNumericEditor;
            }
            // Create data field
            else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_DATE)
            {
                DateEditor = new TtxtPetraDate();
                DateEditor.Date = null;
                cellControl = DateEditor;

                if (DataLabelValuePartnerRow != null)
                {
                    if (!DataLabelValuePartnerRow.IsValueDateNull())
                    {
                        DateEditor.Date = DataLabelValuePartnerRow.ValueDate;
                    }
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    if (!DataLabelValueApplicationRow.IsValueDateNull())
                    {
                        DateEditor.Date = DataLabelValueApplicationRow.ValueDate;
                    }
                }

                // enable save button in editor when cell contents have changed
                DateEditor.DateChanged += new TPetraDateChangedEventHandler(this.ControlValueHasChanged);

                FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell();
                FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)DateEditor, new Position(ARowIndex, 1)));
                FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = DateEditor;
            }
            // Create integer field
            else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_INTEGER)
            {
                TextBoxNumericEditor = new TTxtNumericTextBox();
                TextBoxNumericEditor.ControlMode = TTxtNumericTextBox.TNumericTextBoxMode.Integer;
                TextBoxNumericEditor.NullValueAllowed = true;
                cellControl = TextBoxNumericEditor;

                if (DataLabelValuePartnerRow != null)
                {
                    TextBoxNumericEditor.NumberValueInt = DataLabelValuePartnerRow.ValueInt;
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    TextBoxNumericEditor.NumberValueInt = DataLabelValueApplicationRow.ValueInt;
                }
                else
                {
                    // Default value if no Label data exists for the Partner
                    TextBoxNumericEditor.NumberValueInt = null;
                }

                // enable save button in editor when cell contents have changed
                TextBoxNumericEditor.TextChanged += new EventHandler(this.ControlValueHasChanged);

                FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell();
                FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)TextBoxNumericEditor, new Position(ARowIndex, 1)));
                FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = TextBoxNumericEditor;
            }
            // Create currency field
            else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_CURRENCY)
            {
                TextBoxCurrencyEditor = new TTxtCurrencyTextBox();
                TextBoxCurrencyEditor.DecimalPlaces = 2;
                TextBoxCurrencyEditor.CurrencyCode = ADataLabelRow.CurrencyCode;
                TextBoxCurrencyEditor.NullValueAllowed = true;
                cellControl = TextBoxCurrencyEditor;

                if (DataLabelValuePartnerRow != null)
                {
                    TextBoxCurrencyEditor.NumberValueDecimal = DataLabelValuePartnerRow.ValueCurrency;
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    TextBoxCurrencyEditor.NumberValueDecimal = DataLabelValueApplicationRow.ValueCurrency;
                }
                else
                {
                    // Default value if no Label data exists for the Partner
                    TextBoxCurrencyEditor.NumberValueDecimal = null;
                }

                // enable save button in editor when cell contents have changed
                TextBoxCurrencyEditor.TextChanged += new EventHandler(this.ControlValueHasChanged);

                FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell();
                FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)TextBoxCurrencyEditor, new Position(ARowIndex, 1)));
                FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = TextBoxCurrencyEditor;
            }
            // Create boolean field
            else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_BOOLEAN)
            {
                CheckBoxEditor = new System.Windows.Forms.CheckBox();
                cellControl = CheckBoxEditor;

                if (DataLabelValuePartnerRow != null)
                {
                    CheckBoxEditor.Checked = DataLabelValuePartnerRow.ValueBool;
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    CheckBoxEditor.Checked = DataLabelValueApplicationRow.ValueBool;
                }
                else
                {
                    // Default value if no Label data exists for the Partner
                    CheckBoxEditor.Checked = false;
                }

                // enable save button in editor when cell contents have changed
                CheckBoxEditor.CheckedChanged += new EventHandler(this.ControlValueHasChanged);

                FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell();
                FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)CheckBoxEditor, new Position(ARowIndex, 1)));
                FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = CheckBoxEditor;
            }
            // Create partner key field
            else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_PARTNERKEY)
            {
                PartnerKeyEditor = new TtxtAutoPopulatedButtonLabel();
                PartnerKeyEditor.ASpecialSetting = true;
                PartnerKeyEditor.ButtonText = ADataLabelRow.Text + ':';
                PartnerKeyEditor.ButtonTextAlign = System.Drawing.ContentAlignment.MiddleRight;
                PartnerKeyEditor.ListTable = TtxtAutoPopulatedButtonLabel.TListTableEnum.PartnerKey;
                PartnerKeyEditor.TabStop = false;
                cellControl = PartnerKeyEditor;

                // AutomaticallyUpdateDataSource: very rare, but needed here
                PartnerKeyEditor.AutomaticallyUpdateDataSource = true;

                if (DataLabelValuePartnerRow != null)
                {
                    PartnerKeyEditor.Text = StringHelper.PartnerKeyToStr(DataLabelValuePartnerRow.ValuePartnerKey);
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    PartnerKeyEditor.Text = StringHelper.PartnerKeyToStr(DataLabelValueApplicationRow.ValuePartnerKey);
                }
                else
                {
                    // Default value if no Label data exists for the Partner
                    PartnerKeyEditor.Text = StringHelper.PartnerKeyToStr(0);
                }

                // display partner name linked to partner key
                PartnerKeyEditor.ResetLabelText();

                // enable save button in editor when cell contents have changed
                PartnerKeyEditor.ValueChanged += new TDelegatePartnerChanged(this.PartnerKeyControlValueHasChanged);
                PartnerKeyEditor.TextChanged += new System.EventHandler(this.ControlValueHasChanged);


                FLocalDataLabelValuesGrid[ARowIndex, 0] = new SourceGrid.Cells.Cell();
                FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue(PartnerKeyEditor, new Position(ARowIndex, 0)));
                FLocalDataLabelValuesGrid[ARowIndex, 0].Tag = PartnerKeyEditor;
                FLocalDataLabelValuesGrid[ARowIndex, 0].ColumnSpan = 3;
            }
            // Create lookup field
            else if (ADataLabelRow.DataType == MCommonConstants.OFFICESPECIFIC_DATATYPE_LOOKUP)
            {
                // Get the instance of the combobox (created in the actual user interface class)
                LookupValueEditor = new TCmbAutoPopulated();
                LookupValueEditor.Filter = PDataLabelLookupTable.GetCategoryCodeDBName() + " = '" + ADataLabelRow.LookupCategoryCode + "'";
                LookupValueEditor.ListTable = TCmbAutoPopulated.TListTableEnum.DataLabelLookupList;
                LookupValueEditor.InitialiseUserControl();
                cellControl = LookupValueEditor;

                if (DataLabelValuePartnerRow != null)
                {
                    LookupValueEditor.SetSelectedString(DataLabelValuePartnerRow.ValueLookup);
                }
                else if (DataLabelValueApplicationRow != null)
                {
                    LookupValueEditor.SetSelectedString(DataLabelValueApplicationRow.ValueLookup);
                }
                else
                {
                    // Default value if no Label data exists for the Partner
                    LookupValueEditor.Text = "";
                }

                // enable save button in editor when cell contents have changed
                LookupValueEditor.SelectedValueChanged += new EventHandler(this.ControlValueHasChanged);
                LookupValueEditor.TextChanged += new EventHandler(this.ControlValueHasChanged);

                FLocalDataLabelValuesGrid[ARowIndex, 1] = new SourceGrid.Cells.Cell();
                FLocalDataLabelValuesGrid.LinkedControls.Add(new LinkedControlValue((Control)LookupValueEditor, new Position(ARowIndex, 1)));
                FLocalDataLabelValuesGrid[ARowIndex, 1].Tag = LookupValueEditor;
                FLocalDataLabelValuesGrid[ARowIndex, 1].ColumnSpan = 2;
            }

            // perform actions that need to be done for each control
            if (cellControl != null)
            {
                // remember the added control to get the value back lateron
                FGridRowInfo.SetControl(ARowIndex, cellControl);

                // handle focus change when field is entered
                cellControl.Enter += new EventHandler(this.UpdateGridFocusFromExternalControl);

                // set help text for control
                PetraUtilsObject.SetStatusBarText(cellControl, ADataLabelRow.Description);
            }

            // check if value is editable
            if (!ADataLabelRow.Editable)
            {
                FLocalDataLabelValuesGrid[ARowIndex, 1].Editor.EnableEdit = false;
            }
        }
コード例 #6
0
ファイル: IBGridForm.cs プロジェクト: distagon/daemaged.ibnet
    private void SetupCommonGridResources()
    {
      _columnHeaderView = new SourceGrid.Cells.Views.ColumnHeader();
      _columnHeaderView.ElementText = new RotatedText(-60);
      _columnHeaderView.BackColor = Color.LightYellow;

      _textRenderer = new DevAge.Drawing.VisualElements.TextRenderer();

      _defaultView = new SourceGrid.Cells.Views.Cell();
      _defaultView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;

      _defaultViewClearType = new SourceGrid.Cells.Views.Cell();
      _defaultViewClearType.ElementText = _textRenderer;

      _yellowView = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
      _yellowView.BackColor = Color.LightYellow;
      _yellowView.ElementText = _defaultView.ElementText;

      _lightGray = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
      _lightGray.BackColor = Color.LightGray;
      _lightGray.ElementText = _defaultView.ElementText;

      _whiteView = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
      _whiteView.BackColor = Color.White;
      _whiteView.ElementText = _defaultView.ElementText;

      _lightGreen = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
      _lightGreen.BackColor = Color.LightGreen;
      _lightGreen.ElementText = _defaultView.ElementText;

      _darkGreen = _defaultView.Clone() as SourceGrid.Cells.Views.Cell;
      _darkGreen.BackColor = Color.DarkGreen;
      _darkGreen.ForeColor = Color.White;
      _darkGreen.ElementText = _defaultView.ElementText;

      _highlightView = new SourceGrid.Cells.Views.Cell();
      _highlightView.BackColor = Color.LightPink;
      _highlightView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
      _highlightView.ElementText = _defaultView.ElementText;
    }
コード例 #7
0
ファイル: sgrdDataGrid.cs プロジェクト: Davincier/openpetra
        /// <summary>
        /// add a column that shows a currency value.
        /// aligns the value to the right.
        /// prints number in red if it is negative
        /// </summary>
        /// <param name="AColumnTitle">Title of the HeaderColumn</param>
        /// <param name="ADataColumn">DataColumn to which this column should be DataBound</param>
        /// <param name="ADecimalDigits">Number of digits after the currency decimal point</param>
        public void AddCurrencyColumn(String AColumnTitle, DataColumn ADataColumn, int ADecimalDigits)
        {
            SourceGrid.Cells.Editors.TextBox CurrencyEditor = new SourceGrid.Cells.Editors.TextBox(typeof(decimal));
            CurrencyEditor.TypeConverter = new Ict.Common.TypeConverter.TCurrencyConverter(
                ADataColumn.ColumnName, Thread.CurrentThread.CurrentCulture.NumberFormat, ADecimalDigits);

            CurrencyEditor.EditableMode = EditableMode.None;


            // Non-negative value View
            SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
            view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight;

            // Negative value View
            SourceGrid.Cells.Views.Cell NegativeNumberView = new SourceGrid.Cells.Views.Cell();
            NegativeNumberView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight;
            NegativeNumberView.ForeColor = Color.Red;

            // Condition for negative value View
            SourceGrid.Conditions.ConditionView selectedConditionNegative =
                new SourceGrid.Conditions.ConditionView(NegativeNumberView);
            selectedConditionNegative.EvaluateFunction = (delegate(SourceGrid.DataGridColumn column,
                                                                   int gridRow, object itemRow)
                                                          {
                                                              DataRowView row = (DataRowView)itemRow;
                                                              return row[ADataColumn.ColumnName] is decimal
                                                              && (decimal)row[ADataColumn.ColumnName] < 0;
                                                          });

            AddTextColumn(AColumnTitle, ADataColumn, -1, null, CurrencyEditor, null, view, selectedConditionNegative);
        }
コード例 #8
0
ファイル: sgrdDataGrid.cs プロジェクト: Davincier/openpetra
        /// <summary>
        /// add a column that shows a decimal value.
        /// aligns the value to the right.
        /// </summary>
        /// <param name="AColumnTitle">Title of the HeaderColumn</param>
        /// <param name="ADataColumn">DataColumn to which this column should be DataBound</param>
        /// <param name="ADecimalDigits">Number of digits after the numeric decimal point</param>
        public void AddDecimalColumn(String AColumnTitle, DataColumn ADataColumn, int ADecimalDigits)
        {
            SourceGrid.Cells.Editors.TextBox DecimalEditor = new SourceGrid.Cells.Editors.TextBox(typeof(decimal));
            DecimalEditor.TypeConverter = new Ict.Common.TypeConverter.TDecimalConverter(
                ADataColumn.ColumnName, Thread.CurrentThread.CurrentCulture.NumberFormat, ADecimalDigits);
            DecimalEditor.EditableMode = EditableMode.None;

            SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
            view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight;

            AddTextColumn(AColumnTitle, ADataColumn, -1, null, DecimalEditor, null, view, null);
        }