Exemple #1
0
    private void ShowDialog(ShowDialogMessage param) {
      DialogWindow dw = new DialogWindow(param);
      Nullable<bool> dw_return = dw.ShowDialog();

      if (dw_return != null)
        if((bool)dw_return) 
          param.ExecuteIfTrue();
        else
          param.ExecuteIfFalse();
    }
    public DialogWindow(ShowDialogMessage contents) {

      InitializeComponent();

      _MsgContents = contents;

      this.Title = contents.Title;
      this.txtMessage.Text = contents.Text;

      this.cmdDefault.Content = contents.Buttons.First(b => b.IsDefault).Title;
      this.cmdDefault.IsDefault = contents.Buttons.First(b => b.IsDefault).IsDefault;
      this.cmdCancel.Content = contents.Buttons.First(b => !b.IsDefault).Title;
      this.cmdCancel.IsCancel = contents.Buttons.First(b => !b.IsDefault).IsDefault;
    }
    public override bool CanCloseWindowConfirmation() {
      bool canclose = false;

      ShowDialogMessage sdm = new ShowDialogMessage();
      sdm.Title = "Kilépés a Rendszerből";
      sdm.Text = "Amennyiben kilép a rendszerből a jelenlegi teszt végrehajtás megszakad.\nBiztosan kilép?";
      sdm.Buttons = new DialogButton[] { 
          new DialogButton{Title="Kilépek", IsDefault=false, ReturnValue=true},
          new DialogButton{Title="Maradok", IsDefault=true, ReturnValue=false},
        };
      sdm.ExecuteIfTrue = () => {
        try {
          _DataService.CancelTest((int)App.Current.Properties["CurrentTestID"], _DataService.LoggedInUser.PersonID);
        }
        catch (SessionExpiredException) {
          // hm... what to do?
        }
        _DataService.ClearSession();
        canclose = true;
      };
      sdm.ExecuteIfFalse = () => {
        canclose = false;
      };

      MessengerInstance.Send<ShowDialogMessage>(sdm);

      return canclose;
    }