Exemplo n.º 1
0
        public void ExplorerView_ShouldNotMoveItem_SourceDestinationHasDupicateChild_ReturnsTrue_MessageBox()
        {
            //------------Setup for test--------------------------
            var sourceItem = new Mock <IExplorerItemModel>();

            sourceItem.Setup(model => model.IsVersion).Returns(false);
            sourceItem.Setup(model => model.ResourcePath).Returns("mypath1");
            sourceItem.Setup(model => model.DisplayName).Returns("bob");
            sourceItem.Setup(a => a.ResourcePathWithoutName).Returns("abc");
            var destination = new Mock <IExplorerItemModel>();

            destination.Setup(model => model.IsVersion).Returns(false);
            destination.Setup(model => model.ResourcePath).Returns("mypath");

            var child = new Mock <IExplorerItemModel>();

            child.Setup(model => model.IsVersion).Returns(false);
            child.Setup(model => model.ResourcePath).Returns("mypath2");
            child.Setup(model => model.DisplayName).Returns("bob");
            child.Setup(a => a.ResourcePathWithoutName).Returns("def");
            destination.Setup(a => a.Children).Returns(new ObservableCollection <IExplorerItemModel>(new[] { child.Object }));
            destination.Setup(a => a.Parent).Returns(destination.Object);
            destination.Setup(a => a.ResourcePathWithoutName).Returns("ghi");
            //------------Execute Test---------------------------

            var shouldNotMove = ExplorerView.ShouldNotMove(sourceItem.Object, destination.Object);

            //------------Assert Results-------------------------
            Assert.IsTrue(shouldNotMove);
            _controller.Verify(a => a.Show("Conflicting resources found in the destination", "Conflicting Resources", MessageBoxButton.OK, MessageBoxImage.Error, ""), Times.Once());
        }
Exemplo n.º 2
0
        public void ExplorerView_ShouldNotMoveItem_SourceDestinationNoDuplicateDestinationIsIsFolder_ReturnsTrue()
        {
            //------------Setup for test--------------------------
            var sourceItem = new Mock <IExplorerItemModel>();

            sourceItem.Setup(model => model.IsVersion).Returns(false);
            sourceItem.Setup(model => model.ResourcePath).Returns("mypath1");
            sourceItem.Setup(model => model.DisplayName).Returns("bob");
            var destination = new Mock <IExplorerItemModel>();

            destination.Setup(model => model.IsVersion).Returns(false);
            destination.Setup(model => model.ResourcePath).Returns("mypath");
            destination.Setup(a => a.ResourceType).Returns(ResourceType.Folder);
            var child = new Mock <IExplorerItemModel>();

            child.Setup(model => model.IsVersion).Returns(false);
            child.Setup(model => model.ResourcePath).Returns("mypath1");
            child.Setup(model => model.DisplayName).Returns("bob");
            child.Setup(model => model.ResourceType).Returns(ResourceType.Folder);
            destination.Setup(a => a.Parent).Returns(destination.Object);
            destination.Setup(a => a.Children).Returns(new ObservableCollection <IExplorerItemModel>(new[] { child.Object }));
            //------------Execute Test---------------------------

            var shouldNotMove = ExplorerView.ShouldNotMove(sourceItem.Object, destination.Object);

            //------------Assert Results-------------------------
            Assert.IsFalse(shouldNotMove);
        }
Exemplo n.º 3
0
        /// <summary>Create a new tab.</summary>
        /// <param name="name">Name of the simulation</param>
        /// <param name="simulations">The simulations object to add to tab.</param>
        /// <param name="onLeftTabControl">If true a tab will be added to the left hand tab control.</param>
        private ExplorerPresenter CreateNewTab(string name, Simulations simulations, bool onLeftTabControl)
        {
            ExplorerView      explorerView = new ExplorerView();
            ExplorerPresenter presenter    = new ExplorerPresenter(this);

            if (onLeftTabControl)
            {
                presenters1.Add(presenter);
            }
            else
            {
                presenters2.Add(presenter);
            }

            XmlDocument doc = new XmlDocument();

            presenter.Attach(simulations, explorerView, null);

            this.view.AddTab(name, Properties.Resources.apsim_logo32, explorerView, onLeftTabControl);

            // restore the simulation tree width on the form
            if (simulations.ExplorerWidth == 0)
            {
                presenter.TreeWidth = 250;
            }
            else
            {
                presenter.TreeWidth = simulations.ExplorerWidth;
            }

            return(presenter);
        }
Exemplo n.º 4
0
        protected override void OnViewLoaded(object view)
        {
            _view             = view as ExplorerView;
            _view.DataContext = ActiveScene.Context;

            //(_view.ActiveInstances.ItemsSource as UISafeObservableCollection<Instance>).ListChanged += ExplorerView_ListChanged;
        }
Exemplo n.º 5
0
        /// <summary>Create a new tab.</summary>
        /// <param name="name">Name of the simulation</param>
        /// <param name="simulations">The simulations object to add to tab.</param>
        /// <param name="onLeftTabControl">If true a tab will be added to the left hand tab control.</param>
        private ExplorerPresenter CreateNewTab(string name, Simulations simulations, bool onLeftTabControl)
        {
            this.view.ShowMessage(" ", Simulation.ErrorLevel.Information); // Clear the message window
            ExplorerView      explorerView = new ExplorerView(null);
            ExplorerPresenter presenter    = new ExplorerPresenter(this);

            if (onLeftTabControl)
            {
                presenters1.Add(presenter);
            }
            else
            {
                presenters2.Add(presenter);
            }

            XmlDocument doc = new XmlDocument();

            presenter.Attach(simulations, explorerView, null);

            this.view.AddTab(name, new Gtk.Image(null, "ApsimNG.Resources.apsim logo32.png"), explorerView.MainWidget, onLeftTabControl);

            // restore the simulation tree width on the form
            if (simulations.ExplorerWidth == 0)
            {
                presenter.TreeWidth = 250;
            }
            else
            {
                presenter.TreeWidth = simulations.ExplorerWidth;
            }

            return(presenter);
        }
Exemplo n.º 6
0
        // ReSharper disable once InconsistentNaming
        public void ExplorerView_Move_FolderExpectPopup()
        {
            //------------Setup for test--------------------------
            var stud  = new Mock <IStudioResourceRepository>();
            var popup = new Mock <IPopupController>();

            CustomContainer.Register(popup.Object);
            var model1 = new ExplorerItemModel(new Mock <IConnectControlSingleton>().Object, new Mock <IStudioResourceRepository>().Object)
            {
                ResourceType = ResourceType.Folder, ResourcePath = "bob", EnvironmentId = Guid.NewGuid()
            };
            var model2 = new ExplorerItemModel(new Mock <IConnectControlSingleton>().Object, new Mock <IStudioResourceRepository>().Object)
            {
                ResourceType = ResourceType.Folder, ResourcePath = "dave", Parent = new ExplorerItemModel(new Mock <IConnectControlSingleton>().Object, new Mock <IStudioResourceRepository>().Object)
                {
                    ResourcePath = "moo"
                }
            };

            stud.Setup(a => a.MoveItem(model1, "bob"));
            ExplorerView.MoveItem(model1, model2, stud.Object);

            //------------Execute Test---------------------------
            popup.Verify(a => a.Show());
            popup.VerifySet(a => a.Description = "You are not allowed to move items between Servers using the explorer. Please use the deploy instead");
            //------------Assert Results-------------------------
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initialises and displays the dialog
        /// </summary>
        /// <param name="dest">The Weather object to be replaced, or Zone to which Weather will be added</param>
        /// <param name="view">The ExplorerView displaying the soil object in its tree</param>
        /// <param name="nodePath">The path to the soil object within the view's tree</param>
        /// <param name="explorerPresenter">The ExplorerPresenter that is managing all of this</param>
        public void ShowFor(Model dest, ExplorerView view, string nodePath, ExplorerPresenter explorerPresenter)
        {
            this.dest              = dest;
            this.replaceNode       = nodePath;
            this.owningView        = view;
            this.explorerPresenter = explorerPresenter;
            dialog1.TransientFor   = view.MainWidget.Toplevel as Window;
            dialog1.Parent         = view.MainWidget.Toplevel;
            dialog1.WindowPosition = WindowPosition.CenterOnParent;
            // Attempt to find an initial latitude and longitude from a Weather model
            IModel weather = Apsim.Find(dest, typeof(Models.Interfaces.IWeather));
            double latitude, longitude;

            if (weather != null && weather is Weather)
            {
                Weather weatherObj = weather as Weather;
                this.dest = weatherObj;
                if (weatherObj.OpenDataFile())
                {
                    latitude            = weatherObj.Latitude;
                    longitude           = weatherObj.Longitude;
                    entryLatitude.Text  = latitude.ToString();
                    entryLongitude.Text = longitude.ToString();
                }
            }
            dialog1.Show();
        }
Exemplo n.º 8
0
        public void SetUp()
        {
            var mocks = new MockRepository();

            shellConductor = mocks.StrictMock <IScreenConductor>();
            locator        = MockRepository.GenerateMock <IScreenObjectLocator>();
            view           = new ExplorerView(new TreeView(), new TreeView(), shellConductor, locator);
        }
Exemplo n.º 9
0
        public void OnRightClick(EvBase item, TreeViewItem tItem, ExplorerView view, MouseButtonEventArgs e)
        {
            return;

            tItem.ContextMenu = new ContextMenu();

            tItem.ContextMenu.Items.Add(new MenuItem()
            {
                Header = item.Name,
            });
        }
Exemplo n.º 10
0
        public override IScriptCommand Execute(FileExplorer.ParameterDic pm)
        {
            IWindowManager wm = pm.GetValue <IWindowManager>(WindowManagerKey) ?? new WindowManager();

            WPF.MDI.MdiContainer container = pm.GetValue <WPF.MDI.MdiContainer>(MdiContainerKey);

            if (container == null)
            {
                return(ResultCommand.Error(new KeyNotFoundException("MdiContainerKey")));
            }

            IExplorerViewModel explorer = pm.GetValue <IExplorerViewModel>(ExplorerKey);

            if (explorer == null)
            {
                return(ResultCommand.Error(new KeyNotFoundException("ExplorerKey")));
            }

            var view = new ExplorerView();

            Caliburn.Micro.Bind.SetModel(view, explorer); //Set the ViewModel using this command.
            var mdiChild = new WPF.MDI.MdiChild
            {
                DataContext = explorer,
                ShowIcon    = true,
                Content     = view
            };

            mdiChild.SetBinding(WPF.MDI.MdiChild.TitleProperty, new Binding("DisplayName")
            {
                Mode = BindingMode.OneWay
            });
            mdiChild.SetBinding(WPF.MDI.MdiChild.IconProperty, new Binding("CurrentDirectory.Icon")
            {
                Mode = BindingMode.OneWay
            });
            mdiChild.SetBinding(WPF.MDI.MdiChild.WidthProperty, new Binding("Parameters.Width")
            {
                Mode = BindingMode.TwoWay
            });
            mdiChild.SetBinding(WPF.MDI.MdiChild.HeightProperty, new Binding("Parameters.Height")
            {
                Mode = BindingMode.TwoWay
            });
            mdiChild.SetBinding(WPF.MDI.MdiChild.PositionProperty, new Binding("Parameters.Position")
            {
                Mode = BindingMode.TwoWay
            });
            container.Children.Add(mdiChild);

            return(NextCommand);
        }
Exemplo n.º 11
0
 public ControlViewModel(MainWindow mainView, ScreenView view, List <String> extensions, Explorer explorer, ExplorerView explorerView)
 {
     this.explorerView             = explorerView;
     this.extensions               = extensions;
     this.media                    = view;
     this.mainView                 = mainView;
     this.mainView.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(HandleEsc);
     this.explorer                 = explorer;
     this.isFullscreen             = false;
     timer.Interval                = TimeSpan.FromSeconds(1);
     timer.Tick                   += timer_Tick;
     timer.Start();
 }
Exemplo n.º 12
0
        /// <summary>
        /// Generates completion options for a report. This should also work for the property presenter.
        /// </summary>
        /// <param name="code">Source code.</param>
        /// <param name="offset">Offset of the cursor/caret in the source code.</param>
        /// <param name="controlSpace">True iff this intellisense request was generated by the user pressing control + space.</param>
        /// <returns>True if any completion options are found. False otherwise.</returns>
        private bool GenerateReportCompletions(string code, int offset, bool controlSpace = false)
        {
            //var completionOptions = NeedContextItemsArgs.ExamineModelForNames(model, e.ObjectName, true, true, false);
            string   currentLine = code.Split(Environment.NewLine.ToCharArray()).Last();
            ViewBase currentView = Editor;

            while (!(currentView is ExplorerView))
            {
                currentView = currentView.Owner;
            }
            ExplorerView mainView = currentView as ExplorerView;

            return(false);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Open an .apsimx file into the current tab.
        /// </summary>
        /// <param name="name">Name of the simulation</param>
        /// <param name="contents">The xml content</param>
        public void OpenApsimXFromMemoryInTab(string name, string contents)
        {
            ExplorerView      explorerView = new ExplorerView();
            ExplorerPresenter presenter    = new ExplorerPresenter();

            this.Presenters.Add(presenter);
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(contents);
            Simulations simulations = Simulations.Read(doc.DocumentElement);

            presenter.Attach(simulations, explorerView, null);

            this.view.AddTab(name, Properties.Resources.apsim_logo32, explorerView, true);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Open an .apsimx file into the current tab.
        /// </summary>
        /// <param name="fileName">The file to open</param>
        public void OpenApsimXFileInTab(string fileName)
        {
            if (fileName != null)
            {
                ExplorerView      explorerView = new ExplorerView(this.view as ViewBase);
                ExplorerPresenter presenter    = new ExplorerPresenter();
                this.Presenters.Add(presenter);
                try
                {
                    this.view.WaitCursor = true;
                    try
                    {
                        Simulations simulations = Simulations.Read(fileName);
                        presenter.Attach(simulations, explorerView, null);
                        this.view.AddTab(fileName, "ApsimNG.Resources.apsim logo32.png", explorerView.MainWidget, true);

                        // restore the simulation tree width on the form
                        if (simulations.ExplorerWidth == 0)
                        {
                            presenter.TreeWidth = 250;
                        }
                        else
                        {
                            presenter.TreeWidth = Math.Min(simulations.ExplorerWidth, this.view.TabWidth - 20); // ?
                        }
                        Utility.Configuration.Settings.AddMruFile(fileName);
                        List <string> validMrus = new List <string>();                           // make sure recently used files still exist before displaying them
                        foreach (string s in Utility.Configuration.Settings.MruList)
                        {
                            if (File.Exists(s))
                            {
                                validMrus.Add(s);
                            }
                        }
                        Utility.Configuration.Settings.MruList = validMrus;
                        //this.view.FillMruList(validMrus);
                    }
                    finally
                    {
                        this.view.WaitCursor = false;
                    }
                }
                catch (Exception err)
                {
                    this.view.ShowError(err.Message);
                }
            }
        }
Exemplo n.º 15
0
        public void ExplorerView_ShouldNotMoveItem_SourceDestinationSame_ReturnsTrue()
        {
            //------------Setup for test--------------------------
            var sourceItem = new Mock <IExplorerItemModel>();

            sourceItem.Setup(model => model.IsVersion).Returns(false);
            sourceItem.Setup(model => model.ResourcePath).Returns("mypath1");
            sourceItem.Setup(a => a.Children).Returns(new ObservableCollection <IExplorerItemModel>());
            sourceItem.Setup(a => a.Parent).Returns(sourceItem.Object);
            //------------Execute Test---------------------------

            var shouldNotMove = ExplorerView.ShouldNotMove(sourceItem.Object, sourceItem.Object);

            //------------Assert Results-------------------------
            Assert.IsTrue(shouldNotMove);
        }
Exemplo n.º 16
0
        public void SoftOpen(bool NavForward)
        {
            if (!NavForward && VSHistory.Any())
            {
                BHBuffer = VSHistory.Pop();
            }

            if (GRShortcuts.Visibility == Visibility.Visible)
            {
                GRShortcuts.LoadWidgets();
            }
            else
            {
                ExplorerView.Refresh();
            }
        }
Exemplo n.º 17
0
        private ExplorerView CreateExplorer(string path = SettingsHandler.ROOT_FOLDER)
        {
            var h = new LocalHandler(path);

            h.OnError          += HandlerOnOnError;
            h.OnSetCurrentPath += HOnOnSetCurrentPath;

            var x = new ExplorerView();

            x.Init(h);

            x.SendDirectoryUpdateAsCmd += XOnSendDirectoryUpdateAsCmd;
            x.UpdateStatusBar          += XOnUpdateStatusBar;
            x.UpdatePathBarDirect      += XOnUpdatePathBarDirect;

            x.Margin = new Thickness(0, 0, 0, 0);
            return(x);
        }
Exemplo n.º 18
0
        public void MoveUpDown()
        {
            IExplorerView     explorerView      = new ExplorerView();
            ExplorerPresenter explorerPresenter = new ExplorerPresenter();
            CommandHistory    commandHistory    = new CommandHistory();

            explorerPresenter.Attach(simulations, explorerView, null);

            Model modelToMove = Apsim.Get(simulations, "APS14.Factors.NRate") as Model;

            MoveModelUpDownCommand moveCommand = new MoveModelUpDownCommand(modelToMove, true, explorerView);

            moveCommand.Do(commandHistory);

            Model modelToMove2 = Apsim.Get(simulations, "APS14.Factors.NRate") as Model;

            Assert.AreEqual(simulations.Children[2].Children[0].Children[0].Name, "NRate");
            Assert.AreEqual(simulations.Children[2].Children[0].Children[0].Children.Count, 4);
        }
Exemplo n.º 19
0
        // ReSharper disable once InconsistentNaming
        public void ExplorerView_Move_FolderExpectRename()
        {
            //------------Setup for test--------------------------
            var stud   = new Mock <IStudioResourceRepository>();
            var model1 = new ExplorerItemModel(new Mock <IConnectControlSingleton>().Object, new Mock <IStudioResourceRepository>().Object)
            {
                ResourceType = ResourceType.Folder, ResourcePath = "bob"
            };
            var model2 = new ExplorerItemModel(new Mock <IConnectControlSingleton>().Object, new Mock <IStudioResourceRepository>().Object)
            {
                ResourceType = ResourceType.Folder, ResourcePath = "dave", Parent = new ExplorerItemModel(new Mock <IConnectControlSingleton>().Object, new Mock <IStudioResourceRepository>().Object)
                {
                    ResourcePath = "moo"
                }
            };

            stud.Setup(a => a.MoveItem(model1, "bob"));
            ExplorerView.MoveItem(model1, model2, stud.Object);

            //------------Execute Test---------------------------
            stud.Verify(a => a.MoveItem(model1, "dave"));
            //------------Assert Results-------------------------
        }
Exemplo n.º 20
0
        public override IScriptCommand Execute(ParameterDic pm)
        {
            var viewModel = new ExplorerViewModel(_initializer);

            pm["Explorer"] = viewModel;
            var view = new ExplorerView();

            Caliburn.Micro.Bind.SetModel(view, viewModel); //Set the ViewModel using this command.
            var mdiChild = new MdiChild
            {
                DataContext = viewModel,
                ShowIcon    = true,
                Content     = view,
                Width       = 500,
                Height      = 334,
                Position    = new Point(0, 0)
            };

            mdiChild.SetBinding(MdiChild.TitleProperty, new Binding("DisplayName")
            {
                Mode = BindingMode.OneWay
            });
            mdiChild.SetBinding(MdiChild.IconProperty, new Binding("CurrentDirectory.Icon")
            {
                Mode = BindingMode.OneWay
            });
            _container.Children.Add(mdiChild);

            var selection = _getSelectionFunc == null ? null : _getSelectionFunc(pm);

            if (selection != null && selection.Count() > 0)
            {
                return(UIScriptCommands.ExplorerGoToValue(selection.First()));
            }

            return(ResultCommand.NoError);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Open an .apsimx file into the current tab.
        /// </summary>
        /// <param name="name">Name of the simulation</param>
        /// <param name="contents">The xml content</param>
        public void OpenApsimXFromMemoryInTab(string name, string contents)
        {
            ExplorerView explorerView = new ExplorerView(this.view as ViewBase);
            ExplorerPresenter presenter = new ExplorerPresenter();
            this.Presenters.Add(presenter);
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(contents);
            Simulations simulations = Simulations.Read(doc.DocumentElement);
            presenter.Attach(simulations, explorerView, null);

            this.view.AddTab(name, "ApsimNG.Resources.apsim logo32.png", explorerView.MainWidget, true);
        }
Exemplo n.º 22
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();
                        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();
                        href = Path.GetFileName(createDoc.FileNameWritten);
                    }

                    return(string.Format("<p><a href=\"{0}/{1}\" target=\"_blank\">{2}</a></p>", destinationUrl, href, hrefName));
                }
                else
                {
                    return(null);
                }
            }
        }
Exemplo n.º 23
0
        private void Taps_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.TabControl.Items.Count == 1)
            {
                return;
            }

            if (!(this.TabControl.SelectedItem is TabItem tp))
            {
                return;
            }

            if (tp.Content != null)
            {
                if (!(tp.Content is IPage page))
                {
                    return;
                }

                if (page.Equals(this._currentPage))
                {
                    return;
                }

                this._currentPage = page;
                page.OnReFocus();

                if (!page.ShowTreeView)
                {
                    if (this.TreeControl.Visibility == Visibility.Visible)
                    {
                        this.TreeControl.Visibility = Visibility.Hidden;
                        this._drag                   = this.TreeColumn.Width.Value;
                        this.TreeColumn.Width        = new GridLength(0);
                        this.VerticalSplitter1.Width = new GridLength(0);
                    }
                }
                else if (this.TreeControl.Visibility == Visibility.Hidden)
                {
                    this.TreeControl.Visibility  = Visibility.Visible;
                    this.TreeColumn.Width        = new GridLength(this._drag);
                    this.VerticalSplitter1.Width = new GridLength(6);
                }

                this.Navigation.Visibility = page.HideNavigation ? Visibility.Hidden : Visibility.Visible;

                this.ConsoleHost.Visibility = page.HideConsole ? Visibility.Hidden : Visibility.Visible;

                this._explorerNavigationBarRow.Height = page.HideExplorerNavigation ? new GridLength(0) : GridLength.Auto;

                switch (page)
                {
                case EmptyPage _:
                    //Console.WriteLine();
                    break;

                case ExplorerView explorer:
                    this._currentExplorerView = explorer;
                    break;

                case SettingsView _:
                    //Console.WriteLine();
                    break;

                case ThemeView _:
                    //Console.WriteLine();
                    break;
                }
            }
            else
            {
                if (this.TabControl.Items.Count > 1)
                {
                    this.TabControl.SelectedIndex = this.TabControl.Items.Count - 2;
                }
            }
        }
Exemplo n.º 24
0
        /// <summary>Create a new tab.</summary>
        /// <param name="name">Name of the simulation</param>
        /// <param name="simulations">The simulations object to add to tab.</param>
        /// <param name="onLeftTabControl">If true a tab will be added to the left hand tab control.</param>
        private ExplorerPresenter CreateNewTab(string name, Simulations simulations, bool onLeftTabControl)
        {
            ExplorerView explorerView = new ExplorerView(null);
            ExplorerPresenter presenter = new ExplorerPresenter(this);
            if (onLeftTabControl)
                presenters1.Add(presenter);
            else
                presenters2.Add(presenter);

            XmlDocument doc = new XmlDocument();
            presenter.Attach(simulations, explorerView, null);

            this.view.AddTab(name, new Gtk.Image(null, "ApsimNG.Resources.apsim logo32.png"), explorerView.MainWidget, onLeftTabControl);

            // restore the simulation tree width on the form
            if (simulations.ExplorerWidth == 0)
                presenter.TreeWidth = 250;
            else
                presenter.TreeWidth = simulations.ExplorerWidth;

            return presenter;
        }
Exemplo n.º 25
0
        /// <summary>
        /// Open an .apsimx file into the current tab.
        /// </summary>
        /// <param name="fileName">The file to open</param>
        public void OpenApsimXFileInTab(string fileName)
        {
            if (fileName != null)
            {
                ExplorerView explorerView = new ExplorerView(this.view as ViewBase);
                ExplorerPresenter presenter = new ExplorerPresenter();
                this.Presenters.Add(presenter);
                try
                {
                    this.view.WaitCursor = true;
                    try
                    {
                        Simulations simulations = Simulations.Read(fileName);
                        presenter.Attach(simulations, explorerView, null);
                        this.view.AddTab(fileName, "ApsimNG.Resources.apsim logo32.png", explorerView.MainWidget, true);

                        // restore the simulation tree width on the form
                        if (simulations.ExplorerWidth == 0)
                            presenter.TreeWidth = 250;
                        else
                            presenter.TreeWidth = Math.Min(simulations.ExplorerWidth, this.view.TabWidth - 20); // ?
                        Utility.Configuration.Settings.AddMruFile(fileName);
                        List<string> validMrus = new List<string>();                           // make sure recently used files still exist before displaying them
                        foreach (string s in Utility.Configuration.Settings.MruList)
                            if (File.Exists(s))
                                validMrus.Add(s);
                        Utility.Configuration.Settings.MruList = validMrus;
                        //this.view.FillMruList(validMrus);
                    }
                    finally
                    {
                        this.view.WaitCursor = false;
                    }
                }
                catch (Exception err)
                {
                    this.view.ShowError(err.Message);
                }
            }
        }
Exemplo n.º 26
0
 protected override void OnActivated()
 {
     base.OnActivated();
     TabView.RefreshView();
     ExplorerView.RefreshView();
 }
Exemplo n.º 27
0
 public RedirectResult ChangeView(ExplorerView view)
 {
     Session[Extensions.ExplorerViewSessionName] = view;
     return(Redirect(Request.UrlReferrer.AbsoluteUri));
 }
Exemplo n.º 28
0
 public void OnDoubleClick(EvBase item, TreeViewItem tItem, ExplorerView view, MouseButtonEventArgs e)
 {
     MessageBox.Show("Double Clicked");
 }