private void SetButtons(CustomDialogWindow obj) { switch (Buttons) { case CustomDialogButtons.OK: obj.btnCancel.Visibility = Visibility.Collapsed; obj.btnNo.Visibility = Visibility.Collapsed; obj.btnYes.Visibility = Visibility.Collapsed; break; case CustomDialogButtons.OKCancel: obj.btnNo.Visibility = Visibility.Collapsed; obj.btnYes.Visibility = Visibility.Collapsed; break; case CustomDialogButtons.YesNo: obj.btnOK.Visibility = Visibility.Collapsed; obj.btnCancel.Visibility = Visibility.Collapsed; break; case CustomDialogButtons.YesNoCancel: obj.btnOK.Visibility = Visibility.Collapsed; break; } switch (DefaultButton) { case CustomDialogResults.Cancel: obj.btnCancel.IsDefault = true; break; case CustomDialogResults.No: obj.btnNo.IsDefault = true; obj.btnCancel.IsCancel = true; break; case CustomDialogResults.None: obj.btnCancel.IsCancel = true; break; case CustomDialogResults.OK: obj.btnOK.IsDefault = true; obj.btnCancel.IsCancel = true; break; case CustomDialogResults.Yes: obj.btnYes.IsDefault = true; obj.btnCancel.IsCancel = true; break; } }
public CustomDialogResults Show() { var objTrace = new StackTrace(); if (_strCallingReflectedTypeName.Length == 0) _strCallingReflectedTypeName = objTrace.GetFrame(1).GetMethod().ReflectedType.Name; if (_strCallingMethodName.Length == 0) _strCallingMethodName = objTrace.GetFrame(1).GetMethod().Name; if (_strCallingModuleName.Length == 0) _strCallingModuleName = objTrace.GetFrame(1).GetMethod().Module.Name; var obj = new CustomDialogWindow(); if (InstructionIcon == CustomDialogIcons.None) obj.imgInstructionIcon.Visibility = Visibility.Collapsed; else obj.imgInstructionIcon.Source = new BitmapImage(GetIcon(InstructionIcon)); obj.tbInstructionText.Text = InstructionText; obj.tbInstructionHeading.Text = InstructionHeading; if(AdditionalDetailsText.Length > 0) obj.tbAdditionalDetailsText.Text = AdditionalDetailsText; else obj.expAdditionalDetails.Visibility = Visibility.Collapsed; SetButtons(obj); obj.ShowInTaskbar = false; obj.ShowDialog(); _enumCustomDialogResult = obj.CustomDialogResult; LogDialog(); return _enumCustomDialogResult; }