예제 #1
0
        void btnAddModel_Click(object sender, RoutedEventArgs e)
        {
            shadowMaker.ShadowUp();

            var ctrl = CreateAddModelControl();

            shadowMaker.ShowThis(ctrl);
        }
        private void rbCustom_Checked(object sender, RoutedEventArgs e)
        {
            var colSelectionCtrl = new ColumnSelectionControl();

            colSelectionCtrl.DataContext     = columnsList;
            colSelectionCtrl.btnClose.Click += (s_, e_) =>
            {
                foreach (var item in columnsList)
                {
                    datagrid.Columns[item.Ordinal].Visibility = item.IsVisible ? Visibility.Visible : Visibility.Collapsed;
                }

                shadowMaker.ShadowDown();
                datagrid.Items.Refresh();
            };

            shadowMaker.ShowThis(colSelectionCtrl);

            shadowMaker.ShadowUp();
        }
예제 #3
0
        private void btnLoad_Click(object sender, RoutedEventArgs e)
        {
            ShadowMaker.ShadowUp();
            ShadowMaker.ShowThis(new LoadingControl("Starting VISSIM..."));

            //???
            this.modelControlGrid.IsEnabled = false;

            experimenter.LoadModelAsync(true, this.Dispatcher, () =>
            {
                this.modelControlGrid.IsEnabled = true;
                ShadowMaker.ShadowDown();
            });
        }
예제 #4
0
        void tc_Play()
        {
            RaiseEvent(new RoutedEventArgs(TreeControl.PlayEvent));

            modelControlGrid.IsEnabled = false;
            ShadowMaker.ShadowUp();

            if (!vissim.IsInstanciated)
            {
                ShadowMaker.ShowThis(new LoadingControl("Starting VISSIM ..."));
            }
            else
            {
                ShadowMaker.ShowThis(new LoadingControl("Simulation ..."));
            }

            experimenter.RunSimulationAsync(this.Dispatcher
                                            , StartAction
                                            , (expData) =>
            {
                var ctrl = CreateCreateExperimentControl(expData);
                ShadowMaker.ShowThis(ctrl);
            });
        }
예제 #5
0
        public void AnalyzeExperiment(string modelName, Experiment exp)
        {
            if (Host.List.Count(ctrl => ctrl.ModelName == modelName && ctrl.ExperimentNumber == exp.Number) == 0)
            {
                string key = modelName + exp.Number.ToString();

                if (!experimentsCache.ContainsKey(key))
                {
                    var ctrl   = CreateModelControl(modelName, exp, true);
                    var master = CreateModelControl(modelName, exp, false);

                    ctrl.Clone   = master;
                    master.Clone = ctrl;

                    experimentsCache[key] = ctrl;
                }

                //TODO [redundancy] replace isShadowUp with shadowMaker.isShadowUp
                bool isShadowUp = false;
                if (shadowMaker.Shadow == null)
                {
                    shadowMaker.ShowThis(new LoadingControl("Loading..."));
                    shadowMaker.ShadowUp();
                    isShadowUp = true;
                }

                var control = experimentsCache[key];

                ThreadPool.QueueUserWorkItem(o =>
                {
                    aex.Protect(() =>
                    {
                        // resource-intensive
                        if (!control.HasNetwork)
                        {
                            drNetwork(control);
                        }

                        if (Host.AreCountersGlobalVisible)
                        {
                            if (!control.HasPoints)
                            {
                                drPoints(control);
                            }
                            if (!control.HasCounters)
                            {
                                drCounters(control);
                            }
                        }

                        if (Host.AreTrTimesGlobalVisible)
                        {
                            if (!control.HasSections)
                            {
                                drSections(control);
                            }
                            if (!control.HasTravelTimes)
                            {
                                drTrTimes(control);
                            }
                        }

                        control.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate()
                        {
                            if (Host.AreCountersGlobalVisible)
                            {
                                if (!control.IsMaster)
                                {
                                    control.Clone.OpenCountersGrid();
                                }
                                else
                                {
                                    control.OpenCountersGrid();
                                }
                            }

                            if (Host.AreTrTimesGlobalVisible)
                            {
                                if (!control.IsMaster)
                                {
                                    control.Clone.OpenTrTimesGrid();
                                }
                                else
                                {
                                    control.OpenTrTimesGrid();
                                }
                            }

                            Host.List.Add(control);
                            if (isShadowUp)
                            {
                                shadowMaker.ShadowDown();
                            }
                        }));
                    });
                });
            }
        }
예제 #6
0
        void tc_Multi()
        {
            RaiseEvent(new RoutedEventArgs(TreeControl.MultiEvent));

            ShadowMaker.ShadowUp();
            modelControlGrid.IsEnabled = false;

            var x = new StartMultirunBindingSource()
            {
                DisableAnimation = true,
                NumberOfRuns     = 3
            };

            var startCtrl = new StartMultirunControl();

            startCtrl.DataContext      = x;
            startCtrl.btnCancel.Click += (sender_, e_) =>
            {
                ShadowMaker.ShadowDown();
                modelControlGrid.IsEnabled = true;
            };
            startCtrl.btnOk.Click += (sender_, e_) =>
            {
                ShadowMaker.ShadowDown();

                if (x.NumberOfRuns > 0)
                {
                    var lc = new LoadingControl();
                    if (!vissim.IsInstanciated)
                    {
                        lc.Message = "Starting VISSIM ...";
                    }
                    else
                    {
                        lc.Message = "Simulation ...";
                    }
                    ShadowMaker.ShowThis(lc);

                    experimenter.RunMultiAsync(x, this.Dispatcher
                                               , StartAction
                                               , (expData) =>
                    {
                        var ctrl = CreateCreateExperimentControl(expData);
                        ShadowMaker.ShowThis(ctrl);
                    }
                                               , (message) =>
                    {
                        lc.Message = message;
                    }
                                               );
                }
                else
                {
                    ShadowMaker.ShowThis(startCtrl);
                }

                ShadowMaker.ShadowUp();
            };

            ShadowMaker.ShowThis(startCtrl);
        }