Ejemplo n.º 1
0
        private void picBox_MouseClick(object sender, MouseEventArgs e)
        {
            PictureBox pictureBox = ((PictureBox)sender);
            Node       node       = listNode.Find(o => o.Name.Equals(pictureBox.Name));
            NodeInfo   nodeInfo   = new NodeInfo(node);
            // Show nodeInfo as a modal dialog and determine if DialogResult = OK.
            var nodeInfoStatusReturn = nodeInfo.ShowDialog(this);

            if (nodeInfoStatusReturn == DialogResult.OK)
            {
                // Read the contents of nodeInfo's TextBox.
                node = nodeInfo.ReturnValue11;
                //update picturebox name if changed
                pictureBox.Name = node.Name;
                pictureBox.Image.Dispose();
                pictureBox.Image     = ImageTransparency.ChangeOpacity(Image.FromFile("red.png"), opacityvalue); //calling ChangeOpacity Function
                pictureBox.Image.Tag = "red";
                pictureBox.Refresh();
                networkHeartbeatRestart();
            }
            //node delete
            else if (nodeInfoStatusReturn == DialogResult.Abort)
            {
                listNode.Remove(node);
                pictureBox.Image.Dispose();
                this.Controls.Remove(pictureBox);
                networkHeartbeatRestart();
            }
            nodeInfo.Dispose();
        }
Ejemplo n.º 2
0
        private void CreatePicturebox(Node item)
        {
            PictureBox pictureBox = new PictureBox();

            pictureBox.BackColor = Color.Transparent;

            //set location and size of picturebox when draw
            if (item.Location.Equals(new Point(0, 0)))
            {
                pictureBox.Location = new System.Drawing.Point(103, 82);
            }
            else
            {
                pictureBox.Location = item.Location;
            }

            //width
            if (item.Width == 0)
            {
                pictureBox.Width = Properties.Settings.Default.NodeSize;
            }
            else
            {
                pictureBox.Width = item.Width;
            }

            //height
            if (item.Height == 0)
            {
                pictureBox.Height = Properties.Settings.Default.NodeSize;
            }
            else
            {
                pictureBox.Height = item.Height;
            }

            pictureBox.Name     = item.Name;
            pictureBox.Size     = new System.Drawing.Size(pictureBox.Width, pictureBox.Height);
            pictureBox.TabIndex = 0;
            pictureBox.TabStop  = false;
            pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;


            //event draw pictureBox
            pictureBox.Paint += picBox_Paint;
            //event click pictureBox
            pictureBox.MouseDoubleClick += picBox_MouseClick;

            pictureBox.Image     = ImageTransparency.ChangeOpacity(Image.FromFile("red.png"), opacityvalue); //calling ChangeOpacity Function
            pictureBox.Image.Tag = "red";

            this.Controls.Add(pictureBox);
            //check enable node move
            if (Properties.Settings.Default.MovingandResizeNodeEnable)
            {
                //ControlMover.Init(pictureBox);
                ControlMoverOrResizer.Init(pictureBox);
            }
            pictureBoxes.Add(pictureBox);
        }
Ejemplo n.º 3
0
        private void c_PingDown(object sender, int e)
        {
            pictureBoxes[e].Image.Dispose();
            pictureBoxes[e].Image     = ImageTransparency.ChangeOpacity(Image.FromFile("red.png"), opacityvalue); //calling ChangeOpacity Function
            pictureBoxes[e].Image.Tag = "red";
            //pictureBoxes[e].Image = Image.FromFile("redblink.gif");   //calling ChangeOpacity Function

            //neu enable sound alarm thi moi keu
            if (listNode[e].AlarmEnable)
            {
                var alarmFilePath = !String.IsNullOrEmpty(listNode[e].AlarmFilename) ? Path.Combine(Directory.GetCurrentDirectory(), "soundAlarm", listNode[e].AlarmFilename) : Path.Combine(Directory.GetCurrentDirectory(), "soundAlarm", Properties.Settings.Default.AlarmFileName);
                my_wave_file = new SoundPlayer(alarmFilePath);
                if (Properties.Settings.Default.PlayLooping)
                {
                    my_wave_file.PlayLooping();
                }
                else
                {
                    my_wave_file.Play();
                }
            }
        }
Ejemplo n.º 4
0
 private void c_PingUp(object sender, int e)
 {
     pictureBoxes[e].Image.Dispose();
     pictureBoxes[e].Image     = ImageTransparency.ChangeOpacity(Image.FromFile("green.png"), opacityvalue); //calling ChangeOpacity Function
     pictureBoxes[e].Image.Tag = "green";
 }