コード例 #1
0
        /*
         *  ボタンがフォーカスを取得した。
         *  TextBlockはフォーカスの取得/喪失の管理ができないので、TextBlockの上に透明のRadioButtonをかぶせてフォーカスの管理をしています。
         */
        private async void OverlappedButton_GotFocus(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("<<--- Button GotFocus");

            if (DesignMode.DesignModeEnabled)
            {
                // ビューデザイナーの中で動作している場合は何もしない。

                return;
            }

            if (textServiceManager == null)
            {
                // 初めての場合

                // 少し待たないと「漢字」キーが効かない。
                await Task.Delay(500);

                // CoreTextServicesManagerを作ります。
                Debug.WriteLine("--->> GetForCurrentView");
                textServiceManager = CoreTextServicesManager.GetForCurrentView();

                // IMEの切り替えのイベントハンドラを登録します。
                Debug.WriteLine("--->> Subscribe InputLanguageChanged");
                textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;
            }

            // editContextを作り直します。
            UpdateEditContext();

            // 再描画します。
            Win2DCanvas.Invalidate();
        }
コード例 #2
0
        public RecognizerControl()
        {
            this.InitializeComponent();
            const double penSize = 4;
            // Initialize drawing attributes. These are used in inking mode.
            var drawingAttributes = new InkDrawingAttributes
            {
                Color          = Windows.UI.Colors.Red,
                Size           = new Windows.Foundation.Size(penSize, penSize),
                IgnorePressure = false,
                FitToCurve     = true
            };


            // Show the available recognizers
            _inkRecognizerContainer = new InkRecognizerContainer();
            _recoView = _inkRecognizerContainer.GetRecognizers();
            // Set the text services so we can query when language changes
            _textServiceManager = CoreTextServicesManager.GetForCurrentView();
            _textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;

            SetDefaultRecognizerByCurrentInputMethodLanguageTag();

            // Initialize the InkCanvas
            InkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            InkCanvas.InkPresenter.InputDeviceTypes           = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch;
            InkCanvas.InkPresenter.StrokeInput.StrokeStarted += StrokeInput_StrokeStarted;
            InkCanvas.InkPresenter.StrokeInput.StrokeEnded   += StrokeInput_StrokeEnded;

            _recoTimer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(2)
            };
            _recoTimer.Tick += _recoTimer_Tick;
        }
コード例 #3
0
ファイル: Emoji.cs プロジェクト: UnigramDev/Unigram
        public static async Task <List <EmojiGroup> > SearchAsync(IProtoService protoService, string query, EmojiSkinTone skin)
        {
            var result        = new List <EmojiData>();
            var inputLanguage = CoreTextServicesManager.GetForCurrentView().InputLanguage.LanguageTag;

            var response = await protoService.SendAsync(new SearchEmojis(query, false, new[] { inputLanguage }));

            if (response is Emojis suggestions)
            {
                foreach (var item in suggestions.EmojisValue)
                {
                    var emoji = item;
                    if (EmojiGroupInternal._skinEmojis.Contains(emoji) || EmojiGroupInternal._skinEmojis.Contains(emoji.TrimEnd('\uFE0F')))
                    {
                        result.Add(new EmojiSkinData(emoji, skin));
                    }
                    else
                    {
                        result.Add(new EmojiData(item));
                    }
                }
            }

            return(new List <EmojiGroup>
            {
                new EmojiGroup
                {
                    Title = result.Count > 0 ? Strings.Resources.SearchEmojiHint : Strings.Resources.NoEmojiFound,
                    Stickers = result.ToArray()
                }
            });
        }
コード例 #4
0
        /*
         *  ボタンがフォーカスを取得した。
         *  TextBlockはフォーカスの取得/喪失の管理ができないので、TextBlockの上に透明のRadioButtonをかぶせてフォーカスの管理をしています。
         */
        private async void OverlappedButton_GotFocus(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("<<--- Button GotFocus");

            if (DesignMode.DesignModeEnabled)
            {
                // ビューデザイナーの中で動作している場合は何もしない。

                return;
            }

            // グリッドの外枠を青にしてフォーカスの取得を視覚的にユーザーに示します。
            MainGrid.BorderBrush = new SolidColorBrush(Colors.Blue);

            if (textServiceManager == null)
            {
                // 初めての場合

                // 少し待たないと「漢字」キーが効かない。
                await Task.Delay(1000);

                // CoreTextServicesManagerを作ります。
                Debug.WriteLine("--->> GetForCurrentView");
                textServiceManager = CoreTextServicesManager.GetForCurrentView();

                // IMEの切り替えのイベントハンドラを登録します。
                Debug.WriteLine("--->> Subscribe InputLanguageChanged");
                textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;
            }

            // editContextを作り直します。
            UpdateEditContext();
        }
コード例 #5
0
        public MainPage()
        {
            this.InitializeComponent();

            ink.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Touch | Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Mouse;
            ink.InkPresenter.StrokeInput.StrokeContinued += StrokeInput_StrokeContinued;

           ink.InkPresenter.StrokesCollected += InkPresenter_StrokesCollected;

            var vec1 = new Vector() { Start = new Point() { X = 0, Y = 0 }, End = new Point { X = 1, Y = 1 } };
            var vec2 = new Vector() { Start = new Point() { X = 0, Y = 0 }, End = new Point { X = 1, Y = 0 } };

            System.Diagnostics.Debug.WriteLine("Ängle =" + vec2.Angle(vec1));



            inkRecognizerContainer = new InkRecognizerContainer();
            recoView = inkRecognizerContainer.GetRecognizers();
         

            // Set the text services so we can query when language changes
            textServiceManager = CoreTextServicesManager.GetForCurrentView();
            textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;

            SetDefaultRecognizerByCurrentInputMethodLanguageTag();


            
        }
コード例 #6
0
        public MainPage()
        {
            this.InitializeComponent();
            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();

            drawingAttributes.Color          = Windows.UI.Colors.Black;
            drawingAttributes.Size           = new Size(4, 4);
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve     = true;

            inkRecognizerContainer = new InkRecognizerContainer();
            recoView = inkRecognizerContainer.GetRecognizers();
            if (recoView.Count > 0)
            {
                foreach (InkRecognizer recognizer in recoView)
                {
                    RecoName.Items.Add(recognizer.Name);
                }
            }
            else
            {
                RecoName.IsEnabled = false;
                RecoName.Items.Add("No Recognizer Available");
            }
            RecoName.SelectedIndex = 0;

            // Set the text services so we can query when language changes
            textServiceManager = CoreTextServicesManager.GetForCurrentView();
            textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;

            SetDefaultRecognizerByCurrentInputMethodLanguageTag();

            InkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            InkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch;
        }
コード例 #7
0
 public SearchStickerSetsCollection(IProtoService protoService, StickerType type, string query, long chatId)
 {
     _protoService  = protoService;
     _type          = type;
     _query         = query;
     _inputLanguage = CoreTextServicesManager.GetForCurrentView().InputLanguage.LanguageTag;
     _chatId        = chatId;
 }
コード例 #8
0
 public TextActionsTest()
 {
     Helper.ExecuteOnUIThread(() =>
     {
         CoreTextServicesManager manager = CoreTextServicesManager.GetForCurrentView();
         _textDocument = new TextDocument(manager.CreateEditContext());
     }).Wait();
 }
コード例 #9
0
        public MainPage()
        {
            InitializeComponent();
            _viewModel.LoadQuickTransactions();

            CoreTextServicesManager textServiceManager = CoreTextServicesManager.GetForCurrentView();

            textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;
        }
コード例 #10
0
        public Scenario2()
        {
            this.InitializeComponent();
            //read language related resource file .strings/en or zh-cn/resources.resw
            Run run1 = new Run();

            run1.Text = ResourceManagerHelper.ReadValue("Description2_p1");
            this.textDes.Inlines.Add(run1);
            this.textDes.Inlines.Add(new LineBreak());

            // Initialize drawing attributes. These are used in inking mode.
            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();

            drawingAttributes.Color = Windows.UI.Colors.Red;
            double penSize = 4;

            drawingAttributes.Size           = new Windows.Foundation.Size(penSize, penSize);
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve     = true;

            // Show the available recognizers
            inkRecognizerContainer = new InkRecognizerContainer();
            recoView = inkRecognizerContainer.GetRecognizers();
            if (recoView.Count > 0)
            {
                foreach (InkRecognizer recognizer in recoView)
                {
                    RecoName.Items.Add(recognizer.Name);
                }
            }
            else
            {
                RecoName.IsEnabled = false;
                RecoName.Items.Add("No Recognizer Available");
            }
            RecoName.SelectedIndex = 0;

            // Set the text services so we can query when language changes
            textServiceManager = CoreTextServicesManager.GetForCurrentView();
            textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;

            SetDefaultRecognizerByCurrentInputMethodLanguageTag();

            // Initialize the InkCanvas
            inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            inkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch;

            this.SizeChanged += Scenario2_SizeChanged;
        }
コード例 #11
0
        public Scenario2()
        {
            this.InitializeComponent();

            // Initialize drawing attributes. These are used in inking mode.
            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();

            drawingAttributes.Color = Windows.UI.Colors.Red;
            double penSize = 4;

            drawingAttributes.Size           = new Windows.Foundation.Size(penSize, penSize);
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve     = true;

            // Show the available recognizers
            inkRecognizerContainer = new InkRecognizerContainer();
            recoView = inkRecognizerContainer.GetRecognizers();
            if (recoView.Count > 0)
            {
                foreach (InkRecognizer recognizer in recoView)
                {
                    RecoName.Items.Add(recognizer.Name);
                }
            }
            else
            {
                RecoName.IsEnabled = false;
                RecoName.Items.Add("No Recognizer Available");
            }
            RecoName.SelectedIndex = 0;

            // Set the text services so we can query when language changes
            textServiceManager = CoreTextServicesManager.GetForCurrentView();
            textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;

            SetDefaultRecognizerByCurrentInputMethodLanguageTag();

            // Initialize reco tooltip
            recoTooltip         = new ToolTip();
            recoTooltip.Content = InstallRecoText;
            ToolTipService.SetToolTip(InstallReco, recoTooltip);

            // Initialize the InkCanvas
            inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            inkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch;

            this.Unloaded    += Scenario2_Unloaded;
            this.SizeChanged += Scenario2_SizeChanged;
        }
コード例 #12
0
        /*
         *  IMEが切り替えられた。
         */
        private void TextServiceManager_InputLanguageChanged(CoreTextServicesManager sender, object ev)
        {
            Debug.Write("<<--- InputLanguageChanged");

            // IMEの名前を得ます。
            Windows.Globalization.Language lng = sender.InputLanguage;
            if (lng != null)
            {
                Debug.Write(" Lang:{0}", lng.DisplayName);
            }
            Debug.WriteLine("");

            // editContextを作り直します。
            UpdateEditContext();
        }
コード例 #13
0
        public Scenario2()
        {
            this.InitializeComponent();

            // Initialize drawing attributes. These are used in inking mode.
            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();
            drawingAttributes.Color = Windows.UI.Colors.Red;
            double penSize = 4;
            drawingAttributes.Size = new Windows.Foundation.Size(penSize, penSize);
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve = true;

            // Show the available recognizers
            inkRecognizerContainer = new InkRecognizerContainer();
            recoView = inkRecognizerContainer.GetRecognizers();
            if (recoView.Count > 0)
            {
                foreach (InkRecognizer recognizer in recoView)
                {
                    RecoName.Items.Add(recognizer.Name);
                }
            }
            else
            {
                RecoName.IsEnabled = false;
                RecoName.Items.Add("No Recognizer Available");
            }
            RecoName.SelectedIndex = 0;

            // Set the text services so we can query when language changes
            textServiceManager = CoreTextServicesManager.GetForCurrentView();
            textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;

            SetDefaultRecognizerByCurrentInputMethodLanguageTag();

            // Initialize reco tooltip
            recoTooltip = new ToolTip();
            recoTooltip.Content = InstallRecoText;
            ToolTipService.SetToolTip(InstallReco, recoTooltip);

            // Initialize the InkCanvas
            inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            inkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch;

            this.Unloaded += Scenario2_Unloaded;
            this.SizeChanged += Scenario2_SizeChanged;
        }
コード例 #14
0
        public Scenario2()
        {
            this.InitializeComponent();
            //read language related resource file .strings/en or zh-cn/resources.resw
            Run run1 = new Run();
            run1.Text = ResourceManagerHelper.ReadValue("Description2_p1");
            this.textDes.Inlines.Add(run1);
            this.textDes.Inlines.Add(new LineBreak());

            // Initialize drawing attributes. These are used in inking mode.
            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();
            drawingAttributes.Color = Windows.UI.Colors.Red;
            double penSize = 4;
            drawingAttributes.Size = new Windows.Foundation.Size(penSize, penSize);
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve = true;

            // Show the available recognizers
            inkRecognizerContainer = new InkRecognizerContainer();
            recoView = inkRecognizerContainer.GetRecognizers();
            if (recoView.Count > 0)
            {
                foreach (InkRecognizer recognizer in recoView)
                {
                    RecoName.Items.Add(recognizer.Name);
                }
            }
            else
            {
                RecoName.IsEnabled = false;
                RecoName.Items.Add("No Recognizer Available");
            }
            RecoName.SelectedIndex = 0;

            // Set the text services so we can query when language changes
            textServiceManager = CoreTextServicesManager.GetForCurrentView();
            textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;

            SetDefaultRecognizerByCurrentInputMethodLanguageTag();

            // Initialize the InkCanvas
            inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            inkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch;

            this.SizeChanged += Scenario2_SizeChanged;
        }
コード例 #15
0
        public MyEditBox()
        {
            this.InitializeComponent();

            _coreWindow                 = CoreWindow.GetForCurrentThread();
            _coreWindow.KeyDown        += CoreWindow_KeyDown;
            _coreWindow.PointerPressed += CoreWindow_PointerPressed;

            CoreTextServicesManager manager = CoreTextServicesManager.GetForCurrentView();

            _editContext = manager.CreateEditContext();

            // Get the Input Pane so we can programmatically hide and show it.
            _inputPane = InputPane.GetForCurrentView();

            _editContext.InputScope     = CoreTextInputScope.Text;
            _editContext.TextRequested += EditContext_TextRequested;

            // The system raises this event to request the current selection.
            _editContext.SelectionRequested += EditContext_SelectionRequested;

            // The system raises this event when it wants the edit control to remove focus.
            _editContext.FocusRemoved += EditContext_FocusRemoved;

            // The system raises this event to update text in the edit control.
            _editContext.TextUpdating += EditContext_TextUpdating;

            // The system raises this event to change the selection in the edit control.
            _editContext.SelectionUpdating += EditContext_SelectionUpdating;

            // The system raises this event to request layout information.
            // This is used to help choose a position for the IME candidate window.
            _editContext.LayoutRequested += EditContext_LayoutRequested;

            // The system raises this event to notify the edit control
            // that the string composition has started.
            _editContext.CompositionStarted += EditContext_CompositionStarted;

            // The system raises this event to notify the edit control
            // that the string composition is finished.
            _editContext.CompositionCompleted += EditContext_CompositionCompleted;
        }
コード例 #16
0
        public MainPage()
        {


            this.InitializeComponent();
            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();
            drawingAttributes.Color = Windows.UI.Colors.Black;
            drawingAttributes.Size = new Size(4, 4);
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve = true;

            inkRecognizerContainer = new InkRecognizerContainer();
            recoView = inkRecognizerContainer.GetRecognizers();
            if (recoView.Count > 0)
            {
                foreach (InkRecognizer recognizer in recoView)
                {
                    RecoName.Items.Add(recognizer.Name);
                }
            }
            else
            {
                RecoName.IsEnabled = false;
                RecoName.Items.Add("No Recognizer Available");
            }
            RecoName.SelectedIndex = 0;

            // Set the text services so we can query when language changes
            textServiceManager = CoreTextServicesManager.GetForCurrentView();
            textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;

            SetDefaultRecognizerByCurrentInputMethodLanguageTag();

            InkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            InkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch;

        }
コード例 #17
0
 private void TextServiceManager_InputLanguageChanged(CoreTextServicesManager sender, object args)
 {
     SetDefaultRecognizerByCurrentInputMethodLanguageTag();
 }
コード例 #18
0
 public async void FindStickers(string query)
 {
     if (string.IsNullOrWhiteSpace(query))
     {
         SearchStickers = null;
     }
     else
     {
         var items = SearchStickers = new SearchStickerSetsCollection(ProtoService, Aggregator, false, query, CoreTextServicesManager.GetForCurrentView().InputLanguage.LanguageTag);
         await items.LoadMoreItemsAsync(0);
     }
 }
コード例 #19
0
 private async void FieldEmoji_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(FieldEmoji.Text))
     {
         EmojiCollection.Source = Toolbar.ItemsSource;
     }
     else
     {
         EmojiCollection.Source = await Emoji.SearchAsync(ViewModel.ProtoService, FieldEmoji.Text, _selected, CoreTextServicesManager.GetForCurrentView().InputLanguage.LanguageTag);
     }
 }
コード例 #20
0
 private void TextServiceManager_InputLanguageChanged(CoreTextServicesManager sender, object args)
 {
     Debug.WriteLine("Keyboard layout is changed!");
 }
コード例 #21
0
        public CodeEditBox()
        {
            InitializeComponent();
            Unloaded += CodeEditBox_Unloaded;

            _textFormat = new CanvasTextFormat
            {
                FontFamily = "Consolas",
                FontSize   = 14
            };

            // Make the control focusable
            IsTabStop = true;

            // The CoreTextEditContext processes text input, but other keys are
            // the apps's responsibility.
            _coreWindow                 = CoreWindow.GetForCurrentThread();
            _coreWindow.KeyDown        += CoreWindow_KeyDown;
            _coreWindow.PointerPressed += CoreWindow_PointerPressed;

            // Create a CoreTextEditContext for our custom edit control.
            CoreTextServicesManager manager = CoreTextServicesManager.GetForCurrentView();

            _editContext = manager.CreateEditContext();

            // Create a TextDocument where we will store the text data
            _textDocument                   = new TextDocument(_editContext);
            _textDocument.TextChanged      += TextDocument_TextChanged;
            _textDocument.SelectionChanged += TextDocument_SelectionChanged;

            //! Automatic hide and show the Input Pane. Note that on Desktop, you will need to
            //! implement the UIA text pattern to get expected automatic behavior.
            _editContext.InputPaneDisplayPolicy = CoreTextInputPaneDisplayPolicy.Automatic;
            // Set the input scope to inform software keyboard layout and text behavior.
            _editContext.InputScope = CoreTextInputScope.Default;

            // The system raises this event when it wants the edit control to remove focus.
            _editContext.FocusRemoved += EditContext_FocusRemoved;
            // The system raises this event to request layout information.
            // This is used to help choose a position for the IME candidate window.
            _editContext.LayoutRequested += EditContext_LayoutRequested;
            // The system raises this event to notify the edit control
            // that the string composition has started.
            _editContext.CompositionStarted += EditContext_CompositionStarted;
            // The system raises this event to notify the edit control
            // that the string composition is finished.
            _editContext.CompositionCompleted += EditContext_CompositionCompleted;
            // The system raises this event when the NotifyFocusLeave operation has
            // completed.
            // _editContext.NotifyFocusLeaveCompleted += EditContext_NotifyFocusLeaveCompleted;

            // Focus state reporter
            // TODO: remove this

            GotFocus  += CodeEditBox_FocusChanged;
            LostFocus += CodeEditBox_FocusChanged;
            CodeEditBox_FocusChanged(this, null);

            // Update rendertargets
            TextDisplay.SizeChanged += TextDisplay_SizeChanged;
            TextDisplay_SizeChanged(this, null);

            // Set our initial UI.
            UpdateUI();
        }
コード例 #22
0
ファイル: CustomEditControl.xaml.cs プロジェクト: ice0/test
        public CustomEditControl()
        {
            this.InitializeComponent();

            // The CoreTextEditContext processes text input, but other keys are
            // the apps's responsibility.
            _coreWindow                 = CoreWindow.GetForCurrentThread();
            _coreWindow.KeyDown        += CoreWindow_KeyDown;
            _coreWindow.PointerPressed += CoreWindow_PointerPressed;

            // Create a CoreTextEditContext for our custom edit control.
            CoreTextServicesManager manager = CoreTextServicesManager.GetForCurrentView();

            _editContext = manager.CreateEditContext();

            // Get the Input Pane so we can programmatically hide and show it.
            _inputPane = InputPane.GetForCurrentView();

            // For demonstration purposes, this sample sets the Input Pane display policy to Manual
            // so that it can manually show the software keyboard when the control gains focus and
            // dismiss it when the control loses focus. If you leave the policy as Automatic, then
            // the system will hide and show the Input Pane for you. Note that on Desktop, you will
            // need to implement the UIA text pattern to get expected automatic behavior.
            _editContext.InputPaneDisplayPolicy = CoreTextInputPaneDisplayPolicy.Manual;

            // Set the input scope to Text because this text box is for any text.
            // This also informs software keyboards to show their regular
            // text entry layout.  There are many other input scopes and each will
            // inform a keyboard layout and text behavior.
            _editContext.InputScope = CoreTextInputScope.Text;

            // The system raises this event to request a specific range of text.
            _editContext.TextRequested += EditContext_TextRequested;

            // The system raises this event to request the current selection.
            _editContext.SelectionRequested += EditContext_SelectionRequested;

            // The system raises this event when it wants the edit control to remove focus.
            _editContext.FocusRemoved += EditContext_FocusRemoved;

            // The system raises this event to update text in the edit control.
            _editContext.TextUpdating += EditContext_TextUpdating;

            // The system raises this event to change the selection in the edit control.
            _editContext.SelectionUpdating += EditContext_SelectionUpdating;

            // The system raises this event when it wants the edit control
            // to apply formatting on a range of text.
            _editContext.FormatUpdating += EditContext_FormatUpdating;

            // The system raises this event to request layout information.
            // This is used to help choose a position for the IME candidate window.
            _editContext.LayoutRequested += EditContext_LayoutRequested;

            // The system raises this event to notify the edit control
            // that the string composition has started.
            _editContext.CompositionStarted += EditContext_CompositionStarted;

            // The system raises this event to notify the edit control
            // that the string composition is finished.
            _editContext.CompositionCompleted += EditContext_CompositionCompleted;

            // The system raises this event when the NotifyFocusLeave operation has
            // completed. Our sample does not use this event.
            // _editContext.NotifyFocusLeaveCompleted += EditContext_NotifyFocusLeaveCompleted;

            // Set our initial UI.
            UpdateTextUI();
            UpdateFocusUI();
        }
コード例 #23
0
ファイル: InkTextBox.cs プロジェクト: apulliam/InkTextBox
        protected override void OnApplyTemplate()
        {
            container = this.GetTemplateChild(ContainerName) as Grid;
            textBox = this.GetTemplateChild(TextBoxName) as TextBox;
            inkCanvas = this.GetTemplateChild(InkCanvasName) as InkCanvas;
            inkBorder = this.GetTemplateChild(InkBorderName) as Border;
            inkWindow = this.GetTemplateChild(InkWindowName) as Popup;

            inkRecognizerContainer = new InkRecognizerContainer();
            recognizers = inkRecognizerContainer.GetRecognizers();

            // Set the text services so we can query when language changes
            textServiceManager = CoreTextServicesManager.GetForCurrentView();
            textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;

            SetDefaultRecognizerByCurrentInputMethodLanguageTag();

            // Create a timer that expires after 1 second
            recognitionTimer = new DispatcherTimer();
            recognitionTimer.Interval = new TimeSpan(0, 0, 1);
            recognitionTimer.Tick += RecoTimer_Tick;

            pointerTimer = new DispatcherTimer();
            pointerTimer.Interval = new TimeSpan(0, 0, 2);
            pointerTimer.Tick += PointerTimer_Tick;

            textBox.PointerEntered += TextBox_PointerEntered;
            textBox.AddHandler(PointerPressedEvent, new PointerEventHandler(TextBox_PointerPressed), true);
            textBox.SelectionChanged += TextBox_SelectionChanged;

            inkCanvas.PointerEntered += InkCanvas_PointerEntered;
            inkCanvas.InkPresenter.StrokesCollected += InkCanvas_StrokesCollected;
            inkCanvas.InkPresenter.StrokeInput.StrokeStarted += InkCanvas_StrokeStarted;
            inkCanvas.InkPresenter.StrokesErased += InkPresenter_StrokesErased;
            
            // Initialize drawing attributes. These are used in inking mode.
            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();
            drawingAttributes.Color = InkColor;
            double penSize = PenSize;
            drawingAttributes.Size = new Windows.Foundation.Size(penSize, penSize);
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve = true;

            // Initialize the InkCanvas
            inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            inkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Pen;

            //InputPane inputPane = InputPane.GetForCurrentView();
            //inputPane.Showing += InputPane_Showing;

            this.SizeChanged += InkTextBox_SizeChanged;

            enableText();
            base.OnApplyTemplate();
        }
コード例 #24
0
 /// <summary>
 /// Instantiates the <see cref="RnLanguagesModule"/>.
 /// </summary>
 internal RnLanguagesModule(ReactContext _context)
 {
     this.context = _context;
     CoreTextServicesManager.GetForCurrentView().InputLanguageChanged +=
         OnLanguageChange;
 }
コード例 #25
0
 private void TextServiceManager_InputLanguageChanged(CoreTextServicesManager sender, object args)
 {
     SetDefaultRecognizerByCurrentInputMethodLanguageTag();
 }
コード例 #26
0
 public CoreTextServicesManagerEvents(CoreTextServicesManager This)
 {
     this.This = This;
 }
コード例 #27
0
 private void OnLanguageChange(CoreTextServicesManager sender, object args)
 {
     context.GetJavaScriptModule <RCTDeviceEventEmitter>()
     .emit("languagesDidChange", this.GetLanguageOutput());
 }
コード例 #28
0
        public MainPage()
        {
            this.InitializeComponent();

            var textBoxCandidates = this.FindName("candidateBox") as TextBox;

            textBoxCandidates.IsEnabled = false;

            _coreWindow                    = CoreWindow.GetForCurrentThread();
            _coreWindow.KeyDown           += CoreWindow_KeyDown;
            _coreWindow.CharacterReceived += CoreWindow_CharacterReceived;
            _coreWindow.Activated         += _coreWindow_Activated;

            // Create a CoreTextEditContext for our custom edit control.
            CoreTextServicesManager manager = CoreTextServicesManager.GetForCurrentView();

            _editContext = manager.CreateEditContext();

            // Get the Input Pane so we can programmatically hide and show it.
            _inputPane          = InputPane.GetForCurrentView();
            _inputPane.Showing += (o, e) => _virtualKeyboardHeight = (int)e.OccludedRect.Height;
            _inputPane.Hiding  += (o, e) => _virtualKeyboardHeight = 0;

            // For demonstration purposes, this sample sets the Input Pane display policy to Manual
            // so that it can manually show the software keyboard when the control gains focus and
            // dismiss it when the control loses focus. If you leave the policy as Automatic, then
            // the system will hide and show the Input Pane for you. Note that on Desktop, you will
            // need to implement the UIA text pattern to get expected automatic behavior.
            _editContext.InputPaneDisplayPolicy = CoreTextInputPaneDisplayPolicy.Manual;

            // Set the input scope to Text because this text box is for any text.
            // This also informs software keyboards to show their regular
            // text entry layout.  There are many other input scopes and each will
            // inform a keyboard layout and text behavior.
            _editContext.InputScope = CoreTextInputScope.Text;

            // The system raises this event to request a specific range of text.
            _editContext.TextRequested += EditContext_TextRequested;

            // The system raises this event to request the current selection.
            _editContext.SelectionRequested += EditContext_SelectionRequested;

            // The system raises this event when it wants the edit control to remove focus.
            _editContext.FocusRemoved += EditContext_FocusRemoved;

            // The system raises this event to update text in the edit control.
            _editContext.TextUpdating += EditContext_TextUpdating;

            // The system raises this event to change the selection in the edit control.
            _editContext.SelectionUpdating += EditContext_SelectionUpdating;

            // The system raises this event to request layout information.
            // This is used to help choose a position for the IME candidate window.
            _editContext.LayoutRequested += EditContext_LayoutRequested;

            // The system raises this event to notify the edit control
            // that the string composition has started.
            _editContext.CompositionStarted += EditContext_CompositionStarted;

            // The system raises this event to notify the edit control
            // that the string composition is finished.
            _editContext.CompositionCompleted += EditContext_CompositionCompleted;

            // The system raises this event when the NotifyFocusLeave operation has
            // completed. Our sample does not use this event.
            // _editContext.NotifyFocusLeaveCompleted += EditContext_NotifyFocusLeaveCompleted;

            _timer             = _coreWindow.DispatcherQueue.CreateTimer();
            _timer.Interval    = new TimeSpan(0, 0, 0, 0, 10);
            _timer.IsRepeating = false;
            _timer.Tick       += (o, e) =>
            {
                //Debug.WriteLine("Result text: {0}", (object)_lastResultText);
                foreach (var c in _lastResultText)
                {
                    OnTextInput(c);
                }
            };
        }