Exemple #1
0
        public Altaxo.Worksheet.WorksheetLayout CreateNewTableLayout(Altaxo.Data.DataTable table)
        {
            if (!_dataTables.Contains(table))
            {
                _dataTables.Add(table);
            }

            var layout = new Altaxo.Worksheet.WorksheetLayout(table);

            _tableLayouts.Add(layout);
            return(layout);
        }
Exemple #2
0
 public Altaxo.Worksheet.WorksheetLayout CreateNewTableLayout(Altaxo.Data.DataTable table)
 {
     Altaxo.Worksheet.WorksheetLayout layout = new Altaxo.Worksheet.WorksheetLayout(table);
     this.m_TableLayoutList.Add(layout);
     return(layout);
 }
        /// <summary>
        /// Paints part of the worksheet to the drawing context. Row and column header are always threaten as visible here.
        /// </summary>
        /// <param name="dc">Drawing context.</param>
        /// <param name="layout">Worksheet layout.</param>
        /// <param name="viewSize">Width and height of the viewing area (Pixel or Wpf coordinates).</param>
        /// <param name="clipRectangle">Bounds of the clipping region. Only that parts of the worksheet that are visible within the clipping region are drawn.</param>
        /// <param name="selectedDataColumns">Selected data columns.</param>
        /// <param name="selectedDataRows">Selected data rows.</param>
        /// <param name="selectedPropertyColumns">Selected property columns.</param>
        /// <param name="selectedPropertyRows">Selected property rows.</param>
        /// <param name="horzScrollPos">Horizontal scroll position (0 = first column visible).</param>
        /// <param name="vertScrollPos">Vertical scroll position (0 = first data column visible, negative values: one or more property columns visible).</param>
        public static void PaintTableArea(
            Graphics dc,
            Altaxo.Worksheet.WorksheetLayout layout,
            Size viewSize,
            RectangleD2D clipRectangle,
            IAscendingIntegerCollection selectedDataColumns,
            IAscendingIntegerCollection selectedDataRows,
            IAscendingIntegerCollection selectedPropertyColumns,
            IAscendingIntegerCollection selectedPropertyRows,
            int horzScrollPos, int vertScrollPos
            )
        {
            var dataTable = layout.DataTable;

            bool bDrawColumnHeader = false;

            int firstTableRowToDraw     = WA.GetFirstVisibleTableRow(clipRectangle.Top, layout, vertScrollPos);
            int numberOfTableRowsToDraw = WA.GetVisibleTableRows(clipRectangle.Top, clipRectangle.Bottom, layout, vertScrollPos);

            int firstPropertyColumnToDraw     = WA.GetFirstVisiblePropertyColumn(clipRectangle.Top, layout, vertScrollPos);
            int numberOfPropertyColumnsToDraw = WA.GetVisiblePropertyColumns(clipRectangle.Top, clipRectangle.Bottom, layout, vertScrollPos);

            bool bAreColumnsSelected = selectedDataColumns.Count > 0;
            bool bAreRowsSelected    = selectedDataRows.Count > 0;
            bool bAreCellsSelected   = bAreRowsSelected || bAreColumnsSelected;

            bool bArePropertyColsSelected  = selectedPropertyColumns.Count > 0;
            bool bArePropertyRowsSelected  = selectedPropertyRows.Count > 0;
            bool bArePropertyCellsSelected = ArePropertyCellsSelected(dataTable, selectedPropertyColumns, selectedPropertyRows);

            int yShift = 0;

            var    cellRectangle = new RectangleD2D();
            double left, width;

            if (clipRectangle.Top < layout.ColumnHeaderStyle.Height)
            {
                bDrawColumnHeader = true;
            }

            // if neccessary, draw the row header (the most left column)
            if (clipRectangle.Left < layout.RowHeaderStyle.Width)
            {
                cellRectangle.Height = layout.ColumnHeaderStyle.Height;
                cellRectangle.Width  = layout.RowHeaderStyle.Width;
                cellRectangle.X      = 0;

                // if visible, draw the top left corner of the table
                if (bDrawColumnHeader)
                {
                    cellRectangle.Y = 0;
                    layout.RowHeaderStyle.PaintBackground(dc, (Rectangle)cellRectangle, false);
                }

                // if visible, draw property column header items
                yShift = WA.GetTopCoordinateOfPropertyColumn(firstPropertyColumnToDraw, layout, vertScrollPos);
                cellRectangle.Height = layout.PropertyColumnHeaderStyle.Height;
                for (int nPropCol = firstPropertyColumnToDraw, nInc = 0; nInc < numberOfPropertyColumnsToDraw; nPropCol++, nInc++)
                {
                    cellRectangle.Y = yShift + nInc * layout.PropertyColumnHeaderStyle.Height;
                    bool bPropColSelected = bArePropertyColsSelected && selectedPropertyColumns.Contains(nPropCol);
                    layout.PropertyColumnHeaderStyle.Paint(dc, (Rectangle)cellRectangle, nPropCol, dataTable.PropCols[nPropCol], bPropColSelected);
                }
            }

            // draw the table row Header Items
            yShift = WA.GetTopCoordinateOfTableRow(firstTableRowToDraw, layout, vertScrollPos);
            cellRectangle.Height = layout.RowHeaderStyle.Height;
            for (int nRow = firstTableRowToDraw, nInc = 0; nInc < numberOfTableRowsToDraw; nRow++, nInc++)
            {
                cellRectangle.Y = yShift + nInc * layout.RowHeaderStyle.Height;
                layout.RowHeaderStyle.Paint(dc, (Rectangle)cellRectangle, nRow, null, bAreRowsSelected && selectedDataRows.Contains(nRow));
            }

            if (clipRectangle.Bottom >= layout.ColumnHeaderStyle.Height || clipRectangle.Right >= layout.RowHeaderStyle.Width)
            {
                int firstColToDraw = WA.GetFirstAndNumberOfVisibleColumn(clipRectangle.Left, clipRectangle.Right, layout, horzScrollPos, out var numberOfColumnsToDraw);

                // draw the property columns
                for (int nPropCol = firstPropertyColumnToDraw, nIncPropCol = 0; nIncPropCol < numberOfPropertyColumnsToDraw; nPropCol++, nIncPropCol++)
                {
                    Altaxo.Worksheet.ColumnStyle cs = layout.PropertyColumnStyles[dataTable.PropCols[nPropCol]];
                    bool bPropColSelected           = bArePropertyColsSelected && selectedPropertyColumns.Contains(nPropCol);
                    bool bPropColIncluded           = bArePropertyColsSelected ? bPropColSelected : true; // Property cells are only included if the column is explicite selected

                    cellRectangle.Y      = WA.GetTopCoordinateOfPropertyColumn(nPropCol, layout, vertScrollPos);
                    cellRectangle.Height = layout.PropertyColumnHeaderStyle.Height;

                    for (int nCol = firstColToDraw, nIncCol = 0; nIncCol < numberOfColumnsToDraw; nCol++, nIncCol++)
                    {
                        if (nCol == firstColToDraw)
                        {
                            WA.GetXCoordinatesOfColumn(nCol, layout, horzScrollPos, out left, out width);
                            cellRectangle.X     = left;
                            cellRectangle.Width = width;
                        }
                        else
                        {
                            cellRectangle.X    += cellRectangle.Width;
                            cellRectangle.Width = layout.DataColumnStyles[dataTable.DataColumns[nCol]].WidthD;
                        }

                        bool bPropRowSelected = bArePropertyRowsSelected && selectedPropertyRows.Contains(nCol);
                        bool bPropRowIncluded = bArePropertyRowsSelected ? bPropRowSelected : true;

                        cs.Paint(dc, (Rectangle)cellRectangle, nCol, dataTable.PropCols[nPropCol], bArePropertyCellsSelected && bPropColIncluded && bPropRowIncluded);
                    }
                }

                // draw the cells
                for (int nCol = firstColToDraw, nIncCol = 0; nIncCol < numberOfColumnsToDraw; nCol++, nIncCol++)
                {
                    Altaxo.Worksheet.ColumnStyle cs = layout.DataColumnStyles[dataTable.DataColumns[nCol]];
                    if (nCol == firstColToDraw)
                    {
                        WA.GetXCoordinatesOfColumn(nCol, layout, horzScrollPos, out left, out width);
                        cellRectangle.X     = left;
                        cellRectangle.Width = width;
                    }
                    else
                    {
                        cellRectangle.X    += cellRectangle.Width;
                        cellRectangle.Width = cs.WidthD;
                    }

                    bool bColumnSelected      = bAreColumnsSelected && selectedDataColumns.Contains(nCol);
                    bool bDataColumnIncluded  = bAreColumnsSelected ? bColumnSelected : true;
                    bool bPropertyRowSelected = bArePropertyRowsSelected && selectedPropertyRows.Contains(nCol);

                    if (bDrawColumnHeader) // must the column Header been drawn?
                    {
                        cellRectangle.Height = layout.ColumnHeaderStyle.Height;
                        cellRectangle.Y      = 0;
                        layout.ColumnHeaderStyle.Paint(dc, (Rectangle)cellRectangle, 0, dataTable[nCol], bColumnSelected || bPropertyRowSelected);
                    }

                    yShift = WA.GetTopCoordinateOfTableRow(firstTableRowToDraw, layout, vertScrollPos);
                    cellRectangle.Height = layout.RowHeaderStyle.Height;
                    for (int nRow = firstTableRowToDraw, nIncRow = 0; nIncRow < numberOfTableRowsToDraw; nRow++, nIncRow++)
                    {
                        bool bRowSelected     = bAreRowsSelected && selectedDataRows.Contains(nRow);
                        bool bDataRowIncluded = bAreRowsSelected ? bRowSelected : true;
                        cellRectangle.Y = yShift + nIncRow * layout.RowHeaderStyle.Height;
                        cs.Paint(dc, (Rectangle)cellRectangle, nRow, dataTable[nCol], bAreCellsSelected && bDataColumnIncluded && bDataRowIncluded);
                    }
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="table">The table.</param>
 /// <param name="layout">The layout of the table.</param>
 public TablePlusLayout(Altaxo.Data.DataTable table, Altaxo.Worksheet.WorksheetLayout layout)
 {
     _table  = table;
     _layout = layout;
 }
Exemple #5
0
        /// <summary>
        /// Creates a view content for a table.
        /// </summary>
        /// <param name="table">The table which should be viewed.</param>
        /// <param name="layout">The layout for the table.</param>
        /// <returns>The view content for the provided table.</returns>
        private Altaxo.Gui.Worksheet.Viewing.IWorksheetController CreateNewWorksheet_Unsynchronized(Altaxo.Data.DataTable table, Altaxo.Worksheet.WorksheetLayout layout)
        {
            layout.DataTable = table;
            var ctrl = new Altaxo.Gui.Worksheet.Viewing.WorksheetController(layout);
            var view = new Altaxo.Gui.Worksheet.Viewing.WorksheetViewWpf();

            ctrl.ViewObject = view;

            if (null != Current.Workbench)
            {
                Current.Workbench.ShowView(ctrl, true);
            }

            return(ctrl);
        }
Exemple #6
0
 /// <summary>
 /// Creates a view content for a table.
 /// </summary>
 /// <param name="table">The table which should be viewed.</param>
 /// <param name="layout">The layout for the table.</param>
 /// <returns>The view content for the provided table.</returns>
 public Altaxo.Gui.Worksheet.Viewing.IWorksheetController CreateNewWorksheet(Altaxo.Data.DataTable table, Altaxo.Worksheet.WorksheetLayout layout)
 {
     return(Current.Dispatcher.InvokeIfRequired(CreateNewWorksheet_Unsynchronized, table, layout));
 }
    /// <summary>
    /// Set the member variables to default values. Intended only for use in constructors and deserialization code.
    /// </summary>
    protected virtual void SetMemberVariablesToDefault()
    {
      m_DeserializationSurrogate=null;

      m_Table=null;
      m_TableLayout=null;
      m_View = null;
    
      // The main menu of this controller.
      m_MainMenu = null; 
      m_MenuItemEditRemove = null;
      m_MenuItemColumnSetColumnValues = null;

      // Which selection was done last: selection (i) a data column, (ii) a data row, or (iii) a property column.</summary>
      m_LastSelectionType = SelectionType.Nothing;

    
      // holds the positions (int) of the right boundarys of the __visible__ (!) columns
      m_ColumnStyleCache = new ColumnStyleCache();
    
    
      // Horizontal scroll position; number of first column that is shown.
      m_HorzScrollPos=0;
    
      // Vertical scroll position; Positive values: number of first data column
      m_VertScrollPos=0;
      m_HorzScrollMax=1;
      m_VertScrollMax=1;

      m_LastVisibleColumn=0;
      m_LastFullyVisibleColumn=0;

    
      // Holds the indizes to the selected data columns.
      m_SelectedDataColumns = new Altaxo.Worksheet.IndexSelection(); // holds the selected columns
    
      // Holds the indizes to the selected rows.
      m_SelectedDataRows    = new Altaxo.Worksheet.IndexSelection(); // holds the selected rows
    
      // Holds the indizes to the selected property columns.
      m_SelectedPropertyColumns = new Altaxo.Worksheet.IndexSelection(); // holds the selected property columns

      // Holds the indizes to the selected property columns.
      m_SelectedPropertyRows = new Altaxo.Worksheet.IndexSelection(); // holds the selected property columns

      // Cached number of table rows.
      m_NumberOfTableRows=0; // cached number of rows of the table

      // Cached number of table columns.
      m_NumberOfTableCols=0;
    
      // Cached number of property columns.
      m_NumberOfPropertyCols=0; // cached number of property  columnsof the table
    
        

      m_MouseDownPosition = new Point(0,0); // holds the position of a double click
      m_DragColumnWidth_ColumnNumber=int.MinValue; // stores the column number if mouse hovers over separator
      m_DragColumnWidth_OriginalPos = 0;
      m_DragColumnWidth_OriginalWidth=0;
      m_DragColumnWidth_InCapture=false;
  

      m_CellEdit_IsArmed=false;
      m_CellEdit_EditedCell = new ClickedCellInfo();


      m_CellEditControl = new System.Windows.Forms.TextBox();
      m_CellEditControl.AcceptsTab = true;
      m_CellEditControl.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
      m_CellEditControl.Location = new System.Drawing.Point(392, 0);
      m_CellEditControl.Multiline = true;
      m_CellEditControl.Name = "m_CellEditControl";
      m_CellEditControl.TabIndex = 0;
      m_CellEditControl.Text = "";
      m_CellEditControl.Hide();
      m_CellEdit_IsArmed = false;
      m_CellEditControl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnCellEditControl_KeyDown);
      m_CellEditControl.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.OnCellEditControl_KeyPress);
      //m_View.TableViewWindow.Controls.Add(m_CellEditControl);

    }
Exemple #8
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="table">The table.</param>
		/// <param name="layout">The layout of the table.</param>
		public TablePlusLayout(Altaxo.Data.DataTable table, Altaxo.Worksheet.WorksheetLayout layout)
		{
			_table = table;
			_layout = layout;
		}
Exemple #9
0
        /// <summary>
        /// Creates a view content for a table.
        /// </summary>
        /// <param name="table">The table which should be viewed.</param>
        /// <param name="layout">The layout for the table.</param>
        /// <returns>The view content for the provided table.</returns>
        public Altaxo.Worksheet.GUI.IWorksheetController CreateNewWorksheet(Altaxo.Data.DataTable table, Altaxo.Worksheet.WorksheetLayout layout)
        {
            layout.DataTable = table;
            Altaxo.Gui.SharpDevelop.SDWorksheetViewContent ctrl = new Altaxo.Gui.SharpDevelop.SDWorksheetViewContent(layout);
            Altaxo.Worksheet.GUI.WorksheetView             view = new Altaxo.Worksheet.GUI.WorksheetView();
            ctrl.Controller.View = view;


            if (null != Current.Workbench)
            {
                Current.Workbench.ShowView(ctrl);
            }

            return(ctrl.Controller);
        }