Esempio n. 1
0
 public void SetController(MainController controller) {
   Controller = controller;
   try {
     SplashManager.Status = "Connecting to database...";
     Controller.ConnectToDatabase();
     SplashManager.Status = "Positioning window...";
     SizeableFormOptions = SizeableFormOptions.Create(this);
     SplashManager.Status = "Getting options...";
     SelectEditorView = CreateSelectEditorView();
     ToolStrip.Visible = Controller.IsToolBarVisible;
     StatusLabel.Visible = Controller.IsStatusBarVisible;
   } catch (Exception exception) {
     if (exception is ApplicationException) {
       MessageBox.Show(
         SplashManager.SplashForm,
         exception.Message,
         Application.ProductName,
         MessageBoxButtons.OK,
         MessageBoxIcon.Error);
     } else {
       MessageWindow.Show(SplashManager.SplashForm, exception.ToString(),
         $"{Application.ProductName} - Terminal Error");
     }
     Environment.Exit(0);
   }
 }
 /// <summary>
 ///   Creates a SizeableFormOptions instance and its associated controller,
 ///   as per the Model-View-Controller design pattern,
 ///   returning the view instance created.
 /// </summary>
 /// <param name="form">
 ///   The <see cref="Form" /> whose size, position and state are
 ///   to be saved and restored.
 /// </param>
 public static SizeableFormOptions Create(Form form) {
   // ViewFactory cannot be used to create the view and controller in this case,
   // as the view constructor requires the form parameter.
   SizeableFormOptions result;
   try {
     result = new SizeableFormOptions(form);
     var dummy =
       new SizeableFormOptionsController(result, form.Name);
   } catch (TargetInvocationException ex) {
     throw ex.InnerException ?? ex;
   }
   return result;
 }
Esempio n. 3
0
 protected override void OnLoad(EventArgs e) {
   base.OnLoad(e);
   MainGrid.SetController(new MainGridController(MainGrid, Controller));
   MainGrid.EditorView = this;
   MainGrid.MainView = MainView;
   MainGrid.DataError += MainGrid_DataError;
   MainGrid.RowsRemoved += MainGrid_RowRemoved;
   MainGrid.RowValidated += MainGrid_RowValidated;
   if (Controller.IsParentGridToBeShown) {
     ParentGrid.SetController(new ParentGridController(ParentGrid, Controller));
     ParentGrid.EditorView = this;
     ParentGrid.MainView = MainView;
   }
   // Has to be done here rather than in constructor in order to tell that this is an
   // MDI child form.
   SizeableFormOptions = SizeableFormOptions.Create(this);
   // And better to do this here than in SetController, where any exception would be
   // indirectly reported, due to being thrown in the controller's constructor.
   ShowData();
 }