public static double?PromptCurrency(string fieldName, double?defaultValue) { NumberEntryControl control = new NumberEntryControl(); PosDialogWindow window = new PosDialogWindow(control, fieldName); control.SetDefaultEnterEventHandler(); control.DisplayAsCurrency = true; control.FloatValue = defaultValue; window.IsClosable = true; window.Width = 210; window.Height = 340; window.ShowDialogForActiveWindow(); double?value = null; if (!window.ClosedByUser) { try { value = Convert.ToDouble(StripCurrencySymbols(control.Text)); } catch { } } return(value); }
public static int?PromptNumber(string fieldName, int?defaultValue) { NumberEntryControl control = new NumberEntryControl(); PosDialogWindow window = new PosDialogWindow(control, fieldName); if (defaultValue.HasValue) { control.Text = "" + defaultValue.Value; } else { control.Text = ""; } control.SetDefaultEnterEventHandler(); window.IsClosable = true; window.Width = 210; window.Height = 340; window.ShowDialogForActiveWindow(); int?value = null; if (!window.ClosedByUser) { try { value = Convert.ToInt32(control.Text); } catch { } } return(value); }
public static double?PromptPercentage(DependencyObject parentControl, string fieldName, double?defaultValue) { NumberEntryControl control = new NumberEntryControl(); PosDialogWindow window = new PosDialogWindow(control, fieldName); Window ownerWindow = GetWindow(parentControl); control.SetDefaultEnterEventHandler(); control.DisplayAsPercentage = true; control.UseDecimalPoint = true; control.FloatValue = defaultValue; window.IsClosable = true; window.Width = 210; window.Height = 340; if (ownerWindow is IShadeable) { (ownerWindow as IShadeable).ShowShadingOverlay = true; } window.ShowDialog(ownerWindow); if (ownerWindow is IShadeable) { (ownerWindow as IShadeable).ShowShadingOverlay = false; } double?value = null; if (!window.ClosedByUser) { try { value = Convert.ToDouble(control.Text.Replace("%", "")) / 100; } catch { } } return(value); }