コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: slowmickey/VISLAB
        private void amc_btnAddModelClick(UserControl control)
        {
            shadowMaker.ShadowDown();

            shadowMaker.ShowThis(new LoadingControl("Loading VISSIM..."));
            shadowMaker.ShadowUp();

            ////////////////////////////////////////////////////////////////////
            var amc = control as AddModelControl;

            string modelName = string.Empty;

            if (amc.rbCreateNewModel.IsChecked.Value)
            {
                modelName = amc.tbxModelName.Text;
                manager.AddNewModelAsync(
                    modelName,
                    this.Dispatcher,
                    amc,
                    amc_FinalAction);
            }

            if (amc.rbLoadFromFile.IsChecked.Value)
            {
                string modelFileName = amc.tbxFileName.Text;
                modelName = amc.cbAltModelName.IsChecked.Value
                    ? amc.tbxAltModelName.Text
                    : Path.GetFileNameWithoutExtension(modelFileName);

                manager.AddExistingModelAsync(
                    modelFileName
                    , amc.cbAltModelName.IsChecked.Value ? amc.tbxAltModelName.Text : string.Empty
                    , this.Dispatcher
                    , amc
                    , () =>
                {
                    this.Dispatcher.Invoke(DispatcherPriority.Background,
                                           new ThreadStart(delegate()
                    {
                        MessageBox.Show(this, "Model with name \"" + modelName + "\" already exists!\nPlease define new name.",
                                        "Warning", MessageBoxButton.OK, MessageBoxImage.Stop);
                    }));
                }
                    , amc_FinalAction);
            }
        }