public MainViewModel(IFileDialogService fds, HelixViewport3D viewport, RotateManipulator rmX, RotateManipulator rmY, RotateManipulator rmZ, TranslateManipulator scaleXYZ, PrintConfiguration PrintConfig) { if (viewport == null) { throw new ArgumentNullException("viewport"); } this.printConfig = PrintConfig; ScaleFactor = 100; SizeX = SizeY = SizeZ = 0; this.rotatorManipulatorX = rmX; this.rotatorManipulatorY = rmY; this.rotatorManipulatorZ = rmZ; this.ScaleXYZ = scaleXYZ; this.dispatcher = Dispatcher.CurrentDispatcher; this.Expansion = 1; this.fileDialogService = fds; this.viewport = viewport; this.FileOpenCommand = new DelegateCommand(this.FileOpen); this.FileExportCommand = new DelegateCommand(this.FileExport); this.FileExitCommand = new DelegateCommand(FileExit); this.ViewZoomExtentsCommand = new DelegateCommand(this.ViewZoomExtents); this.EditCopyXamlCommand = new DelegateCommand(this.CopyXaml); this.ViewRotateCommand = new DelegateCommand(this.ViewRotate); this.ViewScaleCommand = new DelegateCommand(this.ViewScale); this.ResetSolidCommand = new DelegateCommand(this.ResetSolid); this.PrintCommand = new DelegateCommand(this.GenerateGCODE); this.PronterfaceCommand = new DelegateCommand(this.Prontercae); this.AbortCommand = new DelegateCommand(this.Abort); this.ApplicationTitle = "Fracktory"; ModelLoaded = Visibility.Collapsed; ModelNotLoaded = Visibility.Visible; ModelPrint = Visibility.Collapsed; ModelPrintDone = Visibility.Collapsed; this.Elements = new List <VisualViewModel>(); foreach (var c in viewport.Children) { this.Elements.Add(new VisualViewModel(c)); } }
private void btnPrint_Click(object sender, RoutedEventArgs e) { Menu.IsEnabled = false; if (FilamentType.SelectedIndex == 0)//abs { config = new PrintConfiguration(PrintMaterial.ABS); } else if (FilamentType.SelectedIndex == 1)//pla { config = new PrintConfiguration(PrintMaterial.PLA); } else //other { config = new PrintConfiguration(PrintMaterial.ABS); config.ExtraConfiguration["temperature"] = ExtruderOtherLayers.Value.ToString(); config.ExtraConfiguration["first-layer-temperature"] = ExtruderFirstLayer.Value.ToString(); config.ExtraConfiguration["bed-temperature"] = BedOtherLayers.Value.ToString(); config.ExtraConfiguration["first-layer-bed-temperature"] = BedFirstLayer.Value.ToString(); config.ExtraConfiguration["skirt-distance"] = DistanceFromObject.Value.ToString(); config.ExtraConfiguration["skirt-height"] = SkirtHeight.Value.ToString(); config.ExtraConfiguration["skirts"] = Loops.Value.ToString(); config.ExtraConfiguration["min-skirt-length"] = MinimumExtrusionLength.Value.ToString(); config.ExtraConfiguration["brim-width"] = BrimWidth.Value.ToString(); } if ((bool)SpiralVase.IsChecked) { config.ExtraConfiguration["spiral-vase"] = "1"; } else { config.ExtraConfiguration["spiral-vase"] = "0"; } if (HeightResolution.SelectedIndex == 0) { config.ExtraConfiguration["layer-height"] = "0.1"; //low } else if (HeightResolution.SelectedIndex == 1) { config.ExtraConfiguration["layer-height"] = "0.2"; //med } else if (HeightResolution.SelectedIndex == 2) { config.ExtraConfiguration["layer-height"] = "0.3"; //high } //config.ExtraConfiguration["fill-density"] = "0.15"; if (FillDensity.SelectedIndex == 0) { config.ExtraConfiguration["fill-density"] = "0"; //hollow } else if (FillDensity.SelectedIndex == 1) { config.ExtraConfiguration["fill-density"] = "0.06"; //low } else if (FillDensity.SelectedIndex == 2) { config.ExtraConfiguration["fill-density"] = "0.15"; //medium } else if (FillDensity.SelectedIndex == 3) { config.ExtraConfiguration["fill-density"] = "0.4"; //medium } config.ExtraConfiguration["infill-every-layers"] = CombineInfillEvery.Value.ToString(); if ((bool)OnlyInfillWhenNeeded.IsChecked) { config.ExtraConfiguration["infill-only-where-needed"] = "1"; } else { config.ExtraConfiguration["infill-only-where-needed"] = "0"; } config.ExtraConfiguration["solid-infill-every-layers"] = SolidInfillEvery.Value.ToString(); config.ExtraConfiguration["solid-infill-below-area"] = SolidInfillThresholdLevels.Value.ToString(); if ((bool)OnlyRetractWhenCrossingPerimeters.IsChecked) { config.ExtraConfiguration["only-retract-when-crossing-perimeters"] = "1"; } else { config.ExtraConfiguration["only-retract-when-crossing-perimeters"] = "0"; } if ((bool)GenerateSupportMaterial.IsChecked) { config.ExtraConfiguration["support-material"] = "1"; } else { config.ExtraConfiguration["support-material"] = "0"; } if ((bool)InfillBeforePerimeters.IsChecked) { config.ExtraConfiguration["infil-first"] = "1"; } else { config.ExtraConfiguration["infill-first"] = "0"; } ((MainViewModel)(this.DataContext)).PrintConfig = config; Menu.IsEnabled = true; }