コード例 #1
0
        private void updateTree(VisualComponent component)
        {
            SensorTree.Nodes.Clear();
            // SensorTree.BeginUpdate();
            List <TreeNode> I = new List <TreeNode>();


            foreach (var symbol in component.IOtree.Symbols)
            {
                TreeNode symbolNode = new TreeNode();
                Input    tempState  = Input.Create();
                if (Connected)
                {
                }   //UPDATE STATE
                symbolNode.Text            = symbolNode.Name = symbol.Name;
                symbolNode.Tag             = symbol;
                symbolNode.ToolTipText     = symbol.Address;
                symbolNode.StateImageIndex = Convert.ToInt16(tempState.State);
                symbolNode.ImageIndex      = 2;

                I.Add(symbolNode);
            }

            component.IOtree.Items = I;
            SensorTree.Nodes.AddRange(component.IOtree.Items.ToArray());
            // SensorTree.EndUpdate();
        }
コード例 #2
0
        private VisualComponent placeDragIO(Point location, VisualComponent vc, object IO)
        {
            if (IO is Symbol)
            {
                Symbol input   = (Symbol)IO;
                Panel  control = new Panel();
                string name    = input.Name + ": " + input.Address;
                control.Size        = new Size(12, 12);
                control.Tag         = input;
                control.Name        = name;
                control.BackColor   = Color.Red;
                control.BorderStyle = BorderStyle.FixedSingle;
                control.BringToFront();
                control.Location         = location;
                control.ContextMenuStrip = redSquareMenu;
                control.MouseEnter      += Control_MouseEnter;
                control.MouseClick      += Panel_MouseClick;
                control.MouseHover      += Panel_MouseHover;
                control.MouseDown       += Panel_MouseDown;
                control.MouseMove       += Panel_MouseMove;
                control.MouseUp         += Panel_MouseUp;
                //ToolTip tt = new ToolTip();
                //tt.IsBalloon = true;
                //tt.UseFading = true;
                //tt.SetToolTip(control,name);
                vc.IO.Add(control);
            }

            return(vc);
        }
コード例 #3
0
        public void createImageBox(VisualComponent component)
        {
            PictureBox box = new PictureBox();

            box.BorderStyle = BorderStyle.FixedSingle;
            box.Width       = component.Image.Width;
            box.Height      = component.Image.Height;
            box.Image       = component.Image;
            box.Name        = component.Name;
            box.Tag         = component;
            box.MouseMove  += imgbox_MouseMove;
            box.MouseLeave += imgbox_MouseLeave;
            box.DragDrop   += Box_DragDrop;
            box.MouseEnter += imgbox_MouseEnter;
            box.Resize     += imgbox_Resize;
            box.MouseClick += imgbox_MouseClick;
            box.SizeMode    = PictureBoxSizeMode.AutoSize;
            foreach (var panel in component.IO)
            {
                panel.ContextMenuStrip = redSquareMenu;
                panel.MouseEnter      += Control_MouseEnter;
                panel.MouseClick      += Panel_MouseClick;
                panel.MouseHover      += Panel_MouseHover;
                panel.MouseDown       += Panel_MouseDown;
                panel.MouseMove       += Panel_MouseMove;
                panel.MouseUp         += Panel_MouseUp;
            }
            box.Controls.AddRange(component.IO.ToArray());
            FLOW.Controls.Clear();
            FLOW.Controls.Add(box);
        }
コード例 #4
0
        public static VisualComponent Read(string path)
        {
            VisualComponent obj = new VisualComponent();

            try
            {
                IFormatter formatter = new BinaryFormatter();
                Stream     stream    = new FileStream(path,
                                                      FileMode.Open,
                                                      FileAccess.Read,
                                                      FileShare.Read);
                obj    = (VisualComponent)formatter.Deserialize(stream);
                obj.IO = new List <Panel>();
                obj.IOview.restoreTags();
                foreach (var ios in obj.ios)
                {
                    Panel io = new Panel();
                    io.BackColor   = Color.Red;
                    io.BorderStyle = BorderStyle.FixedSingle;
                    io.Size        = ios.Size;
                    io.Location    = ios.Location;
                    io.Name        = ios.Name;
                    io.Tag         = ios.IO;

                    obj.IO.Add(io);
                }
                stream.Close();
            }
            catch (Exception ee) {
                ee.ToString();
            }
            return(obj);
        }
コード例 #5
0
 public VcPanel()
 {
     m_vc                = VisualComponent.Create();
     this.Size           = new System.Drawing.Size(75, 100);
     this.BorderStyle    = BorderStyle.FixedSingle;
     this.Name           = "Default";
     m_tooltip.IsBalloon = true;
     m_tooltip.UseFading = true;
     m_tooltip.SetToolTip(this, "Default");
     m_tooltip.SetToolTip(m_button, "Default");
     m_tooltip.SetToolTip(m_imgbox, "Default");
     m_imgbox.Size        = new Size(67, 60);
     m_imgbox.Location    = new Point(3, 3);
     m_imgbox.BorderStyle = BorderStyle.Fixed3D;
     m_imgbox.SizeMode    = PictureBoxSizeMode.Zoom;
     m_button.Anchor      = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | AnchorStyles.Bottom)));
     m_imgbox.Anchor      = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Top)));
     m_button.Size        = new Size(67, 26);
     m_button.Location    = new Point(3, 68);
     m_button.Click      += Button_Click;
     m_button.Text        = "View";
     this.Controls.Add(m_imgbox);
     this.Controls.Add(m_button);
     Invalidate();
 }
コード例 #6
0
 public Visualizer(Sharp7.S7Client client, VisualComponent component)
 {
     this.DoubleBuffered = true;
     Client = client;
     AddVcPanel(component);
     InitializeComponent();
     m_Instance = this;
 }
コード例 #7
0
        public VcPanel(VisualComponent vc)
        {
            this.Size        = new System.Drawing.Size(75, 100);
            this.BorderStyle = BorderStyle.FixedSingle;
            m_vc             = vc;
            this.Name        = vc.Name;
            //menuItems
            ToolStripMenuItem save = new ToolStripMenuItem();

            save.Name   = "saveToolStripMenuItem";
            save.Size   = new System.Drawing.Size(152, 22);
            save.Text   = "Save";
            save.Click += Save_Click;

            ToolStripMenuItem remove = new ToolStripMenuItem();

            remove.Name   = "removeToolStripMenuItem";
            remove.Size   = new System.Drawing.Size(152, 22);
            remove.Text   = "Remove";
            remove.Click += Remove_Click;

            ToolStripMenuItem rename = new ToolStripMenuItem();

            rename.Name   = "renameToolStripMenuItem";
            rename.Size   = new System.Drawing.Size(152, 22);
            rename.Text   = "Rename";
            rename.Click += Rename_Click;
            //ContextMenu
            VcpContextMenu = new System.Windows.Forms.ContextMenuStrip();
            VcpContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { save, remove });
            VcpContextMenu.Name   = "VcpContextMenu";
            VcpContextMenu.Size   = new System.Drawing.Size(153, 120);
            this.ContextMenuStrip = VcpContextMenu;
            //toolTip
            m_tooltip.IsBalloon = true;
            m_tooltip.UseFading = true;
            m_tooltip.SetToolTip(this, vc.Name);
            m_tooltip.SetToolTip(m_button, vc.Name);
            m_tooltip.SetToolTip(m_imgbox, vc.Name);
            //imgbox
            m_imgbox.Image            = vc.Image;
            m_imgbox.SizeMode         = PictureBoxSizeMode.Zoom;
            m_imgbox.Size             = new Size(67, 60);
            m_imgbox.Anchor           = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Top)));
            m_imgbox.Location         = new Point(3, 3);
            m_imgbox.ContextMenuStrip = VcpContextMenu;
            m_imgbox.DoubleClick     += Button_Click;
            //button
            m_button.Anchor   = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | AnchorStyles.Bottom)));
            m_button.Size     = new Size(67, 26);
            m_button.Location = new Point(3, 68);
            m_button.Text     = "View";
            m_button.Click   += Button_Click;

            this.Controls.Add(m_imgbox);
            this.Controls.Add(m_button);
            Invalidate();
        }
コード例 #8
0
        public static VisualComponent Create()
        {
            VisualComponent v = new VisualComponent();

            v.IO     = new List <Panel>();
            v.IOview = VcView.Create();
            v.IOtree = VcTree.Create();

            return(v);
        }
コード例 #9
0
        public void AddVcPanel(VisualComponent vc) //ADD Panel;
        {
            VcPanel vcp = new VcPanel(vc);

            CurrentVcName    = vcp.VisualComponent.Name;
            vcp.ViewClick   += Vcp_ButtonClick;
            vcp.RemoveClick += Vcp_RemoveClick;
            vcp.SaveClick   += Vcp_SaveClick;
            CLibrary.Add(vcp);
            updateVcpFlow(CLibrary);
        }
コード例 #10
0
 private void updateVcp(VisualComponent vc)
 {
     foreach (var control in VcpFlow.Controls)
     {
         var vcp = (VcPanel)control;
         if (vcp.VisualComponent.Name.Equals(vc.Name))
         {
             vcp.VisualComponent = vc;
             return;
         }
     }
 }
コード例 #11
0
        private void openComponentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "Visual Component|*.vc|All Files|*.*";
            ofd.InitialDirectory = Directory.GetCurrentDirectory();
            ofd.ShowDialog();
            if (!ofd.FileName.Equals(""))
            {
                VisualComponent vc = VisualComponent.Read(ofd.FileName);

                CLibrary.Add(new VcPanel(vc));
                CLibrary = assignEventstoVcps(CLibrary);
                updateVcpFlow(CLibrary);
            }
        }
コード例 #12
0
        public void updateView(VisualComponent component)
        {
            try
            {
                if (component.IOview.Items.Count == 0 && component.ios.Count > 0)
                {
                    fillInSensorView(component);
                }
            }
            catch { }
            SensorView.Items.Clear();
            SensorView.BeginUpdate();
            List <ListViewItem> I = new List <ListViewItem>();

            foreach (var i in component.IOview.Items)
            {
                if (i.Tag is Symbol)
                {
                    Symbol input = (Symbol)i.Tag;
                    if (Connected)
                    {
                    }  //READ STATE
                    var b = new ListViewItem.ListViewSubItem[2] {
                        new ListViewItem.ListViewSubItem(), new ListViewItem.ListViewSubItem()
                    };
                    b[1].Text = input.Name;
                    ListViewItem item = new ListViewItem(b, 0);
                    item.Name = input.Name;
                    item.Text = input.Address;
                    item.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    item.UseItemStyleForSubItems = true;
                    item.StateImageIndex         = Convert.ToInt16(input.State);
                    item.ImageIndex = 2;
                    item.Tag        = input;
                    I.Add(item);
                }
            }

            component.IOview.Items = I;
            SensorView.Items.AddRange(I.ToArray());
            SensorView.EndUpdate();
        }
コード例 #13
0
 public void fillInSensorView(VisualComponent component)
 {
     foreach (var io in component.ios)
     {
         var symbol = io.IO as Symbol;
         var b      = new ListViewItem.ListViewSubItem[2] {
             new ListViewItem.ListViewSubItem(), new ListViewItem.ListViewSubItem()
         };
         b[1].Text = symbol.Name;
         ListViewItem item = new ListViewItem(b, 0);
         item.Name = symbol.Name;
         item.Text = "X" + symbol.Address;
         item.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
         item.UseItemStyleForSubItems = true;
         item.StateImageIndex         = Convert.ToInt16(symbol.State);
         item.ImageIndex = 2;
         item.Tag        = symbol;
         component.IOview.Items.Add(item);
     }
     updateView(component);
 }
コード例 #14
0
        public static VisualComponent Create(Image image, VcView view, string name = "", List <Panel> io = null, string serial = "", object tag = null)
        {
            VisualComponent v = new VisualComponent();

            if (io != null)
            {
                v.IO = new List <Panel>();
            }
            else
            {
                v.IO = io;
            }
            v.IOview = view;
            if (v.IOview.Items == null)
            {
                v.IOview.Items = new List <ListViewItem>();
            }
            v.Name         = name;
            v.Image        = image;
            v.SerialNumber = serial;
            v.Tag          = tag;
            return(v);
        }
コード例 #15
0
 public void createViewAndTree(VisualComponent component)
 {
     updateTree(component);
     updateView(component);
 }
コード例 #16
0
 private void DisplayVC(VisualComponent vc)
 {
     updateTree(vc);
     updateView(vc);
     createImageBox(vc);
 }