public ImportPatternDialogViewModel(IEnumerable <IProcessConfiguration> availableProcessConfigurations, string defaultPatternDirectory, string defaultRecipeDirectory) { MShader = new MGLShader(); _terminableTaskExecutor = new TerminableTaskExecutor(); DefaultRecipeDirectory = defaultRecipeDirectory; DefaultPatternDirectory = defaultPatternDirectory; SeperateLayers = true; AlignmentType = MAlignmentType.TypeAuto; TileSettings = new MTileSettings(); Fiducials = new ObservableCollection <MFiducialInfo>(); AvailableProcessModes = new ObservableCollection <IProcessConfiguration>(availableProcessConfigurations); SelectPatternFileCommand = new DelegateCommand( () => { var dialog = new OpenFileDialog(); dialog.Filter = "DXF files (*.dxf)|*.dxf"; dialog.AddExtension = true; dialog.InitialDirectory = defaultPatternDirectory; if (dialog.ShowDialog() != true) { return; } PatternFilePath = dialog.FileName; FetchDXF(PatternFilePath); Render(); } ); SelectParametersFileCommand = new DelegateCommand( () => { if (TargetProcessMode == null) { MessageBox.Show( @"Invalid process mode selected, please select a valid process mode.", "Select a Process Mode" ); return; } var dialog = new MarkParamEditorDialog( TargetProcessMode?.ProcessParameterFileManager, ProcessParametersFilePath ); if (dialog.ShowDialog() != true) { return; } ProcessParametersFilePath = dialog.ParamFileManager.FilePath; } ); AddFiducialCommand = new DelegateCommand( () => { Fiducials.Add(new MFiducialInfo() { Index = Fiducials.Count }); Render(); } ); DeleteFiducialCommand = new DelegateCommand <MFiducialInfo>( (fiducial) => { Fiducials.Remove(fiducial); // update Index for (int i = 0; i < Fiducials.Count; i++) { Fiducials[i].Index = i; } Render(); } ); DeleteAllFiducialsCommand = new DelegateCommand( () => { Fiducials.Clear(); Render(); } ); RefreshCommand = new DelegateCommand( () => { Render(); } ); }
public ImportSTLDialogViewModel(IEnumerable <IProcessConfiguration> availableProcessConfigurations, string defaultSTLDirectory, string defaultRecipeDirectory) { MShader = new MGLShader(); _terminableTaskExecutor = new TerminableTaskExecutor(); DefaultRecipeDirectory = defaultRecipeDirectory; DefaultStlDirectory = defaultSTLDirectory; _modelGroup = new Model3DGroup(); _stlSlices = new List <MSTLSlice>(); _slicePlanes = new List <GeometryModel3D>(); StlModelReferencePoint = new MVertexViewModel(); HatchSettings = new MHatchSettings(); AlignmentType = MAlignmentType.TypeAuto; TileSettings = new MTileSettings(); Fiducials = new ObservableCollection <MFiducialInfo>(); AvailableProcessModes = new ObservableCollection <IProcessConfiguration>(availableProcessConfigurations); SelectPatternFileCommand = new DelegateCommand( async() => { var dialog = new OpenFileDialog(); dialog.Filter = "STL files (*.stl)|*.stl"; dialog.AddExtension = true; dialog.InitialDirectory = defaultSTLDirectory; if (dialog.ShowDialog() != true) { return; } PatternFilePath = dialog.FileName; await FetchSTL(PatternFilePath); Render(); } ); SelectParametersFileCommand = new DelegateCommand( () => { if (TargetProcessMode == null) { MessageBox.Show( @"Invalid process mode selected, please select a valid process mode.", "Select a Process Mode" ); return; } var dialog = new MarkParamEditorDialog( TargetProcessMode?.ProcessParameterFileManager, ProcessParametersFilePath ); if (dialog.ShowDialog() != true) { return; } ProcessParametersFilePath = dialog.ParamFileManager.FilePath; } ); AddFiducialCommand = new DelegateCommand( () => { Fiducials.Add(new MFiducialInfo() { Index = Fiducials.Count }); Render(); } ); DeleteFiducialCommand = new DelegateCommand <MFiducialInfo>( (fiducial) => { Fiducials.Remove(fiducial); // update Index for (int i = 0; i < Fiducials.Count; i++) { Fiducials[i].Index = i; } Render(); } ); DeleteAllFiducialsCommand = new DelegateCommand( () => { Fiducials.Clear(); Render(); } ); RefreshCommand = new DelegateCommand( () => { Render(); } ); ShowPreviousSliceCommand = new DelegateCommand(() => { if (NumberOfSlices == 0) { CurrentSlice = 0; return; } else if (CurrentSlice == 0) { CurrentSlice = NumberOfSlices; } CurrentSlice = Math.Abs((CurrentSlice - 1) % NumberOfSlices); ShowSlice(CurrentSlice); }); ShowNextSliceCommand = new DelegateCommand(() => { if (NumberOfSlices == 0) { CurrentSlice = 0; return; } CurrentSlice = (CurrentSlice + 1) % NumberOfSlices; ShowSlice(CurrentSlice); }); HatchCurrentLayerCommand = new DelegateCommand(async() => { if (NumberOfSlices == 0) { DispatcherMessageBox.ShowBox( "There's no slice to hatch" ); return; } var response = DispatcherMessageBox.ShowBox( "This could take a while, do you wish to continue", "Warning", MessageBoxButton.YesNo ); if (response != MessageBoxResult.Yes) { return; } try { IsLoading = true; await HatchSlice(CurrentSlice); Render(); } finally { IsLoading = false; } }); TileCurrentLayerCommand = new DelegateCommand(async() => { if (NumberOfSlices == 0) { DispatcherMessageBox.ShowBox( "There's no slice to tile" ); return; } try { IsLoading = true; await TileSlice(CurrentSlice); Render(); } finally { IsLoading = false; } }); HatchAllLayersCommand = new DelegateCommand(async() => { if (NumberOfSlices == 0) { DispatcherMessageBox.ShowBox( "There's no slice to hatch" ); return; } var response = DispatcherMessageBox.ShowBox( "This could take a while, do you wish to continue", "Warning", MessageBoxButton.YesNo ); if (response != MessageBoxResult.Yes) { return; } try { IsLoading = true; await HatchAllSlices(); Render(); } finally { IsLoading = false; } }); TileAllLayersCommand = new DelegateCommand(async() => { if (NumberOfSlices == 0) { DispatcherMessageBox.ShowBox( "There's no slice to hatch" ); return; } try { IsLoading = true; await TileAllSlices(); Render(); } finally { IsLoading = false; } }); }