コード例 #1
0
        public static void DrawTopDown(Canvas canvas,
                                       ExperimentsTree.ExperimentsTreeNode node,
                                       Point point, Experiment currentExp)
        {
            if (lastExperimentNumber != currentExp.Number)
            {
                dict = Experiment.GetDict();
                lastExperimentNumber = currentExp.Number;
            }

            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.border.Background = GradientBraker.Brake(Colors.AntiqueWhite, Colors.Blue, maxDescendantsCount + 1).ToArray()[node.DescendantsCount];
            nodeCtrl.IsSelected        = true;
            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]);
                }
                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.IsSelected        = false;
                    nodeCtrl2.border.Background = GradientBraker.Brake(Colors.AntiqueWhite, Colors.Blue, 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.IsOpen)
                {
                    line.Stroke          = Brushes.Black;
                    line.StrokeThickness = 0.1;
                    line.StrokeDashArray = new DoubleCollection(new double[] { 70, 35 });
                }
                else
                {
                    line.Stroke          = Brushes.Gold;
                    line.StrokeThickness = 1;
                }

                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
ファイル: TreePainter.cs プロジェクト: A-n-d-r-e-y/VISLAB
        public static void DrawTopDown(Canvas canvas,
            ExperimentsTree.ExperimentsTreeNode node, 
            Point point, Experiment currentExp)
        {
            if (lastExperimentNumber != currentExp.Number)
            {
                dict = Experiment.GetDict();
                lastExperimentNumber = currentExp.Number;
            }

            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.border.Background = GradientBraker.Brake(Colors.AntiqueWhite, Colors.Blue, maxDescendantsCount + 1).ToArray()[node.DescendantsCount];
            nodeCtrl.IsSelected = true;
            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]);
                }
                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.IsSelected = false;
                    nodeCtrl2.border.Background = GradientBraker.Brake(Colors.AntiqueWhite, Colors.Blue, 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.IsOpen)
                {
                    line.Stroke = Brushes.Black;
                    line.StrokeThickness = 0.1;
                    line.StrokeDashArray = new DoubleCollection(new double[] { 70, 35 });
                }
                else
                {
                    line.Stroke = Brushes.Gold;
                    line.StrokeThickness = 1;
                }
                
                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;
            }
        }
コード例 #3
0
ファイル: ProjectManager.cs プロジェクト: A-n-d-r-e-y/VISLAB
        public void LoadProject(string projectFileName)
        {
            if (string.IsNullOrWhiteSpace(projectFileName)) return;

            if (!File.Exists(projectFileName))
            {
                if (LoadProjectFailed != null) LoadProjectFailed(this, new ProjectEventArgs(projectFileName));
                return;
            }

            projectDir = Path.GetDirectoryName(projectFileName);
            Project = Project.Load(projectFileName);
            experiment = Experiment.Load(Path.Combine(projectDir, project.Files.ExperimentFileName), project.CurrentExperimentId);

            string modelDir = Path.Combine(projectDir, project.Files.ModelDirectory);

            if (vissim.Instance.GetWorkingDirectory() != string.Format("{0}\\", modelDir))
            {

                var filesList = Directory.GetFiles(modelDir, "*.inp");
                if (filesList.Length == 0) throw new FileNotFoundException("There are no input file in the model directory");

                string modelName = Path.GetFileName(filesList[0]);

                vissim.Instance.LoadNet(string.Format("{0}\\{1}{2}", modelDir, modelName,
                    modelName.EndsWith(".inp") ? string.Empty : ".inp"));

                string layoutFileName = string.Format("{0}\\vissim.ini", modelDir);
                if (File.Exists(layoutFileName)) vissim.Instance.LoadLayout(layoutFileName);
            }

            SaveProjectToSettings(projectFileName);

            OnProjectLoaded(projectFileName);
        }
コード例 #4
0
ファイル: ProjectManager.cs プロジェクト: A-n-d-r-e-y/VISLAB
 public void LoadExperiment(Guid id)
 {
     experiment = Experiment.Load(ExperimentFileName, id);
 }
コード例 #5
0
ファイル: ProjectManager.cs プロジェクト: A-n-d-r-e-y/VISLAB
 private void CreateExperiment(string projectDir, Guid id)
 {
     this.experiment = new Experiment(id);
     experiment.Save(Path.Combine(projectDir, project.Files.ExperimentFileName));
 }
コード例 #6
0
ファイル: ProjectManager.cs プロジェクト: slowmickey/VISLAB
 public void LoadExperiment(Guid id)
 {
     experiment = Experiment.Load(ExperimentFileName, id);
 }
コード例 #7
0
ファイル: ProjectManager.cs プロジェクト: slowmickey/VISLAB
 private void CreateExperiment(string projectDir, Guid id)
 {
     this.experiment = new Experiment(id);
     experiment.Save(Path.Combine(projectDir, project.Files.ExperimentFileName));
 }