Beispiel #1
0
        public void GetDataItem(int RecordNo, DataItem SourceItem, TreeNodeX SourceNode)
        {
            if (FetchRecordNo == null)
            {
                logger.Warn("FetchRecordNo FunctionPointer is not set");
                return;
            }

            logger.Info("Fetching Record No {0}", RecordNo);
            var dataItem = FetchRecordNo(RecordNo, SourceItem.Schema);

            if (dataItem == null)
            {
                JdSuite.Common.MessageService.ShowError("Data Missing Error", $"Record Id {RecordNo} does not exist in DataFactory");
                return;
            }
            logger.Info("Fetched DataItem {0}", dataItem.Name);

            dataItem = dataItem.Children.FirstOrDefault(x => x.Name == SourceItem.Name);
            if (dataItem == null)
            {
                JdSuite.Common.MessageService.ShowError("Data Missing Error", $"Record Id {RecordNo} does not exist in DataFactory");
                return;
            }

            SourceNode.ClearChildrenNodes();

            dataItem.TotalRecordCount = SourceItem.TotalRecordCount;
            dataItem.ParentGrid       = SourceItem.ParentGrid;

            SourceNode.LoadData(dataItem);

            RootNode.RemoveDataItem(SourceItem);
            SourceNode.CurrentRecordNo = RecordNo;
            TreeNodeX.AdjustColumnWidth(RootNode, true);
            //LoadData(dataItem);

            //ShowDataItem(dataItem, RecordNo);
        }
Beispiel #2
0
        public static void AdjustColumnWidth(TreeNodeX rootNode, bool IgnoreCollapsed)
        {
            //this.rootNode.grid.ColumnDefinitions[0].
            if (rootNode == null)
            {
                logger.Error("rootNode parameter is null");
                return;
            }
            var rect = LayoutInformation.GetLayoutSlot(rootNode.textBlockType);

            // Debug.WriteLine($"Rect={rect.ToString()}");
            foreach (var child in rootNode.grid.Children.OfType <TreeNodeX>())
            {
                //if (child.IsCollapsed || child.Visibility != Visibility.Visible) continue;

                //logger.Info($"Adjusting_1 Parent={rootNode.NodeText}-->{child.NodeText}={rect.X}");
                child.SetColumnWidth(0, rect.X, IgnoreCollapsed);
            }

            if (rootNode == rootNode.RootNode)
            {
            }
        }
Beispiel #3
0
        /// <summary>
        /// Shows node header alongwith its properties, set GridRow.Height=Auto in which this node lies, which is Parent grid out of this node
        /// </summary>
        /// <param name="node"></param>
        public static void HideNode(TreeNodeX node)
        {
            node.Visibility            = Visibility.Collapsed;
            node.nodeBorder.Visibility = Visibility.Collapsed;
            node.grid.Visibility       = Visibility.Collapsed;


            if (node.NodeLine != null)
            {
                node.NodeLine.Visibility = Visibility.Collapsed;
            }

            /*
             * for (int i = 1; i < treeNode.grid.RowDefinitions.Count; i++)
             * {
             *  if ((string)treeNode.grid.RowDefinitions[i].Tag == PropRowTag)
             *  {
             *      treeNode.grid.RowDefinitions[i].Height = CollapsedRowHeight;
             *  }
             * }*/
            // node.CurrentRecordNo = 0;
            node.IsCollapsed = true;
        }
Beispiel #4
0
        /// <summary>
        /// Shows node header alongwith its properties, set GridRow.Height=Auto in which this node lies, which is Parent grid out of this node
        /// </summary>
        /// <param name="node"></param>
        public void ShowNode(TreeNodeX node)
        {
            node.Visibility            = Visibility.Visible;
            node.nodeBorder.Visibility = Visibility.Visible;
            node.grid.Visibility       = Visibility.Visible;


            if (node.NodeLine != null)
            {
                node.NodeLine.Visibility = Visibility.Visible;
            }

            //bool propertyExpanded = false;

            foreach (var line in node.grid.FindVisualChildren <Line>(2))
            {
                if (line.Name == "propLine")
                {
                    line.Visibility = Visibility.Visible;
                }
            }


            for (int i = 1; i < node.grid.RowDefinitions.Count; i++)
            {
                if ((string)node.grid.RowDefinitions[i].Tag == PropRowTag)
                {
                    node.grid.RowDefinitions[i].Height = GridLength.Auto;
                    // propertyExpanded = true;
                }
            }

            //node.CurrentRecordNo = 0;

            // if (propertyExpanded)
            node.IsCollapsed = false;
        }
Beispiel #5
0
        public void LoadData(DataItem dataItem, int recordNo)
        {
            try
            {
                logger.Trace("Loading_DataItem RecordNo {0}", recordNo);

                rootNode.RootNode = rootNode;

                //TreeNodeX.LoadData(dataItem, this.rootNode);

                rootNode.ShowDataItem(dataItem, recordNo);

                rootNode.textNodeHeader.Text = dataItem.Name;
                rootNode.grid.ColumnDefinitions[0].MinWidth = this.rootNode.DataItem.ReverseLevel * 30;


                rootNode.HideNavigationButtons();
                TreeNodeX.AdjustColumnWidth(rootNode, true);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "DataItem_Loading_Error RecordNo {0}", recordNo);
            }
        }
Beispiel #6
0
        private void TreeGridCtrl_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            // logger.Info("TreeNodeX.AdjustColumnWidth(rootNode, true);");//start from here

            TreeNodeX.AdjustColumnWidth(rootNode, true);
        }
Beispiel #7
0
        /// <summary>
        /// Adds child nodes to parentTreeNode
        /// </summary>
        /// <param name="dataItem"></param>
        /// <param name="parentTreeNode"></param>
        /// <returns></returns>
        private TreeNodeX AddChildNode(DataItem dataItem)
        {
            TreeNodeX parentTreeNode = this;

            logger.Trace("Adding_dataNode {0}", dataItem.ToString());

            var gridRow = new RowDefinition()
            {
                Height = GridLength.Auto
            };

            parentTreeNode.grid.RowDefinitions.Add(gridRow);
            int rowId = parentTreeNode.grid.RowDefinitions.Count - 1;

            gridRow.Tag = NodeRowTag;

            Line line = new Line();

            line.Name              = "nodeLineHor";
            line.StrokeThickness   = 1;
            line.Stroke            = Brushes.Blue;
            line.VerticalAlignment = VerticalAlignment.Top;
            line.X1 = 0;
            line.X2 = NodeLineLength;
            line.Y1 = 10;
            line.Y2 = 10;

            Grid.SetColumn(line, 0);
            Grid.SetRow(line, rowId);

            //Add line to parent
            parentTreeNode.grid.Children.Add(line);

            //Binding binding = new Binding("ActualWidth");
            // binding.Source = nodeStackPanel;
            //binding.Converter = htoPosConverter;
            // binding.Mode = BindingMode.OneWay;

            // l.SetBinding(Line.Y1Property, binding);
            // l.SetBinding(Line.Y2Property, binding);
            //tn.SetBinding(TreeNodeX.WidthProperty, binding);



            TreeNodeX childTreeNode = new TreeNodeX();

            childTreeNode.DataItem    = dataItem;
            childTreeNode.DataContext = dataItem;

            childTreeNode.RootNode                   = parentTreeNode.RootNode;
            childTreeNode.HorizontalAlignment        = HorizontalAlignment.Stretch;
            childTreeNode.HorizontalContentAlignment = HorizontalAlignment.Stretch;
            childTreeNode.Margin = new Thickness(ChildNodeLeftMargin, 0, 0, 0);
            Grid.SetColumn(childTreeNode, 0);
            Grid.SetRow(childTreeNode, rowId);
            Grid.SetColumnSpan(childTreeNode, 3);

            childTreeNode.ParentGridRowNo = rowId;

            childTreeNode.NodeLine = line;



            //childTreeNode.textNodeHeader.Text = dataNode.Name; // + "[" + childId + "]"; Remove square bracket as asked by John

            childTreeNode.CurrentRecordNo = 1;

            childTreeNode.SetDataNodeBinding(dataItem);
            dataItem.ParentGrid = parentTreeNode.grid;

            //Add child node to Parent
            parentTreeNode.grid.Children.Add(childTreeNode);


            //Load children and properties for childTreeNode
            childTreeNode.LoadData(dataItem);



            childTreeNode.HideNavigationButtons();


            if (dataItem.DataType == "Array" && dataItem.Level == 1)
            {
                childTreeNode.ShowNavigationButtons();
            }

            /*
             * if (childTreeNode != childTreeNode.RootNode)
             * {
             *  childTreeNode.TotalRecordCount = dataNode.ChildCount;
             *  if (dataNode.ChildCount <= 1)
             *  {
             *      //TODO:following may not be correct
             *      childTreeNode.HideNavigationButtons();
             *  }
             *
             * }
             */

            return(childTreeNode);
        }
Beispiel #8
0
 private void RootNodeButtonClick(int RecordNo, DataItem SourceItem, TreeNodeX SourceNode)
 {
     GetDataItem(RecordNo, SourceItem, SourceNode);
 }