Esempio n. 1
0
        public Task ShowCurrentEquipmentList(Control parentControl, DeviceToNickNameViewModel viewModel = null, IList <string> equipmentList = null)
        {
            return(Task.Factory.StartNew(() =>
            {
                var devices = baseAction.Devices;

                if (null == viewModel)
                {
                    viewModel = new DeviceToNickNameViewModel();
                }

                if (null != equipmentList && equipmentList.Count > 0)
                {
                    devices = equipmentList.Where(o => devices.Contains(o)).ToList();
                }

                var devicesWithNickList = SingleHepler <DeviceToNickNameBLL> .Instance.GetEquipmentListWithGroupInfo(new DeviceToNickNameViewModel()
                {
                    Devices = devices
                });

                if (devicesWithNickList != null && devicesWithNickList.Count > 0)
                {
                    devicesWithNickList = devicesWithNickList.OrderBy(o => {
                        var defaluteNum = 0;

                        int.TryParse(o.NickName, out defaluteNum);

                        return defaluteNum;
                    }).ToList();
                }

                ShowCheckBoxWithEquipmentList(parentControl, devicesWithNickList, viewModel);
            }));
        }
Esempio n. 2
0
        public void DymicAddEquipment(IList <string> deviceList)
        {
            if (null == deviceList || deviceList.Count == 0)
            {
                return;
            }

            deviceList.ToList().ForEach((item) =>
            {
                var returnData = baseAction.Devices.Any(o => o.Equals(item));

                if (!returnData)
                {
                    var returnList = SingleHepler <DeviceToNickNameBLL> .Instance.GetList(new DeviceToNickNameViewModel()
                    {
                        Device = item
                    });

                    var currentModel = new DeviceToNickNameViewModel()
                    {
                        Device = item, NickName = item
                    };

                    if (null != returnList && returnList.Count > 0)
                    {
                        currentModel.NickName = returnList.FirstOrDefault().NickName;
                    }

                    var currentControl = CreateEquipmentMapToPC(currentModel, new MouseEventHandler(_picBox_MouseDoubleClick));

                    baseAction.Devices.Add(item);

                    if (!baseAction.Dic.Value.Keys.Contains(item))
                    {
                        baseAction.Dic.Value.Add(item, currentControl);
                    }

                    baseAction.MaxPort++;

                    baseAction._tagTaskState(new UpdateWithTaskStateViewModel()
                    {
                        EquipmentDevice = item, TaskStatus = EnumTaskState.Start
                    });

                    baseAction.SingleShowImageWithSocket(currentControl, baseAction.MaxPort, (device) =>
                    {
                        baseAction._tagTaskState(new UpdateWithTaskStateViewModel()
                        {
                            EquipmentDevice = device, TaskStatus = EnumTaskState.Complete
                        });
                    });
                }
            });
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public async void CheckSomeEquipmentToDO(Control parentControl, DeviceToNickNameViewModel viewModel = null)
        {
            await ShowCurrentEquipmentList(parentControl, viewModel);

            if (!parentControl.HasChildren)
            {
                return;
            }

            var childrenList = parentControl.Controls;

            foreach (CheckBox item in childrenList)
            {
                if (baseAction.CheckSomeEquipments.Value.ContainsKey(item.Name))
                {
                    item.Checked = true;
                }
            }
        }
Esempio n. 4
0
 public IList <GroupToDevice> GetGroupToDeviceList(DeviceToNickNameViewModel viewModel)
 {
     return(SingleHepler <GroupToDeviceDAL> .Instance.GetList(viewModel));
 }
Esempio n. 5
0
        private Control CreateEquipmentMapToPC(DeviceToNickNameViewModel model, MouseEventHandler handler)
        {
            CustomControl.RoundPanel _panel = new CustomControl.RoundPanel();

            _panel.Width       = _width;
            _panel.Height      = _height;
            _panel.Margin      = new Padding(10, 20, 10, 20);
            _panel.RoundeStyle = RoundStyle.All;
            _panel.Radius      = 30;
            _panel.Tag         = model.NickName;
            _panel.BorderColor = Color.Black;
            _panel.Name        = string.Format(partialControlName, model.Device);

            var _btn = CreateActionBtn(_panel, model.NickName, _panel.Width - _marginH * 2);

            _btn.Name     = model.Device;
            _btn.Location = new Point(_marginH, _marginV);
            _btn.Click   += (o, s) =>
            {
                var currentBtn = (Button)o;

                OpenSetEquipmentFrom(currentBtn);
            };

            var _checkBox = new CheckBox();

            _checkBox.Location           = new Point(_panel.Width - 15, _marginV);
            _checkBox.Width              = 30;
            _checkBox.Tag                = model.Device;
            _checkBox.Text               = "_";
            _checkBox.CheckStateChanged += (s, o) =>
            {
                var currentCheckBox = s as CheckBox;

                var currentDevice = currentCheckBox.Tag as string;

                if (currentCheckBox.Checked)
                {
                    currentCheckBox.ForeColor = Color.OrangeRed;

                    baseAction.CheckSomeEquipments.Value.Add(currentDevice, currentCheckBox);
                }
                else
                {
                    currentCheckBox.ForeColor = Color.DarkGray;

                    baseAction.CheckSomeEquipments.Value.Remove(currentDevice);
                }

                // currentCheckBox.Checked = !currentCheckBox.Checked;
            };

            PictureBox _picBox = new PictureBox();

            _picBox.BackgroundImageLayout = ImageLayout.Stretch;
            _picBox.SizeMode          = PictureBoxSizeMode.StretchImage;
            _picBox.MouseDoubleClick += handler;
            _picBox.BackColor         = Color.Black;
            _picBox.Width             = _panel.Width - _marginH * 2;
            _picBox.Height            = _panel.Height - 95;
            _picBox.Location          = new Point(_marginH, _btn.Height + _btn.Location.Y);

            FlowLayoutPanel fp = new FlowLayoutPanel();

            fp.Height   = 30;
            fp.Width    = _panel.Width - _marginH * 2;
            fp.Location = new Point(_marginH, _picBox.Height + _picBox.Location.Y);
            fp.Parent   = _panel;
            SingleEquipmentAction(fp);
            fp.Name = string.Format("{0}_{1}", model.NickName, model.Device);

            _panel.Controls.Add(_picBox);

            _panel.Controls.Add(fp);

            //_panel.Controls.Add(_checkBox);

            baseAction.SetContentWithCurrentThread <Control>(this.flowLayoutPanel3, _panel, (parent, panel) =>
            {
                if (string.IsNullOrEmpty(GetPictureByName(parent, panel.Name).Name))
                {
                    parent.Controls.Add(panel);
                }
            });


            if (!baseAction.Dic.Value.Keys.Contains(model.Device))
            {
                baseAction.Dic.Value.Add(model.Device, _panel);
            }


            return(_panel);
        }
Esempio n. 6
0
        protected void ShowCheckBoxWithEquipmentList(Control parentControl, IList <DeviceToNickNameViewModel> list, DeviceToNickNameViewModel viewModel)
        {
            if (null == list || list.Count == 0)
            {
                return;
            }

            list.ToList().ForEach(o =>
            {
                baseAction.SetContentWithCurrentThread <DeviceToNickNameViewModel>(parentControl, o, (control, device) =>
                {
                    CheckBox _checkBox = new CheckBox();

                    var text = device.NickName;

                    Action <CheckBox> action = (p) =>
                    {
                        var currendBox = p as CheckBox;

                        currendBox.Font = new Font(currendBox.Font, currendBox.Font.Style | FontStyle.Bold);

                        currendBox.ForeColor = Color.Black;
                    };

                    if (!string.IsNullOrEmpty(device.GroupName))
                    {
                        text = string.Format("{0}({1})", device.NickName, device.GroupName);

                        if (device.GroupID == viewModel.GroupID && viewModel.GroupID > 0)
                        {
                            action(_checkBox);
                        }
                        else
                        {
                            _checkBox.ForeColor = Color.DarkGray;
                        }
                    }
                    else
                    {
                        _checkBox.ForeColor = Color.OrangeRed;
                    }

                    _checkBox.Text = text;

                    _checkBox.Name = device.Device;

                    _checkBox.TextAlign = ContentAlignment.MiddleLeft;

                    if (device.GroupID == viewModel.GroupID && viewModel.GroupID > 0)
                    {
                        _checkBox.Checked = true;
                    }

                    if (device.Device.Equals(viewModel.Device))
                    {
                        action(_checkBox);
                    }

                    control.Controls.Add(_checkBox);
                });
            });
        }