Exemplo n.º 1
0
        /// <summary>
        /// 点击某一项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void ucs_Click(object sender, EventArgs e)
        {
            UCDevicesState uc   = (UCDevicesState)sender;
            MouseEventArgs args = (MouseEventArgs)e;
            IDevices       dev  = (IDevices)uc.Tag;

            if (selectedUCDev != null)
            {
                selectedUCDev.Select(false);
            }
            uc.Select(true);
            SelectedUCDev = uc;
            this.Device   = dev;
            if (args.Button == MouseButtons.Right)
            {
                contextMenuStrip1.Show(uc.PointToScreen(args.Location));
            }
            else
            {
                if (IsSelectedCloseFrom)
                {
                    this.DialogResult = DialogResult.OK;
                }
            }
        }
Exemplo n.º 2
0
        private void FormSelectDev_Load(object sender, EventArgs e)
        {
            List <IDevices> devs = DevicesCollection.Devices;

            if (devs != null)
            {
                int index = 0;
                foreach (var item in devs)
                {
                    UCDevicesState ucs = new UCDevicesState(item);
                    ucs.Tag      = item;
                    ucs.Location = new Point((index % 5) + 12 + ((index % 5) * 130), (index / 5) + 12 + ((index / 5) * 188));
                    ucs.Click   += ucs_Click;
                    this.panel1.Controls.Add(ucs);
                    index++;
                }
            }
        }