Exemple #1
0
        public static void DrawLinks(ModelControl control, IEnumerable<LinkItem> links)
        {
            control.HasNetwork = control.Clone.HasNetwork = true;

            var canvas1 = control.cnvModel;
            var canvas2 = control.Clone.cnvModel;

            foreach (var link in links)
            {
                AddLinkToCanvas(canvas1, link);
                AddLinkToCanvas(canvas2, link);
            }
        }
Exemple #2
0
        public static void DrawPoints(ModelControl control, IEnumerable<PointsListItem> points)
        {
            double ellipseNormalSize = 20;

            control.HasPoints = control.Clone.HasPoints = true;
            control.Clone.CollectionPoints = new ObservableCollection<PointsListItem>(points);

            var canvas1 = control.cnvModel;
            var canvas2 = control.Clone.cnvModel;

            var trans1 = control.GlobalFixedScale; //new ScaleTransform(1, 1);
            var trans2 = control.Clone.GlobalFixedScale;  //new ScaleTransform(1, 1);

            foreach (var point in points)
            {
                AddPointToCanvas(ellipseNormalSize, canvas1, trans1, point);
                AddPointToCanvas(ellipseNormalSize, canvas2, trans2, point);
            }
        }
        private void LoadModelControl()
        {
            var net = VissimSingleton.Instance.Net;
            if (modelCanvas1 == null)
            {
                modelCanvas1 = new ModelControl();
                net.Wrap().Draw(modelCanvas1.cnvModel, System.Windows.SystemColors.WindowTextBrush);
            }

            ccControlsHost.Content = modelCanvas1;
        }
Exemple #4
0
        private void drTrTimes(ModelControl control)
        {
            string modelName = "";
            int expNumber = -1;
            IEnumerable<SectionListItem> sections = null;

            control.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate()
            {
                modelName = control.ModelName;
                expNumber = control.ExperimentNumber;
                sections = control.Clone.TrTimeSections;
            }));

            string masterModelDir = clerk.GetExperimentModelDirName(modelName, expNumber);
            var ds = CreateDataSetFromGroups(masterModelDir);

            var bindings = from s in sections
                           group s by s.No
                               into gr
                               let coords = (from g in gr select new Point[] { g.FromCoord, g.ToCoord }).FirstOrDefault()
                               select new DataCollectionBindingSource
                               {
                                   MeasureId = gr.Key,
                                   Center = FindCenter(coords),
                                   Points = coords,
                                   AggregatedData = ds.Tables[gr.Key.Value.ToString()],
                               };

            control.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate()
            {
                ModelPlotter.DrawTrTimes(control, bindings);
            }));
        }
Exemple #5
0
        private void drSections(ModelControl control)
        {
            string modelName = "";
            int expNumber = -1;

            control.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate()
            {
                modelName = control.ModelName;
                expNumber = control.ExperimentNumber;
            }));

            string inputFileName = clerk.GetExperimentInputFileName(modelName, expNumber);

            string text = File.ReadAllText(inputFileName);

            var sections = TextProcessor.GetSections(text); //.ToList();

            control.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate()
            {
                ModelPlotter.DrawSections(control, sections);
            }));
        }
Exemple #6
0
        private void drCounters(ModelControl control)
        {
            string modelName = "";
            int expNumber = -1;
            IEnumerable<PointsListItem> points = null;

            control.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate()
            {
                modelName = control.ModelName;
                expNumber = control.ExperimentNumber;
                points = control.Clone.CollectionPoints;
            }));

            string masterModelDir = clerk.GetExperimentModelDirName(modelName, expNumber);

            var bindings = from p in points
                           group p by p.MeasurId
                               into gr
                               let coords = (from p in gr select p.Coord)
                               select new DataCollectionBindingSource
                               {
                                   MeasureId = gr.Key,
                                   Center = FindCenter(coords),
                                   Points = coords,
                                   AggregatedData = CreateTableFromMeasurement(masterModelDir, gr.Key),
                               };

            control.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate()
            {
                ModelPlotter.DrawCounters(control, bindings);
            }));
        }
Exemple #7
0
        private void drNetwork(ModelControl control)
        {
            string modelName = "";
            int expNumber = -1;

            control.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate()
            {
                modelName = control.ModelName;
                expNumber = control.ExperimentNumber;
            }));

            string inputFileName = clerk.GetExperimentInputFileName(modelName, expNumber);
            string text = File.ReadAllText(inputFileName);

            var links = TextProcessor.GetLinks(text);
            var connectors = TextProcessor.GetConnectors(text, links.ToArray());

            control.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate()
            {
                ModelPlotter.DrawLinks(control, links.Union(connectors));
            }));
        }
Exemple #8
0
        private ModelControl CreateModelControl(string modelName, Experiment exp, bool notMaster)
        {
            var ctrl = new ModelControl(modelName)
            {
                DataContext = exp,
                //TODO [redundancy] exp.Number
                ExperimentNumber = exp.Number,
                IsMaster = !notMaster,
            };

            if (notMaster) ctrl.OptimizeForList();

            ctrl.ModelDoubleClick += (sender_, e_) => Host.MoveAllModels((e_ as RoutedEventArgs<Point>).Value);

            return ctrl;
        }
Exemple #9
0
        public static void DrawCounters(ModelControl control, IEnumerable<DataCollectionBindingSource> bindings)
        {
            control.HasCounters = control.Clone.HasCounters = true;

            //var group1 = new TransformGroup();
            //group1.Children.Add(new ScaleTransform(1, 1));
            //group1.Children.Add(new ScaleTransform(1, -1));

            var group2 = new TransformGroup();
            group2.Children.Add(control.Clone.GlobalFixedScale);
            group2.Children.Add(new ScaleTransform(1, -1));

            //var canvas1 = control.cnvModel;
            var canvas2 = control.Clone.cnvModel;

            foreach (var item in bindings)
            {
                //AddCounterToCanvas(group1, canvas1, item);
                AddCounterToCanvas(group2, canvas2, item);
            }
        }
Exemple #10
0
        public static void DrawTrTimes(ModelControl control, IEnumerable<DataCollectionBindingSource> bindings)
        {
            control.HasTravelTimes = control.Clone.HasTravelTimes = true;

            var group2 = new TransformGroup();
            group2.Children.Add(control.Clone.GlobalFixedScale);
            group2.Children.Add(new ScaleTransform(1, -1));

            var canvas2 = control.Clone.cnvModel;

            foreach (var item in bindings)
            {
                AddTrTimesToCanvas(group2, canvas2, item);
            }
        }
Exemple #11
0
        public static void DrawSections(ModelControl control, IEnumerable<SectionListItem> sections)
        {
            double ellipseNormalSize = 15;

            control.HasSections = control.Clone.HasSections = true;
            control.Clone.TrTimeSections = new ObservableCollection<SectionListItem>(sections);

            var canvas1 = control.cnvModel;
            var canvas2 = control.Clone.cnvModel;

            var trans1 = control.GlobalFixedScale; //new ScaleTransform(1, 1);
            var trans2 = control.Clone.GlobalFixedScale; //new ScaleTransform(1, 1);

            foreach (var section in sections)
            {
                AddSectionsToCanvas(ellipseNormalSize, canvas1, trans1, section);
                AddSectionsToCanvas(ellipseNormalSize, canvas2, trans2, section);
            }
        }