Exemplo n.º 1
0
        private void button16_Click(object sender, EventArgs e)
        {
            Device    device = new Device(13);
            ShapeNode node   = diagram1.Factory.CreateShapeNode(10, 10, 40, 40);

            device.SetNode(node);

            countDevice     += 1;
            node.Id          = "" + countDevice;
            node.Image       = Properties.Resources._12_NutAnDoNho;
            node.Transparent = true;
            node.ImageAlign  = MindFusion.Drawing.ImageAlign.Fit;


            device.PortCount = 2;
            device.port.Add(new PointF(0.4f * device.shapenode.Bounds.Width + device.shapenode.Bounds.X,
                                       1 * device.shapenode.Bounds.Height + device.shapenode.Bounds.Y));
            device.port.Add(new PointF(0.6f * device.shapenode.Bounds.Width + device.shapenode.Bounds.X,
                                       1 * device.shapenode.Bounds.Height + device.shapenode.Bounds.Y));

            AllDevice.Add(device);
            //ShapeNode node = diagram1.Factory.CreateShapeNode(20, 20, 40, 40);
            //node.Id = "Role bao ve dien ap";
            //node.Image = Properties.Resources._18_role_bao_ve_dien_ap;
            //node.Transparent = true;
            //node.ImageAlign = MindFusion.Drawing.ImageAlign.Fit;
        }
Exemplo n.º 2
0
        private void button11_Click(object sender, EventArgs e)
        {
            Device    device = new Device(6);
            ShapeNode node   = diagram1.Factory.CreateShapeNode(10, 10, 40, 40);

            device.SetNode(node);

            countDevice     += 1;
            node.Id          = "" + countDevice;
            node.Image       = Properties.Resources._5_Contactor;
            node.Transparent = true;
            node.ImageAlign  = MindFusion.Drawing.ImageAlign.Fit;


            device.PortCount = 4;
            device.port.Add(new PointF(0.45f * device.shapenode.Bounds.Width + device.shapenode.Bounds.X,
                                       0 * device.shapenode.Bounds.Height + device.shapenode.Bounds.Y));
            device.port.Add(new PointF(0.55f * device.shapenode.Bounds.Width + device.shapenode.Bounds.X,
                                       0 * device.shapenode.Bounds.Height + device.shapenode.Bounds.Y));
            device.port.Add(new PointF(0.45f * device.shapenode.Bounds.Width + device.shapenode.Bounds.X,
                                       1 * device.shapenode.Bounds.Height + device.shapenode.Bounds.Y));
            device.port.Add(new PointF(0.55f * device.shapenode.Bounds.Width + device.shapenode.Bounds.X,
                                       1 * device.shapenode.Bounds.Height + device.shapenode.Bounds.Y));

            AllDevice.Add(device);
            //ShapeNode node = diagram1.Factory.CreateShapeNode(20, 20, 40, 40);
            //node.Id = "Role nhiet";
            //node.Image = Properties.Resources._15_RoLE_NHIeT;
            //node.Transparent = true;
            //node.ImageAlign = MindFusion.Drawing.ImageAlign.Fit;
        }
Exemplo n.º 3
0
        private void button9_Click(object sender, EventArgs e)
        {
            Device    device = new Device(4);
            ShapeNode node   = diagram1.Factory.CreateShapeNode(10, 10, 40, 40);

            device.SetNode(node);

            countDevice     += 1;
            node.Id          = "" + countDevice;
            node.Image       = Properties.Resources._3_CauDao3Pha;
            node.Transparent = true;
            node.ImageAlign  = MindFusion.Drawing.ImageAlign.Fit;


            device.PortCount = 4;
            device.port.Add(new PointF(0 * device.shapenode.Bounds.Width + device.shapenode.Bounds.X,
                                       0.45f * device.shapenode.Bounds.Height + device.shapenode.Bounds.Y));
            device.port.Add(new PointF(0 * device.shapenode.Bounds.Width + device.shapenode.Bounds.X,
                                       0.55f * device.shapenode.Bounds.Height + device.shapenode.Bounds.Y));
            device.port.Add(new PointF(1 * device.shapenode.Bounds.Width + device.shapenode.Bounds.X,
                                       0.45f * device.shapenode.Bounds.Height + device.shapenode.Bounds.Y));
            device.port.Add(new PointF(1 * device.shapenode.Bounds.Width + device.shapenode.Bounds.X,
                                       0.55f * device.shapenode.Bounds.Height + device.shapenode.Bounds.Y));

            AllDevice.Add(device);
            //ShapeNode node = diagram1.Factory.CreateShapeNode(20, 20, 40, 40);
            //node.Id = "Role thoi gian";
            //node.Image = Properties.Resources._12_ro_le_thoi_gian;
            //node.Transparent = true;
            //node.ImageAlign = MindFusion.Drawing.ImageAlign.Fit;
        }
Exemplo n.º 4
0
        public bool AddDeviceControl(XML_DeviceControl device, ref string msg)
        {
            bool flag = true;

            try
            {
                if (AllDevice.Exists(c => c.StationUniqueId == device.StationUniqueId && c.Number == device.Number))
                {
                    msg  = "该站点已存在设备编号:" + device.Number;
                    flag = false;
                }
                else if (AllDevice.Exists(c => c.StationUniqueId == device.StationUniqueId && c.DeviceId == device.DeviceId))
                {
                    msg  = "该站点已存在寄存器编号:" + device.DeviceId;
                    flag = false;
                }
                else
                {
                    lock (AllDevice)
                    {
                        int uniqueId = AllDevice.Max(c => c.UniqueId);
                        device.UniqueId = uniqueId + 1;
                        AllDevice.Add(device);
                        flag = AddDeviceControlToXML(device);
                    }
                }
            }
            catch (Exception ex)
            {
                flag = false;
                LogMg.AddError(ex);
            }
            return(flag);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 删除设备控制
        /// </summary>
        /// <param name="uniqueId"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool DelDeviceControl(int uniqueId, ref string msg)
        {
            XML_DeviceControl _device = AllDevice.SingleOrDefault(c => c.UniqueId == uniqueId);

            if (_device != null)
            {
                lock (AllDevice)
                {
                    AllDevice.Remove(_device);
                    DelCountryTestFromXML(uniqueId);
                    return(true);
                }
            }
            else
            {
                msg = "不存在这个站点";
                return(false);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 修改DeviceControl
        /// </summary>
        /// <param name="_device"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool EditDeviceControl(XML_DeviceControl _device, ref string msg)
        {
            bool flag = true;

            try
            {
                lock (AllDevice)
                {
                    XML_DeviceControl dc = AllDevice.SingleOrDefault(c => c.UniqueId == _device.UniqueId);
                    AllDevice.Remove(dc);   //先把这个对象删了
                    AllDevice.Add(_device); //再把新的对象添加进去
                    flag = EditDeviceControlFromXML(_device);
                }
            }
            catch (Exception ex)
            {
                LogMg.AddError(ex);
                flag = false;
            }
            return(flag);
        }