protected override void Resize(double width, double height) { bool saved = Game != null && Game.WasSaved(); var buttons = from button in Buttons where VisibleButtons.Contains(button.Name) select button; foreach (Button b in buttons) { if (saved) { if (b.Name == "ContinueGame") { b.Margin = new Thickness(0, 150, 0, 0); } else if (b.Name == "NewGame") { b.Margin = new Thickness(0, 0, 0, 150); } } else if (b.Name == "NewGame") { b.Margin = new Thickness(0, 0, 0, 0); } } }
private void ThreeButtonDialog_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { if (!closedFromButton) { // User has closed without pressing a button (e.g. the cross) // In the following scenarios we can predict what they mean: if (CancelButton != null) { // There's a cancel button, this most closely maps to the desire of someone telling the window to get lost DialogResult = CancelButton.DialogResult; } else if (VisibleButtons.Find(delegate(Button b) { return(b.DialogResult == DialogResult.Cancel); }) != null) { // There's a cancel button, this most closely maps to the desire of someone telling the window to get lost DialogResult = DialogResult.Cancel; } else if (VisibleButtons.Count == 1) { // Single button, they only had one choice anyway. 99% of the time this an OK prompt DialogResult = VisibleButtons[0].DialogResult; } else if (VisibleButtons.Count == 2 && VisibleButtons[0].DialogResult == DialogResult.Yes && VisibleButtons[1].DialogResult == DialogResult.No) { // Another common scenario, a yes/no prompt. Slightly more dubious this one, but they most likely mean no. // The following issues have been considered: // - If we are performing a dangerous/significant/unreversable action then this should be an OK Cancel dialog anyway // - You've got the Yes/No buttons the wrong way round // // ...either way you should go back to UI school :) DialogResult = DialogResult.No; } else { // We can't figure out what they mean, and since people almost always only assume that the dialog only returns the results on // the buttons we are going to block the close // Set a CancelButton if you want to stop this happening e.Cancel = true; } } } }
protected override void Resize(double width, double height) { var buttons = from button in Buttons where VisibleButtons.Contains(button.Name) select button; foreach (Button b in buttons) { if (b.Name == "Game1") { b.Margin = new Thickness(0.25 * width - 150, 0, 0, 0); } else if (b.Name == "Game3") { b.Margin = new Thickness(0, 0, 0.25 * width - 150, 0); } } }
private string GetTitleAndMessageDetail() { const string separator = "---------------------------"; List <string> lines = new List <String>(); lines.Add(separator); lines.Add(Text); lines.Add(separator); lines.Add(Message); lines.Add(separator); lines.Add(TextUtil.SpaceSeparate(VisibleButtons.Select(btn => btn.Text))); if (null != DetailMessage) { lines.Add(separator); lines.Add(DetailMessage); } lines.Add(separator); lines.Add(string.Empty); return(TextUtil.LineSeparate(lines)); }
public void CopyMessage() { const string separator = "---------------------------"; // Not L10N List <string> lines = new List <String>(); lines.Add(separator); lines.Add(Text); lines.Add(separator); lines.Add(Message); lines.Add(separator); lines.Add(TextUtil.SpaceSeparate(VisibleButtons.Select(btn => btn.Text))); if (null != DetailMessage) { lines.Add(separator); lines.Add(DetailMessage); } lines.Add(separator); lines.Add(string.Empty); ClipboardEx.SetText(TextUtil.LineSeparate(lines)); }