/// <summary> /// /// </summary> /// <param name="text"></param> /// <param name="caption"></param> /// <returns></returns> public static string Show( Form owner, string text, string caption, string suggestion = "" ) { var dlg = new NameDialog(); dlg.textLabel.Text = text; dlg.Text = caption; dlg.textBox.Text = suggestion; var dr = dlg.ShowDialog(owner); if (dr==DialogResult.OK) { return dlg.textBox.Text; } else { return null; } }
/// <summary> /// /// </summary> /// <param name="text"></param> /// <param name="caption"></param> /// <returns></returns> public static string Show(Form owner, string text, string caption, string suggestion = "") { var dlg = new NameDialog(); dlg.textLabel.Text = text; dlg.Text = caption; dlg.textBox.Text = suggestion; var dr = dlg.ShowDialog(owner); if (dr == DialogResult.OK) { return(dlg.textBox.Text); } else { return(null); } }
public void AddAsset() { var dict = Asset.GatherAssetTypes() .Select(type => new KeyValuePair <string, Type>(type.GetCustomAttribute <AssetAttribute>().Category + ": " + type.GetCustomAttribute <AssetAttribute>().NiceName, type)); if (!dict.Any()) { MessageBox.Show("There are not asset classes. Make sure that your classes are inherited from Asset class and has attribute AssetAttribute", "Add Asset", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Type result; if (ObjectSelector.Show(developerConsole, "Select asset type", "Add Asset", dict, out result)) { string suggestion = result.GetCustomAttribute <AssetAttribute>().Category + @"\"; var path = NameDialog.Show(developerConsole, "Enter asset name", "Add Asset", suggestion); if (path == null) { return; } var desc = (Asset)Activator.CreateInstance(result); desc.AssetPath = path; try { contentBuilder.AddAsset(desc); } catch (ContentException e) { MessageBox.Show(e.Message, "Add Asset", MessageBoxButtons.OK, MessageBoxIcon.Error); } Modified = true; developerConsole.RefreshConsole(false); //game.Reload(); } }