public void RemovePresenter()
        {
            if (Presenter != null)
                Presenter.Dispose();

            Presenter = null;
        }
    public void Execute(MainPresenter mainPresenter)
    {
        // Set the current working directory to the bin folder.
        string binFolder = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location);
        Directory.SetCurrentDirectory(binFolder);

        // Get the environment variable 'ModelName'
        string modelName = System.Environment.GetEnvironmentVariable("ModelName");

        // Open wheat validation in a tab
        string fileName = Path.Combine(binFolder, @"..\Tests\Validation\" + modelName + @"\" + modelName + ".apsimx");
        if (File.Exists(fileName))
        {
            mainPresenter.OpenApsimXFileInTab(fileName, true);

            // Get the presenter for this tab.
            ExplorerPresenter presenter = mainPresenter.presenters1[0];
            presenter.SelectNode(".Simulations");

            // Export the model to HTML
            string folderName = Path.Combine(binFolder, @"..\Documentation\PDF");
            Directory.CreateDirectory(folderName);

            ExportNodeCommand command = new ExportNodeCommand(presenter, presenter.CurrentNodePath);
            command.Do(null);

            // Copy the file into the PDF directory.
            File.Copy(command.FileNameWritten, @"..\Documentation\PDF\" + modelName + ".pdf");
        }
        // Close the user interface.
        mainPresenter.Close(false);
    }
Example #3
0
        public static int Main(string[] args)
        {
            Gtk.Application.Init();
            MainView mainForm = new MainView();
            MainPresenter mainPresenter = new MainPresenter();

            // Clean up temporary files.
            string tempFolder = Path.Combine(Path.GetTempPath(), "ApsimX");
            if (Directory.Exists(tempFolder))
                Directory.Delete(tempFolder, true);
            Directory.CreateDirectory(tempFolder);
            Environment.SetEnvironmentVariable("TMP", tempFolder, EnvironmentVariableTarget.Process);
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(Manager.ResolveManagerAssembliesEventHandler);

            try
            {
                mainPresenter.Attach(mainForm, args);
                mainForm.MainWidget.ShowAll();
                if (args.Length == 0 || Path.GetExtension(args[0]) != ".cs")
                    Gtk.Application.Run();
            }
            catch (Exception err)
            {
                File.WriteAllText("errors.txt", err.ToString());
                return 1;
            }
            return 0;
        }
        public void CreatePresenter()
        {
            View = Substitute.For<IMainView>();
            Model = Substitute.For<ITestModel>();

            Presenter = new MainPresenter(View, Model);
        }
Example #5
0
        public void Shouldnt_be_possible_get_an_operation_code_from_a_null_command_line()
        {
            MockRepository mocks = new MockRepository();
            var fakeView = mocks.DynamicMock<IMainView>();
            var fakeModel = mocks.DynamicMock<IMainModel>();

            Expect.Call(delegate { fakeView.ShowMessage(null); }).IgnoreArguments();

            var fakePresenter = new MainPresenter(fakeView, fakeModel);
            fakePresenter.PrepareOptions(null);
            Assert.AreEqual(Operation.Error, fakePresenter.CheckParameters());
        }
Example #6
0
    public void Execute(MainPresenter mainPresenter)
    {
        // Open the standard toolbox in a tab
        mainPresenter.OnStandardToolboxClick(null, null);

        // Get the presenter for this tab.
        ExplorerPresenter presenter = mainPresenter.presenters1[0];

        // Loop through all nodes in the standard toolbox and select each in turn.
        while (presenter.SelectNextNode());

        // Close the user interface.
        mainPresenter.Close(askToSave:false);
    }
Example #7
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (ComboBoxChoose == TextBoxPassword)
            {
                using(EmployeesDomainModel employeesDomainModel = new EmployeesDomainModel())
                {
                    var mainPresenter = new MainPresenter(employeesDomainModel, new MainForm());
                    mainPresenter.Role = ComboBoxChoose;

                    if (mainPresenter.Role == "Administrator")
                    {
                        mainPresenter.View.AddButton.Enabled = true;
                    }

                    ((Form)mainPresenter.View).ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("Wrong password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }
Example #8
0
        static int Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MainView mainForm = new MainView();
            MainPresenter mainPresenter = new MainPresenter();

            // Clean up temporary files.
            string tempFolder = Path.Combine(Path.GetTempPath(), "ApsimX");
            if (Directory.Exists(tempFolder))
                // This may fail if another ApsimX instance is running. If so,
                // we just ignore the exception and leave the cleanup for another day.
                try
                {
                    Directory.Delete(tempFolder, true);
                }
                catch (Exception)
                {
                }
            Directory.CreateDirectory(tempFolder);
            Environment.SetEnvironmentVariable("TMP", tempFolder, EnvironmentVariableTarget.Process);
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(Manager.ResolveManagerAssembliesEventHandler);

            try
            {
                mainPresenter.Attach(mainForm, args);
                if (args.Length == 0 || Path.GetExtension(args[0]) != ".cs")
                    Application.Run(mainForm);
            }
            catch (Exception err)
            {
                File.WriteAllText("errors.txt", err.ToString());
                return 1;
            }

            return 0;
        }
Example #9
0
 public MainWindowView()
 {
     InitializeComponent();
     InitializeListeners();
     CurrentPresenter = IocKernel.Get <MainPresenter>();
 }
Example #10
0
 public MainWindow() :
     base(Gtk.WindowType.Toplevel)
 {
     this.Build();
     mp = new MainPresenter(this);
 }
Example #11
0
 public MainForm()
 {
     InitializeComponent();
     _presenter = new MainPresenter(this);
 }
Example #12
0
 private void MainView_Load(object sender, EventArgs e)
 {
     Presenter = new MainPresenter(this, _formOpener);
 }
Example #13
0
 public void MyTestInitialize()
 {
     target = new MainPresenter(null);
 }
Example #14
0
 public FormMain()
 {
     InitializeComponent();
     presenter = new MainPresenter(this);
 }
 public void Initialize()
 {
     usersRepository = new UsersRepository();
     view            = Substitute.For <IMainView>();
     presenter       = new MainPresenter(view, usersRepository);
 }
Example #16
0
        /// <summary>
        /// Create documentation based on the specified file.
        /// </summary>
        /// <param name="documentObject">The documentObject node that describes what to document.</param>
        /// <param name="apsimDirectory">The APSIM root directory.</param>
        /// <param name="destinationFolder">The folder where the PDF should be created.</param>
        /// <param name="destinationUrl">The server destination URL where all files will end up.</param>
        /// <returns>HTML snippet for a single model document.</returns>
        private static string CreateModelDocumentation(JObject documentObject, string apsimDirectory, string destinationFolder, string destinationUrl)
        {
            string href;
            string hrefName = documentObject["Name"].ToString();

            if (documentObject["URL"] != null)
            {
                href = documentObject["URL"].ToString();
                return(string.Format("<p><a href=\"{0}\" target=\"_blank\">{1}</a></p>", href, hrefName));
            }
            else
            {
                var fileName = Path.Combine(apsimDirectory, documentObject["FileName"].ToString());
                if (File.Exists(fileName))
                {
                    // Open the file.
                    var simulations = FileFormat.ReadFromFile <Simulations>(fileName, out List <Exception> creationExceptions);
                    if (creationExceptions?.Count > 0)
                    {
                        throw creationExceptions[0];
                    }

                    // Create some necessary presenters and views.
                    var mainPresenter     = new MainPresenter();
                    var explorerPresenter = new ExplorerPresenter(mainPresenter);

                    var explorerView = new ExplorerView(null);
                    explorerPresenter.Attach(simulations, explorerView, explorerPresenter);

                    // Document model.
                    if (documentObject["ModelNameToDocument"] == null)
                    {
                        Console.WriteLine("Creating documentation from " + fileName);

                        // Whole of simulation document.
                        var createDoc = new CreateFileDocumentationCommand(explorerPresenter, destinationFolder);
                        createDoc.Do(null);
                        href = Path.GetFileName(createDoc.FileNameWritten);
                    }
                    else
                    {
                        Console.WriteLine("Creating model description documentation from " + fileName);

                        // Specific model description documentation.
                        var modelNameToDocument = documentObject["ModelNameToDocument"].ToString();
                        var model = simulations.FindInScope(modelNameToDocument) as IModel;
                        if (model == null)
                        {
                            return(null);
                        }
                        var outputFileName = documentObject["OutputFileName"]?.ToString();
                        var createDoc      = new CreateParamsInputsOutputsDocCommand(explorerPresenter, model, destinationFolder, outputFileName);
                        createDoc.Do(null);
                        href = Path.GetFileName(createDoc.FileNameWritten);
                    }

                    return(string.Format("<p><a href=\"{0}/{1}\" target=\"_blank\">{2}</a></p>", destinationUrl, href, hrefName));
                }
                else
                {
                    return(null);
                }
            }
        }
Example #17
0
 public void Initialize()
 {
     presenter = new MainPresenter(mockLoginRepository, mockMainView);
 }
 public DatabaseAccess(MainPresenter presenter)
 {
     this.presenter = presenter;
 }
 public Shortcuts(MainPresenter presenter)
 {
     this.presenter = presenter;
     InitializeComponent();
 }
Example #20
0
 private void OpenFile(MainPresenter presenter, string file)
 {
     presenter.OpenApsimXFileInTab(file, true);
 }
Example #21
0
 public void Initialize()
 {
     view      = Substitute.For <IMainView>();
     doc       = new ProjectDocument();
     presenter = new MainPresenter(doc, view);
 }
Example #22
0
 public MainView()
 {
     InitializeComponent();
     var presenter = new MainPresenter(this);
 }
 public void Setup()
 {
     m_View      = new TestMainView();
     m_MainModel = new TestMainModel();
     m_Presenter = new MainPresenter(m_View, m_MainModel);
 }
 public frmInterakcija()
 {
     InitializeComponent();
     _presenter = new MainPresenter(this);
 }
Example #25
0
 public MainView(MainPresenter mainPresenter)
     : this()
 {
     mainPresenter.Setup(this);
 }
Example #26
0
 public void Initialize()
 {
     view = Substitute.For<IMainView>();
     doc = new ProjectDocument();
     presenter = new MainPresenter(doc, view);
 }
Example #27
0
 public MainViewModel(MainPresenter mainPresenter)
 {
     OpenSecondViewCommand = new DelegateCommand(mainPresenter.OpenSecondView);
 }