protected virtual void OnRightClickTableHeader(ClickedCellInfo clickedCell)
 {
   if (null != TableHeaderRightClicked)
     TableHeaderRightClicked(this, clickedCell);
 }
 protected virtual void OnRightClickOutsideAll(ClickedCellInfo clickedCell)
 {
   if (null != OutsideAllRightClicked)
     OutsideAllRightClicked(this, clickedCell);
 }
 protected virtual void OnRightClickDataRowHeader(ClickedCellInfo clickedCell)
 {
   if (null != DataRowHeaderRightClicked)
     DataRowHeaderRightClicked(this, clickedCell);
 }
 protected virtual void OnRightClickPropertyColumnHeader(ClickedCellInfo clickedCell)
 {
   if (null != PropertyColumnHeaderRightClicked)
     PropertyColumnHeaderRightClicked(this, clickedCell);
 }
 protected virtual void OnRightClickDataCell(ClickedCellInfo clickedCell)
 {
   if (null != DataCellRightClicked)
     DataCellRightClicked(this, clickedCell);
 }
 protected virtual void OnRightClickPropertyCell(ClickedCellInfo clickedCell)
 {
   if (null != PropertyCellRightClicked)
     PropertyCellRightClicked(this, clickedCell);
 }
    protected virtual void OnLeftClickPropertyColumnHeader(ClickedCellInfo clickedCell)
    {
      bool bControlKey=(Keys.Control==(Control.ModifierKeys & Keys.Control)); // Control pressed
      bool bShiftKey=(Keys.Shift==(Control.ModifierKeys & Keys.Shift));
          
      bool bWasSelectedBefore = this.SelectedPropertyColumns.IsSelected(clickedCell.Column);

      if((!bControlKey && !bShiftKey) || (m_LastSelectionType!=SelectionType.PropertyColumnSelection && !bControlKey))
      {
        m_SelectedDataColumns.Clear();
        m_SelectedDataRows.Clear(); // if we click a column, we remove row selections
        m_SelectedPropertyColumns.Clear();
        m_SelectedPropertyRows.Clear();
      }

      /*
          if(m_LastSelectionType==SelectionType.DataRowSelection && !bControlKey)
            m_SelectedRows.Clear(); // if we click a column, we remove row selections
          if(m_LastSelectionType==SelectionType.DataRowSelection && !bControlKey)
            m_SelectedPropertyRows.Clear();
          if(m_LastSelectionType==SelectionType.DataColumnSelection && !bControlKey)
            m_SelectedColumns.Clear(); // if we click a column, we remove row selections
          */

      if(this.SelectedPropertyColumns.Count!=0 || !bWasSelectedBefore)
        m_SelectedPropertyColumns.Select(clickedCell.Column,bShiftKey,bControlKey);
          
      m_LastSelectionType = SelectionType.PropertyColumnSelection;
      this.View.TableAreaInvalidate();
    }
    protected virtual void OnLeftClickDataRowHeader(ClickedCellInfo clickedCell)
    {
      bool bControlKey=(Keys.Control==(Control.ModifierKeys & Keys.Control)); // Control pressed
      bool bShiftKey=(Keys.Shift==(Control.ModifierKeys & Keys.Shift));

      bool bWasSelectedBefore = this.SelectedDataRows.IsSelected(clickedCell.Row);

      /*
          if(m_LastSelectionType==SelectionType.DataColumnSelection && !bControlKey)
            m_SelectedColumns.Clear(); // if we click a column, we remove row selections
          */
      if((!bControlKey && !bShiftKey) || (m_LastSelectionType!=SelectionType.DataRowSelection && !bControlKey))
      {
        m_SelectedDataColumns.Clear(); // if we click a column, we remove row selections
        m_SelectedDataRows.Clear();
        m_SelectedPropertyColumns.Clear();
        m_SelectedPropertyRows.Clear();
      }

      // if we had formerly selected property rows, we clear them but add them before as column selection
      if(m_SelectedPropertyRows.Count>0)
      {
        if(m_SelectedDataColumns.Count==0)
        {
          for(int kk=0;kk<m_SelectedPropertyRows.Count;kk++)
            m_SelectedDataColumns.Add(m_SelectedPropertyRows[kk]);
        }
        m_SelectedPropertyRows.Clear();
      }
          
      if(this.SelectedDataRows.Count!=0 || !bWasSelectedBefore)
        m_SelectedDataRows.Select(clickedCell.Row,bShiftKey,bControlKey);
      m_LastSelectionType = SelectionType.DataRowSelection;
      this.View.TableAreaInvalidate();
    }
    protected virtual void OnLeftClickDataColumnHeader(ClickedCellInfo clickedCell)
    {
      if(!this.m_DragColumnWidth_InCapture)
      {
        bool bControlKey=(Keys.Control==(Control.ModifierKeys & Keys.Control)); // Control pressed
        bool bShiftKey=(Keys.Shift==(Control.ModifierKeys & Keys.Shift));
            
        bool bWasSelectedBefore = this.SelectedDataColumns.IsSelected(clickedCell.Column);

        /*
            if(m_LastSelectionType==SelectionType.DataRowSelection && !bControlKey)
              m_SelectedRows.Clear(); // if we click a column, we remove row selections
            */

        if((!bControlKey && !bShiftKey) || (m_LastSelectionType!=SelectionType.DataColumnSelection && m_LastSelectionType!=SelectionType.PropertyRowSelection && !bControlKey))
        {
          m_SelectedDataColumns.Clear();
          m_SelectedDataRows.Clear(); // if we click a column, we remove row selections
          m_SelectedPropertyColumns.Clear();
          m_SelectedPropertyRows.Clear();
        }

        if(m_LastSelectionType==SelectionType.PropertyRowSelection)
        {
          m_SelectedPropertyRows.Select(clickedCell.Column,bShiftKey,bControlKey);
          m_LastSelectionType=SelectionType.PropertyRowSelection;
        }
          // if the last selection has only selected any property cells then add the current selection to the property rows
        else if(!this.AreDataCellsSelected && this.ArePropertyCellsSelected && bControlKey)
        {
          m_SelectedPropertyRows.Select(clickedCell.Column,bShiftKey,bControlKey);
          m_LastSelectionType = SelectionType.PropertyRowSelection;
        }
        else
        {
          if(this.SelectedDataColumns.Count!=0 || !bWasSelectedBefore)
            m_SelectedDataColumns.Select(clickedCell.Column,bShiftKey,bControlKey);
          m_LastSelectionType = SelectionType.DataColumnSelection;
        }

        this.View.TableAreaInvalidate();
      }
    }
 protected virtual void OnLeftClickPropertyCell(ClickedCellInfo clickedCell)
 {
   m_CellEdit_EditedCell=clickedCell;
   m_CellEditControl.Parent = View.TableViewWindow;
   m_CellEditControl.Location = clickedCell.CellRectangle.Location;
   m_CellEditControl.Size = clickedCell.CellRectangle.Size;
   m_CellEditControl.LostFocus += new System.EventHandler(this.OnTextBoxLostControl);
   this.SetCellEditContent();
 }
    /// <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);

    }