public ConfigurationVersionViewModel(SWSetting editedSetting) { isSolidWorksRunning = false; this.editedSetting = editedSetting; if (EditedSetting.BoundVersion != null && SwVersions.Contains(EditedSetting.BoundVersion)) { SelectedVersion = EditedSetting.BoundVersion; } IsFormEnabled = true; MessageVisibility = "Hidden"; }
public DrawingTemplatesViewModel(SWSetting editedSetting) { this.editedSetting = editedSetting; drawingTemplates = new ObservableCollection<DrawingTemplate>(); editedSetting.DrwTemplates.ForEach(i => drawingTemplates.Add(i.Clone())); //deep copy of settings list }
public void OverrideSWSettings(SWVersion version, SWSetting setting) { string baseKey = RegHKCU + version.RegPath + "\\"; string pdmPartPath=null; string pdmAssyPath=null; string pdmDrwPath=null; string bomTable=null; string weldTable=null; string bendTable=null; if (Directory.Exists(setting.PdmTemplateDirectory)) { pdmPartPath = Directory.GetFiles(setting.PdmTemplateDirectory, "*.prtdot", SearchOption.AllDirectories).FirstOrDefault(); pdmAssyPath = Directory.GetFiles(setting.PdmTemplateDirectory, "*.asmdot", SearchOption.AllDirectories).FirstOrDefault(); pdmDrwPath = Directory.GetFiles(setting.PdmTemplateDirectory, "*.drwdot", SearchOption.AllDirectories).FirstOrDefault(); } if (Directory.Exists(setting.TableTemplateDirectory)) { bomTable = Directory.GetFiles(setting.TableTemplateDirectory, "*.sldbomtbt", SearchOption.AllDirectories).FirstOrDefault(); weldTable = Directory.GetFiles(setting.TableTemplateDirectory, "*.sldwldtbt", SearchOption.AllDirectories).FirstOrDefault(); bendTable = Directory.GetFiles(setting.TableTemplateDirectory, "*.sldbndtbt", SearchOption.AllDirectories).FirstOrDefault(); } if (!String.IsNullOrWhiteSpace(pdmAssyPath)) Registry.SetValue(baseKey + "Document Templates", "Default Assy Template", pdmAssyPath); if (!String.IsNullOrWhiteSpace(pdmPartPath)) Registry.SetValue(baseKey + "Document Templates", "Default Part Template", pdmPartPath); if (!String.IsNullOrWhiteSpace(pdmDrwPath)) Registry.SetValue(baseKey + "Document Templates", "Default Draw Template", pdmDrwPath); if (!String.IsNullOrWhiteSpace(bomTable)) Registry.SetValue(baseKey + "Drawings", "Last BOM Template Path", bomTable); if (!String.IsNullOrWhiteSpace(weldTable)) Registry.SetValue(baseKey + "Drawings", "Last Weldment Template Path", weldTable); if (!String.IsNullOrWhiteSpace(bendTable)) Registry.SetValue(baseKey + "Drawings", "Last BendTable Template Path", bendTable); if (Directory.Exists(setting.PdmTemplateDirectory)) { Registry.SetValue(baseKey + "ExtReferences", "Document Template Folders", setting.PdmTemplateDirectory); } if (Directory.Exists(setting.TableTemplateDirectory)) { Registry.SetValue(baseKey + "ExtReferences", "Bend Table Template Folder", setting.TableTemplateDirectory); Registry.SetValue(baseKey + "ExtReferences", "BOM Template Folders", setting.TableTemplateDirectory); Registry.SetValue(baseKey + "ExtReferences", "Weld Table Template Folder", setting.TableTemplateDirectory); Registry.SetValue(baseKey + "ExtReferences", "Revision Table Template Folders", setting.TableTemplateDirectory); Registry.SetValue(baseKey + "ExtReferences", "Punch Table Template Folder", setting.TableTemplateDirectory); } if (!String.IsNullOrWhiteSpace(setting.DrwTemplates?.FirstOrDefault()?.SlddrtPath) && File.Exists(setting.DrwTemplates?.FirstOrDefault()?.SlddrtPath)) { Registry.SetValue(baseKey + "ExtReferences", "Sheet Format Folders", Directory.GetParent(setting.DrwTemplates?.FirstOrDefault()?.SlddrtPath).FullName); } if (Directory.Exists(setting.WorkPath)) { Registry.SetValue(baseKey + "General", "Last user path", setting.WorkPath); Registry.SetValue(baseKey + "ExtReferences", "Document Folders", setting.WorkPath); } }
private void RunSolidWorks() { if (MainViewModel.Instance.SwVersions == null || MainViewModel.Instance.SwVersions.Count == 0) { return; } SWSetting dummySWSetting = new SWSetting(); ConfigurationVersionViewModel viewModel = new ConfigurationVersionViewModel(dummySWSetting); viewModel.Mode = LaunchMode.UserSetting; IConfigurationVersionModalDialog view = ServiceProvider.Instance.Get<IConfigurationVersionModalDialog>(); view.BindViewModel(viewModel); view.Closing += viewModel.OnCancel; view.ShowDialog(); if (!String.IsNullOrEmpty(dummySWSetting.RegSettings)) { SelectedUser.SettingPath = dummySWSetting.RegSettings; SettingsParsedMsg = "Pobrano ustawienia dla " + Environment.UserName + ". \nZapisz by zachować zmiany."; } }