internal static bool IsCompletelySelected(GlyphRunViewModel placeholder) { Contract.Requires(placeholder != null); Contract.Requires(placeholder.IsPlaceholder); return placeholder.Box.Selections.Any(selection => selection.Contains(placeholder)); }
/// <summary> Selects the specified placeholder completely. Does not implement selecting from somewhere TO the placeholder. </summary> internal static void SelectCompletely(GlyphRunViewModel placeholder) { Contract.Requires(placeholder != null); Contract.Requires(placeholder.IsPlaceholder); if (IsCompletelySelected(placeholder)) return; //TODO: whenever the caret is to disappear, so is the placeholder selection (probably). Design! //TODO: specifiy what happens if other selections are already present //start selection from end, such that caret ends at start Selection selection = placeholder.Box.Selections.GetCurrentOrCreate(placeholder.Box, 0);//0 due to new Placeholder.CaretPositionCount == 1 //set caret at start placeholder.Box.CaretPerTree.Set(placeholder.Box, new ExplicitIndex((ElementIndex)1)); selection.Add(placeholder.Box.CaretPerTree); }
public MathGlyphRun(GlyphRunViewModel viewModel) { this.DataContext = viewModel; //VIEW5 viewModel.PropertyChanged += OnFontSizeChanged; this.Height = viewModel.FontSize; //VIEW3//VIEW4 viewModel.Glyphs.CollectionChanged += OnGlyphsChanged; OnGlyphsChanged(viewModel.Glyphs, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, viewModel.Glyphs, 0)); viewModel.PropertyChanged += OnIsPlaceholderChanged; //VIEW15 this.Focusable = viewModel.Modifiable; // viewModel.InputBindings.CollectionChanged += OnInputBindingsChanged; OnInputBindingsChanged(viewModel.InputBindings, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, viewModel.InputBindings)); this.MakeSpacebarTriggerTextInput(); TextBehaviour.SetTextInputCommand(this, viewModel.InsertCharacterCommand); }
public KeyInputCommandParameter(GlyphRunViewModel glyphRun) { GlyphRun = glyphRun; }