Exemple #1
0
        //-------------------------------------------------------------------------
        // 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");
        }
        //-------------------------------------------------------------------------
        // 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");
        }
 void OnNewUserConnected(ToolRunner pNewToolrunner)
 {
     if (m_canvasWindow.InvokeRequired)
     {
         m_canvasWindow.Invoke(new Controller.ToolrunnerHandler(OnNewUserConnected), pNewToolrunner);
     }
     else
     {
         if (pNewToolrunner.username == Controller.LOCAL_USER)
         {
             //add listeners for all functions that should redraw the main canvas
             pNewToolrunner.AddFunctionListener((pToolRunner, pFuncName, pToken) => { m_canvasWindow.Redraw(pToolRunner); }, "tool_down", "tool_up", "tool_move", "undo", "clear", "reorder_layers", "remove_layer");
             //add listeners for all functions that should rebuild the layer list
             pNewToolrunner.AddFunctionListener((pToolRunner, pFuncName, pToken) => { m_layerControl.RebuildLayerControls(); }, "reorder_layers", "rename_layer", "remove_layer", "create_layer");
             //ToolRunner pTarget, string pFunctionName, JToken inputMessage
             //add listeners for all functions that should update a layer thumbnail
             pNewToolrunner.AddFunctionListener((pToolRunner, pFuncName, pToken) => { m_layerControl.UpdateThumbnail(pToken.Value <string>("layer")); }, "tool_up", "undo", "clear");
             //add listeners for updating the status bar (:
             pNewToolrunner.AddFunctionListener((pA, pB, pC) => { m_mainForm.SetStatus("last action: " + pB); }, "tool_down", "tool_up", "tool_move", "undo", "clear", "reorder_layers", "remove_layer", "create_layer");
         }
         else   //network users don't push so many events
                //add listeners for all functions that should redraw the main canvas
         {
             pNewToolrunner.AddFunctionListener((pToolRunner, pFuncName, pToken) => { m_canvasWindow.Redraw(pToolRunner); }, "tool_up", "undo", "clear", "reorder_layers", "remove_layer");
             //add listeners for all functions that should rebuild the layer list
             pNewToolrunner.AddFunctionListener((pToolRunner, pFuncName, pToken) => { m_layerControl.RebuildLayerControls(); }, "reorder_layers", "rename_layer", "remove_layer", "create_layer");
             //ToolRunner pTarget, string pFunctionName, JToken inputMessage
             //add listeners for all functions that should update a layer thumbnail
             pNewToolrunner.AddFunctionListener((pToolRunner, pFuncName, pToken) => { m_layerControl.UpdateThumbnail(pToken.Value <string>("layer")); }, "tool_up", "undo", "clear");
         }
     }
 }