private static void MakeDialog(Panel parent, RacerDetails content, WindowType type) { content._dialogHost = new Dialog(parent, content, false, false, true, delegate() { if (content._type == WindowType.Display) //only allow saving after clicking of dialog, if not creating a new car { if (content.createSaveRacer()) { return(DialogButton.ReturnEvent.Close); } else { return(DialogButton.ReturnEvent.DoNothing); } } else { return(DialogButton.ReturnEvent.DoNothing); } }, (type == WindowType.Display ? new DialogButton("Delete", DialogButton.Alignment.Left, DialogButton.Style.Flat, delegate() { DialogBox.showOptionBox(parent, "This will completly remove \"" + content.tbCarName.Text + "\" from the competition. All of its history will be deleted. The current race will also be reset.", "Delete \"" + content.tbCarName.Text + "\"?", "Keep", "Delete", delegate(DialogBox.DialogResult result) { if (result == DialogBox.DialogResult.MainOption) { DataManager.Competition.Racers.Remove(content._racer); content.triggerUpdatedRacer(); content.triggerDeletedRacer(); content._dialogHost.Close(); //close this host dialog } }); return(DialogButton.ReturnEvent.DoNothing); }) : null), new DialogButton((type == WindowType.Display ? "Revert" : "Forget"), DialogButton.Alignment.Right, DialogButton.Style.Flat, delegate() { if (type == WindowType.Display) { string changes = ""; if (content._racer.Car.Name != content.tbCarName.Text) { changes += Environment.NewLine + "Car's Name: " + content._racer.Car.Name + " -> " + content.tbCarName.Text; } if (content._racer.Car.ImageUri != DataManager.getRelativePath(content.imgCarPicture.Source.ToString())) { changes += Environment.NewLine + "Car's Image"; } if (content._racer.Maker.Name != content.tbCreatorName.Text) { changes += Environment.NewLine + "Creator's Name: " + content._racer.Maker.Name + " -> " + content.tbCreatorName.Text; } if (content._racer.Maker.ImageUri != DataManager.getRelativePath(content.imgCreatorPicture.Source.ToString())) { changes += Environment.NewLine + "Creator's Name"; } if (content._racer.Barcode != content.tbBarcode.Text) { changes += Environment.NewLine + "Barcode: " + content._racer.Barcode + " -> " + content.tbBarcode.Text; } if (content._racer.Class != content.cboClass.Text) { changes += Environment.NewLine + "Class: " + content._racer.Class + " -> " + content.cboClass.Text; } if (content._racer.PassedInspection != (content.passedInspect.IsChecked == true)) { changes += Environment.NewLine + "Passed Inspection: " + (content._racer.PassedInspection ? "Yes" : "No") + " -> " + ((content.passedInspect.IsChecked == true)?"Yes":"No"); } //no nothing, this will act like a revert if (changes.Length > 0) { DialogBox.showOptionBox(parent, "This will revert the following changes" + changes, "Revert Changes Made To \"" + content.tbCarName.Text + "\"?", "Keep", "Revert", delegate(DialogBox.DialogResult result) { if (result == DialogBox.DialogResult.MainOption) { content._dialogHost.Close(); //close this host dialog } }); } else { return(DialogButton.ReturnEvent.Close); } } else { bool changed = false; if ("" != content.tbCarName.Text) { changed = true; } if (DataManager.Settings.DefaltCarImageUri != DataManager.getRelativePath(content.imgCarPicture.Source.ToString())) { changed = true; } if ("" != content.tbCreatorName.Text) { changed = true; } if (DataManager.Settings.DefaltMakerImageUri != DataManager.getRelativePath(content.imgCreatorPicture.Source.ToString())) { changed = true; } if ("" != content.tbBarcode.Text) { changed = true; } if ("" != content.cboClass.Text) { changed = true; } if (false != (content.passedInspect.IsChecked == true)) { changed = true; } if (changed) { DialogBox.showOptionBox(parent, "This will erase all data entered for " + content.tbCarName.Text + ".", "Forget \"" + content.tbCarName.Text + "\"?", "Keep", "Forget", delegate(DialogBox.DialogResult result) { if (result == DialogBox.DialogResult.MainOption) { content._dialogHost.Close(); //close this host dialog } }); } else { return(DialogButton.ReturnEvent.Close); } } return(DialogButton.ReturnEvent.DoNothing); }), new DialogButton("Save", DialogButton.Alignment.Right, DialogButton.Style.Normal, delegate() { if (content.createSaveRacer()) //save racer on save button click { return(DialogButton.ReturnEvent.Close); } else { return(DialogButton.ReturnEvent.DoNothing); } })); }
private static void MakeDialog(Panel parent, RacerDetails content, WindowType type) { content._dialogHost = new Dialog(parent, content, false, false, true, delegate () { if (content._type == WindowType.Display)//only allow saving after clicking of dialog, if not creating a new car { if (content.createSaveRacer()) { return DialogButton.ReturnEvent.Close; } else { return DialogButton.ReturnEvent.DoNothing; } } else { return DialogButton.ReturnEvent.DoNothing; } }, (type == WindowType.Display ? new DialogButton("Delete", DialogButton.Alignment.Left, DialogButton.Style.Flat, delegate () { DialogBox.showOptionBox(parent, "This will completly remove \"" + content.tbCarName.Text + "\" from the competition. All of its history will be deleted. The current race will also be reset.", "Delete \"" + content.tbCarName.Text + "\"?", "Keep", "Delete", delegate (DialogBox.DialogResult result) { if (result == DialogBox.DialogResult.MainOption) { DataManager.Competition.Racers.Remove(content._racer); content.triggerUpdatedRacer(); content.triggerDeletedRacer(); content._dialogHost.Close();//close this host dialog } }); return DialogButton.ReturnEvent.DoNothing; }) : null), new DialogButton((type == WindowType.Display ? "Revert" : "Forget"), DialogButton.Alignment.Right, DialogButton.Style.Flat, delegate () { if(type == WindowType.Display) { string changes = ""; if (content._racer.Car.Name != content.tbCarName.Text) { changes += Environment.NewLine + "Car's Name: " + content._racer.Car.Name + " -> " + content.tbCarName.Text; } if (content._racer.Car.ImageUri != DataManager.getRelativePath(content.imgCarPicture.Source.ToString())) { changes += Environment.NewLine + "Car's Image"; } if (content._racer.Maker.Name != content.tbCreatorName.Text) { changes += Environment.NewLine + "Creator's Name: " + content._racer.Maker.Name + " -> " + content.tbCreatorName.Text; } if (content._racer.Maker.ImageUri != DataManager.getRelativePath(content.imgCreatorPicture.Source.ToString())) { changes += Environment.NewLine + "Creator's Name"; } if (content._racer.Barcode != content.tbBarcode.Text) { changes += Environment.NewLine + "Barcode: " + content._racer.Barcode + " -> " + content.tbBarcode.Text; } if (content._racer.Class != content.cboClass.Text) { changes += Environment.NewLine + "Class: " + content._racer.Class + " -> " + content.cboClass.Text; } if (content._racer.PassedInspection != (content.passedInspect.IsChecked == true)) { changes += Environment.NewLine + "Passed Inspection: " + (content._racer.PassedInspection ? "Yes" : "No") + " -> " + ((content.passedInspect.IsChecked == true)?"Yes":"No"); } //no nothing, this will act like a revert if (changes.Length > 0) { DialogBox.showOptionBox(parent, "This will revert the following changes" + changes, "Revert Changes Made To \"" + content.tbCarName.Text + "\"?", "Keep", "Revert", delegate (DialogBox.DialogResult result) { if (result == DialogBox.DialogResult.MainOption) { content._dialogHost.Close();//close this host dialog } }); } else { return DialogButton.ReturnEvent.Close; } } else { bool changed = false; if ("" != content.tbCarName.Text) { changed = true; } if (DataManager.Settings.DefaltCarImageUri != DataManager.getRelativePath(content.imgCarPicture.Source.ToString())) { changed = true; } if ("" != content.tbCreatorName.Text) { changed = true; } if (DataManager.Settings.DefaltMakerImageUri != DataManager.getRelativePath(content.imgCreatorPicture.Source.ToString())) { changed = true; } if ("" != content.tbBarcode.Text) { changed = true; } if ("" != content.cboClass.Text) { changed = true; } if (false != (content.passedInspect.IsChecked == true)) { changed = true; } if (changed) { DialogBox.showOptionBox(parent, "This will erase all data entered for " + content.tbCarName.Text + ".", "Forget \"" + content.tbCarName.Text + "\"?", "Keep", "Forget", delegate (DialogBox.DialogResult result) { if (result == DialogBox.DialogResult.MainOption) { content._dialogHost.Close();//close this host dialog } }); } else { return DialogButton.ReturnEvent.Close; } } return DialogButton.ReturnEvent.DoNothing; }), new DialogButton("Save", DialogButton.Alignment.Right, DialogButton.Style.Normal, delegate () { if (content.createSaveRacer())//save racer on save button click { return DialogButton.ReturnEvent.Close; } else { return DialogButton.ReturnEvent.DoNothing; } })); }