Exemplo n.º 1
0
        protected override void OnLayout(LayoutEventArgs levent)
        {
            state[stateCalledSpringTableLayout] = false;
            bool          inDisplayedItemCollecton = false;
            ToolStripItem item      = levent.AffectedComponent as ToolStripItem;
            int           itemCount = DisplayedItems.Count;

            if (item != null)
            {
                inDisplayedItemCollecton = DisplayedItems.Contains(item);
            }


            if (this.LayoutStyle == ToolStripLayoutStyle.Table)
            {
                OnSpringTableLayoutCore();
            }
            base.OnLayout(levent);

            if (itemCount != DisplayedItems.Count || (item != null && (inDisplayedItemCollecton != DisplayedItems.Contains(item))))
            {
                // calling OnLayout has changed the displayed items collection
                // the SpringTableLayoutCore requires the count of displayed items to
                // be accurate.
                // - so we need to perform layout again.
                if (this.LayoutStyle == ToolStripLayoutStyle.Table)
                {
                    OnSpringTableLayoutCore();
                    base.OnLayout(levent);
                }
            }

            EnsureRightToLeftGrip();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Filter items
        /// </summary>
        private void FilterItems()
        {
            // Clear displayed items
            DisplayedItems.Clear();

            // Do we have any items to filter?
            if (Items.Count > 0)
            {
                // Iterate over all items
                foreach (MItem item in Items)
                {
                    // Do primary text contains searched word (filter) ?
                    if (item.PrimaryText.ToLower().Contains(_filter.ToLower()))
                    {
                        // Add item to displayed-items collection
                        DisplayedItems.Add(item);
                    }
                }
            }

            // Redraw control
            Invalidate(true);

            // Force update component
            Component.Outdated = true;

            // Force update scroll-bar
            Scrollbar.ForceUpdate();

            // Call resize
            OnResize(EventArgs.Empty);

            // Refresh control
            Refresh();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles support for arrow movement in list-box
        /// </summary>
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            // Process key data
            switch (keyData)
            {
            // Up key
            case Keys.Up:
                // If MultiSelect is off
                if (!MultiSelect)
                {
                    // Get index
                    int index = (DisplayedItems.IndexOf(SelectedItem) - 1 > 0) ? DisplayedItems.IndexOf(SelectedItem) - 1 : 0;

                    // Update selected item
                    SelectedItem = DisplayedItems[index];

                    // Decrement scroll value
                    Scrollbar.Value = SelectedItem.Bounds.Y - (Height / 2) + (SelectedItem.Height / 2);
                }
                else
                {
                    // Scroll top
                    Scrollbar.Value -= 50;
                }

                // End
                break;

            // Down key
            case Keys.Down:
                // If MultiSelect is off
                if (!MultiSelect)
                {
                    // Get index
                    int index = (DisplayedItems.IndexOf(SelectedItem) + 1 < DisplayedItems.Count) ? DisplayedItems.IndexOf(SelectedItem) + 1 : DisplayedItems.Count - 1;

                    // Update selected item
                    SelectedItem = DisplayedItems[index];

                    // Decrement scroll value
                    Scrollbar.Value = SelectedItem.Bounds.Y - (Height / 2) + (SelectedItem.Height / 2);
                }
                else
                {
                    // Scroll down
                    Scrollbar.Value += 50;
                }

                // End
                break;

            // If nothing match - default
            default:
                return(base.ProcessCmdKey(ref msg, keyData));
            }

            // Used CMD key
            return(true);
        }
Exemplo n.º 4
0
        private void GuiUpdater(string newData)
        {
            App.Current.Dispatcher.Invoke(() =>
            {
                // Nachricht: CPU1: 70 (warning)\r\n       Backup Errors1: 0 (warning)
                string noEnter = newData.Replace("\r\n", string.Empty);

                string[] splitData = noEnter.Split(':');
                //CPU1:70(warning)

                string newname = splitData[0];      // CPU1   oder Backup Errors1

                //  eist die Zahl nach CPU (namen) die ID?  erst am Schluss gecheckt aber so könnte man dann die ID extra rausbekommen und extra abspeichern
                //  in meinem Fall is die ID jetzt auch unter Name (Key) zu finden
                if (newname.Contains("1") || newname.Contains("2") || newname.Contains("3") || newname.Contains("4") || newname.Contains("5"))
                {
                    string idvll = newname.Substring(newname.Length - 1, 1);
                    string newid = idvll;
                }

                string noBlank = splitData[1].Replace(" ", string.Empty); // 70(warning)

                string[] splitData2 = noBlank.Split('(');                 // [0]70  [1]warning)

                int newvalue    = Int32.Parse(splitData2[0]);
                string newstate = splitData2[1].Replace(")", string.Empty);

                Item newItem = new Item()
                {
                    //ID = newid,
                    Name  = newname,
                    Value = newvalue,
                    State = newstate
                };
                bool existisAlready = false;
                foreach (var item in DisplayedItems)
                {
                    if (item.Name.Equals(newname))
                    {
                        //DisplayedItems.Remove(item);  // früher mal removed aber da sprangen die Items stark herum
                        item.Value     = newvalue;
                        item.State     = newstate;
                        existisAlready = true;
                        break;
                    }
                }
                if (!existisAlready)
                {
                    DisplayedItems.Add(newItem);
                }

                if (newItem.State.Equals("danger"))
                {
                    ShowNotification(newItem);
                }
            });
        }
Exemplo n.º 5
0
 private void CloseAllDropDown()
 {
     foreach (QMenuItem item in DisplayedItems.OfType <QMenuItem>().Where(item => item.Selected))
     {
         if (item.HasDropDownItems && item.DropDown.Visible)
         {
             item.HideDropDown();
         }
         miUnselect.Invoke(item, null);
         break;
     }
 }
Exemplo n.º 6
0
 protected override void SetDisplayedItems()
 {
     base.SetDisplayedItems();
     for (int i = 0; i < DisplayedItems.Count; i++)
     {
         if (DisplayedItems[i] == SelectedTab)
         {
             DisplayedItems.Add(SelectedTab);
             break;
         }
     }
 }
Exemplo n.º 7
0
 public void UpdateDisplayedItems()
 {
     DisplayedItems.Clear();
     if (_selectedItem != null)
     {
         LoadSelectedItemToDisplayedItems();
     }
     else
     {
         LoadSelectedSupplierItemsToDisplayedItems();
     }
 }
Exemplo n.º 8
0
 private void LoadSelectedSupplierItemsToDisplayedItems()
 {
     using (var context = new ERPContext())
     {
         var supplierFromDatabase =
             context.Suppliers.Include("Items").Single(supplier => supplier.ID.Equals(_selectedSupplier.ID));
         foreach (var item in supplierFromDatabase.Items.ToList().OrderBy(item => item.Name))
         {
             DisplayedItems.Add(new ItemVM {
                 Model = item
             });
         }
     }
 }
Exemplo n.º 9
0
 private void LoadSelectedItemToDisplayedItems()
 {
     if (_selectedItem.Name.Equals("All"))
     {
         foreach (var item in Items.Where(item => !item.Name.Equals("All")))
         {
             DisplayedItems.Add(item);
         }
     }
     else
     {
         DisplayedItems.Add(_selectedItem);
     }
 }
Exemplo n.º 10
0
    private void ChangePage(int newPage)
    {
        if (newPage >= 1 && newPage <= PageCount)
        {
            CurrentPage = newPage;

            DisplayedItems.Clear();
            foreach (T item in _items.Take(CurrentPage * PageSize).Skip((CurrentPage - 1) * PageSize))
            {
                DisplayedItems.Add(item);
            }

            StateHasChanged();
        }
    }
Exemplo n.º 11
0
 protected override void SetDisplayedItems()
 {
     base.SetDisplayedItems();
     if (RequiresScrollButtons)
     {
         DisplayedItems.Add(UpScrollButton);
         DisplayedItems.Add(DownScrollButton);
         UpdateScrollButtonLocations();
         UpScrollButton.Visible   = true;
         DownScrollButton.Visible = true;
     }
     else
     {
         UpScrollButton.Visible   = false;
         DownScrollButton.Visible = false;
     }
 }
Exemplo n.º 12
0
    private void RefreshItems()
    {
        IEnumerable <T> items = Items.ToList();

        if (SortFunction is not null && !string.IsNullOrWhiteSpace(_sortColumn))
        {
            items = SortFunction(items, _sortColumn, _sortAscending);
        }

        if (FilterFunction is not null && !string.IsNullOrWhiteSpace(_filter))
        {
            items = FilterFunction(items, _filter);
        }

        _items = items;

        if (Paginate)
        {
            PageCount = (int)Math.Ceiling(1.0 * _items.Count() / PageSize);
            if (PageCount <= 0)
            {
                DisplayedItems.Clear();
            }
            else
            {
                ChangePage(Math.Clamp(CurrentPage, 1, PageCount));
            }
        }
        else
        {
            DisplayedItems.Clear();
            foreach (T game in _items)
            {
                DisplayedItems.Add(game);
            }
        }

        StateHasChanged();
    }
Exemplo n.º 13
0
        /// <summary>
        /// Clears both Items and DisplayedItems collections. Resets selected item property.
        /// </summary>
        public void Clear()
        {
            // Reset selected item
            SelectedItem = null;

            // Clear items
            Items.Clear();

            // Clear displayed items
            DisplayedItems.Clear();

            // Redraw control
            Invalidate(true);

            // Force update component
            Component.Outdated = true;

            // Force update scroll-bar
            Scrollbar.ForceUpdate();

            // Refresh control
            Refresh();
        }
Exemplo n.º 14
0
 private T[] DisplayedItemsOfType <T>()
 {
     return(DisplayedItems.OfType <T>().ToArray());
 }
Exemplo n.º 15
0
 public void add(object sender, KeyEventArgs e)
 {
     DisplayedItems.Add("dupa");
 }