Пример #1
0
        public IMessageViewModel MakeMessageViewModel(Message message)
        {
            IMessageViewModel messageViewModel = IoC.Get <IMessageViewModel>();

            messageViewModel.Initialize(message);

            return(messageViewModel);
        }
Пример #2
0
        public void Post(string header, IMessageViewModel viewModel)
        {
            var window = _scope.Resolve <MessageBoxWindow>();

            window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            window.Header      = header;
            window.DataContext = viewModel;
            window.ShowDialog();
        }
 public void ShowMessage(IMessageViewModel viewModel)
 {
     MessageBox.Show(
         viewModel.MessageBoxText,
         viewModel.Caption,
         viewModel.Button,
         viewModel.Icon,
         viewModel.DefaultResult,
         viewModel.Options);
 }
Пример #4
0
        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();
            IMessageViewModel vm = this.BindingContext as IMessageViewModel;

            if (vm.Type == Model.MessageType.Text)
            {
                TextMessageView view = new TextMessageView(vm.IsMyMessage);

                /*view.SetBinding(TextMessageView.MessageTextProperty, vm.MessageText);
                 * view.SetBinding(TextMessageView.UserNameProperty, vm.UserName);
                 * view.SetBinding(TextMessageView.TimeStampProperty, vm.SentTime);
                 * */
                view.Name               = vm.UserName;
                view.MessageText        = vm.MessageText;
                view.SentTime           = vm.SentTime;
                view.IsMyMessage        = vm.IsMyMessage;
                view.ProfileImageSource = vm.UserImage;
                this.View               = view;
            }
        }
Пример #5
0
        private void CopyMessage(IMessageViewModel message)
        {
            TextMessage += $"{message.Text} ";

            _telemetryService.TrackEvent("CopyMessage",
                new Dictionary<string, string> { { "Room", Room.Name } });
        }
Пример #6
0
        private async void RemoveMessage(IMessageViewModel message)
        {
            var updatedMessage = await _gitterApiService.UpdateMessageAsync(Room.Id, message.Id, string.Empty);
            message.UpdateMessage(updatedMessage.Text);
            Messages.Remove(message);

            double minutesLeft = _mainViewModel.CurrentDateTime.Subtract(message.SentDate).TotalMinutes;
            _telemetryService.TrackEvent("RemoveMessage",
                new Dictionary<string, string> { { "Room", Room.Name } },
                new Dictionary<string, double> { { "MinutesAgo", minutesLeft } });
        }
Пример #7
0
        private bool CanRemoveMessage(IMessageViewModel message)
        {
            if (message == null)
                return false;

            var currentDate = new DateTimeOffset(_mainViewModel.CurrentDateTime);
            double minutesLeft = currentDate.Subtract(message.SentDate).TotalMinutes;

            return (message.User.Id == _mainViewModel.CurrentUser.Id && minutesLeft < 10);
        }
Пример #8
0
        public MessageView(IMessageViewModel viewModel)
        {
            InitializeComponent();

            DataContext = viewModel;
        }