Ejemplo n.º 1
0
        public virtual void MouseMove(object sender, MouseEventArgs e)
        {
            SimpleOpenGlControl openGLWindow = (SimpleOpenGlControl)sender;

            if (this.RotateButton_down == true && Dimension == Dimension.ThreeDimension)
            {
                this.M_Rotation.Y -= (this.M_RotationD.X - e.X) * 0.5f; //繞x軸轉動幾度
                this.M_Rotation.X -= (this.M_RotationD.Y - e.Y) * 0.5f; //繞y軸轉動幾度
                this.M_RotationD   = e.Location;
                if (AutoRefresh == true)
                {
                    openGLWindow.Refresh();
                }
            }
            if (this.MoveButton_down == true)
            {
                //New Version
                if (this.ConnectedOpenGLWindow.Width >= this.ConnectedOpenGLWindow.Height)
                {
                    this.M_Translation.X -= (this.M_TranslationD.X - e.X) / ((float)this.ConnectedOpenGLWindow.Height / 2.0f) * (float)Range; //x軸平移多少距離
                    this.M_Translation.Y += (this.M_TranslationD.Y - e.Y) / ((float)this.ConnectedOpenGLWindow.Height / 2.0f) * (float)Range; //y軸平移多少距離
                    this.M_TranslationD   = e.Location;
                }
                else
                {
                    this.M_Translation.X -= (this.M_TranslationD.X - e.X) / ((float)this.ConnectedOpenGLWindow.Width / 2.0f) * (float)Range; //x軸平移多少距離
                    this.M_Translation.Y += (this.M_TranslationD.Y - e.Y) / ((float)this.ConnectedOpenGLWindow.Width / 2.0f) * (float)Range; //y軸平移多少距離
                    this.M_TranslationD   = e.Location;
                }
                if (AutoRefresh == true)
                {
                    openGLWindow.Refresh();
                }
            }
        }
Ejemplo n.º 2
0
        public virtual void MouseWheel_EventHandler(object sender, MouseEventArgs e)
        {
            SimpleOpenGlControl openGLWindow = (SimpleOpenGlControl)sender;

            if (e.Delta > 0)//滾輪轉的方向為正 倍率增加
            {
                this.m_Scale         *= this.Mouse_Scale_Sensitive;
                this.m_Translation.X -= (this.M_Translation.X
                                         - (e.Location.X - this.Width / 2.0f) / (this.Width / 2.0f) * (float)this.Range)
                                        * (1.0f - this.Mouse_Scale_Sensitive);              //x軸平移多少距離
                this.m_Translation.Y -= (this.M_Translation.Y
                                         + (e.Location.Y - this.Height / 2.0f) / (this.Width / 2.0f) * (float)this.Range)
                                        * (1.0f - this.Mouse_Scale_Sensitive); //y軸平移多少距離
            }
            if (e.Delta < 0)                                                   //滾輪轉的方向為負 倍率減少
            {
                this.m_Scale         /= this.Mouse_Scale_Sensitive;
                this.m_Translation.X -= (this.M_Translation.X
                                         - (e.Location.X - this.Width / 2.0f) / (this.Width / 2.0f) * (float)this.Range)
                                        * (1.0f - 1.0f / this.Mouse_Scale_Sensitive);              //x軸平移多少距離
                this.m_Translation.Y -= (this.M_Translation.Y
                                         + (e.Location.Y - this.Height / 2.0f) / (this.Width / 2.0f) * (float)this.Range)
                                        * (1.0f - 1.0f / this.Mouse_Scale_Sensitive);             //y軸平移多少距離
            }
            if (AutoRefresh == true)
            {
                openGLWindow.Refresh();
            }
        }
Ejemplo n.º 3
0
        public virtual void Reset(object sender, EventArgs e)
        {
            SimpleOpenGlControl openGLWindow = (SimpleOpenGlControl)sender;

            this.M_Translation = new PointF(0.0f, 0.0f);
            this.M_Rotation    = new PointF(0.0f, 0.0f);
            this.M_Scale       = 1;
            if (AutoRefresh == true)
            {
                openGLWindow.Refresh();
            }
        }