Example #1
0
        public static AppForm NewAppForm(string filePath = null)
        {
            AppForm appForm = null;                            // will assign below
            Func <Project.File, EditorForm> doOpenFile = null; // will assign below
            var openEditorController        = new OpenEditorController(x => doOpenFile(x));
            var projectContentFormViewModel = new ProjectContentFormViewModel(openEditorController);
            var projectContentForm          = new ProjectContentForm(projectContentFormViewModel);
            var findForm = new SearchResultsForm();

            appForm = new AppForm(new AppFormViewModel(filePath), projectContentForm, findForm, out doOpenFile);
            return(appForm);
        }
Example #2
0
        public AppForm(AppFormViewModel viewModel, ProjectContentForm projectContentForm,
                       SearchResultsForm searchResultsForm, out Func <Project.File, EditorForm> doOpenFile)
        {
            InitializeComponent();

            // Exposing this allows the OpenEditorController to manipulate dialogs without needing access to (or knowledge
            // of) the dock panel control.  Similarly, the AppForm does not need to know how the controller does its job;
            // it just does what it's told.
            doOpenFile = DoOpenFile;

            // Project content form
            _ProjectContentForm = projectContentForm;
            _ProjectContentForm.Show(_DockPanel, DockState.DockLeft);
            // Find form
            _SearchResultsForm = searchResultsForm;
            _SearchResultsForm.Show(_DockPanel, DockState.DockLeft);
            // Dock panel
            _DockPanel.BindDockLeftPortion(viewModel.DockLeftPortion);
            _DockPanel.BindDockRightPortion(viewModel.DockRightPortion);
            _DockPanel.BindDockTopPortion(viewModel.DockTopPortion);
            _DockPanel.BindDockBottomPortion(viewModel.DockBottomPortion);
            _ProjectContentForm.BindDockState(viewModel.ProjectContentFormDockState);
            // Window frame
            this.BindLocation(viewModel.Location);
            this.BindSize(viewModel.Size);
            this.BindMinimumSize(viewModel.MinimumSize);
            this.BindWindowState(viewModel.WindowState);
            // Titlebar
            this.BindText(viewModel.Title);
            this.BindClosing(viewModel.PromptClose, viewModel.CanClose);
            // File menu
            _NewButton.BindClick(viewModel.NewClick);
            _NewProjectMnu.BindClick(viewModel.NewClick);
            _OpenButton.BindClick(viewModel.OpenClick);
            _OpenProjectMnu.BindClick(viewModel.OpenClick);
            _SaveButton.BindClick(viewModel.SaveClick);
            _SaveButton.BindEnabled(viewModel.SaveEnabled);
            _SaveProjectMnu.BindClick(viewModel.SaveClick);
            _SaveProjectMnu.BindEnabled(viewModel.SaveEnabled);
            _SaveProjectAsMnu.BindClick(viewModel.SaveAsClick);
            // Edit menu
            _UndoMnu.BindEnabled(viewModel.UndoEnabled);
            _UndoMnu.BindClick(viewModel.UndoClick);
            _RedoMnu.BindEnabled(viewModel.RedoEnabled);
            _RedoMnu.BindClick(viewModel.RedoClick);
            // Program menu
            _NewFileBtn.BindClick(viewModel.NewFileClick);
            _NewFileMnu.BindClick(viewModel.NewFileClick);
            _BuildButton.BindClick(viewModel.BuildClick);
            _CompileMnu.BindClick(viewModel.BuildClick);
            _DeployButton.BindClick(viewModel.DeployClick);
            _DeployMnu.BindClick(viewModel.DeployClick);
            _DebugButton.BindClick(viewModel.DebugClick);
            _DebugMnu.BindClick(viewModel.DebugClick);
            // Help menu
            _AboutMenuItem.BindClick(viewModel.AboutClick);
            // Search box
            _SearchTxt.BindText(viewModel.SearchText);
            _SearchTxt.BindForeColor(viewModel.SearchForeColor);
            _SearchTxt.BindFocused(viewModel.SearchFocused);
            _SearchTxt.BindKeyPress(viewModel.SearchEnterKeyPress, '\n', '\r');
            viewModel.Start(this);

            // Bring the Project Content Form to the front.
            _ProjectContentForm.Show();
        }