示例#1
0
        void Drawing3D_DragEnter(object sender, DragEventArgs e)
        {
            this.Activate();
            if (dragDropMesh != null)
            {
                e.Effect = DragDropEffects.Copy;
                return;
            }

            e.Effect = DragDropEffects.None;
            if (openFileButton.Enabled && e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                Array a = (Array)e.Data.GetData(DataFormats.FileDrop);
                if (a != null && a.Length == 1)
                {
                    string filename = a.GetValue(0).ToString();
                    if (acceptedFileRegex.IsMatch(filename))
                    {
                        dragDropFilename = filename;
                        dragDropMesh     = AddFile(dragDropFilename, loadObjectScale);
                        var plane = new Plane(Vector3.UnitZ, new Vector3(0, 0, 0));
                        var ray   = drawing3D.GetPointerRay(new Point(e.X, e.Y));
                        dragEnterLocation = ray.Start + ray.Direction * plane.Distance(ray);
                        e.Effect          = DragDropEffects.Copy;
                    }
                }
            }
        }
示例#2
0
        internal TriangleMeshGUI AddFile(string filename, float scale)
        {
            if (filename.EndsWith(".nc", StringComparison.OrdinalIgnoreCase) || filename.EndsWith(".gcode", StringComparison.OrdinalIgnoreCase))
            {
                var commands = GCodeLoader.Load(filename);
                foreach (ICommand command in commands)
                {
                    router.AddCommand(command);
                }
                return(null);
            }
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork             += worker_LoadMesh;
            worker.RunWorkerCompleted += worker_LoadMeshCompleted;
            var mesh = new TriangleMeshGUI();

            inProgressMeshes.Add(mesh);
            worker.RunWorkerAsync(new LoadMeshData()
            {
                filename = filename, scale = loadObjectScale, mesh = mesh
            });
            return(mesh);
        }
示例#3
0
 internal TriangleMeshGUI AddFile(string filename, float scale)
 {
     if (filename.EndsWith(".nc", StringComparison.OrdinalIgnoreCase) || filename.EndsWith(".gcode", StringComparison.OrdinalIgnoreCase))
     {
         var commands = GCodeLoader.Load(filename);
         foreach (ICommand command in commands)
         {
             router.AddCommand(command);
         }
         return null;
     }
     BackgroundWorker worker = new BackgroundWorker();
     worker.DoWork += worker_LoadMesh;
     worker.RunWorkerCompleted += worker_LoadMeshCompleted;
     var mesh = new TriangleMeshGUI();
     inProgressMeshes.Add(mesh);
     worker.RunWorkerAsync(new LoadMeshData() { filename = filename, scale = loadObjectScale, mesh = mesh });
     return mesh;
 }
示例#4
0
        void Drawing3D_DragEnter(object sender, DragEventArgs e)
        {
            this.Activate();
            if (dragDropMesh != null)
            {
                e.Effect = DragDropEffects.Copy;
                return;
            }

            e.Effect = DragDropEffects.None;
            if (openFileButton.Enabled && e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                Array a = (Array)e.Data.GetData(DataFormats.FileDrop);
                if (a != null && a.Length == 1)
                {
                    string filename = a.GetValue(0).ToString();
                    if (acceptedFileRegex.IsMatch(filename))
                    {
                        dragDropFilename = filename;
                        dragDropMesh = AddFile(dragDropFilename, loadObjectScale);
                        var plane = new Plane(Vector3.UnitZ, new Vector3(0, 0, 0));
                        var ray = drawing3D.GetPointerRay(new Point(e.X, e.Y));
                        dragEnterLocation = ray.Start + ray.Direction * plane.Distance(ray);
                        e.Effect = DragDropEffects.Copy;
                    }
                }
            }
        }
示例#5
0
 void Drawing3D_DragDrop(object sender, DragEventArgs e)
 {
     dragDropMesh = null;
 }