Exemplo n.º 1
0
 /// <summary>Purges the ListView2 (deletes all items from display and memory). Useful when memory leaks are happen.</summary>
 public void Clear()
 {
     Grid.Clear();
     Items.Clear();
     LastRow     = LastCol = 0;
     PointedItem = null;
 }
Exemplo n.º 2
0
        /// <summary>Add a new ListView2Item into this ListView2</summary>
        /// <param name="Item">The new ListView2Item</param>
        public void AddItem(ListView2Item Item)
        {
            if (Color2)
            {
                Item.NormalBgColor = NormalBgColor2;
                Item.NormalFgColor = NormalFgColor1;
            }
            else
            {
                Item.NormalBgColor = NormalBgColor1;
                Item.NormalFgColor = NormalFgColor1;
            }

            Color2 = !Color2;
            Items.Add(Item);
            Grid.Add(Item, LastCol, LastRow, 1, 1, true);
            Item.ButtonPressed += new EventHandler <ButtonEventArgs>(Item_ButtonPressed);
            Item.CanGetFocus    = true;
            if (LastRow == 0)
            {
                _SetPoint(Item);
            }
            LastRow++;

            Through10Counter++;
            if (Through10Counter == 250)
            {
                Xwt.Application.MainLoop.DispatchPendingEvents();
                Through10Counter = 0;
            }
        }
Exemplo n.º 3
0
        /// <summary>Selects an row</summary>
        /// <param name="Item">The row or null if need to select all rows</param>
        public void Select(ListView2Item Item = null)
        {
            if (Item != null)
            {
                _SelectItem(Item);
                return;
            }

            SelectedItems.Clear();
            foreach (ListView2Item lvi in Items)
            {
                if (lvi.State == ItemStates.Pointed || lvi.State == ItemStates.PointedAndSelected)
                {
                    lvi.State = ItemStates.PointedAndSelected;
                }
                else
                {
                    lvi.State = ItemStates.Selected;
                }

                SelectedItems.Add(lvi);
            }

            if (SelectionChanged != null)
            {
                SelectionChanged(SelectedItems);
            }
        }
Exemplo n.º 4
0
        /// <summary>Sets the pointer to an item</summary>
        /// <param name="lvi">The requested ListView2Item</param>
        private void _SetPoint(ListView2Item lvi)
        {
            //unpoint current
            if (PointedItem != null)
            {
                if ((int)PointedItem.State > 1)
                {
                    PointedItem.State = ItemStates.Selected;
                }
                else
                {
                    PointedItem.State = ItemStates.Default;
                }
            }

            //point new
            if ((int)lvi.State > 1)
            {
                lvi.State = ItemStates.PointedAndSelected;
            }
            else
            {
                lvi.State = ItemStates.Pointed;
            }
            PointedItem = lvi;

            if (PointerMoved != null)
            {
                PointerMoved(lvi);
            }

            //if need, scroll the view
            double top    = -ScrollerIn.PosY;
            double down   = ScrollerIn.Size.Height;
            double newpos = lvi.Size.Height * lvi.RowNo;

            if (top > down)
            {
                //если прокручено далее первой страницы
                down = top + ScrollerIn.Size.Height;
            }

            if (newpos > down || newpos < top)
            {
                ScrollerIn.ScrollTo(-(lvi.Size.Height * lvi.RowNo));
            }

            //todo: add smooth scrolling
        }
Exemplo n.º 5
0
 /// <summary>Removes selection of an item</summary>
 /// <param name="lvi">The requested ListView2Item</param>
 private void _UnselectItem(ListView2Item lvi)
 {
     SelectedItems.Remove(lvi);
     if (lvi.State == ItemStates.PointedAndSelected)
     {
         lvi.State = ItemStates.Pointed;
     }
     else
     {
         lvi.State = ItemStates.Default;
     }
     if (SelectionChanged != null)
     {
         SelectionChanged(SelectedItems);
     }
 }
Exemplo n.º 6
0
        //EVENT HANDLERS

        private void Item_ButtonPressed(object sender, ButtonEventArgs e)
        {
            this.SetFocus();
            ListView2Item lvi = Items[(sender as ListView2Item).RowNo];            //вырезание гланд через жопу автогеном? уточнить лучший способ, sender не работает

            //currently, the mouse click policy is same as in Total and Norton Commander
            if (e.Button == PointerButton.Right)            //right click - select & do nothing
            {
                _SelectItem(lvi);
                return;
            }
            if (e.Button == PointerButton.Left)            //left click - point & don't touch selection
            {
                _SetPoint(lvi);
            }
        }
Exemplo n.º 7
0
        /// <summary>Add a new item</summary>
        /// <param name="Data">The item's content</param>
        /// <param name="Tag">The tag for the new item (optional)</param>
        public void AddItem(List <Object> Data, string Tag = null)
        {
            ListView2Item lvi = new ListView2Item(
                LastRow,
                LastCol,
                Tag,
                _Collumns.ToArray(),
                Data);

            lvi.Font             = Xwt.Drawing.Font.SystemSansSerifFont.WithWeight(Xwt.Drawing.FontWeight.Heavy);
            lvi.PointerBgColor   = PointedBgColor;
            lvi.PointerFgColor   = PointedFgColor;
            lvi.SelectionBgColor = SelectedBgColor;
            lvi.SelectionFgColor = SelectedFgColor;
            lvi.State            = ItemStates.Default;
            AddItem(lvi);
        }
Exemplo n.º 8
0
        /// <summary>Clear selection of row</summary>
        /// <param name="Item">The row or null if need to unselect all</param>
        public void Unselect(ListView2Item Item = null)
        {
            if (Item == null)
            {
                foreach (ListView2Item lvi in SelectedItems)
                {
                    lvi.State = ItemStates.Default;
                }
                SelectedItems.Clear();
            }
            else
            {
                Item.State = ItemStates.Default;
                SelectedItems.Remove(Item);
            }

            if (SelectionChanged != null)
            {
                SelectionChanged(SelectedItems);
            }
        }
Exemplo n.º 9
0
        /// <summary>Inverts selection of an item</summary>
        /// <param name="lvi">The requested ListView2Item</param>
        private void _SelectItem(ListView2Item lvi)
        {
            SelectedItems.Add(lvi);
            switch (lvi.State)
            {
            case ItemStates.Default:
                lvi.State = ItemStates.Selected;
                break;

            case ItemStates.Pointed:
                lvi.State = ItemStates.PointedAndSelected;
                break;

            case ItemStates.Selected:
            case ItemStates.PointedAndSelected:
                _UnselectItem(lvi);
                break;
            }
            if (SelectionChanged != null)
            {
                SelectionChanged(SelectedItems);
            }
        }
Exemplo n.º 10
0
        /// <summary>Inverts selection of an item</summary>
        /// <param name="lvi">The requested ListView2Item</param>
        private void _SelectItem(ListView2Item lvi)
        {
            SelectedItems.Add(lvi);
            switch (lvi.State)
            {
                case ItemStates.Default:
                    lvi.State = ItemStates.Selected;
                    break;
                case ItemStates.Pointed:
                    lvi.State = ItemStates.PointedAndSelected;
                    break;

                case ItemStates.Selected:
                case ItemStates.PointedAndSelected:
                    _UnselectItem(lvi);
                    break;
            }
            if (SelectionChanged != null)
                SelectionChanged(SelectedItems);
        }
Exemplo n.º 11
0
        /// <summary>Clear selection of row</summary>
        /// <param name="Item">The row or null if need to unselect all</param>
        public void Unselect(ListView2Item Item = null)
        {
            if (Item == null)
            {
                foreach (ListView2Item lvi in SelectedItems)
                {
                    lvi.State = ItemStates.Default;
                }
                SelectedItems.Clear();
            }
            else
            {
                Item.State = ItemStates.Default;
                SelectedItems.Remove(Item);
            }

            if (SelectionChanged != null)
                SelectionChanged(SelectedItems);
        }
Exemplo n.º 12
0
        /// <summary>Selects an row</summary>
        /// <param name="Item">The row or null if need to select all rows</param>
        public void Select(ListView2Item Item = null)
        {
            if (Item != null){
                _SelectItem(Item);
                return;
            }

            SelectedItems.Clear();
            foreach (ListView2Item lvi in Items)
            {
                if (lvi.State == ItemStates.Pointed || lvi.State == ItemStates.PointedAndSelected)
                    lvi.State = ItemStates.PointedAndSelected;
                else
                    lvi.State = ItemStates.Selected;

                SelectedItems.Add(lvi);
            }

            if (SelectionChanged != null)
                SelectionChanged(SelectedItems);
        }
Exemplo n.º 13
0
 /// <summary>Removes the specifed item from the list</summary>
 /// <param name="Item">The item</param>
 public void RemoveItem(ListView2Item Item)
 {
     //Note that the removing item is simply hided.
     //To remove it completely, call Clear() sub-programm. But all other rows will be also removed.
     Item.Visible = false;
 }
Exemplo n.º 14
0
 /// <summary>Purges the ListView2 (deletes all items from display and memory). Useful when memory leaks are happen.</summary>
 public void Clear()
 {
     Grid.Clear();
     Items.Clear();
     LastRow = LastCol = 0;
     PointedItem = null;
 }
Exemplo n.º 15
0
        /// <summary>Add a new ListView2Item into this ListView2</summary>
        /// <param name="Item">The new ListView2Item</param>
        public void AddItem(ListView2Item Item)
        {
            if (Color2){
                Item.NormalBgColor = NormalBgColor2;
                Item.NormalFgColor = NormalFgColor1;
            }
            else{
                Item.NormalBgColor = NormalBgColor1;
                Item.NormalFgColor = NormalFgColor1;
            }

            Color2 = !Color2;
            Items.Add(Item);
            Grid.Add(Item, LastCol, LastRow,1,1,true);
            Item.ButtonPressed += new EventHandler<ButtonEventArgs>(Item_ButtonPressed);
            Item.CanGetFocus = true;
            if (LastRow == 0) _SetPoint(Item);
            LastRow++;

            Through10Counter++;
            if (Through10Counter == 250)
            {
                Xwt.Application.MainLoop.DispatchPendingEvents();
                Through10Counter = 0;
            }
        }
Exemplo n.º 16
0
 /// <summary>Add a new item</summary>
 /// <param name="Data">The item's content</param>
 /// <param name="Tag">The tag for the new item (optional)</param>
 public void AddItem(List<Object> Data, string Tag = null)
 {
     ListView2Item lvi = new ListView2Item(
         LastRow,
         LastCol,
         Tag,
         _Collumns.ToArray(),
         Data);
     lvi.Font = Xwt.Drawing.Font.SystemSansSerifFont.WithWeight(Xwt.Drawing.FontWeight.Heavy);
     lvi.PointerBgColor = PointedBgColor;
     lvi.PointerFgColor = PointedFgColor;
     lvi.SelectionBgColor = SelectedBgColor;
     lvi.SelectionFgColor = SelectedFgColor;
     lvi.State = ItemStates.Default;
     AddItem(lvi);
 }
Exemplo n.º 17
0
        /// <summary>Sets the pointer to an item</summary>
        /// <param name="lvi">The requested ListView2Item</param>
        private void _SetPoint(ListView2Item lvi)
        {
            //unpoint current
            if (PointedItem != null)
            {
                if ((int)PointedItem.State > 1)
                    PointedItem.State = ItemStates.Selected;
                else
                    PointedItem.State = ItemStates.Default;
            }

            //point new
            if ((int)lvi.State > 1)
                lvi.State = ItemStates.PointedAndSelected;
            else
                lvi.State = ItemStates.Pointed;
            PointedItem = lvi;

            if (PointerMoved != null)
                PointerMoved(lvi);

            //if need, scroll the view
            double top = -ScrollerIn.PosY;
            double down = ScrollerIn.Size.Height;
            double newpos = lvi.Size.Height * lvi.RowNo;

            if (top > down){
                //если прокручено далее первой страницы
                down = top + ScrollerIn.Size.Height;
            }

            if (newpos > down || newpos < top)
            {
                ScrollerIn.ScrollTo(-(lvi.Size.Height * lvi.RowNo));
            }

            //todo: add smooth scrolling
        }
Exemplo n.º 18
0
 /// <summary>Removes the specifed item from the list</summary>
 /// <param name="Item">The item</param>
 public void RemoveItem(ListView2Item Item)
 {
     //Note that the removing item is simply hided.
     //To remove it completely, call Clear() sub-programm. But all other rows will be also removed.
     Item.Visible = false;
 }
Exemplo n.º 19
0
 /// <summary>Removes selection of an item</summary>
 /// <param name="lvi">The requested ListView2Item</param>
 private void _UnselectItem(ListView2Item lvi)
 {
     SelectedItems.Remove(lvi);
     if (lvi.State == ItemStates.PointedAndSelected)
         lvi.State = ItemStates.Pointed;
     else
         lvi.State = ItemStates.Default;
     if (SelectionChanged != null)
         SelectionChanged(SelectedItems);
 }
Exemplo n.º 20
0
 void ListingView_PointerMoved(ListView2Item data)
 {
     WriteDefaultStatusLabel();
 }