public CanvasViewerInitializer(ICanvas canvas, ISmartSession session)
 {
     _canvas  = canvas;
     _session = session;
     InitIsMultiAoi();
     _canvas.Container.KeyUp   += new KeyEventHandler(Container_KeyUp);
     _canvas.Container.MouseUp += new MouseEventHandler(Container_MouseUp);
     LoadSystemLayers();
     _contextMenuHandler = new CanvasContextMenuHandler(session, _aoiContainer, this as ICanvasViewerMenuHandlerManager);
     _toolbarManager     = new ContextMenuToolbarManager(_session);
 }
 public void Dispose()
 {
     _rightMouseMenu           = null;
     _rightMouseNormalMenus    = null;
     _rightMousePencilToolMenu = null;
     _contextMenuHandlers.Clear();
     if (_canvas != null)
     {
         _canvas.Container.KeyUp   -= new KeyEventHandler(Container_KeyUp);
         _canvas.Container.MouseUp -= new MouseEventHandler(Container_MouseUp);
         _canvas = null;
     }
     if (_aoiContainer != null)
     {
         (_aoiContainer as AOIContainerLayer).Dispose();
         _aoiContainer = null;
     }
     if (_selectedAOILayer != null)
     {
         (_selectedAOILayer as SelectedAOILayer).Dispose();
         _selectedAOILayer = null;
     }
     if (_session != null)
     {
         _session = null;
     }
     if (_contextMenuHandler != null)
     {
         (_contextMenuHandler as CanvasContextMenuHandler).HandleRemoveAll();
         _contextMenuHandler = null;
     }
     if (_toolbarManager != null)
     {
         _toolbarManager.Close();
         _toolbarManager = null;
     }
 }