Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Forms9Patch.iOS.KeyboardService"/> class.
        /// </summary>
        public KeyboardService()
        {
            P42.Utils.DebugExtensions.AddToCensus(this);

            InputPane.GetForCurrentView().Hiding  += KeyboardService_Hiding;
            InputPane.GetForCurrentView().Showing += KeyboardService_Showing;
        }
Esempio n. 2
0
        internal void Destroy()
        {
            Container = null;

            if (Window.Current is Window window)
            {
                window.SizeChanged -= OnSizeChanged;
            }

            if (DisplayInformation.GetForCurrentView() is DisplayInformation displayInformation)
            {
                displayInformation.OrientationChanged -= OnOrientationChanged;
            }

            if (InputPane.GetForCurrentView() is InputPane inputPane)
            {
                inputPane.Showing -= OnKeyboardShowing;
                inputPane.Hiding  -= OnKeyboardHiding;
            }

            if (ContainerElement != null)
            {
                ContainerElement.PointerPressed -= OnBackgroundClick;
            }
        }
Esempio n. 3
0
        internal static void Hide(DependencyObject focusedObject)
        {
            // DDVSO:197685
            // If the touch stack is disabled or the WM_POINTER touch stack
            // is enabled, we get touch KB support for free.  So don't
            // attempt any calls into InputPane for these scenarios.
            if (s_PlatformSupported &&
                StylusLogic.IsStylusAndTouchSupportEnabled &&
                !StylusLogic.IsPointerStackEnabled)
            {
                InputPane ip;

                try
                {
                    using (ip = InputPane.GetForWindow(GetHwndSource(focusedObject)))
                    {
                        ip?.TryHide();
                    }
                }
                catch (PlatformNotSupportedException)
                {
                    s_PlatformSupported = false;
                }
            }
        }
Esempio n. 4
0
        private async void Stickers_Click(object sender, RoutedEventArgs e)
        {
            var channel = ViewModel.With as TLChannel;

            if (channel != null && channel.HasBannedRights && (channel.BannedRights.IsSendStickers || channel.BannedRights.IsSendGifs))
            {
                await TLMessageDialog.ShowAsync("The admins of this group restricted you from posting stickers here.", "Warning", "OK");

                return;
            }

            if (StickersPanel.Visibility == Visibility.Collapsed)
            {
                Focus(FocusState.Programmatic);
                TextField.Focus(FocusState.Programmatic);

                InputPane.GetForCurrentView().TryHide();

                StickersPanel.Visibility = Visibility.Visible;

                ViewModel.OpenStickersCommand.Execute(null);
            }
            else
            {
                Focus(FocusState.Programmatic);
                TextField.Focus(FocusState.Keyboard);

                StickersPanel.Visibility = Visibility.Collapsed;
            }
        }
Esempio n. 5
0
        public MainPage()
        {
            InitializeComponent();
            DataContext = UnigramContainer.Current.ResolveType <MainViewModel>();

            NavigationCacheMode = NavigationCacheMode.Enabled;

            #region Localizations

            TabChats.Header = Strings.Resources.Chats;

            NavigationChats.Content = Strings.Resources.Chats;
            NavigationAbout.Content = Strings.Resources.About;
            NavigationNews.Content  = Strings.Resources.News;

            #endregion

            ViewModel.Aggregator.Subscribe(this);
            Loaded += OnLoaded;

            //Theme.RegisterPropertyChangedCallback(Border.BackgroundProperty, OnThemeChanged);

            searchInit();

            InputPane.GetForCurrentView().Showing += (s, args) => args.EnsuredFocusedElementInView = true;
        }
Esempio n. 6
0
        internal static void OnFocusChanged(Control control, FocusState focusState)
        {
            if (focusState == FocusState.Unfocused)
            {
                if (control == _focusedElement)
                {
                    _focusedElement = null;
                }
            }
            else             // Focused
            {
                if (_focusedElement != control)
                {
                    (_focusedElement as Control)?.Unfocus();
                    _focusedElement = control;
                }

                _fallbackFocusedElement = control;

#if __ANDROID__
                // Forcefully try to bring the control into view when keyboard is open to accommodate adjust nothing mode
                if (InputPane.GetForCurrentView().Visible)
                {
                    control.StartBringIntoView();
                }
#endif
            }
        }
Esempio n. 7
0
        protected void OnLoaded(object s, RoutedEventArgs e)
        {
            var inputPane = InputPane.GetForCurrentView();

            inputPane.Showing += OnInputPaneShowing;
            inputPane.Hiding  += OnInputPaneHiding;
        }
Esempio n. 8
0
 private void InputPaneHidingHandler(InputPane pane, InputPaneVisibilityEventArgs args)
 {
     if (BottomAppBar != null)
     {
         BottomAppBar.Visibility = Windows.UI.Xaml.Visibility.Visible;
     }
 }
Esempio n. 9
0
 private void InputPane_Hiding(InputPane sender, InputPaneVisibilityEventArgs args)
 {
     CaptionWatermark.Visibility    = string.IsNullOrEmpty(Caption.Text) ? Visibility.Visible : Visibility.Collapsed;
     KeyboardPlaceholder.Height     = 0.0;
     KeyboardPlaceholder.Visibility = Visibility.Collapsed;
     ImagesGrid.Margin = new Thickness(0.0);
 }
Esempio n. 10
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            InputPane.GetForCurrentView().Showing += InputPaneShowingHandler;
            InputPane.GetForCurrentView().Hiding  += InputPaneHidingHandler;

            base.OnNavigatedTo(e);
        }
Esempio n. 11
0
 // Helper to hide the app bar when the soft keyboard is showing -
 // works around a bug where it will occlude textboxes.
 private void InputPaneShowingHandler(InputPane pane, InputPaneVisibilityEventArgs args)
 {
     if (BottomAppBar != null)
     {
         BottomAppBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="LayoutAwarePage"/> class.
        /// </summary>
        public LayoutAwarePage()
        {
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                return;
            }

            // When this page is part of the visual tree make two changes:
            // 1) Map application view state to visual state for the page
            // 2) Handle keyboard and mouse navigation requests
            this.Loaded += (sender, e) =>
            {
                this.StartLayoutUpdates(sender, e);

                var inputPane = InputPane.GetForCurrentView();
                inputPane.Showing += OnInputPaneShowing;
                inputPane.Hiding  += OnInputPaneHiding;

                VisualStateManager.GoToState(this, "LayoutInitialize", false);
                this.GetService <IViewService>().RunOnUIThread(() => VisualStateManager.GoToState(this, "LayoutReady", true));
            };

            // Undo the same changes when the page is no longer visible
            this.Unloaded += (sender, e) =>
            {
                this.StopLayoutUpdates(sender, e);

                var inputPane = InputPane.GetForCurrentView();
                inputPane.Showing -= OnInputPaneShowing;
                inputPane.Hiding  -= OnInputPaneHiding;
            };
        }
Esempio n. 13
0
 private void KeyboardService_Showing(InputPane sender, InputPaneVisibilityEventArgs args)
 {
     Forms9Patch.KeyboardService.OnVisiblityChange(KeyboardVisibilityChange.Shown);
     Height = InputPane.GetForCurrentView().OccludedRect.Height;
     _displayInformation = Windows.Graphics.Display.DisplayInformation.GetForCurrentView();
     _displayInformation.OrientationChanged += OnOrienationChanged;
 }
Esempio n. 14
0
        public XnaInputManager(Game game, Core.IO.IGameDescriptor gameDesc)
        {
            _game          = game;
            _width         = gameDesc.Width;
            _height        = gameDesc.Height;
            _window        = game.Window;
            _mousePosition = new Core.Graphics.Point();

            TouchPanel.EnableMouseGestures   = true;
            TouchPanel.EnabledGestures       = GestureType.Hold | GestureType.Tap;
            TouchPanel.EnableMouseTouchPoint = true;

#if WINDOWS_UWP
            var view = SystemNavigationManager.GetForCurrentView();
            view.BackRequested += HardwareButtons_BackPressed;

            bool isHardwareButtonsApiPresent = Windows.Foundation.Metadata.ApiInformation.IsTypePresent
                                                   (typeof(Windows.Phone.UI.Input.HardwareButtons).FullName);

            if (isHardwareButtonsApiPresent)
            {
                Windows.Phone.UI.Input.HardwareButtons.CameraPressed += HardwareButtons_CameraPressed;
            }

            _inputPane              = InputPane.GetForCurrentView();
            _currentWindow          = CoreWindow.GetForCurrentThread();
            _currentWindow.KeyDown += XnaInputManager_KeyDown;
            _currentWindow.KeyUp   += XnaInputManager_KeyUp;
#endif
        }
Esempio n. 15
0
        public SignInPage()
        {
            InitializeComponent();
            ViewModel   = ServiceLocator.Current.GetInstance <SignInViewModel>();
            DataContext = ViewModel;

            //InputPane.GetForCurrentView().Showing += (s, args) =>
            //{
            //    //SignInImage.Visibility = Visibility.Collapsed;
            //    offSet = (int)args.OccludedRect.Height;
            //    args.EnsuredFocusedElementInView = true;
            //    var trans = new TranslateTransform();
            //    trans.Y = -(offSet/2);
            //    this.RenderTransform = trans;
            //};

            //InputPane.GetForCurrentView().Hiding += (s, args) =>
            //{
            //    //SignInImage.Visibility = Visibility.Visible;
            //    var trans = new TranslateTransform();
            //    trans.Y = 0;
            //    this.RenderTransform = trans;
            //    args.EnsuredFocusedElementInView = false;
            //};

            InputPane.GetForCurrentView().Showing += ItemDetailPage_Showing;
            InputPane.GetForCurrentView().Hiding  += ItemDetailPage_Hiding;
        }
        public override void OnNavigatingFrom(NavigatingFromEventArgs e, Dictionary <string, object> viewModelState, bool suspending)
        {
            base.OnNavigatingFrom(e, viewModelState, suspending);

            if (!ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                return;
            }
            var statusBar = StatusBar.GetForCurrentView();

            if (statusBar == null)
            {
                return;
            }
            statusBar.BackgroundOpacity = 1;
            statusBar.BackgroundColor   = _statusBarBackgroundColor;
            statusBar.ForegroundColor   = _statusBarForegroundColor;

            var applicationView = ApplicationView.GetForCurrentView();

            applicationView.SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);

            InputPane.GetForCurrentView().Showing -= OnShowing;
            InputPane.GetForCurrentView().Hiding  -= OnHiding;
        }
Esempio n. 17
0
        private void OnUnloaded(object sender, RoutedEventArgs e)
        {
            ApplicationView.GetForCurrentView().VisibleBoundsChanged -= ApplicationView_VisibleBoundsChanged;

            InputPane.GetForCurrentView().Showing -= InputPane_Showing;
            InputPane.GetForCurrentView().Hiding  -= InputPane_Hiding;
        }
        public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> dictionary)
        {
            base.OnNavigatedTo(e, dictionary);

            if (!ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                return;
            }
            var statusBar = StatusBar.GetForCurrentView();

            if (statusBar == null)
            {
                return;
            }

            var applicationView = ApplicationView.GetForCurrentView();

            applicationView.SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);

            _statusBarBackgroundColor   = statusBar.BackgroundColor;
            _statusBarForegroundColor   = statusBar.ForegroundColor;
            statusBar.BackgroundOpacity = 0;
            statusBar.BackgroundColor   = Color.FromArgb(255, 0, 130, 201);
            statusBar.ForegroundColor   = Colors.White;

            InputPane.GetForCurrentView().Showing += OnShowing;
            InputPane.GetForCurrentView().Hiding  += OnHiding;
        }
Esempio n. 19
0
        /// <summary>
        /// ctor.
        /// </summary>
        public Window(CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation)
            : base(contentRect, aStyle, bufferingType, deferCreation)
        {
            Delegate          = new WindowDelegate(this);
            _inputPane        = InputPane.GetForCurrentView();
            _inputPane.Window = this;

            // Register the types that can be dragging into the window (effectively 'AllowDrop').
            // This must be done before dragging enters the window or dragging methods won't be invoked.
            // We register for all possible types and then confirm whether they
            // are actually supported within the draggingEntered and draggingUpdated methods.
            // This has a minor side effect in the standard UI (zoom effect) but is considered acceptable.
            RegisterForDraggedTypes(new string[]
            {
                NSPasteboard.NSPasteboardTypeUrl,
                NSPasteboard.NSPasteboardTypeTIFF,
                NSPasteboard.NSPasteboardTypePNG,
                NSPasteboard.NSPasteboardTypeHTML,
                NSPasteboard.NSPasteboardTypeRTF,
                NSPasteboard.NSPasteboardTypeRTFD,
                NSPasteboard.NSPasteboardTypeFileUrl,
                NSPasteboard.NSPasteboardTypeString

                /* For future use
                 * UTType.URL,
                 * UTType.Image,
                 * UTType.HTML,
                 * UTType.RTF,
                 * UTType.FileURL,
                 * UTType.PlainText,
                 */
            });
        }
        /// <summary>
        /// Event raised when IsPanIntoViewChanged is changed. It only triggers once
        /// </summary>
        /// <param name="d">FrameworkElement</param>
        /// <param name="e">Event arguments</param>
        private static void IsPanIntoViewChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            _element = d as FrameworkElement;

            InputPane.GetForCurrentView().Showing += onKeyboardShowing;
            InputPane.GetForCurrentView().Hiding  += onKeyboardHidding;
        }
Esempio n. 21
0
        private void OnUnloaded(object sender, RoutedEventArgs e)
        {
            InputPane.GetForCurrentView().Showing -= InputPane_Showing;
            InputPane.GetForCurrentView().Hiding  -= InputPane_Hiding;

            App.AcceleratorKeyActivated -= Dispatcher_AcceleratorKeyActivated;
        }
 /// <summary>
 /// Event raised when the keyboard is hidden
 /// </summary>
 /// <param name="sender">InputPane</param>
 /// <param name="args">InputPane Event Arguments</param>
 private static void onKeyboardHidding(InputPane sender, InputPaneVisibilityEventArgs args)
 {
     _element.RenderTransform = new TranslateTransform
     {
         Y = args.OccludedRect.Height
     };
 }
Esempio n. 23
0
        public Playground()
        {
            MeasureStartup();

            this.InitializeComponent();

            Loaded += Playground_Loaded;

            xamlText.TextChanged        += OnTextChanged;
            jsonDataContext.TextChanged += OnDataContextTextChanged;

            content.SizeChanged += (snd, args) =>
            {
                resolution.Text = $"{content.ActualWidth}x{content.ActualHeight}";
            };

            var abc = DynamicAnimation.StoryboardProperty.ToString();

            DynamicAnimation.GetStoryboard(this);
            DynamicAnimation.SetStoryboard(this, null);

            SizeChanged += (snd, e) => RestoreCodePaneSize(e.PreviousSize, e.NewSize);
#if __WASM__
            Uno.Foundation.WebAssemblyRuntime.InvokeJS("Uno.UI.WindowManager.current.setStyle(\"" + splitter.HtmlId + "\", {\"cursor\": \"col-resize\"});");
#endif
            InputPane.GetForCurrentView().Showing += OnInputPaneShowing;
            InputPane.GetForCurrentView().Hiding  += OnInputPaneHiding;;
        }
Esempio n. 24
0
        static void KeyCheck_Click(object sender, RoutedEventArgs e)
        {
            var  chk   = sender as CheckBox;
            bool isChk = chk.IsChecked ?? false;

            try
            {
                var pane = InputPane.GetForCurrentView();
                if (isChk)
                {
                    pane.TryShow();
                }
                else
                {
                    pane.TryHide();
                }
            }
            catch (Exception ex)
            {
                App.MessageBox(ex.Message + Environment.NewLine + ex.StackTrace);
            }

            // TODO
            //  System.InvalidCastException: Unable to cast object of type 'Windows.UI.ViewManagement.InputPane' to type 'Windows.UI.ViewManagement.IInputPane2'.
            //at System.StubHelpers.StubHelpers.GetCOMIPFromRCW_WinRT(Object objSrc, IntPtr pCPCMD, IntPtr & ppTarget)
            //at Windows.UI.ViewManagement.InputPane.TryShow()
        }
        public UploadPage()
        {
            InitializeComponent();

            _viewModel  = ServiceLocator.Current.GetInstance <UploadViewModel>();
            DataContext = _viewModel;

            Loaded += UploadPage_Loaded;

            // We need to prevent the virtual keyboard covering the textbox control
            InputPane.GetForCurrentView().Showing += (s, args) =>
            {
                RenderTransform = new TranslateTransform {
                    Y = -args.OccludedRect.Height
                };
                args.EnsuredFocusedElementInView = true;
            };

            InputPane.GetForCurrentView().Hiding += (s, args) =>
            {
                RenderTransform = new TranslateTransform {
                    Y = 0
                };
                args.EnsuredFocusedElementInView = false;
            };
        }
 private async void EditorView_Hiding(InputPane sender, InputPaneVisibilityEventArgs args)
 {
     if (Initialized)
     {
         await editor_view.InvokeScriptAsync("eval", new string[] { @"document.activeElement.blur();" });
     }
 }
Esempio n. 27
0
        internal static void Show(DependencyObject focusedObject)
        {
            // DDVSO:222625
            // We need to only show if applicable to this focused object
            // so guard the calls to TryShow here.
            // DDVSO:197685
            // If the touch stack is disabled or the WM_POINTER touch stack
            // is enabled, we get touch KB support for free.  So don't
            // attempt any calls into InputPane for these scenarios.
            // DDVSO:362756
            // Don't show if implicit invocation is turned off.
            if (s_PlatformSupported &&
                !CoreAppContextSwitches.DisableImplicitTouchKeyboardInvocation &&
                StylusLogic.IsStylusAndTouchSupportEnabled &&
                !StylusLogic.IsPointerStackEnabled &&
                ShouldShow(focusedObject))
            {
                InputPane ip;

                try
                {
                    using (ip = InputPane.GetForWindow(GetHwndSource(focusedObject)))
                    {
                        ip?.TryShow();
                    }
                }
                catch (PlatformNotSupportedException)
                {
                    s_PlatformSupported = false;
                }
            }
        }
Esempio n. 28
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            object[] parameters = e.Parameter as object[];
            if (parameters != null && parameters[0] != null)
            {
                ShareObject objShare = parameters[0] as ShareObject;
                this.DataContext = _viewModel = new EditSinaSharePageViewModel(objShare);
            }

            Messenger.Default.Register <NotificationMessage>(this, (msg) =>
            {
                switch (msg.Notification)
                {
                case "gobackSharePage":
                    this.Frame.GoBack();
                    break;

                default:
                    break;
                }
            });

            InputPane.GetForCurrentView().Showing += EditSinaShare_Showing;
            InputPane.GetForCurrentView().Hiding  += EditSinaShare_Hiding;
        }
Esempio n. 29
0
        private void Page_Unloaded(object sender, RoutedEventArgs e)
        {
            var pane = InputPane.GetForCurrentView();

            pane.Showing -= Pane_Showing;
            pane.Hiding  -= Pane_Hiding;
        }
Esempio n. 30
0
 private void OnKeyDownHandler(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == VirtualKey.Enter)
     {
         InputPane.GetForCurrentView().TryHide();
     }
 }