public MainWindow() { InitializeComponent(); renderer = new Renderer(320, 240); renderTargetSource = new WriteableBitmap(320, 240, 96, 96, PixelFormats.Rgb24, null); this.RenderTarget.Source = renderTargetSource; this.updateTimer = new Timer(1.0 / 30.0); this.updateTimer.Elapsed += updateTimer_Elapsed; this.updateTimer.Start(); }
public Field(Canvas canvas, int cols, int rows, int yOffset = 0, int wallThickness = 0, int dispWallThickness = 0) { this.canvas = canvas; this.COLS = cols; this.ROWS = rows; this.yOffset = yOffset; this.wallThickness = wallThickness; cells = new PcColor[COLS + wallThickness * 2, yOffset + ROWS + wallThickness]; if (0 < wallThickness) { setWalls(); } this.renderer = new Renderer(this, dispWallThickness); isDelibleRow = new bool[yOffset + ROWS]; }
void quietInterval_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (SourceArea == null || DrawArea == null) { return; } quietInterval.Stop(); // here is where we could generate the diagram... String txt = ""; Application.Current.Dispatcher.Invoke(() => { txt = SourceArea.Text; }); // here's where we would produce the diagram... // now invoke the WPF thread to draw it... var diagram = Parser.Parse(new Tokenizer(txt)); var renderer = new Renderer(DrawArea, diagram); Application.Current.Dispatcher.Invoke(() => { renderer.Draw(); SrcErrorState = diagram.HasErrors; }); }
public void OnInsertionCompleted() { // anchors must be created in OnInsertionCompleted because they should move only // due to user insertions, not due to insertions of other snippet parts start = context.Document.CreateAnchor(startOffset); start.MovementType = AnchorMovementType.BeforeInsertion; end = context.Document.CreateAnchor(endOffset); end.MovementType = AnchorMovementType.AfterInsertion; start.Deleted += AnchorDeleted; end.Deleted += AnchorDeleted; // Be careful with references from the document to the editing/snippet layer - use weak events // to prevent memory leaks when the text area control gets dropped from the UI while the snippet is active. // The InsertionContext will keep us alive as long as the snippet is in interactive mode. TextDocumentWeakEventManager.TextChanged.AddListener(context.Document, this); background = new Renderer { Layer = KnownLayer.Background, element = this }; foreground = new Renderer { Layer = KnownLayer.Text, element = this }; context.TextArea.TextView.BackgroundRenderers.Add(background); context.TextArea.TextView.BackgroundRenderers.Add(foreground); context.TextArea.Caret.PositionChanged += Caret_PositionChanged; Caret_PositionChanged(null, null); this.Text = GetText(); }
public MainWindow() { InitializeComponent(); _vm = (Renderer)DataContext; }