Canguro.Controller.Controller.scenePanel_MouseUp C# (CSharp) Method

scenePanel_MouseUp() private method

Method to dispatch the MouseUp event from the ScenePanel and forward it to the current ViewCommand. This method is responsible for releasing mouse capture, ending view commands and updating views accordingly.
private scenePanel_MouseUp ( object sender, System e ) : void
sender object
e System MouseUp params
return void
        void scenePanel_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            System.Diagnostics.Debug.Assert(mainFrm != null);
            if (viewCmd != null)
            {
                GraphicView gv = GraphicViewManager.Instance.ActiveView;
                bool windowSelectionOn = SelectionCommand.WindowSelectionOn;

                viewCmd.ButtonUp(gv, e);
                mainFrm.ScenePanel.Capture = false;

                // Check if its time to end current ViewCommand
                if (e.Button == System.Windows.Forms.MouseButtons.Right || e.Button == MouseButtons.Middle)
                {
                    if ((viewCmd != SelectionCommand || gv.ModelRenderer.RenderOptions.ShowAnimated) && EndViewCommand != null)
                        EndViewCommand(this, new EndViewCommandArgs(viewCmd));
                    else if (!SelectionCommand.IsWorkingAsCommandService)
                    {
                        if (!windowSelectionOn)
                            Canguro.Model.Model.Instance.UnSelectAll();
                    }

                    viewCmd = SelectionCommand;

                    if (StartViewCommand != null)
                        StartViewCommand(this, EventArgs.Empty);
                    mainFrm.ScenePanel.Cursor = SelectionCommand.Cursor;
                }

                if (e.Button == MouseButtons.Middle && lastViewCmd != null)
                {
                    if (lastViewCmd == Commands.View.Trackball3D.Instance)
                        Execute("rotate");
                    else if (lastViewCmd == Commands.View.Pan.Instance)
                        Execute("pan");
                    else if (lastViewCmd == Commands.View.ZoomInteractive.Instance)
                        Execute("zoom");

                    lastViewCmd = null;
                }

                if (viewCmd == SelectionCommand)
                    GraphicViewManager.Instance.UpdateView(gv);
            }
        }