Пример #1
0
        void createPanel()
        {
            NewPanel nP = new NewPanel();
            nP.ShowDialog();
            bool existsAlready = false;
            //LinkPanel existingLP;
            foreach (LinkPanel c in linkPanels)
            {
                //#
                //#
                //#
                //MessageBox.Show(c.Position.ToString() + nP.Position.ToString());
                if (c.Position == nP.Position)
                {
                    existsAlready = true; LinkPanel existingLP = c;
                    DialogResult dResult = MessageBox.Show("A Link Panel already exists there!\nEdit?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dResult == DialogResult.Yes)
                    {
                        editPanel(existingLP);
                    }
                }
            }
            if (existsAlready == false)
            {
                LinkPanel lp = new LinkPanel();
                lp.Position = nP.Position;
                int position = nP.Position;
                #region PosSwitch
                switch (position)
                {

                    default:
                        MessageBox.Show("invalid position value");
                        break;
                    case 1:
                        lp.Location = new Point(128, 0);
                        break;
                    case 2:
                        lp.Location = new Point(256, 0);
                        break;
                    case 3:
                        lp.Location = new Point(384, 0);
                        break;
                    case 4:
                        lp.Location = new Point(0, 128);
                        break;
                    case 5:
                        lp.Location = new Point(128, 128);
                        break;
                    case 6:
                        lp.Location = new Point(256, 128);
                        break;
                    case 7:
                        lp.Location = new Point(384, 128);
                        break;
                    case 8:
                        lp.Location = new Point(0, 256);
                        break;
                    case 9:
                        lp.Location = new Point(128, 256);
                        break;
                    case 10:
                        lp.Location = new Point(256, 256);
                        break;
                    case 11:
                        lp.Location = new Point(384, 256);
                        break;
                    case 12:
                        lp.Location = new Point(0, 384);
                        break;
                    case 13:
                        lp.Location = new Point(128, 384);
                        break;
                    case 14:
                        lp.Location = new Point(256, 384);
                        break;
                    case 15:
                        lp.Location = new Point(384, 384);
                        break;
                }
                #endregion
                lp.Link = nP.Command;
                lp.Text = nP.LabText;
                lp.Size = new Size(128, 128);
                lp.MouseLeave += new EventHandler(Main_MouseLeave);
                linkPanels.Add(lp);
                Controls.Add(linkPanels.Last());
            }
        }
Пример #2
0
 void editPanel(LinkPanel lp)
 {
     NewPanel nP = new NewPanel();
     nP.editPositionEnabled = false;
     nP.ShowDialog();
     lp.Link = nP.Command;
     lp.Text = nP.LabText;
 }