private void ProcessTabKey(bool shift) { Point newFocusedCell = VisualItems.FocusedCell; if (shift) { if (newFocusedCell.X == 0 && newFocusedCell.Y > 0) { newFocusedCell.X = CellsArea.ColumnCount - 1; newFocusedCell.Y -= 1; } else if (newFocusedCell.X > 0) { newFocusedCell.X -= 1; } } else if (newFocusedCell.X == CellsArea.ColumnCount - 1 && newFocusedCell.Y < CellsArea.RowCount - 1) { newFocusedCell.X = 0; newFocusedCell.Y += 1; } else if (newFocusedCell.X < CellsArea.ColumnCount - 1) { newFocusedCell.X += 1; } VisualItems.StartSelection(true); VisualItems.FocusedCell = newFocusedCell; }
public void PositionCaret(OneRowCol CaretRowCol) { // position the caret cursor. VisualItemCursor ic = null; if (CaretRowCol != null) { var rowCol = CaretRowCol.ToZeroRowCol(); this.CaretCursor = VisualItems.FindVisualItemCanvas(rowCol); } else { // find the first field on the screen. ic = VisualItems.InputItemList().FirstOrDefault(); this.CaretCursor = new CanvasPositionCursor(ic); } // by default. place the caret at first input field on screen. if (this.CaretCursor.RowCol == null) { var rowCol = new ZeroRowCol(0, 0); this.CaretCursor = VisualItems.FindVisualItemCanvas(rowCol); } // position the caret cursor at the visual item. this.CanvasCaret.StartBlink(this.CaretCursor, true); }
private void InvokeBuildMap() { var nodes = _dataAccessService.GetGraphNodes(); GeoPositionToScreenPosition(nodes); var edges = nodes.SelectMany(node => node.Edges).ToList(); nodes.ForEach(n => VisualItems.Add(n)); edges.ForEach(e => VisualItems.Add(e)); IsItemsLoaded = true; }
/// <summary> /// create visual items from the show items and place those visual items on the /// canvase. /// </summary> /// <param name="ShowItemList"></param> private void PaintScreen_Actual(List <ShowItemBase> ShowItemList) { foreach (IVisualItem iShowItem in ShowItemList) { // a literal value. look first for any fields on the screen which the // literal is applied to. if (iShowItem is ShowLiteralItem) { var findNode = VisualItems.FindFieldItem(iShowItem); if (findNode != null) { // replace textbock segment with the spanner. var visualItem = findNode.Value as IVisualItem; if (visualItem is VisualTextBlockSegment) { var seg = visualItem as VisualTextBlockSegment; visualItem = seg.Parent; } var vim = visualItem as IVisualItemMore; // pos within the canvas item at which to place literal text. int bx = iShowItem.ShowRowCol( ).ColNum - visualItem.ShowRowCol().ColNum; // apply the literal text. vim.ApplyText(iShowItem.ShowText, bx); visualItem.TailAttrByte = iShowItem.TailAttrByte; continue; } } { var visualItem = VisualItemFactory(iShowItem); visualItem.CreateFromItem = (ShowItemBase)iShowItem; var iMore = visualItem as IVisualItemMore; var node = iMore.InsertIntoVisualItemsList(this.VisualItems); // var node = InsertIntoVisualItemsList(visualItem as IVisualItem); (visualItem as IVisualItemMore).AddToCanvas(this); if (iShowItem is ShowFieldItem) { var fieldItem = iShowItem as ShowFieldItem; iMore.SetupFieldItem( fieldItem, this.CanvasDefn.CharBoxDim, this.CanvasDefn.KernDim); iMore.CreateFromItem = fieldItem; } } } }
private void Canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var pos = e.GetPosition(this.Canvas); var loc = pos.CanvasPosToScreenLoc(this.CharDim); var canvasCursor = VisualItems.FindVisualItem(loc); if (canvasCursor.VisualCursor != null) { this.CaretCursor = canvasCursor; this.CanvasCaret.StartBlink(this.CaretCursor); e.Handled = true; } }
private void Canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var pos = e.GetPosition((IInputElement)this.Canvas); var rowCol = pos.CanvasPosToRowCol(this.CanvasDefn.CharBoxDim, this.ContentStart); // rowCol = this.AdjustShowRowCol.LocalPosToParentPos(rowCol); if (this.DoHandleUserInput == true) { this.CaretCursor = VisualItems.FindVisualItemCanvas(rowCol); this.CanvasCaret.StartBlink(this.CaretCursor); this.Canvas.Focus(); } }
public override void PaintScreen(List <ShowItemBase> ShowItemList) { this.ShowItemList = ShowItemList; base.PaintScreen(ShowItemList); // find the first field on the screen. var cursor = VisualItems.FirstInputItem(); if (cursor != null) { this.CaretCursor = new ItemCanvasCursor(cursor); var item = cursor.GetVisualItem(); CanvasCaret.StartBlink(item, item.StrLoc, "_"); } }
/// <summary> /// Provides derived classes an opportunity to handle changes to the ItemsSource property. /// </summary> protected virtual void OnItemsSourceChanged(DependencyPropertyChangedEventArgs e) { var oldItems = e.OldValue as IEnumerable; var newItems = e.NewValue as IEnumerable; if (newItems != null) { if (newItems is INotifyCollectionChanged) { var newObservableItems = newItems as INotifyCollectionChanged; newObservableItems.CollectionChanged += new NotifyCollectionChangedEventHandler(ObservableItems_CollectionChanged); var eventArgs = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, newItems.Cast <object>().ToList()); ObservableItems_CollectionChanged(this, eventArgs); } } if (oldItems != null) { if (oldItems is INotifyCollectionChanged) { var oldObservableItems = oldItems as INotifyCollectionChanged; oldObservableItems.CollectionChanged -= new NotifyCollectionChangedEventHandler(ObservableItems_CollectionChanged); } foreach (var item in oldItems) { var visualItem = (from oldItem in VisualItems where oldItem.DataContext == item select oldItem).FirstOrDefault(); visualItem.LayoutStateChangeCompleted += new EventHandler <LayoutStateChangeEventArgs>(visualItem_LayoutStateChangeCompleted); visualItem.LayoutState = LayoutState.Unloaded; VisualItems.Remove(visualItem); } } }
public void RepaintScreen() { // first, remove from canvas. foreach (var cursor in VisualItems.ItemList()) { var visualItem = cursor.GetVisualItem(); var iMore = visualItem as IVisualItemMore; if (iMore != null) { iMore.RemoveFromCanvas(this); } } // loop adding the draw controls of the visual items back onto the canvas. foreach (var cursor in VisualItems.ItemList()) { var visualItem = cursor.GetVisualItem(); // set the font of the textBlock. if (visualItem is VisualTextBlock) { var iTextBlock = visualItem as VisualTextBlock; iTextBlock.SetPaintDefn(this.CanvasDefn.CharBoxDim, this.CanvasDefn.KernDim, this.CanvasDefn.FontDefn); if (iTextBlock.ShowItem != null) { iTextBlock.SetupFieldItem( iTextBlock.ShowItem, this.CanvasDefn.CharBoxDim, this.CanvasDefn.KernDim); } var iMore = visualItem as IVisualItemMore; iMore.AddToCanvas(this); } } this.CanvasCaret.RefreshCaret(); }
private void PaintScreen_ApplyTextDataOrder(TextDataOrder tdo, IRowCol curRowCol) { var showText = tdo.ShowText; var showRowCol = tdo.ShowRowCol(curRowCol); var itemEndRowCol = tdo.ItemEndRowCol(showRowCol); var itemRange = new RowColRange(curRowCol, itemEndRowCol); IVisualItem ivi = null; // range if visual items which overlap this tdo. var overlapItems = VisualItems.GetOverlapItems(itemRange); if (overlapItems != null) { foreach (var cursor in overlapItems) { var item = cursor.GetVisualItem(); var itemRowCol = item.ItemRowCol; var tailAttrByte = tdo.TailAttrByte; if ((tdo.TailAttrByte != null) && (item.AttrByte != null) && (tdo.ItemEndRowCol(curRowCol).CompareTo(item.ItemRowCol) == 0)) { int xx = 4; } } } else { } if (itemEndRowCol != null) { ivi = VisualItems.FindFieldItem(curRowCol, showRowCol, itemEndRowCol); } if (ivi != null) { // replace textbock segment with the spanner. if (ivi is VisualTextBlockSegment) { var seg = ivi as VisualTextBlockSegment; ivi = seg.Parent; } var vim = ivi as IVisualItemMore; // pos within the canvas item at which to place literal text. int bx = showRowCol.ColNum - ivi.ShowRowCol().ColNum; // apply the literal text. vim.ApplyText(showText, bx); if (tdo.TailAttrByte != null) { ivi.TailAttrByte = tdo.TailAttrByte; } } else if (itemEndRowCol != null) { var visualItem = VisualItemFactory( tdo.ShowText, (ZeroRowCol)curRowCol, tdo.AttrByte, tdo.TailAttrByte); visualItem.FromOrder = tdo; var iMore = visualItem as IVisualItemMore; var node = iMore.InsertIntoVisualItemsList(this.VisualItems); iMore.AddToCanvas(this); } }