public void DuplicateProfile(MyPrintConfigBean myBean) { //1.get a avaiable name //string oldName = myBean.name; string oldName = "Duplicate"; int index = 1; string newName = oldName + " #" + (index); while (ConfigManager.GetInstance().IsProfileNameExist(newName)) { newName = oldName + " #" + (++index); } //2. string path = PathManager.CustomPrintProfilesArchiveDir() + "/" + newName + "." + Global.extension_Profile; myBean.ArchiveForProfile(path); PrintConfigBean newBean = unarchive(path); MyPrintConfigBean newMyBean = new MyPrintConfigBean(newBean, true, path); _customMyBeanList.Add(newMyBean); _allMyBeanList.Add(newMyBean); }
public MyPrintConfigBean ImportProfile(string importPath) { try { //1.get a avaiable name //string oldName = myBean.name; string oldName = "Import"; int index = 1; string newName = oldName + " #" + (index); while (ConfigManager.GetInstance().IsProfileNameExist(newName)) { newName = oldName + " #" + (++index); } //2.parse profile PrintConfigBean newBean = unarchive(importPath); string filePath = PathManager.CustomPrintProfilesArchiveDir() + "/" + newName + "." + Global.extension_Profile; MyPrintConfigBean newMyBean = new MyPrintConfigBean(newBean, true, filePath); newMyBean.ArchiveForProfile(filePath); _customMyBeanList.Add(newMyBean); _allMyBeanList.Add(newMyBean); return(newMyBean); } catch (Exception e) { Debug.LogError("Exception occured : " + e.ToString() + "\n"); return(null); } return(null); }
void Start() { string version = "2.0"; PlayerPrefsManager.GetInstance().SetCurVersion(version); //first launch the version if (PlayerPrefsManager.GetInstance().GetLaunchTimes_CurVersion() == 1) { Debug.Log("First launch: Vserion=" + version); string originPath_customProfile = PathManager.profilePath_custom(); string fileName_customProfile = Path.GetFileName(originPath_customProfile); string dirPath = PathManager.CustomPrintProfilesArchiveDir(); string destinationPath_customProfile = dirPath + "/" + fileName_customProfile; if (!File.Exists(originPath_customProfile)) { Debug.LogWarning("File not exist:" + originPath_customProfile); } if (File.Exists(destinationPath_customProfile)) { Debug.LogWarning("File exist:" + destinationPath_customProfile); } if (File.Exists(originPath_customProfile) && !File.Exists(destinationPath_customProfile)) { //copy file : originPath_customProfile ----> destinationPath_customProfile Debug.LogError("Copy file:" + originPath_customProfile + " ---> " + destinationPath_customProfile); File.Copy(originPath_customProfile, destinationPath_customProfile); } } /********** config ************/ ConfigManager.GetInstance().UnarchiveProfiles(); ConfigManager.GetInstance().SelectProfile_fastPrint(); }
public void UnarchiveProfiles() { _officialMyBeanList.Clear(); _customMyBeanList.Clear(); _allMyBeanList.Clear(); //official profiles, extension is .json string path_fastPrint = PathManager.configPath_fastPrint(); string path_normalQuality = PathManager.configPath_normalQuality(); string path_highQuality = PathManager.configPath_highQuality(); PrintConfigBean bean_fastPrint = unarchive(path_fastPrint); PrintConfigBean bean_normalQuality = unarchive(path_normalQuality); PrintConfigBean bean_highQuality = unarchive(path_highQuality); myBean_fastPrint = new MyPrintConfigBean(bean_fastPrint, false, path_fastPrint); myBean_fastPrint.name = "Fast Print"; myBean_normalQuality = new MyPrintConfigBean(bean_normalQuality, false, path_normalQuality); myBean_normalQuality.name = "Normal Quality"; myBean_highQuality = new MyPrintConfigBean(bean_highQuality, false, path_highQuality); myBean_highQuality.name = "High Quality"; _officialMyBeanList.Add(myBean_fastPrint); _officialMyBeanList.Add(myBean_normalQuality); _officialMyBeanList.Add(myBean_highQuality); //custom profiles, extension is .snapmaker3dProfile string customProfilesDir = PathManager.CustomPrintProfilesArchiveDir(); DirectoryInfo dirInfo = new DirectoryInfo(customProfilesDir); foreach (FileInfo fileInfo in dirInfo.GetFiles()) { string path = fileInfo.FullName; //GetExtension return ".xxx" if (Path.GetExtension(path) == ("." + Global.extension_Profile)) { try { PrintConfigBean bean = unarchive(path); MyPrintConfigBean myBean = new MyPrintConfigBean(bean, true, path); _customMyBeanList.Add(myBean); } catch (Exception e) { Debug.LogError("Exception occur : UnarchiveProfiles e:" + e.ToString() + "\n" + " file path" + path + "\n"); } } } _allMyBeanList.AddRange(_officialMyBeanList); _allMyBeanList.AddRange(_customMyBeanList); if (IsMaterial_PLA()) { SetMaterial_PLA(); } else if (IsMaterial_ABS()) { SetMaterial_ABS(); } else if (IsMaterial_Custom()) { SetMaterial_Custom(); } else { SetMaterial_PLA(); } if (IsAdhesion_brim()) { SetAdhesion_brim(); } else if (IsAdhesion_none()) { SetAdhesion_none(); } else if (IsAdhesion_raft()) { SetAdhesion_raft(); } else if (IsAdhesion_skirt()) { SetAdhesion_skirt(); } else { SetAdhesion_none(); } if (IsSupport_buildplate()) { SetSupport_buildplate(); } else if (IsSupport_everywhere()) { SetSupport_everywhere(); } else if (IsSupport_none()) { SetSupport_none(); } else { SetSupport_none(); } value_bed_temperature_Custom = PlayerPrefs.GetInt(KEY_Custom_bed_temperature); value_bed_temperature_Layer0_Custom = PlayerPrefs.GetInt(KEY_Custom_bed_temperature_Layer0); value_print_temperature_Custom = PlayerPrefs.GetInt(KEY_Custom_print_temperature); value_print_temperature_Layer0_Custom = PlayerPrefs.GetInt(KEY_Custom_print_temperature_Layer0); value_print_temperature_Final_Custom = PlayerPrefs.GetInt(KEY_Custom_print_temperature_Final); //no record, use params of PLA if (value_bed_temperature_Custom == 0) { value_bed_temperature_Custom = value_bed_temperature_PLA; PlayerPrefs.SetInt(KEY_Custom_bed_temperature, value_bed_temperature_Custom); } if (value_bed_temperature_Layer0_Custom == 0) { value_bed_temperature_Layer0_Custom = value_bed_temperature_Layer0_PLA; PlayerPrefs.SetInt(KEY_Custom_bed_temperature_Layer0, value_bed_temperature_Layer0_Custom); } if (value_print_temperature_Custom == 0) { value_print_temperature_Custom = value_print_temperature_PLA; PlayerPrefs.SetInt(KEY_Custom_print_temperature, value_print_temperature_Custom); } if (value_print_temperature_Layer0_Custom == 0) { value_print_temperature_Layer0_Custom = value_print_temperature_Layer0_PLA; PlayerPrefs.SetInt(KEY_Custom_print_temperature_Layer0, value_print_temperature_Layer0_Custom); } if (value_print_temperature_Final_Custom == 0) { value_print_temperature_Final_Custom = value_print_temperature_Final_PLA; PlayerPrefs.SetInt(KEY_Custom_print_temperature_Final, value_print_temperature_Final_Custom); } }