public static void OpenSetStatusPopup(string status, long groupId, Action <string> callback) { EditStatusUC editStatusUC = new EditStatusUC(); editStatusUC.TextBoxText.Text = status; DialogService dialogService = new DialogService(); dialogService.SetStatusBarBackground = true; EditStatusUC editStatusUc = editStatusUC; dialogService.Child = (FrameworkElement)editStatusUc; DialogService statusChangePopup = dialogService; Action updateStatusAction = (Action)(() => { string newStatus = editStatusUC.TextBoxText.Text.Replace("\r\n", "\r").Replace("\r", "\r\n"); AccountService.Instance.StatusSet(newStatus, "", groupId, (Action <BackendResult <long, ResultCode> >)(res => { if (res.ResultCode != ResultCode.Succeeded) { return; } if (groupId == 0L) { AppGlobalStateManager.Current.UpdateCachedUserStatus(newStatus); EventAggregator.Current.Publish((object)new BaseDataChangedEvent()); bool isGroup = groupId > 0L; EventAggregator.Current.Publish((object)new ProfileStatusChangedEvent(isGroup ? groupId : AppGlobalStateManager.Current.LoggedInUserId, isGroup, newStatus)); } if (callback == null) { return; } callback(newStatus); })); statusChangePopup.Hide(); }); editStatusUC.TextBoxText.KeyUp += (KeyEventHandler)((sender, args) => { if (args.Key != Key.Enter) { return; } updateStatusAction(); }); editStatusUC.ButtonSave.Click += (RoutedEventHandler)((s, e) => updateStatusAction()); statusChangePopup.Show(null); }
public static void OpenSetStatusPopup(string status, long groupId, Action <string> callback) { EditStatusUC editStatusUC = new EditStatusUC(); editStatusUC.TextBoxText.Text = (status); DialogService statusChangePopup = new DialogService { SetStatusBarBackground = true, Child = editStatusUC }; Action updateStatusAction = delegate { string newStatus = editStatusUC.TextBoxText.Text.Replace("\r\n", "\r").Replace("\r", "\r\n"); AccountService.Instance.StatusSet(newStatus, "", groupId, delegate(BackendResult <long, ResultCode> res) { if (res.ResultCode == ResultCode.Succeeded) { if (groupId == 0L) { AppGlobalStateManager.Current.UpdateCachedUserStatus(newStatus); EventAggregator.Current.Publish(new BaseDataChangedEvent()); bool flag = groupId > 0L; long id = flag ? groupId : AppGlobalStateManager.Current.LoggedInUserId; EventAggregator.Current.Publish(new ProfileStatusChangedEvent(id, flag, newStatus)); } if (callback != null) { callback.Invoke(newStatus); } } }); statusChangePopup.Hide(); }; editStatusUC.TextBoxText.KeyUp += (delegate(object sender, KeyEventArgs args) { if (args.Key == Key.Enter) { updateStatusAction.Invoke(); } }); editStatusUC.ButtonSave.Click += (delegate(object s, RoutedEventArgs e) { updateStatusAction.Invoke(); }); statusChangePopup.Show(null); }