コード例 #1
0
        public MessageViewModel(Message message)
        {
            Id = message.Id;
            From = message.From ?? string.Empty;
            Content = message.Content ?? string.Empty;
            Subject = message.Subject ?? string.Empty;

            if (message.User != null)
                User = new UserViewModel(message.User);

            When = message.When;
        }
コード例 #2
0
        private void ProcessNonAuth(Message.NotAuthorizedMessage msg)
        {
            if (!msg.IsTriedToLog)
            {
                var dialogMsg = new GalaSoft.MvvmLight.Messaging.DialogMessage("You are not authorized.\n\r Continue authorization?", res =>
                {
                    if (res == MessageBoxResult.OK)
                        ProcessLoginCommand.Execute(null);
                    else
                    {
                        //App.Current.MainWindow.OwnedWindows[0].Close();
                        App.Current.Shutdown(0);
                    }

                });
                dialogMsg.Button = MessageBoxButton.OKCancel;
                Messenger.Default.Send(dialogMsg, "msg1");
            }
        }
コード例 #3
0
        private void ProcessLoginResult(Message.LoginResultMessage message)
        {
            if (message != null && message.LoginResult != null)
            {
                LoginResult = message.LoginResult;
                if (message.LoginResult.IsAuthorized && _outlookInitTask.Status == TaskStatus.Created)
                    _outlookInitTask.Start();

                _afterloginTask.Start();
            }
        }
コード例 #4
0
        private void OnNewGroup(Message.NewGroupMessage msg)
        {
            GalaSoft.MvvmLight.Threading.DispatcherHelper.InvokeAsync(() =>
            {
                var newGroupView = App.Current.MainWindow.OwnedWindows.Cast<Window>().FirstOrDefault();
                if (newGroupView != null)
                    newGroupView.Close();

                if (msg.NewGroup != null)
                    UserGroups.Add(msg.NewGroup);
            });
        }
コード例 #5
0
 private void OnDefaultChanging(Message.ChangeGroupMessage msg)
 {
     if (msg.DefaultGroup != null)
     {
         GroupToSend = msg.DefaultGroup;
     }
 }
コード例 #6
0
        private void LoginPerformed(Message.LoginMessage loginMsg)
        {
            if (loginMsg != null)
            {
                LoginData = loginMsg.Login;
                IsLogged = true;
            }

            var window = App.Current.MainWindow.OwnedWindows.Cast<Window>().FirstOrDefault();
            if (window != null)
                window.Close();

            GC.Collect();
        }
コード例 #7
0
        public Common.Models.Message AddMessage(Common.Models.MessangerUser user, Common.Models.MessangerGroup group, string id, string content)
        {
            var message = new Message
            {
                Id = id,
                User = user,
                Content = content,
                When = DateTimeOffset.UtcNow,
                Group = group
            };

            _repository.Add(message);

            return message;
        }