/// <summary>
        /// Adds the group item. Group item is actually of class GroupList because
        /// group item has sub items (can be zero) which needs to be added.
        /// If beforeCell is not null, new group will be added just before it.
        /// </summary>
        /// <param name="groupList">Group to be added.</param>
        /// <param name="beforeCell">Before cell.</param>
        void AddGroupItem(GroupList groupList, Cell beforeCell = null)
        {
            Cell         groupCell     = groupList.HeaderContent;
            CellRenderer groupRenderer = GetCellRenderer(groupCell, true);

            ItemContext groupItemContext = new ItemContext();

            groupItemContext.Cell           = groupCell;
            groupItemContext.Renderer       = groupRenderer;
            groupItemContext.IsGroupItem    = true;
            groupItemContext.ListOfSubItems = groupList;
            _itemContextList.Add(groupItemContext);

            if (beforeCell != null)
            {
                GenListItem beforeItem = GetItemContext(beforeCell)?.Item as GenListItem;
                groupItemContext.Item = InsertBefore(groupRenderer.Class, groupItemContext, beforeItem, GenListItemType.Group);
            }
            else
            {
                groupItemContext.Item = Append(groupRenderer.Class, groupItemContext, GenListItemType.Group);
            }

            groupItemContext.Item.SelectionMode = GenItemSelectionMode.None;
            groupItemContext.Item.IsEnabled     = groupCell.IsEnabled;
            groupItemContext.Item.Deleted      += ItemDeletedHandler;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Handles item unselected event.
 /// </summary>
 /// <param name="sender">A native list instance from which the event has originated.</param>
 /// <param name="e">Argument associated with handler, it holds native item for which event was raised</param>
 protected void OnListViewItemUnselected(object sender, GenListItemEventArgs e)
 {
     if (_selectedItemChanging == 0)
     {
         _lastSelectedItem = null;
     }
 }
        /// <summary>
        /// Adds the item.
        /// </summary>
        /// <param name="cell">Cell to be added.</param>
        /// <param name="groupCell">Group to which the new item should belong.</param>
        /// <remark>If the value of <c>groupCell</c> is not null, the new item will be put into the requested group. </remark>
        /// <param name="beforeCell">The cell before which the new item should be placed.</param>
        /// <remarks> If the value of <c>beforeCell</c> is not null, the new item will be placed just before the requested cell. </remarks>
        void AddItem(Cell cell, Cell groupCell = null, Cell beforeCell = null)
        {
            CellRenderer renderer   = GetCellRenderer(cell);
            GenListItem  parentItem = null;

            ItemContext itemContext = new ItemContext();

            itemContext.Cell     = cell;
            itemContext.Renderer = renderer;
            _itemContextList.Add(itemContext);

            if (IsGroupingEnabled && groupCell != null)
            {
                var groupContext = GetItemContext(groupCell);
                itemContext.ListOfSubItems = groupContext.ListOfSubItems;
                parentItem = groupContext.Item as GenListItem;
            }

            if (beforeCell != null)
            {
                GenListItem beforeItem = GetItemContext(beforeCell)?.Item as GenListItem;
                itemContext.Item = InsertBefore(renderer.Class, itemContext, beforeItem, GenListItemType.Normal, parentItem);
            }
            else
            {
                itemContext.Item = Append(renderer.Class, itemContext, GenListItemType.Normal, parentItem);
            }

            itemContext.Item.SelectionMode = GenItemSelectionMode.Always;
            itemContext.Item.IsEnabled     = cell.IsEnabled;
            itemContext.Item.Deleted      += ItemDeletedHandler;

            cell.PropertyChanged += OnCellPropertyChanged;
            (cell as ICellController).ForceUpdateSizeRequested += OnForceUpdateSizeRequested;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Method is used for programaticaly selecting choosen item.
        /// </summary>
        void UpdateSelectedItem()
        {
            if (Element.SelectedItem == null)
            {
                if (_lastSelectedItem != null)
                {
                    _lastSelectedItem.IsSelected = false;
                    _lastSelectedItem            = null;
                }
            }
            else
            {
                var templatedItems = TemplatedItemsView.TemplatedItems;
                var results        = templatedItems.GetGroupAndIndexOfItem(Element.SelectedItem);
                if (results.Item1 != -1 && results.Item2 != -1)
                {
                    var itemGroup = templatedItems.GetGroup(results.Item1);
                    var cell      = itemGroup[results.Item2];

                    ++_selectedItemChanging;
                    Control.ApplySelectedItem(cell);
                    --_selectedItemChanging;
                }
            }
        }
Exemplo n.º 5
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();
            Box box = new Box(window);

            conformant.SetContent(box);
            box.Show();

            GenList list = new GenList(window)
            {
                Homogeneous = true,
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1
            };

            Button button = new Button(window)
            {
                Text       = "Remove",
                AlignmentX = -1,
                AlignmentY = -1,
            };

            GenItemClass defaultClass = new GenItemClass("default")
            {
                GetTextHandler = (obj, part) =>
                {
                    return(string.Format("{0} - {1}", (string)obj, part));
                }
            };

            GenListItem[] itemArr = new GenListItem[9];
            for (int i = 0; i < 9; i++)
            {
                itemArr[i] = list.Append(defaultClass, string.Format("{0} Item", i));
            }

            int idx = 0;

            button.Clicked += (s, e) =>
            {
                if (idx < 9)
                {
                    Console.WriteLine("GenListItem deleted");
                    itemArr[idx++].Delete();
                }
            };
            button.Show();

            list.Show();
            list.ItemSelected   += List_ItemSelected;
            list.ItemRealized   += List_ItemRealized;
            list.ItemUnrealized += List_ItemUnrealized;

            box.PackEnd(list);
            box.PackEnd(button);
        }
Exemplo n.º 6
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();

            GenList list = new GenList(window)
            {
                Homogeneous = true,
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1
            };

            Button button = new Button(window)
            {
                Text       = "Remove",
                AlignmentX = -1,
                AlignmentY = -1,
            };

            GenItemClass defaultClass = new GenItemClass("default")
            {
                GetTextHandler = (obj, part) =>
                {
                    return(string.Format("{0} - {1}", (string)obj, part));
                }
            };

            GenListItem[] itemArr = new GenListItem[9];
            for (int i = 0; i < 9; i++)
            {
                itemArr[i] = list.Append(defaultClass, string.Format("{0} Item", i));
            }

            int idx = 0;

            button.Clicked += (s, e) =>
            {
                if (idx < 9)
                {
                    Console.WriteLine("GenListItem deleted");
                    itemArr[idx++].Delete();
                }
            };
            button.Show();

            list.Show();
            list.ItemSelected   += List_ItemSelected;
            list.ItemRealized   += List_ItemRealized;
            list.ItemUnrealized += List_ItemUnrealized;

            var square = window.GetInnerSquare();

            list.Geometry   = new Rect(square.X, square.Y, square.Width, square.Height * 3 / 4);
            button.Geometry = new Rect(square.X, square.Y + square.Height * 3 / 4, square.Width, square.Height / 4);
        }
        /// <summary>
        /// Scrolls the list to a specified cell.
        /// </summary>
        /// <remarks>
        /// Different scrolling behaviors are also possible. The element may be positioned in the center,
        /// top or bottom of the visible part of the list depending on the value of the <c>position</c> parameter.
        /// </remarks>
        /// <param name="cell">Cell which will be displayed after scrolling .</param>
        /// <param name="position">This will defines scroll to behavior based on ScrollToPosition values.</param>
        /// <param name="animated">If <c>true</c>, scrolling will be animated. Otherwise the cell will be moved instantaneously.</param>
        public void ApplyScrollTo(Cell cell, ScrollToPosition position, bool animated)
        {
            GenListItem item = GetItemContext(cell)?.Item as GenListItem;

            if (item != null)
            {
                this.ScrollTo(item, position.ToNative(), animated);
            }
        }
        /// <summary>
        /// Selects the specified cell.
        /// </summary>
        /// <param name="cell">Cell to be selected.</param>
        public void ApplySelectedItem(Cell cell)
        {
            GenListItem item = GetItemContext(cell)?.Item as GenListItem;

            if (item != null)
            {
                item.IsSelected = true;
            }
        }
Exemplo n.º 9
0
 public void RemoveItem(ShellSection section)
 {
     if (_sectionToItem.ContainsKey(section))
     {
         GenListItem del = _sectionToItem[section];
         _sectionToItem.Remove(section);
         _shellSectionList.Remove(section);
         del.Delete();
     }
 }
Exemplo n.º 10
0
        public void AddItem(ShellSection section)
        {
            GenListItem item = Append(_defaultClass, section);

            if (item != null)
            {
                _sectionToItem[section] = item;
                _shellSectionList.AddLast(section);
            }
        }
Exemplo n.º 11
0
        void OnScrollAnimationStopped(object sender, EventArgs args)
        {
            GenListItem item = Control.GetItemByPosition(180, 180, out int pos);

            if (item != null && item.Data is NListView.ItemContext itemContext && pos == 0)
            {
                var obj   = itemContext.Cell.BindingContext;
                var index = Element.TemplatedItems.GetGlobalIndexOfItem(obj);
                Element.NotifyIteFocused(obj, index);
            }
        }
Exemplo n.º 12
0
        public static void SendSignalToItem(this Cell cell, GenListItem item)
        {
            // This is only required for TV profile.
            if (Device.Idiom != TargetIdiom.TV)
            {
                return;
            }

            if (cell is ImageCell)
            {
                item.EmitSignal(ThemeConstants.GenListItem.Signals.TV.SinglelineIconTextTheme, "");
            }
            else if (cell is SwitchCell)
            {
                item.EmitSignal(ThemeConstants.GenListItem.Signals.TV.SinglelineTextIconTheme, "");
            }
        }
Exemplo n.º 13
0
        public void Build(List <List <Element> > items)
        {
            // Only update when items was changed
            if (!IsUpdated(items))
            {
                return;
            }
            _itemCache = items;

            _naviMenu.Clear();
            // header
            _header = _naviMenu.Append(_defaultClass, new Item {
                Text = ""
            });

            // TODO. need to improve, need to support group
            foreach (var group in items)
            {
                foreach (var item in group)
                {
                    var data = new Item
                    {
                        Source = item
                    };
                    if (item is BaseShellItem shellItem)
                    {
                        data.Text = shellItem.Title;
                        data.Icon = (shellItem.Icon as FileImageSource)?.ToAbsPath();
                    }
                    else if (item is MenuItem menuItem)
                    {
                        data.Text = menuItem.Text;
                        data.Icon = (menuItem.IconImageSource as FileImageSource)?.ToAbsPath();
                    }
                    var genitem = _naviMenu.Append(_defaultClass, data, GenListItemType.Normal);
                    genitem.SetPartColor("bg", ElmSharp.Color.Gray);
                }
            }
            _footer = _naviMenu.Append(_defaultClass, new Item {
                Text = ""
            });
        }
Exemplo n.º 14
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();
            GenList list = new GenList(window)
            {
                Homogeneous = true,
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1
            };

            GenItemClass defaultClass = new GenItemClass("default")
            {
                GetTextHandler = (obj, part) =>
                {
                    return(string.Format("{0} - {1}", (string)obj, part));
                }
            };

            GenListItem[] items = new GenListItem[100];
            for (int i = 0; i < 100; i++)
            {
                if (i < 30)
                {
                    items[i] = list.Append(defaultClass, string.Format("{0} Item", i));
                }
                else if (i < 60)
                {
                    items[i] = list.Prepend(defaultClass, string.Format("{0} Item", i));
                }
                else
                {
                    items[i] = list.InsertBefore(defaultClass, string.Format("{0} Item", i), items[50]);
                }
            }
            list.Show();
            list.ItemSelected += List_ItemSelected;;
            conformant.SetContent(list);
        }
Exemplo n.º 15
0
        private void InitializeListItem()
        {
            GenItemClass defaultClass = new GenItemClass("default")
            {
                GetTextHandler = (obj, part) =>
                {
                    return((string)obj);
                }
            };

            for (int i = 0; i < TestItemMax; ++i)
            {
                if (i == 999)
                {
                    ItemTarget = list.Append(defaultClass, new string(arrLabel[i % 10].ToCharArray()));
                }
                else
                {
                    list.Append(defaultClass, new string(arrLabel[i % 10].ToCharArray()));
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Handles item selected event. Note that it has to handle selection also for grouping mode as well.
        /// As a result of this method, ItemTapped event should be invoked in Xamarin.
        /// </summary>
        /// <param name="sender">A native list instance from which the event has originated.</param>
        /// <param name="e">Argument associated with handler, it holds native item for which event was raised</param>
        protected void OnListViewItemSelected(object sender, GenListItemEventArgs e)
        {
            GenListItem item = e.Item;

            _lastSelectedItem = item;

            if (_selectedItemChanging == 0)
            {
                if (item != null)
                {
                    int index = -1;
                    if (Element.IsGroupingEnabled)
                    {
                        Native.ListView.ItemContext itemContext = item.Data as Native.ListView.ItemContext;
                        if (itemContext.IsGroupItem)
                        {
                            return;
                        }
                        else
                        {
                            int groupIndex   = (Element.TemplatedItems as System.Collections.IList).IndexOf(itemContext.ListOfSubItems);
                            int inGroupIndex = itemContext.ListOfSubItems.IndexOf(itemContext.Cell);

                            ++_selectedItemChanging;
                            Element.NotifyRowTapped(groupIndex, inGroupIndex);
                            --_selectedItemChanging;
                        }
                    }
                    else
                    {
                        index = Element.TemplatedItems.IndexOf((item.Data as Native.ListView.ItemContext).Cell);

                        ++_selectedItemChanging;
                        Element.NotifyRowTapped(index);
                        --_selectedItemChanging;
                    }
                }
            }
        }
Exemplo n.º 17
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();

            GenList list = new GenList(window)
            {
                Homogeneous = true,
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1
            };

            GenItemClass defaultClass = new GenItemClass("default")
            {
                GetTextHandler = (obj, part) =>
                {
                    return(string.Format("{0} - {1}", (string)obj, part));
                }
            };

            GenListItem[] items = new GenListItem[100];
            int           i     = 0;

            for (i = 0; i < 100; i++)
            {
                items[i] = list.Append(defaultClass, string.Format("{0} Item", i));
            }
            list.Show();
            list.ItemSelected += List_ItemSelected;

            GenListItem scroll = items[0];

            Button first = new Button(window)
            {
                Text       = "F",
                AlignmentX = -1,
                WeightX    = 1,
            };
            Button last = new Button(window)
            {
                Text       = "L",
                AlignmentX = -1,
                WeightX    = 1,
            };
            Button add = new Button(window)
            {
                Text       = "A",
                AlignmentX = -1,
                WeightX    = 1,
            };

            add.Clicked += (s, e) =>
            {
                scroll = list.InsertBefore(defaultClass, string.Format("{0} Item", i++), scroll);
                list.ScrollTo(scroll, ScrollToPosition.In, false);
            };
            first.Clicked += (s, e) =>
            {
                list.ScrollTo(scroll, ScrollToPosition.In, true);
            };
            last.Clicked += (s, e) =>
            {
                list.ScrollTo(items[99], ScrollToPosition.In, true);
            };
            first.Show();
            last.Show();
            add.Show();

            var square = window.GetInnerSquare();

            list.Geometry  = new Rect(square.X, square.Y, square.Width, square.Height * 3 / 4);
            first.Geometry = new Rect(square.X, square.Y + square.Height * 3 / 4, square.Width / 3, square.Height / 4);
            last.Geometry  = new Rect(square.X + square.Width / 3, square.Y + square.Height * 3 / 4, square.Width / 3, square.Height / 4);
            add.Geometry   = new Rect(square.X + square.Width * 2 / 3, square.Y + square.Height * 3 / 4, square.Width / 3, square.Height / 4);
        }
Exemplo n.º 18
0
        public override void Run(Window window)
        {
            Console.WriteLine("AA");
            Conformant conformant = new Conformant(window);

            conformant.Show();
            Box box = new Box(window)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };

            box.Show();
            conformant.SetContent(box);

            GenList list = new GenList(window)
            {
                Homogeneous = true,
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1
            };

            GenItemClass defaultClass = new GenItemClass("default")
            {
                GetTextHandler = (obj, part) =>
                {
                    return(string.Format("{0} - {1}", obj, part));
                },
                GetContentHandler = (obj, part) =>
                {
                    Console.WriteLine("{0} - {1}", obj, part);

                    return(null);
                }
            };

            GenListItem treeItem = list.Append(defaultClass, "TreeItem", GenListItemType.Tree);

            for (int i = 0; i < 5; i++)
            {
                list.Append(defaultClass, i, GenListItemType.Normal, treeItem);
            }

            list.Show();
            box.PackEnd(list);

            Button first = new Button(window)
            {
                Text       = "Check first and last item",
                AlignmentX = -1,
                WeightX    = 1,
            };

            first.Clicked += (s, e) =>
            {
                Console.WriteLine("Before : " + (list.LastItem.Index - list.FirstItem.Index + 1).ToString());
                treeItem.ClearSubitems();
                Console.WriteLine("After : " + (list.LastItem.Index - list.FirstItem.Index + 1).ToString());
            };
            first.Show();
            box.PackEnd(first);
        }
Exemplo n.º 19
0
 public static void DeleteBottomlineColor(this GenListItem item)
 {
     item.DeletePartColor(ThemeConstants.GenListItem.ColorClass.BottomLine);
 }
Exemplo n.º 20
0
 public static void DeleteBackgroundColor(this GenListItem item)
 {
     item.DeletePartColor(ThemeConstants.GenListItem.ColorClass.Background);
 }
Exemplo n.º 21
0
 public static void SetBottomlineColor(this GenListItem item, EColor color)
 {
     item.SetPartColor(ThemeConstants.GenListItem.ColorClass.BottomLine, color);
 }
Exemplo n.º 22
0
 public static void SetBackgroundColor(this GenListItem item, EColor color)
 {
     item.SetPartColor(ThemeConstants.GenListItem.ColorClass.Background, color);
 }
Exemplo n.º 23
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();
            Box box = new Box(window)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };

            box.Show();
            conformant.SetContent(box);

            GenList list = new GenList(window)
            {
                Homogeneous = false,
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1
            };

            GenItemClass defaultClass = new GenItemClass("full")
            {
                GetContentHandler = (obj, part) =>
                {
                    Console.WriteLine("{0} part create requested", part);
                    var btn = new Button(window)
                    {
                        Text       = obj.ToString(),
                        AlignmentX = -1,
                        WeightX    = 1,
                    };
                    return(btn);
                }
            };

            GenItemClass headerClass = new GenItemClass("full")
            {
                GetContentHandler = (obj, part) =>
                {
                    Console.WriteLine("{0} part create requested", part);
                    var btn = new Button(window)
                    {
                        Text       = obj.ToString(),
                        AlignmentX = -1,
                        WeightX    = 1,
                    };
                    btn.Show();

                    var label = new Label(window)
                    {
                        Text = "GenItem with full style"
                    };
                    label.Show();

                    Box hBox = new Box(window)
                    {
                        AlignmentX = -1,
                        AlignmentY = -1,
                        WeightX    = 1,
                        WeightY    = 1,
                    };
                    hBox.Show();
                    hBox.PackEnd(btn);
                    hBox.PackEnd(label);
                    return(hBox);
                }
            };

            List <GenListItem> itemList  = new List <GenListItem>();
            GenListItem        firstItem = null;

            for (int i = 0; i < 5; i++)
            {
                GenListItem now = list.Append(defaultClass, string.Format("{0} Item", i));
                itemList.Add(now);

                if (firstItem == null)
                {
                    firstItem = now;
                }
            }
            list.Show();
            list.ItemSelected += List_ItemSelected;
            box.PackEnd(list);

            Button first = new Button(window)
            {
                Text       = "First",
                AlignmentX = -1,
                WeightX    = 1,
            };
            Button last = new Button(window)
            {
                Text       = "last",
                AlignmentX = -1,
                WeightX    = 1,
            };

            first.Clicked += (s, e) =>
            {
                firstItem = list.InsertBefore(headerClass, "Header", firstItem);
            };
            last.Clicked += (s, e) =>
            {
                list.Append(headerClass, "Footer");
            };

            first.Show();
            last.Show();
            box.PackEnd(first);
            box.PackEnd(last);
        }
Exemplo n.º 24
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();

            GenList list = new GenList(window)
            {
                Homogeneous = true,
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1
            };

            GenItemClass defaultClass = new GenItemClass("default")
            {
                GetTextHandler = (obj, part) =>
                {
                    return(string.Format("{0} - {1}", (string)obj, part));
                },
                DeleteHandler = new GenItemClass.DeleteDelegate((obj) =>
                {
                    Log.Debug($"DeleteHandler was called with... {(string)obj}");
                }),
            };

            GenListItem[] items = new GenListItem[100];
            for (int i = 0; i < 100; i++)
            {
                items[i] = list.Append(defaultClass, string.Format("{0} Item", i));
            }
            list.Show();
            list.ItemSelected      += List_ItemSelected;
            list.ItemActivated     += List_ItemActivated;
            list.ItemUnselected    += List_ItemUnselected;
            list.ItemPressed       += List_ItemPressed;
            list.ItemRealized      += List_ItemRealized;
            list.ItemReleased      += List_ItemReleased;
            list.ItemUnrealized    += List_ItemUnrealized;
            list.ItemLongPressed   += List_ItemLongPressed;
            list.ItemDoubleClicked += List_ItemDoubleClicked;

            var square = window.GetInnerSquare();

            list.Geometry = new Rect(square.X, square.Y, square.Width, square.Height * 3 / 4);

            Button first = new Button(window)
            {
                Text       = "Delete",
                AlignmentX = -1,
                WeightX    = 1,
            };

            first.Clicked += (s, e) =>
            {
                selected?.Delete();
            };
            first.Show();
            first.Geometry = new Rect(square.X, square.Y + square.Height * 3 / 4, square.Width, square.Height / 4);
        }
Exemplo n.º 25
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();
            Box box = new Box(window)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };

            box.Show();
            conformant.SetContent(box);


            GenList list = new GenList(window)
            {
                Homogeneous = true,
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1
            };

            GenItemClass defaultClass = new GenItemClass("default")
            {
                GetTextHandler = (obj, part) =>
                {
                    return(string.Format("{0} - {1}", (string)obj, part));
                }
            };

            GenListItem[] items = new GenListItem[100];
            int           i     = 0;

            for (i = 0; i < 100; i++)
            {
                items[i] = list.Append(defaultClass, string.Format("{0} Item", i));
            }
            list.Show();
            list.ItemSelected += List_ItemSelected;

            GenListItem scroll = items[0];

            box.PackEnd(list);
            Button first = new Button(window)
            {
                Text       = "First",
                AlignmentX = -1,
                WeightX    = 1,
            };
            Button last = new Button(window)
            {
                Text       = "last",
                AlignmentX = -1,
                WeightX    = 1,
            };
            Button Add = new Button(window)
            {
                Text       = "Add",
                AlignmentX = -1,
                WeightX    = 1,
            };

            Add.Clicked += (s, e) =>
            {
                scroll = list.InsertBefore(defaultClass, string.Format("{0} Item", i++), scroll);
                list.ScrollTo(scroll, ScrollToPosition.In, false);
            };
            first.Clicked += (s, e) =>
            {
                list.ScrollTo(scroll, ScrollToPosition.In, true);
            };
            last.Clicked += (s, e) =>
            {
                list.ScrollTo(items[99], ScrollToPosition.In, true);
            };
            first.Show();
            last.Show();
            Add.Show();
            box.PackEnd(first);
            box.PackEnd(last);
            box.PackEnd(Add);
        }
Exemplo n.º 26
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();
            Box box = new Box(window)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };

            box.Show();
            conformant.SetContent(box);


            GenList list = new GenList(window)
            {
                Homogeneous = true,
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1
            };

            GenItemClass defaultClass = new GenItemClass("default")
            {
                GetTextHandler = (obj, part) =>
                {
                    return(string.Format("{0} - {1}", (string)obj, part));
                },
                DeleteHandler = new GenItemClass.DeleteDelegate((obj) =>
                {
                    Console.WriteLine("DeleteHandler was called with... {0}", (string)obj);
                }),
            };

            GenListItem[] items = new GenListItem[100];
            for (int i = 0; i < 100; i++)
            {
                items[i] = list.Append(defaultClass, string.Format("{0} Item", i));
            }
            list.Show();
            list.ItemSelected      += List_ItemSelected;
            list.ItemActivated     += List_ItemActivated;
            list.ItemUnselected    += List_ItemUnselected;
            list.ItemPressed       += List_ItemPressed;
            list.ItemRealized      += List_ItemRealized;
            list.ItemReleased      += List_ItemReleased;
            list.ItemUnrealized    += List_ItemUnrealized;
            list.ItemLongPressed   += List_ItemLongPressed;
            list.ItemDoubleClicked += List_ItemDoubleClicked;
            box.PackEnd(list);
            Button first = new Button(window)
            {
                Text       = "Delete",
                AlignmentX = -1,
                WeightX    = 1,
            };

            first.Clicked += (s, e) =>
            {
                selected?.Delete();
            };
            first.Show();
            box.PackEnd(first);
        }
Exemplo n.º 27
0
 private void List_ItemSelected(object sender, GenListItemEventArgs e)
 {
     selected = e.Item;
     Console.WriteLine("{0} Item was selected", (string)(e.Item.Data));
 }
Exemplo n.º 28
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();
            Box box = new Box(window)
            {
                AlignmentX   = -1,
                AlignmentY   = -1,
                WeightX      = 1,
                WeightY      = 1,
                IsHorizontal = true,
            };

            box.Show();
            GenList list = new GenList(window)
            {
                Homogeneous = false,
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1
            };

            list.Show();
            Index index = new Index(window)
            {
                IsHorizontal = false,
                AlignmentY   = -1,
                WeightY      = 1,
                MinimumWidth = 100,
                AutoHide     = false,
                Style        = "fastscroll"
            };

            index.Show();

            GenItemClass groupClass = new GenItemClass("group_index")
            {
                GetTextHandler = (obj, part) =>
                {
                    return(string.Format("{0} - {1}", (string)obj, part));
                }
            };

            GenListItem[] groups = new GenListItem[10];

            for (int i = 0; i < 10; i++)
            {
                groups[i] = list.Append(groupClass, string.Format("{0}", i), GenListItemType.Group);
                var indexitem = index.Append(string.Format("{0}", i));
                indexitem.Selected += (s, e) =>
                {
                    Console.WriteLine("Index selected : {0}", ((IndexItem)s).Text);
                    list.ScrollTo(_indexTable[(IndexItem)s], ScrollToPosition.In, true);
                };
                _indexTable[indexitem] = groups[i];
            }

            GenItemClass defaultClass = new GenItemClass("default")
            {
                GetTextHandler = (obj, part) =>
                {
                    return(string.Format("{0} - {1}", (string)obj, part));
                }
            };

            for (int j = 0; j < 10; j++)
            {
                for (int i = 0; i < 20; i++)
                {
                    list.Append(defaultClass, string.Format("{0} Item", i), GenListItemType.Normal, groups[j]);
                }
            }

            list.ItemSelected += List_ItemSelected;
            index.Update(0);
            box.PackEnd(list);
            box.PackEnd(index);
            box.SetLayoutCallback(() =>
            {
                list.Geometry  = box.Geometry;
                index.Geometry = box.Geometry;
            });
            conformant.SetContent(box);
        }
Exemplo n.º 29
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();
            GenList list = new GenList(window)
            {
                Homogeneous = false,
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1
            };

            GenItemClass groupClass = new GenItemClass("group_index")
            {
                GetTextHandler = (obj, part) =>
                {
                    return(string.Format("{0} - {1}", (string)obj, part));
                }
            };

            GenListItem[] groups = new GenListItem[10];

            for (int i = 0; i < 10; i++)
            {
                groups[i] = list.Append(groupClass, string.Format("{0}", i), GenListItemType.Group);
            }


            GenItemClass defaultClass = new GenItemClass("default")
            {
                GetTextHandler = (obj, part) =>
                {
                    return(string.Format("{0} - {1}", (string)obj, part));
                },
                GetContentHandler = (obj, part) =>
                {
                    Console.WriteLine("{0} - {1}", (string)obj, part);
                    return(null);
                }
            };

            GenItemClass fullyCustomizeClass = new GenItemClass("full")
            {
                GetContentHandler = (obj, part) =>
                {
                    Console.WriteLine("{0} part create requested", part);
                    var btn = new Button(window)
                    {
                        Text       = "Button in List",
                        AlignmentX = -1,
                        WeightX    = 1,
                    };
                    return(btn);
                }
            };

            for (int j = 0; j < 10; j++)
            {
                for (int i = 0; i < 20; i++)
                {
                    list.Append(j == 0 ? fullyCustomizeClass : defaultClass, string.Format("{0} Item", i), GenListItemType.Normal, groups[j]);
                }
            }

            list.Show();
            list.ItemSelected += List_ItemSelected;;
            conformant.SetContent(list);
        }