Example #1
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                _logger.Info("Create Model started.");

                var uiApp = commandData.Application;
                var uiDoc = uiApp.ActiveUIDocument;

                if (View != null)
                {
                    if (View.WindowState == WindowState.Minimized)
                    {
                        View.WindowState = WindowState.Normal;
                    }
                    View.Activate();

                    return(Result.Succeeded);
                }

                var m  = new CreateModelModel(uiDoc);
                var vm = new CreateModelViewModel(m, false);
                var v  = new CreateModelView
                {
                    DataContext = vm
                };

                View          = v;
                View.Closing += OnViewClosing;

                var unused = new WindowInteropHelper(v)
                {
                    Owner = Process.GetCurrentProcess().MainWindowHandle
                };

                v.Show();

                _logger.Info("Create Model ended.");

                return(Result.Succeeded);
            }
            catch (Exception e)
            {
                _logger.Fatal(e);

                return(Result.Failed);
            }
        }
Example #2
0
        public CreateModelViewModel(CreateModelModel model, bool dragonfly)
        {
            DispatcherHelper.Initialize();

            Model               = model;
            Dragonfly           = dragonfly;
            Title               = Dragonfly ? "Dragonfly - Create Model" : "Honeybee - Create Model";
            Settings            = AppSettings.Instance;
            ContextShades       = Model.GetContextShades().ToObservableCollection();
            BldgConstructionSet = new ConstructionSet(Settings.StoredSettings.EnergyModelSettings.BldgConstructionSet);
            BldgProgramType     = new ProgramType(Settings.StoredSettings.EnergyModelSettings.BldgProgramType);

            var color = dragonfly
                ? Color.FromRgb(0, 166, 81)
                : Color.FromRgb(245, 179, 76);

            BorderBrush = new SolidColorBrush(color);

            SpatialObjects = new ListCollectionView(SpatialObjectsModels);
            SpatialObjects.GroupDescriptions.Clear();
            SpatialObjects.GroupDescriptions.Add(new PropertyGroupDescription("Level", new LevelToNameConverter()));
            SpatialObjects.Filter = FilterDataGrid;

            Close                         = new RelayCommand <Window>(OnClose);
            Help                          = new RelayCommand(OnHelp);
            ClearFilters                  = new RelayCommand(OnClearFilters);
            FilterChanged                 = new RelayCommand(OnFilterChanged);
            PickSpatialObjects            = new RelayCommand(OnPickSpatialObjects);
            OpenPopup                     = new RelayCommand <Popup>(OnOpenPopup);
            ClosePopup                    = new RelayCommand <Popup>(OnClosePopup);
            CloseBldgConstructionSetPopup = new RelayCommand <Popup>(OnCloseBldgConstructionSetPopup);
            CloseProgramTypePopup         = new RelayCommand <Popup>(OnCloseProgramTypePopup);
            CloseBuildingProgramTypePopup = new RelayCommand <Popup>(OnCloseBuildingProgramTypePopup);
            ResetConstructionSet          = new RelayCommand(OnResetConstructionSet);
            ResetProgramType              = new RelayCommand(OnResetProgramType);
            ShowBoundaryConditions        = new RelayCommand <SpatialObjectWrapper>(OnShowBoundaryConditions);
            ShowDetails                   = new RelayCommand <SpatialObjectWrapper>(OnShowDetails);
            ExportModel                   = new RelayCommand(OnExportModel);
            RunSimulation                 = new RelayCommand(OnRunSimulation);
            AddPlanting                   = new RelayCommand(OnAddPlanting);
            AddFaces                      = new RelayCommand(OnAddFaces);
            ClearShades                   = new RelayCommand(OnClearShades);
            ShowLog                       = new RelayCommand(OnShowLog);
        }