private void SaveScript(bool askForLocation) { var saveStorageCount = storageList.Count(x => x.IsSaveSupported); Storage.ICodeNowStorage saveStorage = null; if (saveStorageCount == 1) { saveStorage = storageList.Find(x => x.IsSaveSupported); } else { StorageSelector ss = new StorageSelector(storageList, true); if (ss.ShowDialog() == DialogResult.OK && ss.SelectedStorage != null) { saveStorage = ss.SelectedStorage; } } if (saveStorage != null) { if (saveStorage.Save(CurrentScript, askForLocation)) { CurrentScript.SourceStorage = saveStorage; tbLocation.Text = CurrentScript.Location; } } }
private void tbLoadItem_Click(object sender, EventArgs e) { StorageSelector ss = new StorageSelector(storageList, false); if (ss.ShowDialog() == DialogResult.OK) { if (ss.SelectedStorage.CustomCodeSelector) { var script = ss.SelectedStorage.Open(); if (script != null) { CurrentScript = script; CurrentScript.SourceStorage = ss.SelectedStorage; } } else { StorageForm sf = new StorageForm(ss.SelectedStorage); if (sf.ShowDialog() == DialogResult.OK) { if (sf.SelectedScript != null) { CurrentScript = sf.SelectedScript; CurrentScript.SourceStorage = ss.SelectedStorage; } } } } /* * StorageForm sf = new StorageForm(false); * if (sf.ShowDialog() == DialogResult.OK) * { * if (sf.SelectedScript != null) * { * CurrentScript = sf.SelectedScript; * } * } */ /* * OpenFileDialog ofd = new OpenFileDialog(); * ofd.Filter = "All Files|*.*"; * if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) * { * System.IO.StreamReader sr = new * System.IO.StreamReader(ofd.FileName); * tbCode.Text = sr.ReadToEnd(); * fileName = ofd.FileName; * sr.Close(); * } */ }