예제 #1
0
        public static void DrawTopDown(Canvas canvas, ExperimentsTree.ExperimentsTreeNode node, Point point, int currentExpNumber)
        {
            if (lastExperimentNumber != currentExpNumber)
            {
                dict = Experiment.GetDict();
                lastExperimentNumber = currentExpNumber;
            }

            if (node.DescendantsCount > maxDescendantsCount) maxDescendantsCount = node.DescendantsCount;

            var nodeCtrl = new NodeControl();
            nodeCtrl.Tag = node;
            nodeCtrl.Header = string.Format("Exp. Nr. {0}", dict[node.Id].Number);
            nodeCtrl.Counter = node.ChildsCount;
            nodeCtrl.lbl1.Content = "Id: " + node.Id.ToString();
            nodeCtrl.lbl2.Content = "Descendants Count: " + node.DescendantsCount.ToString();
            nodeCtrl.lbl3.Content = dict[node.Id].HasBackup ? "Backup - yes" : "Backup - no";
            nodeCtrl.lbl4.Content = dict[node.Id].HasSnapshot ? "Snapshot - yes" : "Snapshot - no";
            if (!dict[node.Id].HasBackup || !dict[node.Id].HasSnapshot) nodeCtrl.Background = Brushes.LightPink;
            nodeCtrl.border.Background = GradientBraker.Brake(Colors.White, Colors.LightBlue, maxDescendantsCount + 1).ToArray()[node.DescendantsCount];
            nodeCtrl.IsSelected = node.IsLoaded;
            canvas.Children.Add(nodeCtrl);
            Canvas.SetTop(nodeCtrl, point.Y);
            Canvas.SetLeft(nodeCtrl, point.X);
            Canvas.SetZIndex(nodeCtrl, 100);

            // calculate coordinates
            double trainLength = (node.ChildsCount - 1) * l;
            double startX = point.X - trainLength / 2;
            double startY = h * (node.Level + 1);

            foreach (var chld in node.ChildNodes)
            {
                if (chld.IsOpen)
                {
                    DrawTopDown(canvas, chld, new Point(startX, startY), dict[chld.Id].Number);
                }
                else
                {
                    var nodeCtrl2 = new NodeControl();
                    nodeCtrl2.Header = string.Format("Exp. Nr. {0}", dict[chld.Id].Number);
                    nodeCtrl2.Tag = chld;
                    nodeCtrl2.Counter = chld.ChildsCount;
                    nodeCtrl2.lbl1.Content = "Id: " + chld.Id.ToString();
                    nodeCtrl2.lbl2.Content = "Descendants Count: " + chld.DescendantsCount.ToString();
                    nodeCtrl2.lbl3.Content = dict[chld.Id].HasBackup ? "Backup - yes" : "Backup - no";
                    nodeCtrl2.lbl4.Content = dict[chld.Id].HasSnapshot ? "Snapshot - yes" : "Snapshot - no";
                    if (!dict[chld.Id].HasBackup || !dict[chld.Id].HasSnapshot) nodeCtrl2.Background = Brushes.LightPink;
                    nodeCtrl2.IsSelected = chld.IsLoaded;
                    nodeCtrl2.border.Background = GradientBraker.Brake(Colors.White, Colors.LightBlue, maxDescendantsCount + 1).ToArray()[chld.DescendantsCount];
                    canvas.Children.Add(nodeCtrl2);
                    Canvas.SetTop(nodeCtrl2, startY);
                    Canvas.SetLeft(nodeCtrl2, startX);
                    Canvas.SetZIndex(nodeCtrl2, 100);
                }

                var line = new Line();

                if (!chld.IsLoaded)
                {
                    line.Stroke = Brushes.Black;
                    line.StrokeThickness = 0.3;
                    line.StrokeDashArray = new DoubleCollection(new double[] { 35, 35 });
                }
                else
                {
                    line.Stroke = Brushes.Gold;
                    line.StrokeThickness = 1.5;
                }

                //if (chld.IsOpen) line.StrokeThickness = 2;
                
                line.X1 = point.X + l/1.39;
                line.Y1 = point.Y + w/2;
                line.X2 = startX + l/1.39;
                line.Y2 = startY + w / 2;
                canvas.Children.Add(line);
                Canvas.SetZIndex(line, 99);

                startX += l;
            }
        }
예제 #2
0
        private static void DrawTopDown(Experiment exp, Canvas canvas, Point point, int lvl)
        {
            if (exp.DescendantsCount > maxDescendantsCount) maxDescendantsCount = exp.DescendantsCount;

            var nodeCtrl = new NodeControl();
            nodeCtrl.DataContext = exp;
            nodeCtrl.Counter = exp.ChildsCount;
            //if (!dict[node.Id].HasBackup || !dict[node.Id].HasSnapshot) nodeCtrl.Background = Brushes.LightPink;
            nodeCtrl.border.Background = GradientBraker.Brake(Colors.White, Colors.LightBlue, maxDescendantsCount + 1).ToArray()[exp.DescendantsCount];
            nodeCtrl.IsSelected = exp.IsLoaded;
            canvas.Children.Add(nodeCtrl);
            Canvas.SetTop(nodeCtrl, point.Y);
            Canvas.SetLeft(nodeCtrl, point.X);
            Canvas.SetZIndex(nodeCtrl, 100);

            nodeCtrl.cbxAnalyze.IsChecked = exp.Data == null ? false : exp.Data.Alanyze;

            // calculate coordinates
            double trainLength = (exp.ChildsCount - 1) * horizontalGap;
            double startX = point.X - trainLength / 2;
            double startY = verticalGap * (lvl + 1);

            foreach (var chld in exp.ChildNodes)
            {
                if (chld.IsOpen)
                {
                    DrawTopDown(chld, canvas, new Point(startX, startY), lvl + 1);
                }
                else
                {
                    var nodeCtrl2 = new NodeControl();
                    nodeCtrl2.DataContext = chld;
                    nodeCtrl2.Counter = chld.ChildsCount;
                    //if (!dict[chld.Id].HasBackup || !dict[chld.Id].HasSnapshot) nodeCtrl2.Background = Brushes.LightPink;
                    nodeCtrl2.IsSelected = chld.IsLoaded;
                    nodeCtrl2.border.Background = GradientBraker.Brake(Colors.White, Colors.LightBlue, maxDescendantsCount + 1).ToArray()[chld.DescendantsCount];
                    canvas.Children.Add(nodeCtrl2);
                    Canvas.SetTop(nodeCtrl2, startY);
                    Canvas.SetLeft(nodeCtrl2, startX);
                    Canvas.SetZIndex(nodeCtrl2, 100);

                    nodeCtrl2.cbxAnalyze.IsChecked = chld.Data == null ? false : chld.Data.Alanyze;
                }

                var line = new Line();

                if (!chld.IsLoaded)
                {
                    line.Stroke = Brushes.Black;
                    line.StrokeThickness = 0.3;
                    line.StrokeDashArray = new DoubleCollection(new double[] { 35, 35 });
                }
                else
                {
                    line.Stroke = Brushes.Gold;
                    line.StrokeThickness = 1.5;
                }

                //if (chld.IsOpen) line.StrokeThickness = 2;

                line.X1 = point.X + horizontalGap / 1.39;
                line.Y1 = point.Y + linesOffset / 2;
                line.X2 = startX + horizontalGap / 1.39;
                line.Y2 = startY + linesOffset / 2;
                canvas.Children.Add(line);
                Canvas.SetZIndex(line, 99);

                startX += horizontalGap;
            }
        }