private void LoadLights()
        {
            foreach (SmartCity.DatasetSmartCity.LightRow light in smartCity1.Light)
            {
                Image im = Image.FromFile(@"photo/light.jpg"); // System.Drawing.Color.Lime;


                UCLight mylight = new UCLight(im, light.LightName);

                //  PictureBox mytag = new PictureBox();
                //   mytag.Image = im;

                mylight.AutoSize = true;
                mylight.Tag      = "LIGHT";

                mylight.Location = new System.Drawing.Point(light.x, light.y);
                //  mytag.Name = name.Split(',')[0].ToString();
                mylight.Size = new System.Drawing.Size(40, 60);


                mylight.BackColor = Color.White;

                mylight.MouseMove += new System.Windows.Forms.MouseEventHandler(this.label1_MouseMove);



                this.panel1.Controls.Add(mylight);
                mylight.BringToFront();
            }
            this.panel1.PerformLayout();
            this.ResumeLayout(true);
        }
Exemple #2
0
        private void LoadLights()
        {
            ArrayList al = new ArrayList();



            foreach (Control item in panel1.Controls)
            {
                if (item.ToString() == "SmartCity.UCLight")
                {
                    al.Add(item);
                }
            }

            foreach (Control item in al)
            {
                panel1.Controls.Remove(item);
            }

            foreach (SmartCity.DatasetSmartCity.LightRow light in smartCity1.Light)
            {
                if ((light.x == 0 & light.y == 0) || (light.x == null & light.y == null))
                {
                    continue;
                }
                Image im = Properties.Resources.light; // System.Drawing.Color.Lime;


                UCLight mylight = new UCLight(im, smartCity1.Controller.Select("controllerName='" + light.controller + "'")[0]["SIM"].ToString(), "SETPW-" + light.LightName + "X250");

                //  PictureBox mytag = new PictureBox();
                //   mytag.Image = im;

                mylight.AutoSize = true;
                mylight.Tag      = "LIGHT";

                mylight.Location = new System.Drawing.Point(light.x, light.y);
                //  mytag.Name = name.Split(',')[0].ToString();
                mylight.Size = new System.Drawing.Size(40, 60);


                mylight.BackColor = Color.White;

                mylight.MouseMove += new System.Windows.Forms.MouseEventHandler(this.label1_MouseMove);



                this.panel1.Controls.Add(mylight);
                mylight.BringToFront();
            }
            this.panel1.PerformLayout();
            this.ResumeLayout(true);
        }
        private void panel1_DragDrop(object sender, DragEventArgs e)
        {
            //   int x = readerx;
            //  int y = readery;
            try
            {
                SmartCity.DatasetSmartCity.LightRow light = (SmartCity.DatasetSmartCity.LightRow)gridView6.GetFocusedDataRow();



                foreach (Control item in panel1.Controls)
                {
                    if (item.ToString() == "SmartCity.UCLight")
                    {
                        if (((UCLight)item).labelname == light.LightName)
                        {
                            //   MessageBox.Show("This Antenna is already in the map.");
                            return;
                        }
                    }
                }

                label2.Text = e.X.ToString() + " " + e.Y.ToString();

                int overallx = PointToClient(Cursor.Position).X;
                int overally = PointToClient(Cursor.Position).Y;
                int x        = overallx - this.panel1.Location.X; // - this.panel1.Width;// +scrollx;
                int y        = overally - this.panel1.Location.Y; // +scrolly;


                this.panel1.SuspendLayout();
                this.SuspendLayout();
                // add the selected string to bottom of list

                Image im = Image.FromFile(@"photo/light.jpg"); // System.Drawing.Color.Lime;


                UCLight mylight = new UCLight(im, light.LightName);

                //  PictureBox mytag = new PictureBox();
                //   mytag.Image = im;

                mylight.AutoSize = true;
                mylight.Tag      = "LIGHT";

                mylight.Location = new System.Drawing.Point(x, y);
                //  mytag.Name = name.Split(',')[0].ToString();
                mylight.Size = new System.Drawing.Size(40, 60);

                ((SmartCity.DatasetSmartCity.LightRow)gridView6.GetFocusedDataRow()).x = x + scrollx;
                ((SmartCity.DatasetSmartCity.LightRow)gridView6.GetFocusedDataRow()).y = y + scrolly;


                mylight.BackColor = Color.White;

                mylight.MouseMove += new System.Windows.Forms.MouseEventHandler(this.label1_MouseMove);


                foreach (Control item in panel1.Controls)
                {
                    if (item.ToString() == "UCLight")
                    {
                        if (((UCLight)item).labelname == light.LightName)
                        {
                            //  MessageBox.Show("This Antenna is already in the map.");
                            return;
                        }
                    }
                }
                this.panel1.Controls.Add(mylight);
                mylight.BringToFront();
                this.panel1.PerformLayout();
                this.ResumeLayout(true);
                // button5.Select();

                panel1.AllowDrop = false;

                //   gridView6.SelectRow(0);
                button5_Click(null, null);

                //panel1.AllowDrop = true;

                // textBox1.SelectAll();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }