Exemplo n.º 1
0
        /// <summary>Lock the left most number of columns.</summary>
        /// <param name="number"></param>
        public void LockLeftMostColumns(int number)
        {
            if (number == numberLockedCols || !Grid.IsMapped)
            {
                return;
            }

            for (int i = 0; i < gridmodel.NColumns; i++)
            {
                if (Fixedcolview.Columns.Length > i)
                {
                    Fixedcolview.Columns[i].Visible = i < number;
                    if (Fixedcolview.Columns[i].Visible && headerHeight > 0 && Fixedcolview.Columns[i].Widget != null)
                    {
                        Fixedcolview.Columns[i].Widget.HeightRequest = headerHeight;
                    }
                }

                if (Grid.Columns.Length > i)
                {
                    Grid.Columns[i].Visible = i >= number;
                    if (refColWidget == null & Grid.Columns[i].Visible)
                    {
                        refColWidget = Grid.Columns[i].Widget;
                        if (refColWidget != null)
                        {
                            refColWidget.SizeAllocated += RefColWidget_SizeAllocated;
                        }
                    }
                }
            }
            if (number > 0)
            {
                if (numberLockedCols == 0)
                {
                    Grid.Vadjustment.ValueChanged         += Gridview_Vadjustment_Changed;
                    Grid.Selection.Changed                += Gridview_CursorChanged;
                    Fixedcolview.Vadjustment.ValueChanged += Fixedcolview_Vadjustment_Changed1;
                    Fixedcolview.Selection.Changed        += Fixedcolview_CursorChanged;
                    Gridview_CursorChanged(this, EventArgs.Empty);
                    Gridview_Vadjustment_Changed(this, EventArgs.Empty);
                }
                if (!splitter.Child1.Visible)
                {
                    //Grid.Vadjustment.ValueChanged += GridviewVadjustmentChanged;
                    //Grid.Selection.Changed += GridviewCursorChanged;
                    //fixedcolview.Vadjustment.ValueChanged += FixedcolviewVadjustmentChanged;
                    //fixedcolview.Selection.Changed += FixedcolviewCursorChanged;
                    //GridviewCursorChanged(this, EventArgs.Empty);
                    //GridviewVadjustmentChanged(this, EventArgs.Empty);
                }

                Fixedcolview.Model        = gridmodel;
                Fixedcolview.Visible      = true;
                splitter.Child1.NoShowAll = false;
                splitter.ShowAll();
                splitter.PositionSet = true;
                int splitterWidth = (int)splitter.StyleGetProperty("handle-size");
                if (splitter.Allocation.Width > 1)
                {
                    splitter.Position = Math.Min(Fixedcolview.WidthRequest + splitterWidth, splitter.Allocation.Width / 2);
                }
                else
                {
                    splitter.Position = Fixedcolview.WidthRequest + splitterWidth;
                }
            }
            else
            {
                Grid.Vadjustment.ValueChanged         -= Gridview_Vadjustment_Changed;
                Grid.Selection.Changed                -= Gridview_CursorChanged;
                Fixedcolview.Vadjustment.ValueChanged -= Fixedcolview_Vadjustment_Changed1;
                Fixedcolview.Selection.Changed        -= Fixedcolview_CursorChanged;
                Fixedcolview.Visible = false;
                splitter.Position    = 0;
                splitter.Child1.Hide();
            }
            numberLockedCols = number;
        }
Exemplo n.º 2
0
        /// <summary>Lock the left most number of columns.</summary>
        /// <param name="number"></param>
        public void LockLeftMostColumns(int number)
        {
            if (number == numberLockedCols || !gridview.IsMapped)
            {
                return;
            }

            for (int i = 0; i < gridmodel.NColumns; i++)
            {
                if (fixedcolview.Columns.Length > i)
                {
                    fixedcolview.Columns[i].Visible = i < number;
                }

                if (gridview.Columns.Length > i)
                {
                    gridview.Columns[i].Visible = i >= number;
                }
            }
            if (number > 0)
            {
                if (numberLockedCols == 0)
                {
                    gridview.Vadjustment.ValueChanged     += Gridview_Vadjustment_Changed;
                    gridview.Selection.Changed            += Gridview_CursorChanged;
                    fixedcolview.Vadjustment.ValueChanged += Fixedcolview_Vadjustment_Changed1;
                    fixedcolview.Selection.Changed        += Fixedcolview_CursorChanged;
                    Gridview_CursorChanged(this, EventArgs.Empty);
                    Gridview_Vadjustment_Changed(this, EventArgs.Empty);
                }
                if (!splitter.Child1.Visible)
                {
                    //Grid.Vadjustment.ValueChanged += GridviewVadjustmentChanged;
                    //Grid.Selection.Changed += GridviewCursorChanged;
                    //fixedcolview.Vadjustment.ValueChanged += FixedcolviewVadjustmentChanged;
                    //fixedcolview.Selection.Changed += FixedcolviewCursorChanged;
                    //GridviewCursorChanged(this, EventArgs.Empty);
                    //GridviewVadjustmentChanged(this, EventArgs.Empty);
                }

                fixedcolview.Model        = gridmodel;
                fixedcolview.Visible      = true;
                splitter.Child1.NoShowAll = false;
                splitter.ShowAll();
                splitter.PositionSet = true;
                int splitterWidth = (int)splitter.StyleGetProperty("handle-size");
                if (splitter.Allocation.Width > 1)
                {
                    splitter.Position = Math.Min(fixedcolview.SizeRequest().Width + splitterWidth, splitter.Allocation.Width / 2);
                }
                else
                {
                    splitter.Position = fixedcolview.SizeRequest().Width + splitterWidth;
                }
            }
            else
            {
                gridview.Vadjustment.ValueChanged     -= Gridview_Vadjustment_Changed;
                gridview.Selection.Changed            -= Gridview_CursorChanged;
                fixedcolview.Vadjustment.ValueChanged -= Fixedcolview_Vadjustment_Changed1;
                fixedcolview.Selection.Changed        -= Fixedcolview_CursorChanged;
                fixedcolview.Visible = false;
                splitter.Position    = 0;
                splitter.Child1.HideAll();
            }
            numberLockedCols = number;
        }