private void addResolutionBt_Click(object sender, EventArgs e) { string deviceName = this.deviceNameTxtBx.Text; TargetResolution res = new TargetResolution(deviceName, new Size(Convert.ToInt32(this.widthNumUpDw.Value), Convert.ToInt32(this.heightNumUpDw.Value))); this.mainForm.resolutionsCmbBx.Items.Add(res); this.mainForm.saveResolutions(); this.mainForm.initResolutions(); initResolutionListBox(); }
private void removeResolutionBt_Click(object sender, EventArgs e) { for (int i = 0; i < this.customResolutionListBx.SelectedItems.Count; i++) { TargetResolution res = (TargetResolution)this.customResolutionListBx.SelectedItems[i]; if (res != null) { if (this.mainForm.resolutionsCmbBx.Items.Contains(res)) { this.mainForm.resolutionsCmbBx.Items.Remove(res); } } } initResolutionListBox(); }
public void initResolutions() { this.resolutionsCmbBx.Items.Clear(); string documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Native-Software"; if (!Directory.Exists(documentsDirectory)) Directory.CreateDirectory(documentsDirectory); string filename = documentsDirectory + "\\resolutions.txt"; if (File.Exists(filename)) { List<string> listRes = new List<string>(File.ReadAllLines(filename)); //Check for basic corona presets resolutions (NEWS) string[] newPresets = new string[14]; newPresets[0] = "iPhone : 320x480"; newPresets[1] = "iPhone 4 : 640x960"; newPresets[2] = "iPad : 768x1024"; newPresets[3] = "Moto Droid : 480x854"; newPresets[4] = "Galaxy Tab : 600x1024"; newPresets[5] = "Nexus One : 480x800"; newPresets[6] = "Htc Sensation : 540x960"; newPresets[7] = "Kindle Fire : 600x1024"; newPresets[8] = "Nook Color : 600x1024"; newPresets[9] = "iPhone 5 : 640x1136"; newPresets[10] = "Galaxy S3 : 720x1280"; newPresets[11] = "iPad Retina : 1536x2048"; newPresets[12] = "Kindle Fire HD 7: 800x1280"; newPresets[13] = "Kindle Fire HD 9: 1200x1920"; for (int i = 0; i < newPresets.Length; i++) { if (!listRes.Contains(newPresets[i])) listRes.Add(newPresets[i]); } for (int i = 0; i < listRes.Count; i++) { string str = listRes[i]; if(!str.Equals("") && !str.Contains("\0") ) { string[] splittedStr = str.Split(':'); if(splittedStr.Length<2) continue; string targetDevice = splittedStr[0]; string resolution = splittedStr[1]; int width = 0; int height = 0; int.TryParse((resolution.Split('x'))[0],out width); int.TryParse((resolution.Split('x'))[1],out height); if(width >0 && height >0) { TargetResolution res = new TargetResolution(targetDevice, new Size(width, height)); this.resolutionsCmbBx.Items.Add(res); } } } if(this.resolutionsCmbBx.Items.Count>0) this.resolutionsCmbBx.SelectedIndex =0; } else { string[] lines = new string[15]; lines[0] = "iPhone : 320x480"; lines[1] = "iPhone 4 : 640x960"; lines[2] = "iPad : 768x1024"; lines[3] = "Moto Droid : 480x854"; lines[4] = "Galaxy Tab : 600x1024"; lines[5] = "Nexus One : 480x800"; lines[6] = "Htc Sensation : 540x960"; lines[8] = "Kindle Fire : 600x1024"; lines[9] = "Nook Color : 600x1024"; lines[10] = "iPhone 5 : 640x1136"; lines[11] = "Galaxy S3 : 720x1280"; lines[12] = "iPad Retina : 1536x2048"; lines[13] = "Kindle Fire HD 7: 800x1280"; lines[14] = "Kindle Fire HD 9: 1200x1920"; File.WriteAllLines(filename, lines); initResolutions(); } }
private void resolutionsCmbBx_SelectedIndexChanged(object sender, EventArgs e) { if (this.resolutionsCmbBx.SelectedItem != null) { this.currentTargetResolution = (TargetResolution)this.resolutionsCmbBx.SelectedItem; } }