Esempio n. 1
0
 //-------------------------------------------------------------------------
 // Constructor
 //-------------------------------------------------------------------------
 public CanvasSession(MainForm pMainForm, CanvasWindow pCanvasWindow, LayerControlForm pLayerControlForm)
 {
     m_controller = new Controller(pCanvasWindow.GetPicture(), pCanvasWindow);
     m_controller.NewUserConnected = OnNewUserConnected;
     m_mainForm = pMainForm;
     m_canvasWindow = pCanvasWindow;
     m_canvasWindow.m_session = this;
     m_layerControl = pLayerControlForm;
     m_layerControl.SetCanvasSession(this);
     //setup first layer
     m_controller.CreateLocalUser();
     ResetCanvas();
     m_controller.Connect(ResetCanvas);
 }
        //-------------------------------------------------------------------------
        // Constructor
        //-------------------------------------------------------------------------
        public CanvasSession(MainForm pMainForm, CanvasWindow pCanvasWindow, LayerControlForm pLayerControlForm)
        {
            m_toolRunner = new ToolRunner("localUserInput", pCanvasWindow.GetPicture());
            m_mainForm = pMainForm;
            m_canvasWindow = pCanvasWindow;
            m_canvasWindow.m_session = this;
            m_layerControl = pLayerControlForm;

            //setup first layer
            selectedLayerID = Gui_CreateLayer();
            Gui_ClearSelectedLayer();

            //add listeners for all functions that should redraw the main canvas
            m_toolRunner.AddFunctionListener( (pA, pB, pC) => { m_canvasWindow.Redraw(pA); }, "tool_down", "tool_up", "tool_move", "undo", "clear", "reorder_layers", "remove_layer");

            //add listeners for all functions that should rebuild the layer list
            m_toolRunner.AddFunctionListener((pA, pB, pC) => { m_layerControl.RebuildLayerControls(); }, "reorder_layers", "rename_layer", "remove_layer", "create_layer");

            //add listeners for all functions that should update a layer thumbnail
            m_toolRunner.AddFunctionListener((pA, pB, pC) => { m_layerControl.UpdateThumbnail(pC["layer"] as string); }, "tool_up", "undo", "clear");

            //add listeners for updating the status bar (:
            m_toolRunner.AddFunctionListener((pA, pB, pC) => { m_mainForm.SetStatus("last action: " + pB); }, "tool_down", "tool_up", "tool_move", "undo", "clear", "reorder_layers", "remove_layer", "create_layer");
        }