Beispiel #1
0
        ///<summary>
        /// This function defines what a "stable" state is -- meaning that if the pnlCollapsible is
        /// stable, then there should not be any chance of a runtime error (except for the case of the usercontrolnamespace
        /// string being wrong. That cannot be be checked correctly before runtime).
        ///</summary>
        void assertIsStable2(TPnlCollapsible APnl)
        {
            APnl.AssertDirStyleMatch();
            APnl.AssertHckDataMatch();

            Assert.AreNotEqual(null, APnl.TaskListNode); //required because expand() may be called at any moment, and it will throw an error if TaskListNode is null. So we require it's existance at all times.
        }
        private void OnItemActivation(TTaskList ATaskList, XmlNode ATaskListNode, LinkLabel AItemClicked)
        {
            TTaskList       FoundTaskList;
            TPnlCollapsible CollPanel;

            if (FOnlyOneActiveTaskOnAllCollapsiblePanelsTaskLists)
            {
                // Remove the Active Task Item from any Collapsible Panel's TaskList that
                // isn't the sending instance (that is passed in in ATaskList) as we only
                // want *one* Active Task Item in one hosted Collapsible Panel!
                for (int Counter = 0; Counter < FCollPanelCount; Counter++)
                {
                    CollPanel     = GetCollapsiblePanelInstance(Counter);
                    FoundTaskList = CollPanel.TaskListInstance;

                    if (FoundTaskList != ATaskList)
                    {
                        FoundTaskList.ActiveTaskItem = null;
                    }
                }
            }

            FCollPanelWhereLastItemActivationHappened = GetCollapsiblePanelInstance(ATaskListNode.ParentNode);

            // Re-fire Event
            if (ItemActivation != null)
            {
                ItemActivation(ATaskList, ATaskListNode, AItemClicked, GetCollapsiblePanelInstance(0));
            }
        }
Beispiel #3
0
        private void TestEmptyConstructor(object sender, EventArgs e)
        {
            this.Controls.Remove(this.FPnl);

            this.FPnl      = new TPnlCollapsible();
            this.FPnl.Text = "&With empty constructor";
            this.Controls.Add(this.FPnl);
        }
Beispiel #4
0
    private void TestEmptyConstructor(object sender, EventArgs e)
    {
        this.Controls.Remove(this.FPnl);

        this.FPnl = new TPnlCollapsible();
        this.FPnl.Text = "&With empty constructor";
        this.Controls.Add(this.FPnl);
    }
Beispiel #5
0
        private void TestStacked(object sender, EventArgs e)
        {
            this.Controls.Remove(this.FPnl);
            this.Controls.Remove(this.FPnl2);

            this.FPnl  = new TPnlCollapsible();
            this.FPnl2 = new TPnlCollapsible();
            this.Controls.Add(this.FPnl);
            this.Controls.Add(this.FPnl2);
        }
Beispiel #6
0
        private void TestTaskListVerticalConstructor(object sender, EventArgs e)
        {
            this.Controls.Remove(this.FPnl);

            this.FPnl      = new TPnlCollapsible(THostedControlKind.hckTaskList, FTestYAMLNode, TCollapseDirection.cdVertical, 10, false, FEnumStyle);
            this.FPnl.Text = "&Tasks";
            this.Controls.Add(this.FPnl);

            HookupItemActivationEvent();
        }
Beispiel #7
0
    private void TestTaskListVerticalConstructor(object sender, EventArgs e)
    {
        this.Controls.Remove(this.FPnl);

        this.FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, FTestYAMLNode, TCollapseDirection.cdVertical, 10, false, FEnumStyle);
        this.FPnl.Text = "&Tasks";
        this.Controls.Add(this.FPnl);

        HookupItemActivationEvent();
    }
Beispiel #8
0
        private void TestTaskListHorizontalConstructor(object sender, EventArgs e)
        {
            this.Controls.Remove(this.FPnl);

            this.FPnl             = new TPnlCollapsible(THostedControlKind.hckTaskList, FTestYAMLNode, TCollapseDirection.cdHorizontal, 183, false, FEnumStyle);
            this.FPnl.BorderStyle = BorderStyle.FixedSingle;
            this.FPnl.Text        = "&Finance";
            this.Controls.Add(this.FPnl);

            HookupItemActivationEvent();
        }
        /// <summary>
        /// Returns a TaskList Instance.
        /// </summary>
        /// <param name="ANumber">Corresponds with the order of the Collapsible Panels that represent
        /// XmlNodes which host the corresponding Task List instance (Range 0..n, 0 being the Collapsible Panel
        /// that matches the first XmlNode).</param>
        /// <returns>TaskList Instance that corresponds with <paramref name="ANumber" />.</returns>
        public TTaskList GetTaskListInstance(int ANumber)
        {
            TPnlCollapsible CollPanelInstance = GetCollapsiblePanelInstance(ANumber);

            if (CollPanelInstance != null)
            {
                return(CollPanelInstance.TaskListInstance);
            }
            else
            {
                return(null);
            }
        }
Beispiel #10
0
        private void TestFullConstructor(object sender, EventArgs e)
        {
            this.Controls.Remove(this.FPnl);

            this.FPnl = new TPnlCollapsible(FTestYAMLNode,
                                            THostedControlKind.hckUserControl,
                                            "Foo.Bar",
                                            FEnumStyle,
                                            TCollapseDirection.cdHorizontal,
                                            true);
            this.FPnl.Text = "&With full constructor";
            this.Controls.Add(this.FPnl);
        }
Beispiel #11
0
        private void TestUserControlVerticalConstructor(object sender, EventArgs e)
        {
            this.Controls.Remove(this.FPnl);

            this.FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl,
                                            "Ict.Petra.Client.MPartner.Gui.TUC_PartnerInfo",
                                            TCollapseDirection.cdVertical,
                                            false,
                                            FEnumStyle);
            this.FPnl.Text = "&Partner Info";
            this.FPnl.InitUserControl();

            this.Controls.Add(this.FPnl);
        }
Beispiel #12
0
        void TestTaskListHorizontalRightConstructor(object sender, System.EventArgs e)
        {
            this.Controls.Remove(this.FPnl);

            this.FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl,
                                            "Ict.Petra.Client.MPartner.Gui.TUC_PartnerInfo",
                                            TCollapseDirection.cdHorizontalRight,
                                            250,
                                            false,
                                            FEnumStyle);
            this.FPnl.BorderStyle = BorderStyle.FixedSingle;
            this.FPnl.Text        = "&To-Do Bar";
            this.Controls.Add(this.FPnl);
        }
Beispiel #13
0
        /// <summary>
        /// Returns the Collapsible Panel for a TaskList Instance.
        /// </summary>
        /// <param name="AChildNode">The XmlNode that the Collapsible Panel represents.</param>
        /// <returns>Collapsible Panel that corresponds with <paramref name="AChildNode" />.</returns>
        public TPnlCollapsible GetCollapsiblePanelInstance(XmlNode AChildNode)
        {
            TPnlCollapsible ReturnValue = null;

            foreach (Control WrapperPanel in this.Controls)
            {
                if (WrapperPanel.Tag == AChildNode)
                {
                    ReturnValue = (TPnlCollapsible)WrapperPanel.Controls[0];
                    break;
                }
            }

            return(ReturnValue);
        }
Beispiel #14
0
    private void TestFullConstructor(object sender, EventArgs e)
    {
        this.Controls.Remove(this.FPnl);

        this.FPnl = new TPnlCollapsible(FTestYAMLNode,
            THostedControlKind.hckUserControl,
            "Foo.Bar",
            FEnumStyle,
            TCollapseDirection.cdHorizontal,
            true);
        this.FPnl.Text = "&With full constructor";
        this.Controls.Add(this.FPnl);
    }
Beispiel #15
0
        public void TestSetter_TaskListInstance()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, TTestTaskList.GetTestXmlNode());
            FPnl.RealiseTaskListNow();

            TTaskList TLst1 = FPnl.TaskListInstance;
            int ExpandedSize = FPnl.ExpandedSize;

            TTaskList TLst2 = new TTaskList(TTestTaskList.GetTestXmlNode2());

            FPnl.TaskListInstance = TLst2;

            Assert.AreNotEqual(TLst1, FPnl.TaskListInstance, "FPnl.TaskListInstance");

            Assert.AreNotEqual(ExpandedSize, FPnl.ExpandedSize, "ExpandedSize");

            assertIsStable2(FPnl);
        }
Beispiel #16
0
    void TestTaskListHorizontalRightConstructor(object sender, System.EventArgs e)
    {
        this.Controls.Remove(this.FPnl);

        this.FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl,
            "Ict.Petra.Client.MPartner.Gui.TUC_PartnerInfo",
            TCollapseDirection.cdHorizontalRight,
            250,
            false,
            FEnumStyle);
        this.FPnl.BorderStyle = BorderStyle.FixedSingle;
        this.FPnl.Text = "&To-Do Bar";
        this.Controls.Add(this.FPnl);
    }
Beispiel #17
0
        public void TestDirStyleMismatch()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL);

            try
            {
                FPnl.AssertDirStyleMatch(TCollapseDirection.cdHorizontal, TVisualStylesEnum.vsTaskPanel);
            }
            catch (Exception e)
            {
                Assert.AreEqual(typeof(EVisualStyleAndDirectionMismatchException), e.GetType());
            }
        }
Beispiel #18
0
        public void TestSetter_UserControlClass_UserControlNamespace_UserControlString()
        {
            // Changing of UserControl after realising a first UserControl specified through Constructor
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL);
            FPnl.RealiseUserControlNow();

            UserControl UC1 = FPnl.UserControlInstance;

            FPnl.UserControlClass = "TUC_Subscription";
            FPnl.UserControlNamespace = "Ict.Petra.Client.MPartner.Gui";
            FPnl.RealiseUserControlNow();

            Assert.AreNotEqual(UC1, FPnl.UserControlInstance);
            Assert.IsInstanceOf <Ict.Petra.Client.MPartner.Gui.TUC_Subscription>(FPnl.UserControlInstance);

            // Assigning of UserControl with UserControlClass and UserControlNamespace Properties
            FPnl = new TPnlCollapsible(new object[] { });
            FPnl.UserControlClass = "TUC_Subscription";
            FPnl.UserControlNamespace = "Ict.Petra.Client.MPartner.Gui";
            FPnl.RealiseUserControlNow();

            Assert.IsInstanceOf <Ict.Petra.Client.MPartner.Gui.TUC_Subscription>(FPnl.UserControlInstance);


            // Assigning of UserControl with UserControlString Property
            FPnl = new TPnlCollapsible(new object[] { });
            FPnl.UserControlString = "Ict.Petra.Client.MPartner.Gui.TUC_Subscription";

            // Calling Expand() has the side effect of instantiating the UserControl
            FPnl.Expand();

            UserControl UC2 = FPnl.UserControlInstance;
            Assert.IsInstanceOf <Ict.Petra.Client.MPartner.Gui.TUC_Subscription>(UC2);

            // Assures that a further call only makes a previously instantiated UserControl visible again
            FPnl.Expand();
            Assert.AreEqual(UC2, FPnl.UserControlInstance);
        }
Beispiel #19
0
 public void TestConstructorWinFormsDesigner()
 {
     // To ensure Unit Test code coverage only - nothing to assert here...
     FPnl = new TPnlCollapsible();
 }
Beispiel #20
0
    private void TestTaskListHorizontalConstructor(object sender, EventArgs e)
    {
        this.Controls.Remove(this.FPnl);

        this.FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, FTestYAMLNode, TCollapseDirection.cdHorizontal, 183, false, FEnumStyle);
        this.FPnl.BorderStyle = BorderStyle.FixedSingle;
        this.FPnl.Text = "&Finance";
        this.Controls.Add(this.FPnl);

        HookupItemActivationEvent();
    }
Beispiel #21
0
        public void TestConstructorMultipleSameArguments()
        {
            // when given multiple arguments of same type, simply use the latest.
            FPnl = new TPnlCollapsible("first.control.given", "System.Console.Write");
            Assert.AreEqual("System.Console", FPnl.UserControlNamespace);
            Assert.AreEqual("Write", FPnl.UserControlClass);
            Assert.AreEqual("System.Console.Write", FPnl.UserControlString);

            assertIsStable(FPnl);
        }
Beispiel #22
0
        public void TestLazyInitialisation()
        {
            // UserControl
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL);
            Assert.AreEqual(null, FPnl.UserControlInstance);    // Lazy initialisation!
            Assert.AreEqual(null, FPnl.TaskListInstance);
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);

            assertIsStable(FPnl);

            FPnl.Expand();
            Assert.AreNotEqual(null, FPnl.UserControlInstance); // Now initialised as Expand() got called
            Assert.AreEqual(null, FPnl.TaskListInstance);
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);

            assertIsStable(FPnl);
            FPnl.Collapse();
            assertIsStable(FPnl);

            // TaskList
            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, TTestTaskList.GetTestXmlNode());
            Assert.AreEqual(null, FPnl.TaskListInstance);  // Lazy initialisation!

            assertIsStable2(FPnl);

            FPnl.Expand();
            Assert.AreNotEqual(null, FPnl.TaskListInstance);     // Now initialised as Expand() got called
            Assert.AreEqual(null, FPnl.UserControlInstance);
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);

            assertIsStable2(FPnl);
            FPnl.Collapse();
            assertIsStable2(FPnl);

            // CollapsiblePanelHoster
            FPnl = new TPnlCollapsible(THostedControlKind.hckCollapsiblePanelHoster, TTestTaskList.GetTestXmlNode());
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);  // Lazy initialisation!

            assertIsStable2(FPnl);

            FPnl.Expand();
            Assert.AreNotEqual(null, FPnl.CollapsiblePanelHosterInstance); // Now initialised as Expand() got called
            Assert.AreEqual(null, FPnl.UserControlInstance);
            Assert.AreEqual(null, FPnl.TaskListInstance);


            assertIsStable2(FPnl);
            FPnl.Collapse();
            assertIsStable2(FPnl);
        }
Beispiel #23
0
        public void TestLazyInitialisationCumulative()
        {
            // UserControl
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL);
            Assert.AreEqual(null, FPnl.UserControlInstance);    // Lazy initialisation!
            Assert.AreEqual(null, FPnl.TaskListInstance);
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);

            assertIsStable(FPnl);

            FPnl.Expand();
            Assert.AreNotEqual(null, FPnl.UserControlInstance); // Now initialised as Expand() got called
            Assert.AreEqual(null, FPnl.TaskListInstance);
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);

            FPnl.TaskListNode = TTestTaskList.GetTestXmlNode();
            Assert.AreEqual(null, FPnl.TaskListInstance);  // Lazy initialisation!

            // TaskList
            FPnl.HostedControlKind = THostedControlKind.hckTaskList;
            FPnl.Collapse();
            FPnl.Expand();
            Assert.AreNotEqual(null, FPnl.TaskListInstance);     // Now initialised as Expand() got called
            Assert.AreNotEqual(null, FPnl.UserControlInstance);  // This still exists from previous operation!
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);

            assertIsStable2(FPnl);

            // CollapsiblePanelHoster
            FPnl.HostedControlKind = THostedControlKind.hckCollapsiblePanelHoster;
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance); // Lazy initialisation!
            Assert.AreNotEqual(null, FPnl.TaskListInstance);  // This still exists from previous operation!
            Assert.AreNotEqual(null, FPnl.UserControlInstance);  // This still exists from previous operation!

            FPnl.Toggle(); // same as FPnl.Collapse(); above
            FPnl.Toggle(); // same as FPnl.Expand(); above
            Assert.AreNotEqual(null, FPnl.CollapsiblePanelHosterInstance);  // Now initialised as Expand() got called (trough Toggle())
            Assert.AreNotEqual(null, FPnl.TaskListInstance);  // This still exists from previous operation!
            Assert.AreNotEqual(null, FPnl.UserControlInstance);  // This still exists from previous operation!

            assertIsStable2(FPnl);
        }
        private void InstantiateCollapsiblePanels()
        {
            this.SuspendLayout();

            this.Controls.Clear();
            FCollPanelCount = 0;

            if (FMasterXmlNode == null)
            {
                throw new Exception("MasterXmlNode Property not set to an instance of XmlNode");
            }

            XmlNode TaskNode = FMasterXmlNode.FirstChild;

            //Iterate through all children nodes of the node
            while (TaskNode != null)
            {
                // Create a wrapper Panel. This is only needed to be able to set a distance between Collapsible Panels.
                Panel WrapperPanel = new Panel();
                WrapperPanel.AutoSize = true;
                WrapperPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                WrapperPanel.BackColor = Color.Transparent;
                WrapperPanel.Dock = DockStyle.Top;
                WrapperPanel.Padding = new Padding(0, 0, 0, FDistanceBetweenCollapsiblePanels);
                WrapperPanel.TabIndex = FCollPanelCount;
                WrapperPanel.Tag = TaskNode;
                WrapperPanel.Name = TaskNode.Name;

                // Create a Collapsible Panel
                TPnlCollapsible CollPanel = new TPnlCollapsible(THostedControlKind.hckTaskList,
                    TaskNode,
                    TCollapseDirection.cdVertical,
                    10,
                    false,
                    FVisualStyle);
                CollPanel.Tag = WrapperPanel;
                CollPanel.Name = TaskNode.Name;
                CollPanel.Text = TLstFolderNavigation.GetLabel(TaskNode);
                CollPanel.Dock = DockStyle.Top;
                CollPanel.TabIndex = 0;

                if ((TaskNode.Attributes["Visible"] != null)
                    && (TaskNode.Attributes["Visible"].Value.ToLower() == "false"))
                {
                    CollPanel.Visible = false;
                }

                if ((TaskNode.Attributes["Enabled"] != null)
                    && (TaskNode.Attributes["Enabled"].Value.ToLower() == "false"))
                {
                    CollPanel.Enabled = false;
                }
                else
                {
                    CollPanel.ItemActivation += delegate(TTaskList ATaskList, XmlNode ATaskListNode, LinkLabel AItemClicked, object AOtherData)
                    {
                        OnItemActivation(ATaskList, ATaskListNode, AItemClicked);
                    };
                }

                WrapperPanel.Height = CollPanel.ExpandedSize + FDistanceBetweenCollapsiblePanels;
                WrapperPanel.Controls.Add(CollPanel);
                this.Controls.Add(WrapperPanel);

                // Make sure the Collapsible Panels' Wrapper Panels are shown in correct order and not in reverse order.
                // (This is needed because we 'stack them up' with '.Controls.Dock = DockStyle.Top')
                WrapperPanel.BringToFront();

                TaskNode = TaskNode.NextSibling;

                FCollPanelCount++;
            }

            this.ResumeLayout();
        }
Beispiel #25
0
        public void TestExpandAdditionalCodeCoverage()
        {
            // UserControl
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL);
            FPnl.Expand();

            FPnl.HostedControlKind = THostedControlKind.hckTaskList;
            FPnl.TaskListNode = TTestTaskList.GetTestXmlNode();

            FPnl.Expand();

            FPnl.HostedControlKind = THostedControlKind.hckCollapsiblePanelHoster;
            FPnl.Expand();

            FPnl.HostedControlKind = THostedControlKind.hckTaskList;
            FPnl.Expand();

            FPnl.HostedControlKind = THostedControlKind.hckUserControl;
            FPnl.Expand();
        }
Beispiel #26
0
        public void TestToggleDirection()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL, TCollapseDirection.cdVertical);
            Assert.AreEqual(TCollapseDirection.cdVertical, FPnl.CollapseDirection);

            FPnl.ToggleDirection();

            Assert.AreEqual(TCollapseDirection.cdHorizontal, FPnl.CollapseDirection);

            FPnl.ToggleDirection();

            Assert.AreEqual(TCollapseDirection.cdVertical, FPnl.CollapseDirection);
        }
Beispiel #27
0
        public void TestHckDataMismatch()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl);

            try
            {
                FPnl.AssertHckDataMatch();
            }
            catch (Exception e)
            {
                Assert.AreEqual(typeof(EInsufficientDataSetForHostedControlKindException), e.GetType());
            }
        }
Beispiel #28
0
    private void TestStacked(object sender, EventArgs e)
    {
        this.Controls.Remove(this.FPnl);
        this.Controls.Remove(this.FPnl2);

        this.FPnl = new TPnlCollapsible();
        this.FPnl2 = new TPnlCollapsible();
        this.Controls.Add(this.FPnl);
        this.Controls.Add(this.FPnl2);
    }
Beispiel #29
0
        public void TestCollapsiblePanelHosterOtherTests()
        {
            // Ensure ENoTaskListNodeSpecifiedException is thrown if no TaskListNode got specified
            FPnl = new TPnlCollapsible(THostedControlKind.hckCollapsiblePanelHoster);

            try
            {
                FPnl.RealiseCollapsiblePanelHoster();
            }
            catch (Exception e)
            {
                Assert.AreEqual(typeof(ENoTaskListNodeSpecifiedException), e.GetType());
            }

            // To ensure Unit Test code coverage only - nothing to assert here...
            FPnl = new TPnlCollapsible(THostedControlKind.hckCollapsiblePanelHoster,
                TTestTaskList.GetTestXmlNode(), TCollapseDirection.cdHorizontalRight);
            FPnl.VisualStyleEnum = TVisualStylesEnum.vsHorizontalCollapse;

            FPnl.RealiseCollapsiblePanelHoster();

            // To ensure Unit Test code coverage only - nothing to assert here...
            FPnl.Expand();
        }
Beispiel #30
0
        public void TestSetter_CollapsiblePanelHosterInstance()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckCollapsiblePanelHoster, TTestTaskList.GetTestXmlNode());
            FPnl.RealiseCollapsiblePanelHoster();

            TPnlCollapsibleHoster CpH1 = FPnl.CollapsiblePanelHosterInstance;

            TPnlCollapsibleHoster CpH2 = new TPnlCollapsibleHoster(TTestTaskList.GetTestXmlNode2(), TVisualStylesEnum.vsTaskPanel);

            FPnl.CollapsiblePanelHosterInstance = CpH2;

            Assert.AreNotEqual(CpH1, FPnl.CollapsiblePanelHosterInstance);

            assertIsStable2(FPnl);
        }
Beispiel #31
0
        public void TestSetter_ActiveTaskItem()
        {
            XmlNode TestNode = TTestTaskList.GetTestXmlNode();

            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, TestNode);
            FPnl.Expand();

            Assert.IsNull(FPnl.ActiveTaskItem);

            FPnl.ActiveTaskItem = TestNode.ChildNodes[1];
            Assert.AreEqual(FPnl.ActiveTaskItem, TestNode.ChildNodes[1]);

            FPnl.ActiveTaskItem = TestNode.ChildNodes[2];
            Assert.AreEqual(FPnl.ActiveTaskItem, TestNode.ChildNodes[2]);

            FPnl.ActiveTaskItem = null;

            Assert.IsNull(FPnl.ActiveTaskItem);

            FPnl.TaskListNode = null;

            Assert.IsNull(FPnl.ActiveTaskItem);
        }
Beispiel #32
0
    private void TestUserControlVerticalConstructor(object sender, EventArgs e)
    {
        this.Controls.Remove(this.FPnl);

        this.FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl,
            "Ict.Petra.Client.MPartner.Gui.TUC_PartnerInfo",
            TCollapseDirection.cdVertical,
            false,
            FEnumStyle);
        this.FPnl.Text = "&Partner Info";
        this.FPnl.InitUserControl();

        this.Controls.Add(this.FPnl);
    }
Beispiel #33
0
        public void TestSetter_VisualStyleEnum()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, TTestTaskList.GetTestXmlNode());

            Assert.AreEqual(TVisualStylesEnum.vsAccordionPanel, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsTaskPanel;
            Assert.AreEqual(TVisualStylesEnum.vsTaskPanel, FPnl.VisualStyleEnum);

            FPnl.Collapse();  // To ensure Unit Test code coverage only - nothing to assert here...
            FPnl.Expand();  // To ensure Unit Test code coverage only - nothing to assert here...
            FPnl.RealiseTaskListNow();  // To ensure Unit Test code coverage only - nothing to assert here...

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsAccordionPanel;
            Assert.AreEqual(TVisualStylesEnum.vsAccordionPanel, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsDashboard;
            Assert.AreEqual(TVisualStylesEnum.vsDashboard, FPnl.VisualStyleEnum);
            FPnl.Expand();  // To ensure Unit Test code coverage only - nothing to assert here...

            // The following Tests should work with 'Assert.AreNotEqual' because the Visual Style we try to assign is only valid
            // for a different CollapseDirection: cdHorizontal or cdHorizontalRight
            FPnl.VisualStyleEnum = TVisualStylesEnum.vsHorizontalCollapse;
            Assert.AreNotEqual(TVisualStylesEnum.vsHorizontalCollapse, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsShepherd;
            Assert.AreNotEqual(TVisualStylesEnum.vsShepherd, FPnl.VisualStyleEnum);


            // Specifiying 'TVisualStylesEnum.vsHorizontalCollapse' in the next statement, which is invalid and...
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL, TVisualStylesEnum.vsHorizontalCollapse);

            // ...gets automatically corrected to TVisualStylesEnum.vsDashboard by the Control!
            Assert.AreEqual(TVisualStylesEnum.vsDashboard, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsAccordionPanel;
            Assert.AreEqual(TVisualStylesEnum.vsAccordionPanel, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsTaskPanel;
            Assert.AreEqual(TVisualStylesEnum.vsTaskPanel, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsDashboard;
            Assert.AreEqual(TVisualStylesEnum.vsDashboard, FPnl.VisualStyleEnum);

            // The following Tests should work with 'Assert.AreNotEqual' because the Visual Style we try to assign is only valid
            // for a different CollapseDirection: cdHorizontal or cdHorizontalRight
            FPnl.VisualStyleEnum = TVisualStylesEnum.vsHorizontalCollapse;
            Assert.AreNotEqual(TVisualStylesEnum.vsHorizontalCollapse, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsShepherd;
            Assert.AreNotEqual(TVisualStylesEnum.vsShepherd, FPnl.VisualStyleEnum);


            FPnl = new TPnlCollapsible(THostedControlKind.hckCollapsiblePanelHoster, TTestTaskList.GetTestXmlNode());

            Assert.AreEqual(TVisualStylesEnum.vsAccordionPanel, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsTaskPanel;
            Assert.AreEqual(TVisualStylesEnum.vsTaskPanel, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsAccordionPanel;
            Assert.AreEqual(TVisualStylesEnum.vsAccordionPanel, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsDashboard;
            Assert.AreEqual(TVisualStylesEnum.vsDashboard, FPnl.VisualStyleEnum);

            // The following Tests should work with 'Assert.AreNotEqual' because the Visual Style we try to assign is only valid
            // for a different CollapseDirection: cdHorizontal or cdHorizontalRight
            FPnl.VisualStyleEnum = TVisualStylesEnum.vsHorizontalCollapse;
            Assert.AreNotEqual(TVisualStylesEnum.vsHorizontalCollapse, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsShepherd;
            Assert.AreNotEqual(TVisualStylesEnum.vsShepherd, FPnl.VisualStyleEnum);


            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList,
                TTestTaskList.GetTestXmlNode(), TVisualStylesEnum.vsShepherd, TCollapseDirection.cdHorizontal);

            Assert.AreEqual(TVisualStylesEnum.vsShepherd, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsHorizontalCollapse;
            Assert.AreEqual(TVisualStylesEnum.vsHorizontalCollapse, FPnl.VisualStyleEnum);


            // To ensure Unit Test code coverage only - nothing to assert here...
            FPnl.RealiseTaskListNow();
            FPnl.VisualStyleEnum = TVisualStylesEnum.vsShepherd;


            // To ensure Unit Test code coverage only - nothing to assert here...
            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList,
                TTestTaskList.GetTestXmlNode(), TVisualStylesEnum.vsHorizontalCollapse, TCollapseDirection.cdHorizontal);
            FPnl.VisualStyleEnum = TVisualStylesEnum.vsHorizontalCollapse_InfoPanelWithGradient;
        }
Beispiel #34
0
        public void TestGetHardCodedXmlNodes_ForDesignerOnly()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, TTestTaskList.GetTestXmlNode());

            // Need to resort to .NET Reflection as GetHardCodedXmlNodes_ForDesignerOnly() is a Private Method...
            MethodInfo InvokedPrivateMethod = FPnl.GetType().GetMethod("GetHardCodedXmlNodes_ForDesignerOnly",
                BindingFlags.NonPublic | BindingFlags.Instance);

            XmlNode Nodes = (XmlNode)InvokedPrivateMethod.Invoke(FPnl, new object[] { });
            Assert.IsNotNull(Nodes);
        }
Beispiel #35
0
        public void TestIsCollapsed()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL);

            Assert.IsTrue(FPnl.IsCollapsed);

            FPnl.Toggle();
            Assert.IsFalse(FPnl.IsCollapsed);
            FPnl.Toggle();
            Assert.IsTrue(FPnl.IsCollapsed);
            FPnl.Collapse();
            Assert.IsTrue(FPnl.IsCollapsed);
            FPnl.Expand();
            Assert.IsFalse(FPnl.IsCollapsed);

            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL, false);
            Assert.IsFalse(FPnl.IsCollapsed);

            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, true);
            Assert.IsTrue(FPnl.IsCollapsed);
            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, false);
            Assert.IsFalse(FPnl.IsCollapsed);

            FPnl = new TPnlCollapsible(THostedControlKind.hckCollapsiblePanelHoster, true);
            Assert.IsTrue(FPnl.IsCollapsed);
            FPnl = new TPnlCollapsible(THostedControlKind.hckCollapsiblePanelHoster, false);
            Assert.IsFalse(FPnl.IsCollapsed);
        }
Beispiel #36
0
        private void InstantiateCollapsiblePanels()
        {
            this.SuspendLayout();

            this.Controls.Clear();
            FCollPanelCount = 0;

            if (FMasterXmlNode == null)
            {
                throw new Exception("MasterXmlNode Property not set to an instance of XmlNode");
            }

            XmlNode TaskNode = FMasterXmlNode.FirstChild;

            //Iterate through all children nodes of the node
            while (TaskNode != null)
            {
                // Create a wrapper Panel. This is only needed to be able to set a distance between Collapsible Panels.
                Panel WrapperPanel = new Panel();
                WrapperPanel.AutoSize     = true;
                WrapperPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                WrapperPanel.BackColor    = Color.Transparent;
                WrapperPanel.Dock         = DockStyle.Top;
                WrapperPanel.Padding      = new Padding(0, 0, 0, FDistanceBetweenCollapsiblePanels);
                WrapperPanel.TabIndex     = FCollPanelCount;
                WrapperPanel.Tag          = TaskNode;
                WrapperPanel.Name         = TaskNode.Name;

                // Create a Collapsible Panel
                TPnlCollapsible CollPanel = new TPnlCollapsible(THostedControlKind.hckTaskList,
                                                                TaskNode,
                                                                TCollapseDirection.cdVertical,
                                                                10,
                                                                false,
                                                                FVisualStyle);
                CollPanel.Tag      = WrapperPanel;
                CollPanel.Name     = TaskNode.Name;
                CollPanel.Text     = TLstFolderNavigation.GetLabel(TaskNode);
                CollPanel.Dock     = DockStyle.Top;
                CollPanel.TabIndex = 0;

                if ((TaskNode.Attributes["Visible"] != null) &&
                    (TaskNode.Attributes["Visible"].Value.ToLower() == "false"))
                {
                    CollPanel.Visible = false;
                }

                if ((TaskNode.Attributes["Enabled"] != null) &&
                    (TaskNode.Attributes["Enabled"].Value.ToLower() == "false"))
                {
                    CollPanel.Enabled = false;
                }
                else
                {
                    CollPanel.ItemActivation += delegate(TTaskList ATaskList, XmlNode ATaskListNode, LinkLabel AItemClicked, object AOtherData)
                    {
                        OnItemActivation(ATaskList, ATaskListNode, AItemClicked);
                    };
                }

                WrapperPanel.Height = CollPanel.ExpandedSize + FDistanceBetweenCollapsiblePanels;
                WrapperPanel.Controls.Add(CollPanel);
                this.Controls.Add(WrapperPanel);

                // Make sure the Collapsible Panels' Wrapper Panels are shown in correct order and not in reverse order.
                // (This is needed because we 'stack them up' with '.Controls.Dock = DockStyle.Top')
                WrapperPanel.BringToFront();

                TaskNode = TaskNode.NextSibling;

                FCollPanelCount++;
            }

            this.ResumeLayout();
        }
Beispiel #37
0
        public void TestEvents()
        {
            // Not just test that Events are fired, but that the RIGHT Events are fired under
            // the RIGHT circumstances, and that no wrong Event is fired under wrong circumstances!
            // (Uses EventHandlerCapture Class for that as NUnit doesn't provide Asserts for
            // something nifty like that!)
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL);
            var EhcExpanded = new TNUnitEventHandlerCheck <System.EventArgs>();
            var EhcCollapsed = new TNUnitEventHandlerCheck <System.EventArgs>();

            FPnl.Expanded += EhcExpanded.Handler;
            FPnl.Collapsed += EhcCollapsed.Handler;

            // Assert that the Expanded Event is fired when the Control is Expanded (and that the Collapsed Event isn't)
            TNUnitEventAsserter.Assert(EhcExpanded, TNUnitEventAsserter.GotRaised <System.EventArgs>(), () => FPnl.Expand());
            TNUnitEventAsserter.Assert(EhcCollapsed, TNUnitEventAsserter.DidNotGetRaised <System.EventArgs>(), () => FPnl.Expand());

            // Assert that the Collapsed Event is fired when the Control is Expanded (and that the Expanded Event isn't)
            TNUnitEventAsserter.Assert(EhcCollapsed, TNUnitEventAsserter.GotRaised <System.EventArgs>(), () => FPnl.Collapse());
            TNUnitEventAsserter.Assert(EhcExpanded, TNUnitEventAsserter.DidNotGetRaised <System.EventArgs>(), () => FPnl.Collapse());

            FPnl.Expanded -= EhcExpanded.Handler;
            FPnl.Collapsed -= EhcCollapsed.Handler;

            // Assert that the Expanded/Collapsed Events are fired when the Control's Toggle Button is clicked
            // Need to resort to .NET Reflection as BtnToggleClick() is a Private Method...
            MethodInfo InvokedPrivateMethod = FPnl.GetType().GetMethod("BtnToggleClick",
                BindingFlags.NonPublic | BindingFlags.Instance);

            // It might look a bit weird to check Assert AreNotSame, but only this way we find out that the
            // .Invoke calls below do in fact do something!
            FPnl.Expanded += delegate(object sender, EventArgs e) {
                Assert.AreNotSame(FPnl, null);
            };
            FPnl.Expanded += delegate(object sender, EventArgs e) {
                Assert.AreSame(FPnl, sender);
            };
            FPnl.Collapsed += delegate(object sender, EventArgs e) {
                Assert.AreNotSame(FPnl, null);
            };
            FPnl.Collapsed += delegate(object sender, EventArgs e) {
                Assert.AreSame(FPnl, sender);
            };

            InvokedPrivateMethod.Invoke(FPnl, new object[] { FPnl, null });
            InvokedPrivateMethod.Invoke(FPnl, new object[] { FPnl, null });
        }
Beispiel #38
0
 private void HookupItemActivationEvent_CollPanel(TPnlCollapsible ACollPanel)
 {
     ACollPanel.ItemActivation += new TTaskList.TaskLinkClicked(ItemActivationHandler);
 }
        private void UpdateSubsystemLinkStatus(int ALedgerNr, TPnlCollapsible APnlCollapsible)
        {
            if (APnlCollapsible == null)
            {
                return;
            }

            UpdateSubsystemLinkStatus(ALedgerNr, APnlCollapsible.TaskListInstance, APnlCollapsible.TaskListNode.FirstChild);
        }
        private void OnItemActivation(TTaskList ATaskList, XmlNode ATaskListNode, LinkLabel AItemClicked)
        {
            TTaskList FoundTaskList;
            TPnlCollapsible CollPanel;

            if (FOnlyOneActiveTaskOnAllCollapsiblePanelsTaskLists)
            {
                // Remove the Active Task Item from any Collapsible Panel's TaskList that
                // isn't the sending instance (that is passed in in ATaskList) as we only
                // want *one* Active Task Item in one hosted Collapsible Panel!
                for (int Counter = 0; Counter < FCollPanelCount; Counter++)
                {
                    CollPanel = GetCollapsiblePanelInstance(Counter);
                    FoundTaskList = CollPanel.TaskListInstance;

                    if (FoundTaskList != ATaskList)
                    {
                        FoundTaskList.ActiveTaskItem = null;
                    }
                }
            }

            FCollPanelWhereLastItemActivationHappened = GetCollapsiblePanelInstance(ATaskListNode.ParentNode);

            // Re-fire Event
            if (ItemActivation != null)
            {
                ItemActivation(ATaskList, ATaskListNode, AItemClicked, GetCollapsiblePanelInstance(0));
            }
        }
Beispiel #41
0
        public void TestConstructorUserControlWithInvalidClass()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL + "WRONG");

            assertIsStable(FPnl);

            //Now we want to check that we can't realise the task list without it throwing an exception.
            try
            {
                FPnl.Expand();
            }
            catch (Exception e)
            {
                Assert.AreEqual(typeof(EUserControlCantInstantiateClassException), e.GetType());
            }
        }