private void SetButtons(CustomDialog obj) { switch (this.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 (this.DefaultButton) { case CustomDialogResults.Cancel: obj.btnCancel.IsDefault = true; break; case CustomDialogResults.No: obj.btnNo.IsDefault = true; obj.btnCancel.IsCancel = true; break; case CustomDialogResults.None: //do nothing 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() { //get the calling code information System.Diagnostics.StackTrace objTrace = new System.Diagnostics.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; } CustomDialog obj = new CustomDialog(this.ButtonsDisabledDelay); obj.tbCaption.Text = Caption; obj.Title = Caption; if (this.FooterText.Length > 0) { obj.tbFooterText.Text = this.FooterText; if (this.FooterIcon != CustomDialogIcons.None) { obj.imgFooterIcon.Source = new BitmapImage(GetIcon(this.FooterIcon)); } else { obj.imgFooterIcon.Visibility = Visibility.Collapsed; } } else { obj.tbFooterText.Visibility = Visibility.Collapsed; obj.imgFooterIcon.Visibility = Visibility.Collapsed; } if (this.InstructionIcon == CustomDialogIcons.None) { obj.imgInstructionIcon.Visibility = Visibility.Collapsed; } else { obj.imgInstructionIcon.Source = new BitmapImage(GetIcon(this.InstructionIcon)); } obj.tbInstructionText.Text = this.InstructionText; obj.tbInstructionHeading.Text = this.InstructionHeading; if (this.AdditionalDetailsText.Length > 0) { obj.tbAdditionalDetailsText.Text = this.AdditionalDetailsText; } else { obj.expAdditionalDetails.Visibility = Visibility.Collapsed; } SetButtons(obj); obj.ShowInTaskbar = true; obj.ShowDialog(); _enumCustomDialogResult = obj.CustomDialogResult; LogDialog(); return(_enumCustomDialogResult); }