CopyTo() public méthode

public CopyTo ( ToolStripItem array, int index ) : void
array ToolStripItem
index int
Résultat void
        /// <summary>
        /// Sorts a ToolStripItemCollection by the Text property of each ToolStripItem.
        /// Sorting is alphanumeric and case insensitive.
        /// </summary>
        /// <param name="items">The System.Windows.Forms.ToolStripItemCollection to sort.</param>
        public static void Sort(ToolStripItemCollection items)
        {
            List <ToolStripMenuItem> itemList = new List <ToolStripMenuItem>(items.Count);

            ToolStripItem[] itemArray = new ToolStripItem[items.Count];
            items.CopyTo(itemArray, 0);

            Array.Sort <ToolStripItem>(itemArray, new ToolStripItemSorter());
            items.Clear();
            items.AddRange(itemArray);
        }
Exemple #2
0
        private int DBSelect_LoadingLists_Reset()
        {
            DataTable openedLists = new DataTable();
            using (OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from LoadingListOpened_View", conn))
            {
                adapter.SelectCommand.Parameters.Add("@stock_id", OleDbType.Integer).Value = getStockId();
                adapter.Fill(openedLists);
            }
            openedLists.PrimaryKey = new DataColumn[] { openedLists.Columns[openedLists.Columns.IndexOf("id")] };

            //checking for contained buttons, remove not existing in db
            KryptonCheckButton[] buttons = new KryptonCheckButton[openedLists.Rows.Count];
            ToolStripMenuItem[] items = new ToolStripMenuItem[openedLists.Rows.Count];
            foreach (DataRow row in openedLists.Rows)
            {
                long listId = long.Parse(row.ItemArray[openedLists.Columns.IndexOf("id")].ToString());
                string index = (string)row.ItemArray[openedLists.Columns.IndexOf("index")];
                KryptonCheckButton button = CreateLoadingListButton(listId, index);

                if (!flpControls.Controls.ContainsKey(button.Name))
                {
                    //buttons[openedLists.Rows.IndexOf(row)] = button;
                    flpControls.Controls.Add(button);
                    tsmiLL.DropDownItems.Insert(tsmiLL.DropDownItems.IndexOf(tsmiHistorySeparator), newLoadingListMenuItem(listId, index));
                    newLoadingListToolStripItem(listId, index);
                }
            }

            ToolStripItemCollection col2 = new ToolStripItemCollection(cmsLoadingLists, ((ToolStripItem[])cmsLoadingLists.Tag));
            foreach (Control control in flpControls.Controls)
            {
                if (!openedLists.Rows.Contains(control.Tag))
                {
                    flpControls.Controls.RemoveAt(flpControls.Controls.IndexOfKey(control.Name));

                    col2.RemoveAt(col2.IndexOfKey(csLoadingList.CheckedButton.Name));
                    col2.CopyTo((ToolStripItem[])cmsLoadingLists.Tag, 0);

                    tsmiLL.DropDownItems.RemoveAt(tsmiLL.DropDownItems.IndexOfKey(control.Name));
                }
            }

            //flpControls.Controls.AddRange(buttons);
            return openedLists.Rows.Count;
        }
Exemple #3
0
        private ToolStripItem newLoadingListToolStripItem(long listId, String index)
        {
            ToolStripMenuItem item = new ToolStripMenuItem(LL_DeserializeName(index), WarehouseApp.Properties.Resources.table, null, "l" + listId);
            item.Tag = listId;
            item.Click += new System.EventHandler(LoadingList_MoveToSelected_Click);
            Events_LoadingListButton(item);

            if (cmsLoadingLists.Tag != null)
            {
                ToolStripItemCollection col2 = new ToolStripItemCollection(cmsLoadingLists, ((ToolStripItem[])cmsLoadingLists.Tag));
                if (col2.IndexOfKey(item.Name) == -1)
                {
                    col2.Insert(col2.IndexOf(tsmiNewLL), item);
                    cmsLoadingLists.Tag = new ToolStripItem[col2.Count];
                    col2.CopyTo((ToolStripItem[])cmsLoadingLists.Tag, 0);
                }
            }

            return item;
        }
Exemple #4
0
            public static ContextMenuStrip CombineItems_ContextMenu(ContextMenuStrip[] cmsTargets, CancelEventHandler[] eventsOpening)
            {
                ContextMenuStrip cmsBlank = new ContextMenuStrip();//components
                cmsBlank.Font = new System.Drawing.Font("Segoe UI", 8.25F);
                cmsBlank.Name = "cmsBlank";
                cmsBlank.Size = new System.Drawing.Size(153, 26);
                if (eventsOpening != null)
                {

                    cmsBlank.Opening += delegate(object sender, CancelEventArgs e)
                    {
                        foreach (CancelEventHandler eventOpening in eventsOpening)
                        {
                            if (!e.Cancel)
                            {
                                eventOpening(sender, e);
                            }
                            else
                            {
                                break;
                            }
                        }
                    };

                }

                foreach (ContextMenuStrip strip in cmsTargets)
                {
                    if (strip.Tag == null)
                    {
                        strip.Tag = new ToolStripItem[strip.Items.Count];
                        strip.Items.CopyTo((ToolStripItem[])strip.Tag, 0);
                    }
                    ToolStripItemCollection stripItems = new ToolStripItemCollection(strip, ((ToolStripItem[])strip.Tag));
                    ToolStripItem[] items = new ToolStripItem[stripItems.Count];
                    if (items.Length == 0 && strip.Tag != null)
                    {
                        items = (ToolStripItem[])strip.Tag;
                    }

                    stripItems.CopyTo(items, 0);
                    strip.Tag = items;
                    cmsBlank.Items.AddRange(items);
                    cmsBlank.Tag = items;
                }
                return cmsBlank;
            }
Exemple #5
0
 private static void MoveToolStripItems(ToolStripItemCollection from, ToolStripItemCollection to)
 {
     ToolStripItem[] arr = new ToolStripItem[from.Count];
     from.CopyTo(arr, 0);
     to.AddRange(arr);
 }