bool IDictionary <IFocusIndex, IFocusNodeState> .TryGetValue(IFocusIndex key, out IFocusNodeState value) { bool Result = TryGetValue((ILayoutIndex)key, out ILayoutNodeState Value); value = Value; return(Result); }
/// <summary> /// Changes the value of a text. The caret position is also moved for this view and other views where the caret is at the same focus and position. /// </summary> /// <param name="newText">The new text.</param> /// <param name="newCaretPosition">The new caret position.</param> /// <param name="changeCaretBeforeText">True if the caret should be changed before the text, to preserve the caret invariant.</param> public virtual void ChangeFocusedText(string newText, int newCaretPosition, bool changeCaretBeforeText) { Debug.Assert(Focus is IFocusTextFocus); bool IsHandled = false; IFocusNodeState State = Focus.CellView.StateView.State; IFocusIndex ParentIndex = State.ParentIndex; int OldCaretPosition = CaretPosition; if (Focus is IFocusStringContentFocus AsStringContentFocus) { IFocusStringContentFocusableCellView CellView = AsStringContentFocus.CellView; IFocusTextValueFrame Frame = CellView.Frame as IFocusTextValueFrame; Debug.Assert(Frame != null); if (Frame.AutoFormat) { switch (AutoFormatMode) { case AutoFormatModes.None: IsHandled = true; break; case AutoFormatModes.FirstOnly: newText = StringHelper.FirstOnlyFormattedText(newText); IsHandled = true; break; case AutoFormatModes.FirstOrAll: newText = StringHelper.FirstOrAllFormattedText(newText); IsHandled = true; break; case AutoFormatModes.AllLowercase: newText = StringHelper.AllLowercaseFormattedText(newText); IsHandled = true; break; } } else { IsHandled = true; } Controller.ChangeTextAndCaretPosition(ParentIndex, AsStringContentFocus.CellView.PropertyName, newText, OldCaretPosition, newCaretPosition, changeCaretBeforeText); } else if (Focus is IFocusCommentFocus AsCommentFocus) { Controller.ChangeCommentAndCaretPosition(ParentIndex, newText, OldCaretPosition, newCaretPosition, changeCaretBeforeText); IsHandled = true; } Debug.Assert(IsHandled); }
/// <summary> /// Changes the value of a comment. /// </summary> /// <param name="nodeIndex">Index of the state with the comment to change.</param> /// <param name="text">The new text.</param> /// <param name="oldCaretPosition">The old caret position.</param> /// <param name="newCaretPosition">The new caret position.</param> /// <param name="changeCaretBeforeText">True if the caret should be changed before the text, to preserve the caret invariant.</param> public virtual void ChangeCommentAndCaretPosition(IFocusIndex nodeIndex, string text, int oldCaretPosition, int newCaretPosition, bool changeCaretBeforeText) { Contract.RequireNotNull(nodeIndex, out IFocusIndex NodeIndex); Contract.RequireNotNull(text, out string Text); Debug.Assert(StateTable.ContainsKey(NodeIndex)); System.Action <IWriteableOperation> HandlerRedo = (IWriteableOperation operation) => RedoChangeComment(operation); System.Action <IWriteableOperation> HandlerUndo = (IWriteableOperation operation) => UndoChangeComment(operation); IFocusNodeState State = (IFocusNodeState)StateTable[NodeIndex]; FocusChangeCommentOperation Operation = CreateChangeCommentOperation(State.Node, Text, oldCaretPosition, newCaretPosition, changeCaretBeforeText, HandlerRedo, HandlerUndo, isNested: false); Operation.Redo(); SetLastOperation(Operation); CheckInvariant(); }
/// <summary> /// Changes the value of a comment. /// </summary> /// <param name="nodeIndex">Index of the state with the comment to change.</param> /// <param name="text">The new text.</param> /// <param name="oldCaretPosition">The old caret position.</param> /// <param name="newCaretPosition">The new caret position.</param> /// <param name="changeCaretBeforeText">True if the caret should be changed before the text, to preserve the caret invariant.</param> public virtual void ChangeCommentAndCaretPosition(IFocusIndex nodeIndex, string text, int oldCaretPosition, int newCaretPosition, bool changeCaretBeforeText) { Debug.Assert(nodeIndex != null); Debug.Assert(StateTable.ContainsKey(nodeIndex)); Debug.Assert(text != null); Action <IWriteableOperation> HandlerRedo = (IWriteableOperation operation) => RedoChangeComment(operation); Action <IWriteableOperation> HandlerUndo = (IWriteableOperation operation) => UndoChangeComment(operation); IFocusNodeState State = StateTable[nodeIndex]; IFocusChangeCommentOperation Operation = CreateChangeCommentOperation(State.Node, text, oldCaretPosition, newCaretPosition, changeCaretBeforeText, HandlerRedo, HandlerUndo, isNested: false); Operation.Redo(); SetLastOperation(Operation); CheckInvariant(); }
/// <summary></summary> protected override void AddNextNodeToCycle(IFocusCyclableNodeState state) { FocusInsertionChildNodeIndexList CycleIndexList = state.CycleIndexList; Node ParentNode = state.ParentState.Node; IFocusIndex NodeIndex = state.ParentIndex; CycleBodyInfo Info = new(); List <Type> BodyTypeList = new List <Type>() { Type.FromTypeof <EffectiveBody>(), Type.FromTypeof <DeferredBody>(), Type.FromTypeof <ExternBody>(), Type.FromTypeof <PrecursorBody>() }; foreach (IFocusInsertionChildNodeIndex Index in CycleIndexList) { Body Body = (Body)Index.Node; if (BodyTypeList.Contains(Type.FromGetType(Body))) { BodyTypeList.Remove(Type.FromGetType(Body)); } Info.Update(Body); } // If the list is full, no need to add more nodes to the cycle. if (BodyTypeList.Count > 0) { Type NodeType = BodyTypeList[0]; Node NewBody = NodeHelper.CreateInitializedBody(NodeType, Info.Documentation, Info.RequireBlocks, Info.EnsureBlocks, Info.ExceptionIdentifierBlocks, Info.EntityDeclarationBlocks, Info.BodyInstructionBlocks, Info.ExceptionHandlerBlocks, Info.AncestorType); IFocusBrowsingInsertableIndex InsertableNodeIndex = NodeIndex as IFocusBrowsingInsertableIndex; Debug.Assert(InsertableNodeIndex != null); IFocusInsertionChildNodeIndex InsertionIndex = InsertableNodeIndex.ToInsertionIndex(ParentNode, NewBody) as IFocusInsertionChildNodeIndex; Debug.Assert(InsertionIndex != null); CycleIndexList.Add(InsertionIndex); } }
/// <summary> /// Initializes a new instance of the <see cref="FocusNodeState{IInner}"/> class. /// </summary> /// <param name="parentIndex">The index used to create the state.</param> public FocusNodeState(IFocusIndex parentIndex) : base(parentIndex) { }
bool IDictionary <IFocusIndex, IFocusNodeState> .Remove(IFocusIndex key) { return(Remove((ILayoutIndex)key)); }
bool IDictionary <IFocusIndex, IFocusNodeState> .ContainsKey(IFocusIndex key) { return(ContainsKey((ILayoutIndex)key)); }
void IDictionary <IFocusIndex, IFocusNodeState> .Add(IFocusIndex key, IFocusNodeState value) { Add((ILayoutIndex)key, (ILayoutNodeState)value); }
IFocusNodeState IDictionary <IFocusIndex, IFocusNodeState> .this[IFocusIndex key] { get { return(this[(ILayoutIndex)key]); } set { this[(ILayoutIndex)key] = (ILayoutNodeState)value; } }
/// <summary></summary> protected override void AddNextNodeToCycle(IFocusCyclableNodeState state) { IFocusInsertionChildNodeIndexList CycleIndexList = state.CycleIndexList; INode ParentNode = state.ParentState.Node; IFocusIndex NodeIndex = state.ParentIndex; IDocument Documentation = null; IBlockList <IAssertion, Assertion> RequireBlocks = null; IBlockList <IAssertion, Assertion> EnsureBlocks = null; IBlockList <IIdentifier, Identifier> ExceptionIdentifierBlocks = null; IBlockList <IEntityDeclaration, EntityDeclaration> EntityDeclarationBlocks = null; IBlockList <IInstruction, Instruction> BodyInstructionBlocks = null; IBlockList <IExceptionHandler, ExceptionHandler> ExceptionHandlerBlocks = null; IOptionalReference <IObjectType> AncestorType = null; List <Type> BodyTypeList = new List <Type>() { typeof(EffectiveBody), typeof(DeferredBody), typeof(ExternBody), typeof(PrecursorBody) }; foreach (IFocusInsertionChildNodeIndex Index in CycleIndexList) { IBody Body = Index.Node as IBody; Debug.Assert(Body != null); if (BodyTypeList.Contains(Body.GetType())) { BodyTypeList.Remove(Body.GetType()); } switch (Body) { case IEffectiveBody AsEffective: Documentation = AsEffective.Documentation; RequireBlocks = AsEffective.RequireBlocks; EnsureBlocks = AsEffective.EnsureBlocks; ExceptionIdentifierBlocks = AsEffective.ExceptionIdentifierBlocks; EntityDeclarationBlocks = AsEffective.EntityDeclarationBlocks; BodyInstructionBlocks = AsEffective.BodyInstructionBlocks; ExceptionHandlerBlocks = AsEffective.ExceptionHandlerBlocks; break; case IDeferredBody AsDeferred: Documentation = AsDeferred.Documentation; RequireBlocks = AsDeferred.RequireBlocks; EnsureBlocks = AsDeferred.EnsureBlocks; ExceptionIdentifierBlocks = AsDeferred.ExceptionIdentifierBlocks; break; case IExternBody AsExtern: Documentation = AsExtern.Documentation; RequireBlocks = AsExtern.RequireBlocks; EnsureBlocks = AsExtern.EnsureBlocks; ExceptionIdentifierBlocks = AsExtern.ExceptionIdentifierBlocks; break; case IPrecursorBody AsPrecursor: Documentation = AsPrecursor.Documentation; RequireBlocks = AsPrecursor.RequireBlocks; EnsureBlocks = AsPrecursor.EnsureBlocks; ExceptionIdentifierBlocks = AsPrecursor.ExceptionIdentifierBlocks; AncestorType = AsPrecursor.AncestorType; break; } } // If the list is full, no need to add more nodes to the cycle. if (BodyTypeList.Count > 0) { Type NodeType = BodyTypeList[0]; INode NewBody = NodeHelper.CreateInitializedBody(NodeType, Documentation, RequireBlocks, EnsureBlocks, ExceptionIdentifierBlocks, EntityDeclarationBlocks, BodyInstructionBlocks, ExceptionHandlerBlocks, AncestorType); IFocusBrowsingInsertableIndex InsertableNodeIndex = NodeIndex as IFocusBrowsingInsertableIndex; Debug.Assert(InsertableNodeIndex != null); IFocusInsertionChildNodeIndex InsertionIndex = InsertableNodeIndex.ToInsertionIndex(ParentNode, NewBody) as IFocusInsertionChildNodeIndex; Debug.Assert(InsertionIndex != null); CycleIndexList.Add(InsertionIndex); } }
IFocusNodeState IReadOnlyDictionary <IFocusIndex, IFocusNodeState> .this[IFocusIndex key] { get { return(this[(ILayoutIndex)key]); } }
bool IFocusIndexNodeStateReadOnlyDictionary.ContainsKey(IFocusIndex key) { return(ContainsKey((ILayoutIndex)key)); }