private void Camera_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.LeftButton == MouseButtonState.Pressed)
     {
         System.Windows.DataObject dataObject = new System.Windows.DataObject();
         dataObject.SetData("Object", new Camera());
         DragDrop.DoDragDrop(this, dataObject, System.Windows.DragDropEffects.Copy);
     }
 }
        /// <summary>
        /// Metoda odpowiadająca za przesuwanie płaszczyzn obcinających i zaznaczanie
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Views_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            ClipPlaneType planeType = ClipPlaneType.NONE;

            if (Renderer.Clipping && e.Button == MouseButtons.Left && !GetShiftPressed())
            {
                ViewportInfo views = GetViewCoords(tabWidok.SelectedIndex);
                int x = (int)e.X;
                int y = (int)e.Y;

                ViewportOrientation viewport = GetViewportType(x, y);

                if (viewport != ViewportOrientation.None)
                {
                    ViewportType viewportType = viewport == ViewportOrientation.Perspective
                                                    ? ViewportType.Perspective
                                                    : ViewportType.Orto;
                    int rect = (int)viewport;
                    int orthoRect = rect == 3 ? 0 : rect;

                    planeType = SelectingElems.SelectClippingPlane(Renderer.clipVertices, Renderer.clipIndices, viewportType,
                                                       new System.Drawing.Point(x - views.posX[rect],
                                                                                y - views.posY[rect]),
                                                       new System.Drawing.Point(views.sizeX[rect], views.sizeY[rect]),
                                                       new Vector2(renderer.OrthoWidth[orthoRect],
                                                                   (float)views.sizeY[rect] / views.sizeX[rect] *
                                                                   renderer.OrthoWidth[orthoRect]),
                                                       renderer.OrthoPos[orthoRect], renderer.OrthoLookAt[orthoRect],
                                                       viewport);

                    //Console.WriteLine(planeType.ToString());

                    if(planeType != ClipPlaneType.NONE)
                    {
                        System.Windows.DataObject dataObject = new System.Windows.DataObject();

                        switch(viewport)
                        {
                            case ViewportOrientation.Front:
                                dataObject.SetData("Viewport", "front");
                                break;

                            case ViewportOrientation.Side:
                                dataObject.SetData("Viewport", "side");
                                break;

                            case ViewportOrientation.Top:
                                dataObject.SetData("Viewport", "top");
                                break;

                            case ViewportOrientation.Perspective:
                                dataObject.SetData("Viewport", "perspective");
                                break;

                            default:
                                break;
                        }
                        dragX = (float)e.X + xOffset;
                        dragY = (float)e.Y + yOffset;
                        dataObject.SetData("Plane", planeType.ToString());
                        DragDrop.DoDragDrop(this, dataObject, System.Windows.DragDropEffects.Copy);
                    }
                }
            }

            int sumSelected = currScene.selTriangles.Count + currScene.selLights.Count + currScene.selCams.Count;

            if(e.Button == MouseButtons.Left && planeType == ClipPlaneType.NONE && contextMenu.MenuItems[0].Checked == true && sumSelected <= 1 && !GetShiftPressed())
            {
                mouseDownHandled = true;

                ViewportInfo views = GetViewCoords(tabWidok.SelectedIndex);
                int x = (int)e.X;
                int y = (int)e.Y;

                ViewportOrientation viewport = GetViewportType(x, y);

                if(viewport != ViewportOrientation.None)
                {
                    ViewportType viewportType = viewport == ViewportOrientation.Perspective
                                                    ? ViewportType.Perspective
                                                    : ViewportType.Orto;
                    int rect = (int)viewport;
                    int orthoRect = rect == 3 ? 0 : rect;

                    SelectingElems.SelectElems(currScene, renderer.GetCamsPoints(), renderer.GetLightsPoints(), viewportType, new System.Drawing.Point(x - views.posX[rect], y - views.posY[rect]),
                        new System.Drawing.Point(views.sizeX[rect], views.sizeY[rect]), new Vector2(renderer.OrthoWidth[orthoRect], (float)views.sizeY[rect] / views.sizeX[rect] * renderer.OrthoWidth[orthoRect]),
                        renderer.OrthoPos[orthoRect], renderer.OrthoLookAt[orthoRect], GetCtrlPressed());

                    rect = (int)viewport;
                    orthoRect = rect == 3 ? 0 : rect;

                    System.Windows.DataObject dataObject = new System.Windows.DataObject();

                    switch(viewport)
                    {
                        case ViewportOrientation.Front:
                            dataObject.SetData("Viewport", "front");
                            break;

                        case ViewportOrientation.Side:
                            dataObject.SetData("Viewport", "side");
                            break;

                        case ViewportOrientation.Top:
                            dataObject.SetData("Viewport", "top");
                            break;

                        case ViewportOrientation.Perspective:
                            dataObject.SetData("Viewport", "perspective");
                            break;

                        default:
                            break;
                    }

                    dataObject.SetData("Point", SelectingElems.pointFound);

                    Renderer.RecalculateData(currScene);
                    if (GetAltPressed())
                    {
                        for (int i = 0; i < currScene.parts.Count; i++)
                        {
                            foreach (HierarchyMesh obj in currScene.selTriangles)
                            {
                                if (currScene.parts[i].triangles.Contains((int) obj.triangles[0]))
                                {
                                    Material_ material = null;
                                    foreach (Material_ m in currScene.materials)
                                    {
                                        if (m.name == currScene.materialAssign[i])
                                        {
                                            material = new Material_(m);
                                            material.colorR = material.colorR*255;
                                            material.colorG = material.colorG*255;
                                            material.colorB = material.colorB*255;
                                        }
                                    }
                                    dataObject.SetData("Object", material);
                                    i = Int32.MaxValue - 1;
                                    break;
                                }
                            }
                        }
                    }

                    if(currScene.selLights.Count == 1 && GetAltPressed())
                    {
                        dataObject.SetData("Light", currScene.lights[currScene.selLights[0]]);
                        dataObject.SetData("LightPrevious", new Light_(currScene.lights[currScene.selLights[0]]));
                    }

                    if (currScene.selTriangles.Count > 0 && GetAltPressed())
                    {
                        System.Windows.DataObject do1 = new DataObject();
                        do1.SetData("Prepared", "");
                        DragDrop.DoDragDrop(this, do1, System.Windows.DragDropEffects.Copy);
                    }

                    dragX = (float)e.X + xOffset;
                    dragY = (float)e.Y + yOffset;
                    undo.Save(currScene);
                    DragDrop.DoDragDrop(this, dataObject, System.Windows.DragDropEffects.Copy);

                    RenderViews();
                }
            }
        }
        private void Views_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            Views.Focus();
            mouseDownHandled = false;

            if (!GetShiftPressed() && e.Button == MouseButtons.Left)
            {
                if (currScene.selCams.Count > 0 || currScene.selLights.Count > 0 || currScene.selTriangles.Count > 0)
                {
                    System.Windows.DataObject dataObject = new System.Windows.DataObject();
                    ViewportInfo coords = GetViewCoords(tabWidok.SelectedIndex);
                    undo.Save(currScene);

                    ViewportOrientation viewport = GetViewportType(e.X, e.Y);
                    switch(viewport)
                    {
                        case ViewportOrientation.Front:
                            dataObject.SetData("Viewport", "front");
                            break;

                        case ViewportOrientation.Side:
                            dataObject.SetData("Viewport", "side");
                            break;

                        case ViewportOrientation.Top:
                            dataObject.SetData("Viewport", "top");
                            break;

                        case ViewportOrientation.Perspective:
                            dataObject.SetData("Viewport", "perspective");
                            break;

                        default:
                            break;
                    }

                    if (currScene.selLights.Count == 1)
                    {
                        dataObject.SetData("Light", currScene.lights[currScene.selLights[0]]);
                        dataObject.SetData("LightPrevious", new Light_(currScene.lights[currScene.selLights[0]]));
                    }

                    dragX = (float)e.X + xOffset;
                    dragY = (float)e.Y + yOffset;
                    if (contextMenu.MenuItems[1].Checked == true)
                    {
                        directionX = 0;
                        directionY = 0;
                        angle = undefined;
                        int rect = (int)viewport;
                        ViewportInfo views = GetViewCoords(tabWidok.SelectedIndex);
                        dragX = (int)(views.posX[rect] + views.sizeX[rect] / 2.0f) + xOffset;
                        dragY = (int)(views.posY[rect] + views.sizeY[rect] / 2.0f) + yOffset;
                    }
                    DragDrop.DoDragDrop(this, dataObject, System.Windows.DragDropEffects.Move);
                    currScene.selectedHierObj = null;
                    RenderViews();
                }
                //else
                //{
                //    ViewportInfo views = GetViewCoords(tabWidok.SelectedIndex);
                //    int x = (int)e.X;
                //    int y = (int)e.Y;

                //    ViewportOrientation viewport = GetViewportType(x, y);

                //    if(viewport != ViewportOrientation.None)
                //    {
                //        ViewportType viewportType = viewport == ViewportOrientation.Perspective ? ViewportType.Perspective : ViewportType.Orto;
                //        int rect = (int)viewport;
                //        int orthoRect = rect == 3 ? 0 : rect;

                //        SelectingElems.SelectElems(currScene, renderer.GetCamsPoints(), renderer.GetLightsPoints(), viewportType, new System.Drawing.Point(x - views.posX[rect], y - views.posY[rect]),
                //            new System.Drawing.Point(views.sizeX[rect], views.sizeY[rect]), new Vector2(renderer.OrthoWidth[orthoRect], (float)views.sizeY[rect] / views.sizeX[rect] * renderer.OrthoWidth[orthoRect]),
                //            renderer.OrthoPos[orthoRect], renderer.OrthoLookAt[orthoRect], false);
                //    }

                //    for (int i = 0; i < currScene.parts.Count; i++)
                //    {
                //        foreach (HierarchyMesh obj in currScene.selTriangles)
                //            if (currScene.parts[i].triangles.Contains((int)obj.triangles[0]))
                //            {
                //                System.Windows.DataObject dataObject = new System.Windows.DataObject();
                //                Material_ material = null;
                //                foreach (Material_ m in currScene.materials)
                //                {
                //                    if (m.name == currScene.materialAssign[i])
                //                    {
                //                        material = new Material_(m);
                //                        material.colorR = material.colorR * 255;
                //                        material.colorG = material.colorG * 255;
                //                        material.colorB = material.colorB * 255;
                //                    }
                //                }
                //                dataObject.SetData("Object", material);
                //                currScene.selTriangles.Clear();
                //                DragDrop.DoDragDrop(this, dataObject, System.Windows.DragDropEffects.Move);
                //                i = Int32.MaxValue - 1;
                //                break;
                //            }
                //    }

                //    currScene.ClearSelectedTriangles();
                //}
            }
            //Console.WriteLine(e.Button + " " + GetShiftPressed());
            else if(e.Button == MouseButtons.Middle || (e.Button == MouseButtons.Left && GetShiftPressed()))
            {
                ViewportInfo views = GetViewCoords(tabWidok.SelectedIndex);
                int x = (int)e.X;
                int y = (int)e.Y;

                ViewportOrientation viewport = GetViewportType(x, y);
                if(shiftingViewport == ViewportOrientation.None && viewport != ViewportOrientation.None && viewport != ViewportOrientation.Perspective)
                {
                    shiftingViewport = viewport;
                }

                if(shiftingViewport != ViewportOrientation.None)
                {
                    renderer.MoveOrtho((int)shiftingViewport, (int)-(e.X - mousePos.X), (int)-(e.Y - mousePos.Y),
                        views.sizeX[(int)shiftingViewport], views.sizeY[(int)shiftingViewport]);

                    RenderViews();
                }
            }
            else
            {
                shiftingViewport = ViewportOrientation.None;
            }

            mousePos.X = e.X;
            mousePos.Y = e.Y;
        }
        //private void ViewsBezier_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
        //{
        //    ViewportInfo views = GetViewCoords();
        //    int x = (int)e.X;
        //    int y = (int)e.Y;
        //    ViewportOrientation viewport = GetViewportType(x, y);
        //    if (viewport != ViewportOrientation.None)
        //    {
        //        ViewportType viewportType = viewport == ViewportOrientation.Perspective ? ViewportType.Perspective : ViewportType.Orto;
        //        int rect = (int)viewport;
        //        int orthoRect = rect == 3 ? 0 : rect;
        //        SelectingElems.SelectBezierControlPoint(bezierSurface, renderer.bezierCam, viewportType, new System.Drawing.Point(x - views.posX[rect], y - views.posY[rect]),
        //                new System.Drawing.Point(views.sizeX[rect], views.sizeY[rect]), new Vector2(renderer.BezierOrthoWidth[orthoRect],
        //                (float)views.sizeY[rect] / views.sizeX[rect] * renderer.BezierOrthoWidth[orthoRect]),
        //                renderer.BezierOrthoPos[orthoRect], renderer.BezierOrthoLookAt[orthoRect]);
        //        RenderBezier();
        //    }
        //}
        private void ViewsBezier_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            ViewsBezier.Focus();

            if (e.Button == MouseButtons.Left && !GetShiftPressed())
            {
                if (bezierSurface.selectedPointIdx != -1)
                {
                    System.Windows.DataObject dataObject = new System.Windows.DataObject();
                    ViewportInfo coords = GetViewCoords(tabWidok.SelectedIndex);
                    undo.Save(currScene);

                    ViewportOrientation viewport = GetViewportType(e.X, e.Y);
                    switch (viewport)
                    {
                        case ViewportOrientation.Front:
                            dataObject.SetData("Viewport", "front");
                            break;

                        case ViewportOrientation.Side:
                            dataObject.SetData("Viewport", "side");
                            break;

                        case ViewportOrientation.Top:
                            dataObject.SetData("Viewport", "top");
                            break;

                        case ViewportOrientation.Perspective:
                            dataObject.SetData("Viewport", "perspective");
                            break;

                        default:
                            break;
                    }

                    dragX = (float)e.X + xOffset;
                    dragY = (float)e.Y + yOffset;
                    DragDrop.DoDragDrop(this, dataObject, System.Windows.DragDropEffects.Move);
                }
            }
            else if (e.Button == MouseButtons.Middle || e.Button == MouseButtons.Left && GetShiftPressed())
            {
                ViewportInfo views = GetViewCoords(tabWidok.SelectedIndex);
                int x = (int)e.X;
                int y = (int)e.Y;

                ViewportOrientation viewport = GetViewportType(x, y);
                if (shiftingViewport == ViewportOrientation.None && viewport != ViewportOrientation.None && viewport != ViewportOrientation.Perspective)
                {
                    shiftingViewport = viewport;
                }

                if (shiftingViewport != ViewportOrientation.None)
                {
                    renderer.MoveBezierOrtho((int)shiftingViewport, (int)-(e.X - mousePos.X), (int)-(e.Y - mousePos.Y),
                        views.sizeX[(int)shiftingViewport], views.sizeY[(int)shiftingViewport]);

                    RenderBezier();
                }
            }
            else
            {
                shiftingViewport = ViewportOrientation.None;
            }
            mousePos.X = e.X;
            mousePos.Y = e.Y;
        }
        private void ViewsBezier_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && !GetShiftPressed())
            {
                ViewportInfo views = GetViewCoords(tabWidok.SelectedIndex);
                int x = (int)e.X;
                int y = (int)e.Y;

                ViewportOrientation viewport = GetViewportType(x, y);

                if (viewport != ViewportOrientation.None)
                {
                    ViewportType viewportType = viewport == ViewportOrientation.Perspective ? ViewportType.Perspective : ViewportType.Orto;
                    int rect = (int)viewport;
                    int orthoRect = rect == 3 ? 0 : rect;

                    SelectingElems.SelectBezierControlPoint(bezierSurface, renderer.bezierCam, viewportType, new System.Drawing.Point(x - views.posX[rect], y - views.posY[rect]),
                            new System.Drawing.Point(views.sizeX[rect], views.sizeY[rect]), new Vector2(renderer.BezierOrthoWidth[orthoRect],
                            (float)views.sizeY[rect] / views.sizeX[rect] * renderer.BezierOrthoWidth[orthoRect]),
                            renderer.BezierOrthoPos[orthoRect], renderer.BezierOrthoLookAt[orthoRect]);
                    RenderBezier();
                }

                if (bezierSurface.selectedPointIdx != -1)
                {
                    System.Windows.DataObject dataObject = new System.Windows.DataObject();
                    ViewportInfo coords = GetViewCoords(tabWidok.SelectedIndex);

                    //ViewportOrientation viewport = GetViewportType(e.X, e.Y);
                    switch (viewport)
                    {
                        case ViewportOrientation.Front:
                            dataObject.SetData("Viewport", "front");
                            break;

                        case ViewportOrientation.Side:
                            dataObject.SetData("Viewport", "side");
                            break;

                        case ViewportOrientation.Top:
                            dataObject.SetData("Viewport", "top");
                            break;

                        case ViewportOrientation.Perspective:
                            dataObject.SetData("Viewport", "perspective");
                            break;

                        default:
                            break;
                    }

                    dragX = (float)e.X + xOffset;
                    dragY = (float)e.Y + yOffset;
                    bezierUndo.Save(bezierSurface);
                    DragDrop.DoDragDrop(this, dataObject, System.Windows.DragDropEffects.Move);
                    RenderBezier();
                }
                else
                {
                    System.Windows.DataObject dataObject = new System.Windows.DataObject();
                    dataObject.SetData("Bezier", bezierSurface);
                    DragDrop.DoDragDrop(this, dataObject, System.Windows.DragDropEffects.Copy);
                }
            }
        }
 private void treeView1_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
 {
     if (e.LeftButton == MouseButtonState.Pressed && treeView1.SelectedItem != null && treeView1.SelectedItem != treeView1.Items.GetItemAt(0))
     {
         System.Windows.DataObject dataObject = new System.Windows.DataObject();
         dataObject.SetData("treeItem", treeView1.SelectedItem);
         DragDrop.DoDragDrop(this, dataObject, System.Windows.DragDropEffects.Move);
     }
 }
 private void swiatla_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
 {
     if (e.LeftButton == MouseButtonState.Pressed && swiatla_ListView.SelectedIndex > -1)
     {
         System.Windows.DataObject dataObject = new System.Windows.DataObject();
         dataObject.SetData("Object", _lightGallery.ElementAt(swiatla_ListView.SelectedIndex));
         DragDrop.DoDragDrop(this, dataObject, System.Windows.DragDropEffects.Copy);
         //Console.WriteLine(_elementsCol.ElementAt(gotowe_ListView.SelectedIndex).ToString());
     }
     currScene.selectedHierObj = null;
 }
 ////////////////////////////////////////////////////////////////////////////////////
 // Sekcja odpowiadająca za interakcje DRAG
 private void ksztalt_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
 {
     if (e.LeftButton == MouseButtonState.Pressed && ksztalty_ListView.SelectedIndex > -1)
     {
         System.Windows.DataObject dataObject = new System.Windows.DataObject();
         dataObject.SetData("Object", _shapesGallery.ElementAt(ksztalty_ListView.SelectedIndex));
         DragDrop.DoDragDrop(this, dataObject, System.Windows.DragDropEffects.Copy);
         //Console.WriteLine(_shapesCol.ElementAt(ksztalty_ListView.SelectedIndex).ToString());
     }
 }