public void Attach()
 {
     if (ChooseAttachment == null)
     {
         ChooseAttachment = new ChooseAttachmentViewModel(With, CacheService, EventAggregator, NavigationService, StateService);
         NotifyOfPropertyChange(() => ChooseAttachment);
     }
     BeginOnUIThread(() => ChooseAttachment.Open());
 }
 public void Attach()
 {
     if (ChooseAttachment == null)
     {
         ChooseAttachment = new ChooseAttachmentViewModel(With, OpenInlineBot, SendDocument, SendVideo, SendPhoto, SendLocation, OpenContact, CacheService, EventAggregator, NavigationService, StateService);
         NotifyOfPropertyChange(() => ChooseAttachment);
     }
     BeginOnUIThread(() => ChooseAttachment.Open());
 }
Esempio n. 3
0
 public void Attach()
 {
     BeginOnUIThread(() => ChooseAttachment.Open());
 }
        public DialogDetailsView()
        {
            InitializeComponent();

            AnimationContext = LayoutRoot;

            _sendButton.Click   += (sender, args) => ViewModel.Send();
            _attachButton.Click += (sender, args) =>
            {
                EmojiPlaceholder.Visibility = Visibility.Collapsed;
                //DialogPhoto.Visibility = Visibility.Visible;
                //Title.Visibility = Visibility.Visible;

                ChooseAttachment.Focus();
                ViewModel.Attach();
            };
            _smileButton.Click += (sender, args) =>
            {
                if (_emojiKeyboard == null)
                {
                    _emojiKeyboard = EmojiControl.GetInstance();

                    _emojiKeyboard.BindTextBox(InputMessage);
                    EmojiPlaceholder.Content = _emojiKeyboard;
                    _emojiKeyboard.IsOpen    = true;
                }

                if (EmojiPlaceholder.Visibility == Visibility.Visible)
                {
                    if (InputMessage == FocusManager.GetFocusedElement())
                    {
                        _smileButtonPressed = true;

                        EmojiPlaceholder.Opacity = 1.0;
                        EmojiPlaceholder.Height  = EmojiControl.PortraitOrientationHeight;
                        Items.Focus();
                    }
                    else
                    {
                        EmojiPlaceholder.Visibility = Visibility.Collapsed;
                        //DialogPhoto.Visibility = Visibility.Visible;
                        //Title.Visibility = Visibility.Visible;
                    }
                }
                else
                {
                    var awaitKeyboardDown = false;
                    if (InputMessage == FocusManager.GetFocusedElement())
                    {
                        awaitKeyboardDown = true;
                        Items.Focus();
                    }

                    ThreadPool.QueueUserWorkItem(state =>
                    {
                        if (awaitKeyboardDown)
                        {
                            Thread.Sleep(400);
                        }
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            EmojiPlaceholder.Opacity    = 1.0;
                            EmojiPlaceholder.Visibility = Visibility.Visible;
                            //DialogPhoto.Visibility = Visibility.Collapsed;
                            //Title.Visibility = Visibility.Collapsed;
                        });
                    });
                }
            };
            _manageButton.Click  += (sender, args) => SwitchToSelectionMode();
            _forwardButton.Click += (sender, args) =>
            {
                var selectedItems = ViewModel.Items.Where(x => x.Id != null && x.IsSelected).ToList();
                if (selectedItems.Count == 0)
                {
                    return;
                }

                ViewModel.IsSelectionEnabled = false;

                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    try
                    {
                        if (Items.Visibility == Visibility.Visible)
                        {
                            var writeableBitmap   = new WriteableBitmap(Items, null);
                            ViewModel.With.Bitmap = writeableBitmap;
                        }
                    }
                    catch (Exception ex)
                    {
                        Telegram.Api.Helpers.Execute.ShowDebugMessage("WritableBitmap exception " + ex);
                    }

                    ViewModel.ForwardMessages(selectedItems);
                });
            };
            _deleteButton.Click += (sender, args) => ViewModel.DeleteMessages();

            Loaded += (sender, args) =>
            {
                SetRootFrameBinding();

                if (!ViewModel.StateService.IsEmptyBackground)
                {
                    var color = Colors.White;
                    color.A = 254;
                    SystemTray.ForegroundColor = color;
                }

                if (ViewModel.StateService.CurrentBackground != null)
                {
                    var color = Colors.White;
                    color.A = 254;
                    SystemTray.ForegroundColor = color;
                }

                if (ViewModel.With is TLBroadcastChat)
                {
                    _forwardButton.IsEnabled = false;
                }

                ThreadPool.QueueUserWorkItem(state =>
                {
                    Thread.Sleep(300);

                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        if (ViewModel.StateService.FocusOnInputMessage)
                        {
                            ViewModel.StateService.FocusOnInputMessage = false;
                            InputMessage.Focus();
                        }
                    });
                });
                if (ViewModel.ChooseAttachment != null)
                {
                    ViewModel.ChooseAttachment.PropertyChanged += OnChooseAttachmentPropertyChanged;
                }
                if (ViewModel.ImageViewer != null)
                {
                    ViewModel.ImageViewer.PropertyChanged += OnImageViewerPropertyChanged;
                }
                if (ViewModel.ImageEditor != null)
                {
                    ViewModel.ImageEditor.PropertyChanged += OnImageEditorPropertyChanged;
                }
                ViewModel.PropertyChanged += OnViewModelPropertyChanged;
                ViewModel.ScrollToBottom  += OnViewModelScrollToBottom;

                BuildLocalizedAppBar();
                //MessageBox.Show("Time: " + timer.Elapsed);
            };

            Unloaded += (sender, args) =>
            {
                RemoveRootFrameBinding();

                if (ViewModel.ChooseAttachment != null)
                {
                    ViewModel.ChooseAttachment.PropertyChanged -= OnChooseAttachmentPropertyChanged;
                }
                if (ViewModel.ImageViewer != null)
                {
                    ViewModel.ImageViewer.PropertyChanged -= OnImageViewerPropertyChanged;
                }
                if (ViewModel.ImageEditor != null)
                {
                    ViewModel.ImageEditor.PropertyChanged -= OnImageEditorPropertyChanged;
                }
                ViewModel.ScrollToBottom  -= OnViewModelScrollToBottom;
                ViewModel.PropertyChanged -= OnViewModelPropertyChanged;
            };
        }