Viewport / Panel maximum zoom + CommandHandler

Question 1: Setting the maximumScale
I tried to set the maximum zoom level but in the constructor but the panel object is null. Any Suggestions on where this can be set?
myDiagram.Panel.MaximumScale = 4.0
Question 2: Setting custom zoom factor.
Is this the correct way to extend the zoom factor? I wanted +/- 10%.
// CommandHandler
public override void IncreaseZoom(object param)
{
Diagram diagram = this.Diagram;
if (diagram != null)
{
DiagramPanel panel = diagram.Panel;
if (panel != null)
{
panel.Scale += zoomFactor;
}
}
}
Question 3: Extending CommandHandler
Will there be support to plug-in custom commands into the CommandHandler? On which event in the Diagram should I update commands?
I have added custom command like so.
// Inside CommandHandler
public void UpdateCanExecute()
{
if (_leftAlignCommand != null)
_leftAlignCommand.RaiseCanExecuteChanged(this.Diagram);
...
public ICommand AlignLeftCommand
{
get
{
if (_leftAlignCommand == null)
{
_leftAlignCommand = new RelayCommand(LeftAlign);
}
return _leftAlignCommand;
}
}
Thank you,
Pavel
  1. You could try executing that in a Loaded event handler. With version 1.1, use the Diagram.TemplateApplied event.

  2. That’s right – except I wouldn’t add, I would multiply the DiagramPanel.Scale value.

  3. That looks about right. CommandHandler just supports defining and modifying the behavior of a fixed set of commands. It does not support any manner of managing an arbitrary number of custom commands.

For this command to align selected nodes, I suggest implementing a Diagram.SelectionChanged event handler to update your _leftAlignCommand.

Thank you,

Worked great!