コード例 #1
0
 private static void StartTextBoxBlinker(TimedAction timedAction, TRef <int> blinkerCounter)
 {
     timedAction.Reset(() =>
     {
         // The blinker is on falf of the time and events such as input
         // changes can reset the blinker.
         var value = Volatile.Read(ref blinkerCounter.Value);
         value     = (value + 1) % (2 * TextBoxBlinkThreshold);
         Volatile.Write(ref blinkerCounter.Value, value);
     }, TextBoxBlinkSleepMilliseconds);
 }
コード例 #2
0
        private static void StartTextBoxBlinker(TimedAction timedAction, SoftwareKeyboardUiState state, object stateLock)
        {
            timedAction.Reset(() =>
            {
                lock (stateLock)
                {
                    // The blinker is on half of the time and events such as input
                    // changes can reset the blinker.
                    state.TextBoxBlinkCounter = (state.TextBoxBlinkCounter + 1) % (2 * SoftwareKeyboardRendererBase.TextBoxBlinkThreshold);

                    // Tell the render thread there is something new to render.
                    Monitor.PulseAll(stateLock);
                }
            }, TextBoxBlinkSleepMilliseconds);
        }
コード例 #3
0
        private static void StartRenderer(TimedAction timedAction, SoftwareKeyboardRendererBase renderer, SoftwareKeyboardUiState state, object stateLock)
        {
            SoftwareKeyboardUiState internalState = new SoftwareKeyboardUiState();

            bool canCreateSurface = false;
            bool needsUpdate      = true;

            timedAction.Reset(() =>
            {
                lock (stateLock)
                {
                    if (!Monitor.Wait(stateLock, RendererWaitTimeoutMilliseconds))
                    {
                        return;
                    }

                    needsUpdate  = UpdateStateField(ref state.InputText, ref internalState.InputText);
                    needsUpdate |= UpdateStateField(ref state.CursorBegin, ref internalState.CursorBegin);
                    needsUpdate |= UpdateStateField(ref state.CursorEnd, ref internalState.CursorEnd);
                    needsUpdate |= UpdateStateField(ref state.AcceptPressed, ref internalState.AcceptPressed);
                    needsUpdate |= UpdateStateField(ref state.CancelPressed, ref internalState.CancelPressed);
                    needsUpdate |= UpdateStateField(ref state.OverwriteMode, ref internalState.OverwriteMode);
                    needsUpdate |= UpdateStateField(ref state.TypingEnabled, ref internalState.TypingEnabled);
                    needsUpdate |= UpdateStateField(ref state.ControllerEnabled, ref internalState.ControllerEnabled);
                    needsUpdate |= UpdateStateField(ref state.TextBoxBlinkCounter, ref internalState.TextBoxBlinkCounter);

                    canCreateSurface = state.SurfaceInfo != null && internalState.SurfaceInfo == null;

                    if (canCreateSurface)
                    {
                        internalState.SurfaceInfo = state.SurfaceInfo;
                    }
                }

                if (canCreateSurface)
                {
                    renderer.CreateSurface(internalState.SurfaceInfo);
                }

                if (needsUpdate)
                {
                    renderer.DrawMutableElements(internalState);
                    renderer.CopyImageToBuffer();
                    needsUpdate = false;
                }
            });
        }