コード例 #1
0
 public IKeyboardMode ObtainMode( string modes )
 {
     if ( modes == null || modes.Length == 0 ) return _empty;
     modes = modes.Normalize();
     KeyboardMode m;
     if ( !_modes.TryGetValue( modes, out m ) )
     {
         int modeCount;
         string[] splitModes = SplitMultiMode( modes, out modeCount );
         if ( modeCount <= 0 ) return _empty;
         if ( modeCount == 1 )
         {
             modes = splitModes[0];
             if ( !_modes.TryGetValue( modes, out m ) )
             {
                 m = new KeyboardMode( this, modes );
                 _modes.Add( modes, m );
             }
             Debug.Assert( m.IsAtomic, "Special construction for atomic modes." );
         }
         else
         {
             modes = String.Join( "+", splitModes, 0, modeCount );
             if ( !_modes.TryGetValue( modes, out m ) )
             {
                 IKeyboardMode[] atomics = new IKeyboardMode[modeCount];
                 for ( int i = 0; i < modeCount; ++i )
                 {
                     atomics[i] = ObtainMode( splitModes[i] );
                 }
                 m = new KeyboardMode( this, modes, new CKReadOnlyListOnIList<IKeyboardMode>( atomics ) );
                 _modes.Add( modes, m );
             }
             Debug.Assert( !m.IsAtomic && m.AtomicModes.Count == modeCount, "Combined mode." );
         }
     }
     return m;
 }
コード例 #2
0
 public LayoutKeyModeModeChangedEventArgs( ILayoutKeyMode key, IKeyboardMode previousMode )
     : base(key)
 {
     PreviousMode = previousMode;
 }
コード例 #3
0
 public ModeChangedEventArgs( IKeyboardMode mode )
 {
     Mode = mode;
 }
コード例 #4
0
        /// <summary>
        /// Obtains a mode from a list of atomic (already sorted) modes.
        /// Used by fall back generation.
        /// </summary>
        public IKeyboardMode ObtainMode( IKeyboardMode[] atomicModes, int count )
        {
            Debug.Assert( count > 1, "Atomic modes are handled directly." );

            Debug.Assert( !Array.Exists( atomicModes, delegate( IKeyboardMode mA ) { return mA.Context != this || mA.AtomicModes.Count != 1; } ),
                "Modes are from this Context and they are atomic and not empty." );

            StringBuilder b = new StringBuilder( atomicModes[0].ToString() );
            for ( int i = 1; i < count; ++i )
            {
                Debug.Assert( StringComparer.Ordinal.Compare( atomicModes[i - 1].ToString(), atomicModes[i].ToString() ) < 0,
                    "Modes are already sorted and NO DUPLICATE exists." );
                b.Append( '+' ).Append( atomicModes[i].ToString() );
            }
            string modes = b.ToString();
            KeyboardMode m;
            if ( !_modes.TryGetValue( modes, out m ) )
            {
                if ( atomicModes.Length != count )
                {
                    IKeyboardMode[] subArray = new IKeyboardMode[count];
                    Array.Copy( atomicModes, subArray, count );
                    atomicModes = subArray;
                }
                else atomicModes = (IKeyboardMode[])atomicModes.Clone();
                m = new KeyboardMode( this, modes, new CKReadOnlyListOnIList<IKeyboardMode>( atomicModes ) );
                _modes.Add( modes, m );
            }
            return m;
        }
コード例 #5
0
 public KeyboardModeChangingEventArgs( IKeyboard kb, IKeyboardMode next )
     : base(kb)
 {
     Mode = next;
 }
コード例 #6
0
        bool SetCurrentMode( IKeyboardMode newCurrentMode )
        {
            Debug.Assert( _currentMode != newCurrentMode && newCurrentMode.Context == this.Context, "These checks have been done before." );

            EventHandler<KeyboardModeChangingEventArgs> changing = CurrentModeChanging;
            if( changing != null )
            {
                KeyboardModeChangingEventArgs e = new KeyboardModeChangingEventArgs( this, newCurrentMode );
                changing( this, e );
                if( e.Cancel ) return false;
            }

            IKeyboardMode previous = _currentMode;
            _currentMode = newCurrentMode;

            // Listeners had the opportunity to cancel the setting. We can now
            // impact the choice of the actual key and actual key layout for each key.
            foreach( Key k in Keys )
            {
                k.OnCurrentModeChanged();
            }
            Layouts.OnCurrentModeChanged();

            EventHandler<KeyboardModeChangedEventArgs> changed = CurrentModeChanged;
            if( changed != null ) changed( this, new KeyboardModeChangedEventArgs( this, previous ) );

            return true;
        }
コード例 #7
0
 public KeyboardModeChangedEventArgs( IKeyboard kb, IKeyboardMode previous )
     : base(kb)
 {
     Previous = previous;
 }
コード例 #8
0
ファイル: VMKeyboardMode.cs プロジェクト: rit3k/ck-certified
 public VMKeyboardMode( VMContextEditable holder, IKeyboardMode keyboardMode )
 {
     Mode = keyboardMode;
     _holder = holder;
 }
コード例 #9
0
 public VMKeyModeBase( VMContextEditable context, ILayoutKeyMode model )
     : base(context)
 {
     _model = model;
     _modelMode = model.Mode;
 }