Exemple #1
0
        private void DevicesTitlebarButton_Click(object sender, MouseEventArgs e)
        {
            RefreshCurrentDevices();

            int controlSize = _frm.TitlebarHeight * 2;
            ModernForm frm = new ModernForm()
            {
                Sizable = false,
                ShowInTaskbar = false,
                BackColor = _frm.BackColor,
                ForeColor = _frm.ColorScheme.ForegroundColor,
                ColorScheme = _frm.ColorScheme,
                TitlebarVisible = false,
                MinimumSize = new Size(0, controlSize),
                Size = new Size(Width * 2, Math.Max(controlSize * CurrentConnections, controlSize) + 2)
            };

            //Hacky method to get this button rectangle on screen
            var rect = _frm.RectangleToScreen(_frm.TitlebarButtonsRectangle);
            rect.Width = rect.Width - (rect.Width - Width);
            frm.Location = new Point(rect.Right - frm.Width, rect.Bottom);
            frm.Deactivate += (s, ee) => frm.Dispose();
            Size controlFinalSize = new Size(frm.DisplayRectangle.Width, controlSize);

            //Load devices
            foreach (var device in DevicePersistManager.PersistedDevices) {
                try {

                    var ctrl = new DeckDeviceInformationControl()
                    {
                        DeckDevice = device,
                        Size = controlFinalSize,
                        ForeColor = _frm.ColorScheme.SecondaryColor,
                        Dock = DockStyle.Top,
                        Tag = _frm
                    };
                    frm.Controls.Add(ctrl);
                } catch (Exception) {
                    continue;
                }
            }

            frm.Show();
        }
        private void DevicesTitlebarButton_Click(object sender, MouseEventArgs e)
        {
            RefreshCurrentDevices();

            int controlSize = _frm.TitlebarHeight * 2;

            System.Drawing.Size result;
            if (Initilizator.mode == 0)
            {
                result = new Size(Width * 2, Math.Max(controlSize * CurrentConnections, controlSize) + 2);
            }
            else
            {
                var list = Program.device_list;
                result = new Size(Width * 2, Math.Max(controlSize * list.Count, controlSize) + 2);
            }

            ModernForm frm = new ModernForm()
            {
                Sizable         = false,
                ShowInTaskbar   = false,
                BackColor       = _frm.BackColor,
                ForeColor       = _frm.ColorScheme.ForegroundColor,
                ColorScheme     = _frm.ColorScheme,
                TitlebarVisible = false,
                MinimumSize     = new Size(0, controlSize),

                Size = result
            };

            //Hacky method to get this button rectangle on screen
            var rect = _frm.RectangleToScreen(_frm.TitlebarButtonsRectangle);

            rect.Width      = rect.Width - (rect.Width - Width);
            frm.Location    = new Point(rect.Right - frm.Width, rect.Bottom);
            frm.Deactivate += (s, ee) => frm.Dispose();
            Size controlFinalSize = new Size(frm.DisplayRectangle.Width, controlSize);

            if (Program.mode == 0)
            {
                //Load devices
                foreach (var device in DevicePersistManager.PersistedDevices)
                {
                    try
                    {
                        var ctrl = new DeckDeviceInformationControl()
                        {
                            DeckDevice = device,
                            Size       = controlFinalSize,
                            ForeColor  = _frm.ColorScheme.SecondaryColor,
                            Dock       = DockStyle.Top,
                            Tag        = _frm
                        };

                        frm.Controls.Add(ctrl);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }
            else
            {
                //  var devices = AdbClient.Instance.GetDevices();

                foreach (DeviceData device in Program.device_list)
                {
                    //  Debug.WriteLine("adicionando " + device.Model);
                    try
                    {
                        var ttt = new DeckDeviceInformationControl()
                        {
                            DeckUsb   = device,
                            Size      = controlFinalSize,
                            ForeColor = _frm.ColorScheme.SecondaryColor,
                            Dock      = DockStyle.Top,
                            Tag       = _frm
                        };
                        frm.Controls.Add(ttt);
                    }
                    catch (Exception ee)
                    {
                        Debug.WriteLine(ee);
                        continue;
                    }
                }
            }

            frm.Show();
        }