/// <summary> /// Attach the Manager model and ManagerView to this presenter. /// </summary> /// <param name="model">The model</param> /// <param name="view">The view to attach</param> /// <param name="presenter">The explorer presenter being used</param> public void Attach(object model, object view, ExplorerPresenter presenter) { manager = model as Manager; managerView = view as IManagerView; explorerPresenter = presenter; intellisense = new IntellisensePresenter(managerView as ViewBase); intellisense.ItemSelected += OnIntellisenseItemSelected; scriptModel = manager.Children.FirstOrDefault(); // See if manager script has a description attribute on it's class. if (scriptModel != null) { DescriptionAttribute descriptionName = ReflectionUtilities.GetAttribute(scriptModel.GetType(), typeof(DescriptionAttribute), false) as DescriptionAttribute; if (descriptionName != null) { explorerPresenter.ShowDescriptionInRightHandPanel(descriptionName.ToString()); } } propertyPresenter.Attach(scriptModel, managerView.GridView, presenter); managerView.Editor.Mode = EditorType.ManagerScript; managerView.Editor.Text = manager.Code; managerView.Editor.ContextItemsNeeded += OnNeedVariableNames; managerView.Editor.LeaveEditor += OnEditorLeave; managerView.Editor.AddContextSeparator(); managerView.Editor.AddContextActionWithAccel("Test compile", OnDoCompile, "Ctrl+T"); managerView.Editor.AddContextActionWithAccel("Reformat", OnDoReformat, "Ctrl+R"); managerView.Editor.Location = manager.Location; managerView.TabIndex = manager.ActiveTabIndex; presenter.CommandHistory.ModelChanged += CommandHistory_ModelChanged; }
/// <summary> /// Attach the Manager model and ManagerView to this presenter. /// </summary> /// <param name="model">The model</param> /// <param name="view">The view to attach</param> /// <param name="presenter">The explorer presenter being used</param> public void Attach(object model, object view, ExplorerPresenter presenter) { manager = model as Manager; managerView = view as IManagerView; explorerPresenter = presenter; intellisense = new IntellisensePresenter(managerView as ViewBase); intellisense.ItemSelected += OnIntellisenseItemSelected; scriptModel = manager.Children.FirstOrDefault(); if (scriptModel != null) { propertyPresenter.Attach(scriptModel, managerView.GridView, presenter); } managerView.Editor.ScriptMode = true; managerView.Editor.Text = manager.Code; managerView.Editor.ContextItemsNeeded += OnNeedVariableNames; managerView.Editor.LeaveEditor += OnEditorLeave; managerView.Editor.AddContextSeparator(); managerView.Editor.AddContextActionWithAccel("Test compile", OnDoCompile, "Ctrl+T"); managerView.Editor.AddContextActionWithAccel("Reformat", OnDoReformat, "Ctrl+R"); managerView.Editor.Location = manager.Location; managerView.TabIndex = manager.ActiveTabIndex; presenter.CommandHistory.ModelChanged += CommandHistory_ModelChanged; }
/// <summary> /// Attach the specified Model and View. /// </summary> /// <param name="model">The model</param> /// <param name="view">The view</param> /// <param name="explorerPresenter">The parent explorer presenter</param> public void Attach(object model, object view, ExplorerPresenter explorerPresenter) { this.map = model as Map; this.view = view as MapView; this.explorerPresenter = explorerPresenter; propertyPresenter = new PropertyPresenter(); propertyPresenter.Attach(model, this.view.Grid, this.explorerPresenter); // Tell the view to populate the axis. this.PopulateView(); this.view.Zoom = this.map.Zoom; this.view.Center = this.map.Center; this.view.ViewChanged += this.OnViewChanged; explorerPresenter.CommandHistory.ModelChanged += OnModelChanged; }
/// <summary> /// Attach the Manager model and ManagerView to this presenter. /// </summary> /// <param name="model">The model</param> /// <param name="view">The view to attach</param> /// <param name="presenter">The explorer presenter being used</param> public void Attach(object model, object view, ExplorerPresenter presenter) { manager = model as Manager; managerView = view as IManagerView; explorerPresenter = presenter; intellisense = new IntellisensePresenter(managerView as ViewBase); intellisense.ItemSelected += OnIntellisenseItemSelected; scriptModel = manager.Children.FirstOrDefault(); // See if manager script has a description attribute on it's class. if (scriptModel != null) { DescriptionAttribute descriptionName = ReflectionUtilities.GetAttribute(scriptModel.GetType(), typeof(DescriptionAttribute), false) as DescriptionAttribute; if (descriptionName != null) { explorerPresenter.ShowDescriptionInRightHandPanel(descriptionName.ToString()); } } propertyPresenter = new PropertyPresenter(); try { propertyPresenter.Attach(scriptModel, managerView.PropertyEditor, presenter); } catch (Exception err) { explorerPresenter.MainPresenter.ShowError(err); } managerView.Editor.Mode = EditorType.ManagerScript; managerView.Editor.Text = manager.Code; #if NETFRAMEWORK // In gtk3 builds, the gtksourceview completion infrastructure // handles all of the completion functionality internally. managerView.Editor.ContextItemsNeeded += OnNeedVariableNames; #endif managerView.Editor.LeaveEditor += OnEditorLeave; managerView.Editor.AddContextSeparator(); managerView.Editor.AddContextActionWithAccel("Test compile", OnDoCompile, "Ctrl+T"); managerView.Editor.AddContextActionWithAccel("Reformat", OnDoReformat, "Ctrl+R"); managerView.Editor.Location = manager.Location; managerView.TabIndex = manager.ActiveTabIndex; presenter.CommandHistory.ModelChanged += CommandHistory_ModelChanged; }
/// <summary> /// Attaches the model to the view. /// </summary> /// <param name="model">The model.</param> /// <param name="view">The view.</param> /// <param name="explorerPresenter">The explorer presenter.</param> public void Attach(object model, object view, ExplorerPresenter explorerPresenter) { this.view = view as IGraphPanelView; this.panel = model as GraphPanel; this.presenter = explorerPresenter; graphs = new List <GraphTab>(); if (this.view == null || this.panel == null || this.presenter == null) { throw new ArgumentException(); } presenter.CommandHistory.ModelChanged += OnModelChanged; this.view.GraphViewCreated += ModifyGraphView; properties = new PropertyPresenter(); properties.Attach(panel, this.view.PropertiesView, presenter); (processingThread, startTime) = StartWork(); }
/// <summary> /// Attach the model to the view. /// </summary> /// <param name="model">The model to connect to.</param> /// <param name="v">The view to connect to.</param> /// <param name="parentPresenter">The parent explorer presenter.</param> public void Attach(object model, object v, ExplorerPresenter parentPresenter) { explorerPresenter = parentPresenter; view = v as IDualGridView; tableModel = model as IModelAsTable; if (tableModel.Tables.Count != 1) { throw new Exception("PropertyAndTablePresenter must have a single data table."); } table = tableModel.Tables[0]; view.Grid2.DataSource = table; view.Grid2.CellsChanged += OnCellValueChanged2; view.Grid2.NumericFormat = null; parentPresenter.CommandHistory.ModelChanged += OnModelChanged; propertyPresenter = new PropertyPresenter(); explorerPresenter.ApsimXFile.Links.Resolve(propertyPresenter); propertyPresenter.Attach(model, view.Grid1, parentPresenter); gridPresenter = new GridPresenter(); gridPresenter.Attach(model, view.Grid2, parentPresenter); }