コード例 #1
0
        private void AddOption(string optionName, int optionIndex)
        {
            // Get the base panel with the name and remove button
            Panel overallPanel = ListRandomiserUtils.GetBasePanel(optionName, optionIndex);

            // Add Remove button Click event
            overallPanel.Controls[1].Click += RemoveOption_Click;


            // Adds the MoveDown and MoveUp button to the previous control and current control if not the first
            if (optionIndex != 0)
            {
                // Add down button to previous panel - Note bottom panel is index 0
                Pnl_listOptions.Controls[0].PaddingToDownButton(optionIndex - 1);

                // Add up button to current panel
                overallPanel.AddMoveUpButton(optionIndex);
                overallPanel.AddPaddingPanel();

                // Add Click events
                overallPanel.Controls[2].Click += MoveUp_Click;
                Pnl_listOptions.Controls[0].Controls[3].Click += MoveDown_Click;
            }
            else
            {
                // Add padding rather than buttons
                overallPanel.AddPaddingPanel();
                overallPanel.AddPaddingPanel();
            }

            Pnl_listOptions.Controls.Insert(0, overallPanel);

            UpdateButtons();
        }
コード例 #2
0
        private void LoadCurrentList()
        {
            Pnl_listOptions.Controls.Clear();

            if (Application.CurrentList != null)
            {
                Txt_currentList.Lines = new string[] { Application.CurrentList.Name };

                for (int i = 0; i < Application.CurrentList.Items.Count; i++)
                {
                    // Get the base panel with the name and remove button
                    Panel overallPanel = ListRandomiserUtils.GetBasePanel(Application.CurrentList.Items[i], i);

                    // Add Remove button Click event
                    overallPanel.Controls[1].Click += RemoveOption_Click;

                    // Add Move Up button and Click event if not at the top of the list
                    if (i != 0)
                    {
                        overallPanel.AddMoveUpButton(i);
                        overallPanel.Controls[2].Click += MoveUp_Click;
                    }
                    else
                    {
                        overallPanel.AddPaddingPanel();
                    }

                    // Add Move Down button and Click event if not at the bottom of the list
                    if (i != Application.CurrentList.Items.Count - 1)
                    {
                        overallPanel.AddMoveDownButton(i);
                        overallPanel.Controls[3].Click += MoveDown_Click;
                    }
                    else
                    {
                        overallPanel.AddPaddingPanel();
                    }

                    Pnl_listOptions.Controls.Add(overallPanel);
                }

                Pnl_listOptions.Controls.Reverse();
            }
        }