Exemplo n.º 1
0
        /// <summary>
        /// </summary>
        /// <param name="placementDim"></param>
        /// <returns></returns>
        public int getPlacementDif(PlacementDim placementDim)
        {
            int result = 0;

#if !PocketPC
            //tmp
            bool containerRightToLeft = _tableManager.RightToLeftLayout;
#else
            bool containerRightToLeft = false;
#endif
            switch (placementDim)
            {
            case PlacementDim.PLACE_X:
            case PlacementDim.PLACE_DX:
                ILogicalColumn columnManager = _tableManager.ColumnsManager.getLgColumnByMagicIdx(MgColumn);
                int            dx            = columnManager.getDx();
                result = dx * _logicalControl.PlacementData.getPlacement(placementDim, containerRightToLeft) / 100;
                break;

            case PlacementDim.PLACE_Y:
            case PlacementDim.PLACE_DY:
                result = 0; // no Y placement in table's children
                break;

            default:
                break;
            }


            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Accumulates all the widthes of columns with placement if there is no such columns return -1
        /// </summary>
        /// <param name="dx"></param>
        /// <param name="columns"></param>
        /// <returns></returns>
        public int allowedPlacementWidth(int dx, List <ILogicalColumn> columns)
        {
            bool hasPlacement = false;
            int  width        = 0;

            for (int i = 0; i < columns.Count; i++)
            {
                ILogicalColumn column = columns[i];
                if (PlacementAllowed(column, ShouldApplyPlacementToHiddenColumns))
                {
                    // for such column placement is not allowed
                    if (dx < 0 && column.getWidth() == 0)
                    {
                        continue;
                    }
                    hasPlacement = true;
                    width       += column.getWidth();
                }
            }
            if (!hasPlacement)
            {
                width = -1;
            }
            return(width);
        }
Exemplo n.º 3
0
        public override void PaintControl(PlacementDrivenLogicalControl lg, Rectangle cellRect, Graphics g, bool isRowMarked, bool isSelected, ColumnsManager columnsManager)
        {
            base.PaintControl(lg, cellRect, g, isRowMarked, isSelected, columnsManager);

            LogicalControl logicalControl = (LogicalControl)lg;

            // paint controls
            if (GuiUtilsBase.isOwnerDrawControl(logicalControl.GuiMgControl))
            {
                var tableCoordinator = (TableCoordinator)lg.Coordinator;

                ILogicalColumn lgColumn = columnsManager.getLgColumnByMagicIdx(lg._mgColumn);
                if (lg.Visible && lgColumn.Visible && tableCoordinator.getEditorControl() == null)
                {
                    bool keepColor;
                    //calculate background color
                    Color controlBgColor = computeControlBgColor((LogicalControl)lg, columnsManager, null, isRowMarked, false,
                                                                 OnGetGuiRowIndex(lg._mgRow), true, out keepColor);

                    Rectangle displayRect = tableCoordinator.getDisplayRect(cellRect, false);

                    //calculate foreground color
                    Color fgColor = computeControlFgColor(isSelected, isRowMarked, (LogicalControl)lg);

                    //paint the control
                    logicalControl.paint(g, displayRect, controlBgColor, fgColor, keepColor);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///   returns control rectangle
        /// </summary>
        /// <param name = "cellRect">rectangle of table's cell </param>
        /// <returns> </returns>
        public virtual Rectangle getDisplayRect(Rectangle cellRect, bool isHeaderEditor)
        {
            var rect = new Rectangle(0, 0, 0, 0);

            //if (_logicalControl is Line)
            //   rect = ((Line)_logicalControl).calcDisplayRect();
            //else
            {
                // compute rectangle relativly to table
                rect.Height = Height;
                rect.Width  = Width;
                PlacementData placementData = _logicalControl.PlacementData;

                // apply X placement (depends on column width)
                Rectangle      placementRect = placementData.Placement;
                ILogicalColumn columnManager = _tableManager.ColumnsManager.getLgColumnByMagicIdx(MgColumn);
                int            dx            = columnManager.getDx();
                if (_tableManager.RightToLeftLayout)
                {
                    int right = cellRect.Right - _xorigin;
                    right      -= dx * placementRect.X / 100;
                    rect.Width += ((dx * placementRect.Width) / 100);
                    rect.X      = right - rect.Width;
                }
                else
                {
                    rect.X      = GetDisplayRectangleLeft(cellRect);
                    rect.X     += dx * placementRect.X / 100;
                    rect.Width += ((dx * placementRect.Width) / 100);
                }

                // apply Y placement (depends on row height)
                // Defect 138536: For Header control, do not consider change in row height and hence do not consider placement for Y & Height
                int dy = isHeaderEditor ? 0 : _tableManager.GetChangeInRowHeight();
                rect.Y  = GetDisplayRectangleTop(cellRect);
                rect.Y += dy * placementRect.Y / 100;

                //Height of the 3D ComboBox is fixed and depends on the Font.
                //We cannot change it by setting the Height.
                //So, the Height placement is irrelevant.
                //Sets height only for 2D combobox
                if (!IsComboControl() || Is2DComboBoxControl())
                {
                    rect.Height += ((dy * placementRect.Height) / 100);
                }

                rect = _tableManager.GetTableMultiColumnStrategy(isHeaderEditor).GetRectToDraw(rect, cellRect);
            }

            return(rect);
        }
Exemplo n.º 5
0
        /// <summary>
        /// return table log size which is sum of it's visible columns width
        /// </summary>
        /// <param name="columns"></param>
        /// <returns></returns>
        internal int getLogSize(List <ILogicalColumn> columns)
        {
            int logSize = 0;

            for (int i = 0; i < columns.Count; i++)
            {
                ILogicalColumn column = columns[i];
                if (ShouldApplyPlacementToHiddenColumns || column.Visible)
                {
                    logSize += column.getWidth();
                }
            }
            return(logSize);
        }
Exemplo n.º 6
0
        /// <summary>
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public int transformXToCell(int x)
        {
            ILogicalColumn columnManager = _tableManager.ColumnsManager.getLgColumnByMagicIdx(MgColumn);

            if (_tableManager.RightToLeftLayout)
            {
                int right       = x + Width;
                int columnRight = columnManager.getStartXPos();
                return(columnRight - right);
            }
            else
            {
                return(x - columnManager.getStartXPos());
            }
        }
Exemplo n.º 7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="tableControl"></param>
 /// <param name="column"></param>
 /// <param name="shouldPaintImmediately"></param>
 private void HandleEditors(TableControl tableControl, ILogicalColumn column, bool shouldPaintImmediately, bool shouldApplyPlacementToHiddenColumns)
 {
     if (PlacementAllowed(column, shouldApplyPlacementToHiddenColumns))
     {
         //we must paint all columns before persistent editors, otherwise these columns get
         //garbaged by the editors
         if (shouldPaintImmediately)
         {
             tableControl.AllowPaint = true;
         }
         column.setWidthOnPlacement(column.getWidth(), true);
         if (shouldPaintImmediately)
         {
             tableControl.AllowPaint = false;
         }
     }
 }
Exemplo n.º 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="column"></param>
 /// <returns></returns>
 bool PlacementAllowed(ILogicalColumn column, bool shouldApplyPlacementToHiddenColumns)
 {
     return((shouldApplyPlacementToHiddenColumns || column.Visible) && column.HasPlacement());
 }
Exemplo n.º 9
0
        /// <summary>
        /// Execute the placement
        /// </summary>
        /// <param name="tablecontrol"></param>
        /// <param name="columns"></param>
        /// <param name="dx"></param>
        /// <param name="newRect"></param>
        /// <param name="considerEditors"></param>
        /// <param name="maxColumnWithEditor"></param>
        /// <param name="tablePlacementStrategy"></param>
        public void ExecutePlacement(TableControl tablecontrol, List <ILogicalColumn> columns, int dx, Rectangle newRect, bool considerEditors, int maxColumnWithEditor, ITablePlacementStrategy tablePlacementStrategy)
        {
            int colNum = 0;

            // compute number of columns for placement
            for (int i = 0; i < columns.Count; i++)
            {
                ILogicalColumn column = columns[i];
                if (dx <= 0 && tablePlacementStrategy.GetColumnWidth(column) == 0)
                {
                    continue;
                }
                if (PlacementAllowed(column, tablePlacementStrategy.ShouldApplyPlacementToHiddenColumns(ShouldApplyPlacementToHiddenColumns)))
                {
                    colNum++;
                }
            }

            // Handle Column Placement
            if (colNum != 0)
            {
                int  colDx       = dx / colNum; // dx to move a column
                int  rem         = Math.Abs(dx) - Math.Abs(colDx) * colNum;
                int  addOn       = 0;
                bool secondRound = false;

                for (int i = columns.Count - 1; i >= 0; i--)
                {
                    ILogicalColumn column = columns[i];

                    int colWidth = tablePlacementStrategy.GetColumnWidth(column);

                    if (!PlacementAllowed(column, tablePlacementStrategy.ShouldApplyPlacementToHiddenColumns(ShouldApplyPlacementToHiddenColumns)))
                    {
                        continue;
                    }
                    if (colDx < 0 && colWidth == 0)
                    {
                        continue;
                    }
                    if (colDx < 0 && (colWidth < Math.Abs(colDx) + Math.Abs(addOn)) && colWidth > 0)
                    {
                        // the column width is less then the amount need to shrink it, pass the remainder of ColMoveDX to
                        // the next col's.
                        addOn += colWidth + colDx; // save the remainder
                        column.setWidthOnPlacement(0, false);
                        secondRound = true;
                    }
                    else
                    {
                        column.setWidthOnPlacement(Math.Max(0, colWidth + colDx + addOn), false);
                        secondRound = false;
                        addOn       = 0;
                    }
                }
                if (secondRound)
                {
                    for (int i = columns.Count - 1; i >= 0; i--)
                    {
                        ILogicalColumn column   = columns[i];
                        int            colWidth = column.getWidth();
                        if (addOn < 0 && PlacementAllowed(column, tablePlacementStrategy.ShouldApplyPlacementToHiddenColumns(ShouldApplyPlacementToHiddenColumns)) && colWidth > 0)
                        {
                            if (colWidth < Math.Abs(addOn))
                            {
                                addOn += colWidth;
                                column.setWidthOnPlacement(0, false);
                            }
                            else
                            {
                                column.setWidthOnPlacement(colWidth + addOn, false);
                                addOn = 0;
                            }
                        }
                    }
                }

                // resize columns the remainder of dx
                int count = 0;

                while (rem > 0 && count < columns.Count)
                {
                    ILogicalColumn column = columns[_placementIdx];
                    if (PlacementAllowed(column, tablePlacementStrategy.ShouldApplyPlacementToHiddenColumns(ShouldApplyPlacementToHiddenColumns)))
                    {
                        int colWidth = column.getWidth();
                        if (dx > 0 || (dx < 0 && colWidth > 0))
                        {
                            long ResizeDx = rem;

                            if (dx < 0)
                            {
                                // can not set widht less then 0
                                ResizeDx = Math.Min(ResizeDx, colWidth);
                            }
                            colWidth = (int)(colWidth + (dx > 0 ? ResizeDx : -ResizeDx));
                            column.setWidthOnPlacement(colWidth, false);
                            rem = (int)(rem - ResizeDx);
                        }
                    }
                    if (--_placementIdx < 0)
                    {
                        _placementIdx = columns.Count - 1;
                    }
                    count++;
                }
                //QCR #913300, column.setWidthOnPlacement causes repaints,
                //this is will improve performance

                tablecontrol.AllowPaint = false;

                if (considerEditors)
                {
                    if (tablecontrol.RightToLeft == System.Windows.Forms.RightToLeft.Yes)
                    {
                        for (int i = columns.Count - 1; i >= 0; i--)
                        {
                            ILogicalColumn column = columns[i];
                            HandleEditors(tablecontrol, column, i <= maxColumnWithEditor, tablePlacementStrategy.ShouldApplyPlacementToHiddenColumns(ShouldApplyPlacementToHiddenColumns));
                        }
                    }
                    else
                    {
                        for (int i = 0; i < columns.Count; i++)
                        {
                            ILogicalColumn column = columns[i];
                            HandleEditors(tablecontrol, column, i <= maxColumnWithEditor, tablePlacementStrategy.ShouldApplyPlacementToHiddenColumns(ShouldApplyPlacementToHiddenColumns));
                        }
                    }
                }

                tablecontrol.MoveColumns(0);

                tablecontrol.AllowPaint = true;
                tablecontrol.Invalidate();
            }
        }
Exemplo n.º 10
0
 public int GetColumnWidth(ILogicalColumn column)
 {
     return(column.getWidth());
 }
Exemplo n.º 11
0
 public int GetColumnWidth(ILogicalColumn column)
 {
     return(((LgColumn)column).WidthForFillTablePlacement);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Inserts column to Column list
        /// </summary>
        /// <param name="column"></param>
        /// <param name="mgColumn"></param>
        /// <param name="rightToLeft"></param>
        public void Insert(ILogicalColumn column, int mgColumn, bool rightToLeft)
        {
            int guiColumn = rightToLeft ? ColumnsCount - 1 - mgColumn : mgColumn;

            _columns[guiColumn] = column;
        }