Esempio n. 1
0
        private CVector2f getPositionFromMouseClick(System.Windows.Forms.MouseEventArgs mouseArgs)
        {
            //Debug.Write("Click - X: " + mouseArgs.X + " Y: " + mouseArgs.Y + "\n");
            // da die Y-Koordinate von Oben ausgeht aber unser ViewPort von unten ausgeht muss
            // die Y-Koordiante umgekehrt werden, damit die Stadt an der korrekten Position
            // eingefügt werden kann
            float mouseX = mouseArgs.X;
            float mouseY = this.Height - mouseArgs.Y;

            CVector2f position = new CVector2f();

            position.x = (float)(mBounds.left + ((mouseX * (mBounds.right - mBounds.left)) / (float)this.Width));
            position.y = (float)(mBounds.bottom + ((mouseY * (mBounds.top - mBounds.bottom)) / (float)this.Height));
            return(position);
        }
Esempio n. 2
0
        public void click(object sender, EventArgs args)
        {
            if (mCursorAction.change || mCursorAction.add || mCursorAction.del)
            {
                System.Windows.Forms.MouseEventArgs mouseArgs = (System.Windows.Forms.MouseEventArgs)args;

                if (mouseArgs.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    CVector2f position = getPositionFromMouseClick(mouseArgs);

                    //Debug.Write("pos - X: " + position.x + " Y: " + position.y + "\n");
                    handleCursorAction(position);
                    CConnectionList.getInstance().generateFromPointList(CTSPLibFileParser.E_EDGE_WEIGHT_TYPE.E_EUC_2D);
                    this.Refresh();
                }
            }
        }
Esempio n. 3
0
        public void click(object sender, EventArgs args)
        {
            System.Windows.Forms.MouseEventArgs mouseArgs = (System.Windows.Forms.MouseEventArgs)args;

            Debug.Write("Click - X: " + mouseArgs.X + " Y: " + mouseArgs.Y + "\n");
            // da die Y-Koordinate von Oben ausgeht aber unser ViewPort von unten ausgeht muss
            // die Y-Koordiante umgekehrt werden, damit die Stadt an der korrekten Position
            // eingefügt werden kann
            CVector2f mouseClickPos = new CVector2f(mouseArgs.X, this.Height - mouseArgs.Y);

            CVector2f position = new CVector2f();

            position.x = mouseClickPos.x / (float)this.Width * (mBounds.right - mBounds.left);
            position.y = mouseClickPos.y / (float)this.Height * (mBounds.top - mBounds.bottom);

            mCityList.Add(position);
            this.Refresh();
        }
Esempio n. 4
0
        private void handleCursorAction(CVector2f position)
        {
            if (mCursorAction.add)
            {
                try
                {
                    CMemoryTester.fitMemory(CTSPPointList.getInstance().length() + 1);
                }
                catch (CInsufficientMemoryException memoryException)
                {
                    if (memoryException.getType() == CInsufficientMemoryException.E_EXCEPTION_TYPE.E_32_BIT_ERROR)
                    {
                        MessageBox.Show("Um ein Projekt mit einem Knoten mehr erzeugen zu können, benötigen Sie ca. " + memoryException.getMemoryNeeded()
                                        + " MByte. 32-Bit-Anwendungen können aber maximal " + memoryException.getMemoryAvailable() + " MByte verwalten. "
                                        + "Bitte verwenden sie die 64-Bit Version oder verwenden Sie ein geringe Anzahl an Punkten.", "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show("Auf ihrem System stehen noch " + memoryException.getMemoryAvailable() + " MByte zur Verfügung. Es werden aber ca. "
                                        + memoryException.getMemoryNeeded() + " MByte benötigt. "
                                        + "Wenn Sie ein Projekt mit einer höheren Anzahl von Punkten verwenden möchten stellen Sie Bitte mehr RAM zur Verfügung.", "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                CTSPPointList.getInstance().addPoint(new CTSPPoint(position.x, position.y));
            }

            if (mCursorAction.del)
            {
                float     precision = (float)((mBounds.right - mBounds.left) / 100);
                CTSPPoint Point     = CTSPPointList.getInstance().getPointsbyCoordinates(position.x, position.y, precision);
                if (!(Point == null))
                {
                    CTSPPointList.getInstance().remove(Point);
                }
            }

            if (mCursorAction.change)
            {
                pointToMove.movePoint = false;
            }
        }
Esempio n. 5
0
        public void mMouseDown(object sender, EventArgs args)
        {
            if (mCursorAction.change)
            {
                System.Windows.Forms.MouseEventArgs mouseArgs = (System.Windows.Forms.MouseEventArgs)args;

                if (mouseArgs.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    CVector2f position = getPositionFromMouseClick(mouseArgs);

                    float     precision = (float)((mBounds.right - mBounds.left) / 100);
                    CTSPPoint Point     = CTSPPointList.getInstance().getPointsbyCoordinates(position.x, position.y, precision);
                    if (!(Point == null))
                    {
                        pointToMove.movePoint   = true;
                        pointToMove.pointToMove = Point;
                    }
                }
            }
        }
Esempio n. 6
0
        public void mMouseMove(object sender, EventArgs args)
        {
            System.Windows.Forms.MouseEventArgs mouseArgs = (System.Windows.Forms.MouseEventArgs)args;

            CVector2f position = getPositionFromMouseClick(mouseArgs);

            if (!mCursorAction.change)
            {
                return;
            }

            if (pointToMove.movePoint)
            {
                if (mouseArgs.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    pointToMove.pointToMove.x = position.x;
                    pointToMove.pointToMove.y = position.y;
                }
            }
        }
Esempio n. 7
0
        public void render(object sender, EventArgs args)
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);

            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Gl.glLoadIdentity();

            Gl.glColor3f(0.0f, 0.0f, 0.0f);

            Gl.glPointSize(5);

            Gl.glColor3f(0.8f, 0.8f, 0.8f);


            // Linien Zeichnen
            for (int cityIndex = 0; cityIndex < mCityList.Count; cityIndex++)
            {
                CVector2f fromCity = mCityList[cityIndex];
                for (int connectionToCityIndex = cityIndex + 1; connectionToCityIndex < mCityList.Count; connectionToCityIndex++)
                {
                    CVector2f toCity = mCityList[connectionToCityIndex];
                    Gl.glBegin(Gl.GL_LINES);
                    Gl.glVertex3f(fromCity.x, fromCity.y, 0.0f);
                    Gl.glVertex3f(toCity.x, toCity.y, 0.0f);
                    Gl.glEnd();
                }
            }

            Gl.glColor3f(0.0f, 0.0f, 0.0f);

            // Städte Zeichnen
            foreach (CVector2f city in mCityList)
            {
                Gl.glBegin(Gl.GL_POINTS);
                Gl.glVertex3f(city.x, city.y, 0.0f);
                Gl.glEnd();
            }

            Gl.glFlush();
        }