private void Run() { #if !DEBUG Program.AllocConsole(); Console.Title = "Graphic Canvas - Interactive"; #endif Console.WriteLine("# GRAPHIC CANVAS INTERACTIVE #\nEnter any command in this command line and press enter.\n"); Thread consoleThread = new Thread(new ThreadStart(ConsoleWorker)); consoleThread.Start(); window.Run(1.0 / 60.0); consoleThread.Abort(); Program.FreeConsole(); window.Dispose(); canvas.Dispose(); runtime.Dispose(); }
public PlainViewer(string sourceFile, string title) { canvas = new Canvas(512, 512); window = new CanvasWindow(canvas, title); runtime = new Runtime(window, canvas, 99); vm = new VirtualMachine(); if (File.Exists(sourceFile)) { source = File.ReadAllText(sourceFile); } else { Program.MessageBox(IntPtr.Zero, "The given source code file(" + sourceFile + " could not be found.", "Error!", 0); return; } window.Load += OnLoad; window.Run(1 / 60.0); window.Dispose(); canvas.Dispose(); runtime.Dispose(); }
public void Dispose() { if (IsDisposed) { return; } #region unregistor events _gestureParser.IntentRecognized -= WhenIntentRecognized; _gestureParser.IntentInvalid -= WhenIntentInvalid; _gestureParser.IntentExecuted -= WhenIntentExecuted; _gestureParser.IntentOrPathCanceled -= WhenIntentOrPathCanceled; _gestureParser.PathTracker.PathStart -= WhenPathStart; _gestureParser.PathTracker.PathGrow -= WhenPathGrow; _gestureParser.PathTracker.PathTimeout -= WhenPathTimeout; _gestureParser.IntentReadyToExecute -= WhenIntentReadyToExecute; _gestureParser.IntentReadyToExecuteOnModifier -= WhenIntentReadyToExecuteOnModifier; _gestureParser.GestureCaptured -= WhenGestureCaptured; #endregion #region dispose pens _mainPen.Dispose(); _middleBtnPen.Dispose(); _borderPen.Dispose(); _alternativePen.Dispose(); _shadowPen.Dispose(); #endregion if (_bitmap != null) { _bitmap.Dispose(); _bitmap = null; } if (_canvasWindow != null) { _canvasWindow.Dispose(); _canvasWindow = null; } if (_gPath != null) { _gPath.Dispose(); _gPath = null; } if (_pathDirtyRegion != null) { _pathDirtyRegion.Dispose(); _pathDirtyRegion = null; } if (_labelPath != null) { _labelPath.Dispose(); _labelPath = null; } if (_labelFont != null) { _labelFont.Dispose(); _labelFont = null; } if (_fadeOuTimer != null) { _fadeOuTimer.Elapsed -= OnFadeOutTimerElapsed; _fadeOuTimer.Dispose(); _fadeOuTimer = null; } SystemEvents.DisplaySettingsChanged -= SystemDisplaySettingsChanged; Debug.WriteLine("Dispose"); IsDisposed = true; }
public void Dispose() { if (IsDisposed) { return; } #region unregistor events _gestureParser.IntentRecognized -= HandleIntentRecognized; _gestureParser.IntentInvalid -= HandleIntentInvalid; _gestureParser.IntentOrPathCanceled -= HandleIntentOrPathCanceled; _gestureParser.PathTracker.PathStart -= HandlePathStart; _gestureParser.PathTracker.PathGrow -= HandlePathGrow; _gestureParser.PathTracker.PathTimeout -= HandlePathTimeout; _gestureParser.IntentReadyToExecute -= HandleIntentReadyToExecute; _gestureParser.IntentReadyToExecuteOnModifier -= HandleIntentReadyToExecuteOnModifier; _gestureParser.GestureCaptured -= HandleGestureRecorded; _gestureParser.CommandReportStatus -= HandleCommandReportStatus; #endregion #region dispose pens _mainPen.Dispose(); _middleBtnPen.Dispose(); _borderPen.Dispose(); _alternativePen.Dispose(); foreach (var p in _shadowPens) { p.Dispose(); } _shadowPens = null; _dirtyMarkerPen.Dispose(); #endregion if (_canvasBuf != null) { _canvasBuf.Dispose(); _canvasBuf = null; } if (_canvasWindow != null) { _canvasWindow.Dispose(); _canvasWindow = null; } if (_gPath != null) { _gPath.Dispose(); _gPath = null; } if (_gPathDirty != null) { _gPathDirty.Dispose(); _gPathDirty = null; } if (_labelPath != null) { _labelPath.Dispose(); _labelPath = null; } if (_labelFont != null) { _labelFont.Dispose(); _labelFont = null; } if (_fadeOuTimer != null) { _fadeOuTimer.Elapsed -= OnFadeOutTimerElapsed; _fadeOuTimer.Dispose(); _fadeOuTimer = null; } SystemEvents.DisplaySettingsChanged -= SystemDisplaySettingsChanged; Debug.WriteLine("Dispose"); IsDisposed = true; }