public void ItemSizeTest()
        {
            TabControl tc = new TabControl();

            Assert.AreEqual(Size.Empty, tc.ItemSize, "#A0");

            tc.CreateControl();
            Assert.IsTrue(tc.ItemSize.Width == 0, "#B0");
            Assert.IsTrue(tc.ItemSize.Height > 0, "#B1");

            tc.TabPages.Add("A");
            Assert.IsTrue(tc.ItemSize.Width > 0, "#C0");
            Assert.IsTrue(tc.ItemSize.Height > 0, "#C1");

            // ItemSize.Height can change, depending on Font
            Size prev_size = tc.ItemSize;

            tc.Font = new Font(tc.Font.FontFamily, tc.Font.Height * 2);
            Assert.IsTrue(tc.ItemSize.Height > prev_size.Height, "#D0");

            // Images can cause a change as well
            prev_size = tc.ItemSize;
            ImageList image_list = new ImageList();

            image_list.ImageSize = new Size(image_list.ImageSize.Width, tc.Font.Height * 2);
            tc.ImageList         = image_list;
            Assert.IsTrue(tc.ItemSize.Height > prev_size.Height, "#E0");
        }
Beispiel #2
0
        public void TabControlAccessibilityObject_Ctor_Default()
        {
            using TabControl tabControl = new TabControl();
            tabControl.CreateControl();

            Assert.NotNull(tabControl.AccessibilityObject);
            Assert.True(tabControl.IsHandleCreated);
        }
        private static TabControl AddPluginTabContainer()
        {
            if (m_of == null)
            {
                PluginDebug.AddError("Could not identify KeePass options form", 0);
                return(null);
            }
            TabControl tcMain = Tools.GetControl("m_tabMain", m_of) as TabControl;

            if (tcMain == null)
            {
                PluginDebug.AddError("Could not locate m_tabMain", 0);
                return(null);
            }
            TabPage    tPlugins  = null;
            TabControl tcPlugins = null;

            if (tcMain.TabPages.ContainsKey(c_tabRookiestyle))
            {
                tPlugins  = tcMain.TabPages[c_tabRookiestyle];
                tcPlugins = (TabControl)tPlugins.Controls[c_tabControlRookiestyle];
                if (tcPlugins == null)
                {
                    PluginDebug.AddError("Could not locate " + c_tabControlRookiestyle, 0);
                    return(null);
                }
                tcPlugins.Multiline = false;                 //Older version of PluginTools might still be used by other plugins
                PluginDebug.AddInfo("Found " + c_tabControlRookiestyle, 0);
                return(tcPlugins);
            }
            tPlugins      = new TabPage(KeePass.Resources.KPRes.Plugin + " " + m_of.Text);
            tPlugins.Name = c_tabRookiestyle;
            tPlugins.CreateControl();
            if (!OptionsEnabled)
            {
                while (tcMain.TabCount > 0)
                {
                    tcMain.TabPages.RemoveAt(0);
                }
                PluginDebug.AddInfo("Removed tab pages from KeePass options form", 0);
            }
            tcMain.TabPages.Add(tPlugins);
            tcPlugins           = new TabControl();
            tcPlugins.Name      = c_tabControlRookiestyle;
            tcPlugins.Dock      = DockStyle.Fill;
            tcPlugins.Multiline = false;
            tcPlugins.CreateControl();
            if (tcPlugins.ImageList == null)
            {
                tcPlugins.ImageList = new ImageList();
            }
            tPlugins.Controls.Add(tcPlugins);
            PluginDebug.AddInfo("Added " + c_tabControlRookiestyle, 0);
            return(tcPlugins);
        }
Beispiel #4
0
        public void TabControlAccessibilityObject_Role_IsPageTabList_ByDefault()
        {
            using TabControl tabControl = new TabControl();
            tabControl.CreateControl();
            // AccessibleRole is not set = Default

            AccessibleRole actual = tabControl.AccessibilityObject.Role;

            Assert.Equal(AccessibleRole.PageTabList, actual);
            Assert.True(tabControl.IsHandleCreated);
        }
Beispiel #5
0
        public void TabControlAccessibilityObject_ControlType_IsTabControl_IfAccessibleRoleIsDefault()
        {
            using TabControl tabControl = new TabControl();
            tabControl.CreateControl();
            // AccessibleRole is not set = Default

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

            Assert.Equal(UiaCore.UIA.TabControlTypeId, actual);
            Assert.True(tabControl.IsHandleCreated);
        }
        public void ItemSizeTestPadding()
        {
            TabControl tc = new TabControl();

            tc.TabPages.Add("One");          // Need to add a page to force to calc the width
            tc.CreateControl();              // And create the control as well

            Assert.IsTrue(tc.ItemSize != Size.Empty, "#A0");

            Size item_size = tc.ItemSize;

            tc.Padding = new Point(tc.Padding.X * 2, tc.Padding.Y * 2);

            Assert.IsTrue(tc.ItemSize.Height > item_size.Height, "#B0");
            Assert.IsTrue(tc.ItemSize.Width > item_size.Width, "#B1");
        }
        public void ItemSizeFixedTest()
        {
            TabControl tc = new TabControl();

            tc.SizeMode = TabSizeMode.Fixed;
            Assert.AreEqual(Size.Empty, tc.ItemSize, "#A0");

            tc.CreateControl();
            Assert.IsTrue(tc.ItemSize.Width == 0, "#B0");
            Assert.IsTrue(tc.ItemSize.Height > 0, "#B1");

            tc.TabPages.Add("A");
            Assert.IsTrue(tc.ItemSize.Width == 96, "#C0");
            Assert.IsTrue(tc.ItemSize.Width > 0, "#C1");

            // Height can change automatically depending on Font,
            // but not Width
            Size prev_size = tc.ItemSize;

            tc.Font = new Font(tc.Font.FontFamily, tc.Font.Height * 2);
            Assert.IsTrue(tc.ItemSize.Width == 96, "#D0");
            Assert.IsTrue(tc.ItemSize.Height > prev_size.Height, "#D1");

            // Manually set ItemSize
            tc.ItemSize = new Size(100, 35);
            Assert.AreEqual(100, tc.ItemSize.Width, "#E0");
            Assert.AreEqual(35, tc.ItemSize.Height, "#E1");

            // Font size is decreased, but since we manually set
            // the size we can't automatically update it.
            tc.Font = new Font(tc.Font.FontFamily, tc.Font.Height / 2);
            Assert.AreEqual(100, tc.ItemSize.Width, "#F0");
            Assert.AreEqual(35, tc.ItemSize.Height, "#F1");

            // Manually set even if control has not been created.
            tc          = new TabControl();
            tc.SizeMode = TabSizeMode.Fixed;
            tc.ItemSize = new Size(100, 35);
            Assert.AreEqual(100, tc.ItemSize.Width, "#G0");
            Assert.AreEqual(35, tc.ItemSize.Height, "#G1");
        }
Beispiel #8
0
        private static TabControl AddPluginTabContainer()
        {
            TabControl tcMain    = Tools.GetControl("m_tabMain", m_of) as TabControl;
            TabPage    tPlugins  = null;
            TabControl tcPlugins = null;

            if (tcMain.TabPages.ContainsKey(c_tabRookiestyle))
            {
                tPlugins            = tcMain.TabPages[c_tabRookiestyle];
                tcPlugins           = (TabControl)tPlugins.Controls[c_tabControlRookiestyle];
                tcPlugins.Multiline = false;                 //Older version of PluginTools might still be used by other plugins
                return(tcPlugins);
            }
            tPlugins      = new TabPage(KeePass.Resources.KPRes.Plugin + " " + m_of.Text);
            tPlugins.Name = c_tabRookiestyle;
            tPlugins.CreateControl();
            if (!OptionsEnabled)
            {
                while (tcMain.TabCount > 0)
                {
                    tcMain.TabPages.RemoveAt(0);
                }
            }
            tcMain.TabPages.Add(tPlugins);
            tcPlugins           = new TabControl();
            tcPlugins.Name      = c_tabControlRookiestyle;
            tcPlugins.Dock      = DockStyle.Fill;
            tcPlugins.Multiline = false;
            tcPlugins.CreateControl();
            if (tcPlugins.ImageList == null)
            {
                tcPlugins.ImageList = new ImageList();
            }
            tPlugins.Controls.Add(tcPlugins);
            return(tcPlugins);
        }