- Add Dashboards Module
- Add DashboardsPane Pane Module
- Add Modules to Interfaces.cs
ModuleType
enum (ViewModel) - Add type to ModuleType in MainForm.cs
- Add new Modules to ModuleTypesResolver in
GetId
,GetMainModule
, andGetNavPaneModuleType
(Services) - RUN (note bad title)
- Add string to
ModuleResourceProvider
(Services) - RUN again!
- Add data to DashboardsViewModel using the
dashdata
template. - Add basic code to DashboardViewModel using the
dashvm
template. - Drop DashboardViewer into Dashboard
- Change view object in Presenter constructor to
DashboardViewer
- Wire up CurrentDashboard in DashboardsPresenter using the
dashbind
template.
-
Go to DashboardPanePresenter and add PopulateTree method using
dashlist
-
Add event handler for _tree.DoubleClick
-
Add if statement with
dashlif
-
Add code
var viewModel = ViewModel.ParentViewModel; viewModel.CurrentDashboard = _tree.Selection[0].Tag.ToString();
-
Add Message type to DashboardViewModel using
dashmsg
(creates types for dashboard messages) -
Add Message sender to event
Messenger.Default.Send<DashboardMessage>(DashboardMessage.View());
-
Register message in DashboardsPresenter
Messenger.Default.Register<DashboardMessage>(this, OnDashboardMessage);
-
Add appropriate method as well as call to
BindDashboard()
-
RUN
-
Add New and Edit buttons to Dashboard (use [icon new opportunities] and [icon edit]
-
Add code to BindCommands using
dashevt
template. -
Add methods using CodeRush to ViewModel, decorate with
[Command]
attribute. -
Add Form open code using
dashform
(will add ServiceProperty and Open command) -
Go to DetailFormDocumentManagerService and add "Dashboard" to
GetActualViewModuleType
(Services, line 134)if (documentType == "Dashboard") { var resolver = GetService<Services.IModuleTypesResolver>(parentViewModel); return resolver.GetDashboardModuleType(viewModuleType); }
-
Add appropriate
GetDashboardModuleType
function to interface and class -
Modify
NewDashboard
andEditDashboard
functions usingdashcmd
(overwrite)[Command] public void NewDashboard() { Dashboard d = new Dashboard(); BindDashboard(d); OpenDashboard(d); } [Command] public void EditDashboard() { OpenDashboard(GetCurrentDashboard()); }
-
RUN
-
Drop designer onto DashboardEdit form
-
Add New Save button (remove all others)
-
Remove Data Source tab
-
Modify Presenter to accept a DashboardDesigner and add the following
void View_DashboardClosing(object sender, DashboardClosingEventArgs e) { e.IsDashboardModified = false; } public void BindDashboard() { View.Dashboard = ViewModel.Parameter as Dashboard; }
-
Make sure to wire closing event as well as BindDashboard method in
.ctor
of PresenterView.DashboardClosing += View_DashboardClosing;
-
In DashboardEdit add the following to wait for proper ViewModel attachment
protected override void OnParentViewModelAttached() { Presenter.BindDashboard(); }
-
RUN
-
Bind Save button in
BindCommands
method usingdashsave
template. Will look like:private void BindCommands() { // bind commands to DashboardsEditViewModel here barButtonSave.BindCommand(() => ViewModel.SaveDashboard(), ViewModel); }
-
Implement SaveDashboard method:
[Command] public void SaveDashboard() { Messenger.Default.Send<DashboardMessage>(new DashboardMessage(Parameter as Dashboard, DashboardMessageType.Save)); }
-
Capture message in DashboardsPresenter
private void OnDashboardMessage(DashboardMessage message) { if (message.MessageType == DashboardMessageType.View) BindDashboard(); else if (message.MessageType == DashboardMessageType.Save) ViewModel.Save(message.Dashboard); }
-
Handle new
Save
method (inner code usesdashsv
template)public void Save(Dashboard dashboard) { var file = string.Format("{0}\\{1}.xml", DashboardDirectory, dashboard.Title.Text); dashboard.SaveToXml(file); // refresh dashboard list just in case Dashboards = Directory.EnumerateFiles(DashboardDirectory, "*.xml").ToArray(); }
-
Notify everyone involved something has changed using
dashnote
templatepublic void Save(Dashboard dashboard) { var file = string.Format("{0}\\{1}.xml", DashboardDirectory, dashboard.Title.Text); dashboard.SaveToXml(file); // refresh dashboard list just in case Dashboards = Directory.EnumerateFiles(DashboardDirectory, "*.xml").ToArray(); // send out messages CurrentDashboard = file; Messenger.Default.Send<DashboardMessage>(DashboardMessage.View()); Messenger.Default.Send<DashboardMessage>(DashboardMessage.Refresh()); }
-
Register message in DashboardPanePresenter
Messenger.Default.Register<DashboardMessage>(this, OnDashboardMessage);
-
Handle
OnDashboardMessage
eventprivate void OnDashboardMessage(DashboardMessage message) { if (message.MessageType == DashboardMessageType.Refresh) PopulateTree(); }
-
RUN