public void FlowLayoutPanelAccessibilityObject_Ctor_Default()
        {
            using FlowLayoutPanel flowLayoutPanel = new FlowLayoutPanel();
            flowLayoutPanel.CreateControl();

            Assert.NotNull(flowLayoutPanel.AccessibilityObject);
            Assert.True(flowLayoutPanel.IsHandleCreated);
        }
        public void FlowLayoutPanelAccessibilityObject_Role_IsClient_ByDefault()
        {
            using FlowLayoutPanel flowLayoutPanel = new FlowLayoutPanel();
            flowLayoutPanel.CreateControl();
            // AccessibleRole is not set = Default

            AccessibleRole actual = flowLayoutPanel.AccessibilityObject.Role;

            Assert.Equal(AccessibleRole.Client, actual);
            Assert.True(flowLayoutPanel.IsHandleCreated);
        }
        public void FlowLayoutPanelAccessibilityObject_ControlType_IsPane_IfAccessibleRoleIsDefault()
        {
            using FlowLayoutPanel flowLayoutPanel = new FlowLayoutPanel();
            flowLayoutPanel.CreateControl();
            // AccessibleRole is not set = Default

            object actual = flowLayoutPanel.AccessibilityObject.GetPropertyValue(UiaCore.UIA.ControlTypePropertyId);

            Assert.Equal(UiaCore.UIA.PaneControlTypeId, actual);
            Assert.True(flowLayoutPanel.IsHandleCreated);
        }
Beispiel #4
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            timer.Enabled = false;
            var sb = new StringBuilder();

            void PrintDpiAwareness(Control control)
            {
                sb.AppendFormat("{0} DPI Awareness: {1}", control.Name, Utility.GetAwarenessFromDpiAwarenessContext(control.Handle.GetDpiAwarenessContext()));
                sb.AppendLine();
            }

            void PrintParent(Control control)
            {
                sb.AppendFormat("{0} managed parent: {1}", control.Name, control.Parent);
                sb.AppendLine();
                var pp = Utility.GetParent(control.Handle);

                sb.AppendFormat("{0} GetParent(): {1:X} ({2})", control.Name, pp, Utility.TextFromHandle(pp));
                sb.AppendLine();
            }

            sb.AppendLine("Process DPI Awareness: " + DpiAwareness.ProcessDpiAwarenessContext);
            PrintDpiAwareness(this);
            PrintDpiAwareness(textBox1);
            var oldAwareness = Utility.SetThreadDpiAwarenessContext(new IntPtr((int)DpiAwarenessContext.SystemAware));

            Trace.Assert(oldAwareness != IntPtr.Zero);
            FlowLayoutPanel panel1;

            try
            {
                panel1 = new FlowLayoutPanel
                {
                    Name        = "panel1",
                    BackColor   = Color.Blue,
                    Location    = new Point(20, 20),
                    Size        = new Size(300, 300),
                    BorderStyle = BorderStyle.FixedSingle
                };
                panel1.CreateControl();
            }
            finally
            {
                Utility.SetThreadDpiAwarenessContext(oldAwareness);
            }
            PrintDpiAwareness(panel1);
            PrintParent(panel1);
            sb.AppendLine("Set panel1 parent.");
            this.Controls.Add(panel1);
            PrintParent(panel1);
            textBox1.Text = sb.ToString();
        }
Beispiel #5
0
        /// <summary>
        /// Creates a panel contains the warning message for accounts not in training.
        /// </summary>
        /// <param name="warningMessage"></param>
        /// <returns></returns>
        private static FlowLayoutPanel CreateAccountsNotTrainingPanel(string warningMessage)
        {
            // Create a flowlayout to hold the content
            FlowLayoutPanel warningPanel;
            FlowLayoutPanel tempWarningPanel = null;

            try
            {
                tempWarningPanel = new FlowLayoutPanel
                {
                    AutoSize     = true,
                    AutoSizeMode = AutoSizeMode.GrowAndShrink,
                    Margin       = new Padding(0, 0, 0, 2)
                };

                // Add a picture on the left with a warning icon
                if (!Settings.UI.SafeForWork)
                {
                    int portraitSize = Int32.Parse(Settings.UI.SystemTrayPopup.PortraitSize.ToString().Substring(1),
                                                   CultureConstants.InvariantCulture);

                    PictureBox tempPictureBoxWarning = null;
                    try
                    {
                        tempPictureBoxWarning          = new PictureBox();
                        tempPictureBoxWarning.Image    = SystemIcons.Warning.ToBitmap();
                        tempPictureBoxWarning.SizeMode = PictureBoxSizeMode.StretchImage;
                        tempPictureBoxWarning.Size     = new Size(portraitSize, portraitSize);
                        tempPictureBoxWarning.Margin   = new Padding(2);

                        PictureBox pbWarning = tempPictureBoxWarning;
                        tempPictureBoxWarning = null;

                        tempWarningPanel.Controls.Add(pbWarning);
                    }
                    finally
                    {
                        tempPictureBoxWarning?.Dispose();
                    }
                }

                // Adds a label to hold the message
                Label tempLabelMessage = null;
                try
                {
                    tempLabelMessage = new Label
                    {
                        AutoSize = true,
                        Text     = warningMessage
                    };

                    Label lblMessage = tempLabelMessage;
                    tempLabelMessage = null;

                    tempWarningPanel.Controls.Add(lblMessage);
                }
                finally
                {
                    tempLabelMessage?.Dispose();
                }

                tempWarningPanel.CreateControl();

                warningPanel     = tempWarningPanel;
                tempWarningPanel = null;
            }
            finally
            {
                tempWarningPanel?.Dispose();
            }

            return(warningPanel);
        }
Beispiel #6
0
        /// <summary>
        /// Performs the custom layout.
        /// </summary>
        private void PerformCustomLayout()
        {
            // Remove controls and dispose them
            IEnumerable <Control> oldControls = MainFlowLayoutPanel.Controls.Cast <Control>().ToList();

            MainFlowLayoutPanel.Controls.Clear();
            foreach (Control ctl in oldControls)
            {
                ctl.Dispose();
            }

            IEnumerable <Character> characters = GetCharacters;

            // Add controls for characters
            if (Settings.UI.SystemTrayPopup.GroupBy == TrayPopupGrouping.Account &&
                Settings.UI.SystemTrayPopup.IndentGroupedAccounts)
            {
                List <ESIKey> prevAPIKeys = new List <ESIKey>();
                foreach (Character character in characters)
                {
                    OverviewItem  charPanel = GetOverviewItem(character);
                    List <ESIKey> apiKeys   = character.Identity.ESIKeys.ToList();

                    if (!apiKeys.Exists(apiKey => prevAPIKeys.Contains(apiKey)))
                    {
                        MainFlowLayoutPanel.Controls.Add(charPanel);
                        prevAPIKeys = apiKeys;
                    }
                    else
                    {
                        FlowLayoutPanel tempAccountGroupPanel = null;
                        try
                        {
                            tempAccountGroupPanel = new FlowLayoutPanel();
                            tempAccountGroupPanel.Controls.Add(charPanel);
                            tempAccountGroupPanel.AutoSize      = true;
                            tempAccountGroupPanel.AutoSizeMode  = AutoSizeMode.GrowAndShrink;
                            tempAccountGroupPanel.FlowDirection = FlowDirection.TopDown;
                            tempAccountGroupPanel.Padding       = new Padding(10, 0, 0, 0);

                            tempAccountGroupPanel.CreateControl();

                            FlowLayoutPanel accountGroupPanel = tempAccountGroupPanel;
                            tempAccountGroupPanel = null;

                            MainFlowLayoutPanel.Controls.Add(accountGroupPanel);
                        }
                        finally
                        {
                            tempAccountGroupPanel?.Dispose();
                        }

                        prevAPIKeys = apiKeys;
                    }
                }
            }
            else
            {
                MainFlowLayoutPanel.Controls.AddRange(characters.Select(GetOverviewItem).ToArray <Control>());
            }
        }