PTMyView Customization Point

Creating a custom UI view to display in PlanetTogether using a customization

This guide will step through the process of coding a PTMyView Customization. If you are just getting started, you can learn about getting started with customizations.

Required Assemblies

PT.Scheduler

PTUserInterfaceCustomization

System.Windows.Forms

Creating the Class

To create and load a custom view to display in PlanetTogether we need to create a new class.

1. Name the class MyView, this is required.

2. This class must be defined in the PTUserInterfaceCustomization namespace

2. It needs to inherit from PTMyView-- a customization class is located at PTUserCustomization.PTMyView

Here is what a basic class should look like:

namespace PTUserInterfaceCustomization
{
/// <summary>
/// Inherit from PTMyView to implement MyViews member functions and properties
/// </summary>
public class MyView : PTMyView
{
//Empty constructor needed to add customization
public MyView() { }

//Create instance of custom control
private readonly System.Windows.Forms.UserControl m_control = new UserControl();

/// <summary>
/// Override Name property to display customization name
/// </summary>
public override string Name => " Custom My Views Control";

/// <summary>
/// Overrride Description property to display customization description
/// </summary>
public override string Description => "Shows custom view of custom data";

/// <summary>
/// Override TabCaption property to display View Caption
/// </summary>
public override string TabCaption => "Custom View";

/// <summary>
/// Override MyViewTransmissionFiredEvent to let UI know when a transmission has been fired
/// </summary>
public override event MyViewTransmissionHander MyViewTransmissionFiredEvent;

/// <summary>
/// Override this function to return custom control
/// </summary>
/// <returns></returns>
public override UserControl GetUserControl()
{
return m_control;
}

/// <summary>
/// Override Init function to initialize custom control and subscribe to events needed to update the control
/// </summary>
/// <param name="a_sd"></param>
/// <param name="a_eventListener"></param>
/// <param name="a_currentUser"></param>
public override void Init(PT.Scheduler.ScenarioDetail a_sd, UICustomizationsLink a_eventListener, User a_currentUser)
{
//Subscribe to events and initialize control here
}
}
}

 

Creating a control

There must be a singular UserControl returned form this customization. Create a new user control class and use that in place of the base UserControl for m_userControl. In order to add more content to your MyView control, the UserControl returned from GetUserControl can be a container such as a panel or tab control. Any additional custom controls can be added onto the base UserControl to create complex user interfaces, however the MyView screen will be limited to the MyView tab pane within the PlanetTogether client.

There are two functions for implementing PTMyView:

GetUserControl is used to return the instance of the custom MyViews control.

Init can be used to subscribe to events and initialize the custom control.

Let's take a look at the parameters for Init.

  • ScenarioDetail a_sd: Via the various manager objects in this top level object, all other data objects can be accessed.
  • UICustomizationsLink a_eventListener: An event listener that can be used to subscribe to scheduler events such as: ScenarioOpened, ScheduleChanged, JobsSelectedInJobsPane, and GanttBlocksSelected.
  • User a_currentUser: The object containing information about the user operating PlanetTogether.

Loading your MyView

To load this user interface customization, please refer to the Loading a UI Customization File section in Load a Customization File.

If the MyView option does not show up under Views, verify that the class and namespace have been named correctly.

Including Additional Assemblies

See Customization Basics Including Additional Assemblies if your project needs library references not included in PlanetTogether's included assemblies.

Next Steps

Create an example MyView customization: Unscheduled Jobs Grid MyView