示例#1
0
        public BranchAccessor(Branch branch)
        {
            if (branch == null)
            {
                throw new ArgumentNullException(nameof(branch));
            }

            m_branch = branch;

            var firstChildBranch = branch.FirstItem as Branch;

            if (firstChildBranch != null)
            {
                m_firstItemBranchAccessor = new BranchAccessor(firstChildBranch);
            }
            else
            {
                m_firstItemTabablzControl = FindTabablzControl(branch.FirstItem, branch.FirstContentPresenter);
            }

            var secondChildBranch = branch.SecondItem as Branch;

            if (secondChildBranch != null)
            {
                m_secondItemBranchAccessor = new BranchAccessor(secondChildBranch);
            }
            else
            {
                m_secondItemTabablzControl = FindTabablzControl(branch.SecondItem, branch.SecondContentPresenter);
            }
        }
示例#2
0
 private static void BranchVisitor(LocationReportBuilder locationReportBuilder, BranchAccessor branchAccessor)
 {
     if (Equals(branchAccessor.FirstItemTabablzControl, locationReportBuilder.TargetTabablzControl))
         locationReportBuilder.MarkFound(branchAccessor.Branch, false);
     else if (Equals(branchAccessor.SecondItemTabablzControl, locationReportBuilder.TargetTabablzControl))
         locationReportBuilder.MarkFound(branchAccessor.Branch, true);
     else
     {
         branchAccessor.Visit(BranchItem.First, ba => BranchVisitor(locationReportBuilder, ba));
         if (locationReportBuilder.IsFound) return;
         branchAccessor.Visit(BranchItem.Second, ba => BranchVisitor(locationReportBuilder, ba));
     }            
 }
示例#3
0
        public LayoutAccessor(Layout layout)
        {
            Layout = layout ?? throw new ArgumentNullException(nameof(layout));

            if (Layout.Content is Branch branch)
            {
                BranchAccessor = new BranchAccessor(branch);
            }
            else
            {
                TabablzControl = Layout.VisualTreeDepthFirstTraversal().OfType <TabablzControl>().FirstOrDefault();
            }
        }
示例#4
0
        public LayoutAccessor(Layout layout)
        {
            Layout = layout ?? throw new ArgumentNullException(nameof(layout));

            if (Layout.Content is Branch branch)
            {
                BranchAccessor = new BranchAccessor(branch);
            }
            else
            {
                TabablzControl = Layout.Content as TabablzControl;
            }
        }
        private static void BranchAccessorVisitor(TreeNode treeNode, BranchAccessor branchAccessor)
        {
            var branchNode = new TreeNode {Content = "Branch " + branchAccessor.Branch.Orientation};
            treeNode.Children.Add(branchNode);

            var firstBranchNode = new TreeNode { Content = "Branch Item 1" };
            branchNode.Children.Add(firstBranchNode);
            var secondBranchNode = new TreeNode { Content = "Branch Item 2" };
            branchNode.Children.Add(secondBranchNode);

            branchAccessor
                .Visit(firstBranchNode, BranchItem.First, BranchAccessorVisitor, TabablzControlVisitor)
                .Visit(secondBranchNode, BranchItem.Second, BranchAccessorVisitor, TabablzControlVisitor);
        }
示例#6
0
        public BranchAccessor(Branch branch)
        {
            if (branch == null) throw new ArgumentNullException("branch");

            _branch = branch;

            var firstChildBranch = branch.FirstItem as Branch;
            if (firstChildBranch != null)
                _firstItemBranchAccessor = new BranchAccessor(firstChildBranch);
            else
                _firstItemTabablzControl = FindTabablzControl(branch.FirstItem, branch.FirstContentPresenter);

            var secondChildBranch = branch.SecondItem as Branch;            
            if (secondChildBranch != null)
                _secondItemBranchAccessor = new BranchAccessor(secondChildBranch);
            else
                _secondItemTabablzControl = FindTabablzControl(branch.SecondItem, branch.SecondContentPresenter);
        }
示例#7
0
        public LayoutAccessor(Layout layout)
        {
            if (layout == null)
            {
                throw new ArgumentNullException("layout");
            }

            _layout = layout;

            var branch = Layout.Content as Branch;

            if (branch != null)
            {
                _branchAccessor = new BranchAccessor(branch);
            }
            else
            {
                _tabablzControl = Layout.Content as TabablzControl;
            }
        }
示例#8
0
        public LayoutAccessor(Layout layout)
        {
            if (layout == null)
            {
                throw new ArgumentNullException("layout");
            }

            _layout = layout;

            var branch = Layout.Content as Branch;

            if (branch != null)
            {
                _branchAccessor = new BranchAccessor(branch);
            }
            else
            {
                _tabablzControl = Layout.VisualTreeDepthFirstTraversal().OfType <TabablzControl>().FirstOrDefault();
            }
        }
示例#9
0
        public BranchAccessor(Branch branch)
        {
            Branch = branch ?? throw new ArgumentNullException(nameof(branch));

            if (branch.FirstItem is Branch firstChildBranch)
            {
                FirstItemBranchAccessor = new BranchAccessor(firstChildBranch);
            }
            else
            {
                FirstItemTabablzControl = FindTabablzControl(branch.FirstItem, branch.FirstContentPresenter);
            }

            if (branch.SecondItem is Branch secondChildBranch)
            {
                SecondItemBranchAccessor = new BranchAccessor(secondChildBranch);
            }
            else
            {
                SecondItemTabablzControl = FindTabablzControl(branch.SecondItem, branch.SecondContentPresenter);
            }
        }
示例#10
0
        /// <summary>
        /// Helper method for <see cref="BranchAccessor.Visit"/> which allows a context to be passed through.
        /// </summary>
        /// <typeparam name="TContext"></typeparam>
        /// <param name="branchAccessor"></param>
        /// <param name="context"></param>
        /// <param name="childItem"></param>
        /// <param name="branchVisitor"></param>
        /// <param name="tabablzControlVisitor"></param>
        /// <param name="contentVisitor"></param>
        /// <returns></returns>
        public static BranchAccessor Visit <TContext>(
            this BranchAccessor branchAccessor,
            TContext context,
            BranchItem childItem,
            Action <TContext, BranchAccessor> branchVisitor         = null,
            Action <TContext, TabablzControl> tabablzControlVisitor = null,
            Action <TContext, object> contentVisitor = null)
        {
            if (branchAccessor == null)
            {
                throw new ArgumentNullException("branchAccessor");
            }

            branchAccessor.Visit(
                childItem,
                WrapVisitor(context, branchVisitor),
                WrapVisitor(context, tabablzControlVisitor),
                WrapVisitor(context, contentVisitor)
                );

            return(branchAccessor);
        }
示例#11
0
 private static void BranchVisitor(LocationReportBuilder locationReportBuilder, BranchAccessor branchAccessor)
 {
     if (Equals(branchAccessor.FirstItemTabablzControl, locationReportBuilder.TargetTabablzControl))
     {
         locationReportBuilder.MarkFound(branchAccessor.Branch, false);
     }
     else if (Equals(branchAccessor.SecondItemTabablzControl, locationReportBuilder.TargetTabablzControl))
     {
         locationReportBuilder.MarkFound(branchAccessor.Branch, true);
     }
     else
     {
         branchAccessor.Visit(BranchItem.First, ba => BranchVisitor(locationReportBuilder, ba));
         if (locationReportBuilder.IsFound)
         {
             return;
         }
         branchAccessor.Visit(BranchItem.Second, ba => BranchVisitor(locationReportBuilder, ba));
     }
 }
示例#12
0
 private static void BranchAccessorVisitor(IList <TabablzControl> resultSet, BranchAccessor branchAccessor)
 {
     branchAccessor
     .Visit(resultSet, BranchItem.First, BranchAccessorVisitor, TabablzControlVisitor)
     .Visit(resultSet, BranchItem.Second, BranchAccessorVisitor, TabablzControlVisitor);
 }
示例#13
0
        private static void BranchAccessorVisitor(XElement stateNode, BranchAccessor branchAccessor)
        {
            var proportion = branchAccessor.Branch.GetFirstProportion();
            var firstBranch = new XElement(XmlStructure.BranchNode.Branch, new XAttribute(XmlStructure.BranchNode.Proportion, proportion));
            var secondBranch = new XElement(XmlStructure.BranchNode.Branch, new XAttribute(XmlStructure.BranchNode.Proportion, 1 - proportion));

            var branchNode = new XElement(XmlStructure.BranchNode.Branches, new XAttribute(XmlStructure.BranchNode.Orientation, branchAccessor.Branch.Orientation.ToString()));
            branchNode.Add(firstBranch);
            branchNode.Add(secondBranch);

            stateNode.Add(branchNode);

            branchAccessor
                .Visit(firstBranch, BranchItem.First, BranchAccessorVisitor, TabablzControlVisitor)
                .Visit(secondBranch, BranchItem.Second, BranchAccessorVisitor, TabablzControlVisitor);
        }
示例#14
0
        private static void BranchAccessorVisitor(StateNode stateNode, BranchAccessor branchAccessor)
        {
            var branchNode = new StateNode( new BranchNode(branchAccessor.Branch.Orientation.ToString()) );
            stateNode.Children.Add(branchNode);

            var proportion = branchAccessor.Branch.GetFirstProportion();

            var firstBranchNode = new StateNode(new BranchNode(proportion));
            branchNode.Children.Add(firstBranchNode);
            var secondBranchNode = new StateNode(new BranchNode(1-proportion));
            branchNode.Children.Add(secondBranchNode);

            branchAccessor
                .Visit(firstBranchNode, BranchItem.First, BranchAccessorVisitor, TabablzControlVisitor)
                .Visit(secondBranchNode, BranchItem.Second, BranchAccessorVisitor, TabablzControlVisitor);
        }