/// <summary>Show the window.</summary> public void Run(uint time) { if (this.first_time || this.entry.Text.Length > 0) { this.window.GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Watch); this.window.GdkWindow.Display.Flush(); this.ignore_change = true; this.entry.Text = String.Empty; this.ignore_change = false; GLib.IdleHandler func = new GLib.IdleHandler(ResetFunc); GLib.Idle.Add(func); this.first_time = false; } else { this.list.SelectFirst(); } this.entry.GrabFocus(); this.window.Show(); this.window.GdkWindow.Focus(time); }
public void DrawAllTiles() { tileUpdaterIndex = 0; tileUpdaterRedraw = false; GLib.IdleHandler handler = new GLib.IdleHandler(TileUpdater); GLib.Idle.Add(handler); }
public void GenerateImage() { if (_map == null) { _image = null; return; } idleX = 0; idleY = 0; Func <bool> OnIdleGenerateImage = () => { int x = idleX; int y = idleY; if (idleY >= _map.MapHeight) { return(false); } int roomWidth = (int)(_map.RoomWidth * 16 * scale); int roomHeight = (int)(_map.RoomHeight * 16 * scale); const System.Drawing.Drawing2D.InterpolationMode interpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; Graphics g = Graphics.FromImage(_image); g.InterpolationMode = interpolationMode; Image img = GenerateTileImage(x, y); g.DrawImage(img, (int)(x * roomWidth), (int)(y * roomHeight), (int)(roomWidth), (int)(roomHeight)); g.Dispose(); QueueDrawArea(x * roomWidth, y * roomHeight, roomWidth, roomHeight); idleX++; if (idleX >= _map.MapWidth) { idleY++; idleX = 0; } return(true); }; int width = (int)(_map.RoomWidth * _map.MapWidth * 16 * scale); int height = (int)(_map.RoomHeight * _map.MapHeight * 16 * scale); _image = new Bitmap(width, height); SetSizeRequest(width, height); idleX = 0; idleY = 0; var handler = new GLib.IdleHandler(OnIdleGenerateImage); GLib.Idle.Remove(handler); GLib.Idle.Add(handler); }
/// <summary> /// Process video, the worker thread /// </summary> private void ProcessVideo() { using (Video video = new Video()){ try{ video.Open(this.currentDevice); video.Enabled = true; using (ImageScanner scanner = new ImageScanner()){ scanner.Cache = true; this.CaptureVideo(video, scanner); } video.Enabled = false; } catch (ZBarException ex) { lock (this.drawLock){ this.toDraw = null; this.symbols = null; } GLib.IdleHandler hdl = delegate(){ if (this.Stopped != null) { this.Stopped(this, new EventArgs()); } if (this.Error != null) { this.Error(this, new ErrorEventArgs(ex.Message, ex)); } this.QueueDraw(); return(false); }; GLib.Idle.Add(hdl); } } }
// Constructor /// <summary> /// Create a new <see cref="IdleData" /> object. /// </summary> public IdleData(Album album, Pixbuf pixbuf) { this.album = album; this.pixbuf = pixbuf; GLib.IdleHandler idle = new GLib.IdleHandler(IdleFunc); GLib.Idle.Add(idle); }
// RENAMEME: It is linguistically awkward that we pass in // "handlers", and get back "handles". static public Handle Add(GLib.IdleHandler idle_handler) { Closure c; c = new Closure(idle_handler); c.Id = GLib.Idle.Add(new GLib.IdleHandler(c.Handler)); return(c); }
/// <summary> /// Simple threadsafe redraw method /// </summary> private void ThreadSafeRedraw() { GLib.IdleHandler hdl = delegate(){ this.QueueDraw(); return(false); }; GLib.Idle.Add(hdl); }
/// <summary>Display the new results.</summary> private void Reset() { Search(); // We want to get the normal cursor back *after* treeview // has done its thing. GLib.IdleHandler func = new GLib.IdleHandler(RestoreCursorFunc); GLib.Idle.Add(func); }
// Constructor public ThreadBase() { queue = Queue.Synchronized(new Queue()); GLib.IdleHandler idle = new GLib.IdleHandler(MainLoopIdle); GLib.Idle.Add(idle); thread = new Thread(new ThreadStart(ThreadFunc)); thread.IsBackground = true; thread.Priority = ThreadPriority.BelowNormal; }
static DispatchService() { guiContext = new GuiSyncContext(); guiThread = Thread.CurrentThread; handler = new GLib.IdleHandler(guiDispatcher); arrBackgroundQueue = new ArrayList(); arrGuiQueue = new ArrayList(); thrBackground = new Thread(new ThreadStart(backgroundDispatcher)); thrBackground.IsBackground = true; thrBackground.Priority = ThreadPriority.Lowest; thrBackground.Start(); DispatchDebug = Environment.GetEnvironmentVariable("MONODEVELOP_DISPATCH_DEBUG") != null; }
static DispatchService() { guiContext = new GuiSyncContext (); guiThread = Thread.CurrentThread; handler = new GLib.IdleHandler (guiDispatcher); arrBackgroundQueue = new ArrayList (); arrGuiQueue = new ArrayList (); thrBackground = new Thread (new ThreadStart (backgroundDispatcher)); thrBackground.IsBackground = true; thrBackground.Priority = ThreadPriority.Lowest; thrBackground.Start (); DispatchDebug = Environment.GetEnvironmentVariable ("MONODEVELOP_DISPATCH_DEBUG") != null; }
public Abuse (DirectoryObject root, EventTracker tracker, ICollection hammers) { this.root = root; this.tracker = tracker; this.hammers = new IHammer [hammers.Count]; int i = 0; foreach (IHammer hammer in hammers) this.hammers [i++] = hammer; idle_handler = new GLib.IdleHandler (AbuseWorker); timeout_handler = new GLib.TimeoutHandler (RescheduleAbuse); verified_handler = new Daemon.VerifiedHandler (VerifiedWorker); }
public Abuse(DirectoryObject root, EventTracker tracker, ICollection hammers) { this.root = root; this.tracker = tracker; this.hammers = new IHammer [hammers.Count]; int i = 0; foreach (IHammer hammer in hammers) { this.hammers [i++] = hammer; } idle_handler = new GLib.IdleHandler(AbuseWorker); timeout_handler = new GLib.TimeoutHandler(RescheduleAbuse); verified_handler = new Daemon.VerifiedHandler(VerifiedWorker); }
public void ScheduleRefresh(uint time) { lock (this) { if (timeoutId != 0) { return; } if (time == 0) { GLib.IdleHandler handler; handler = new GLib.IdleHandler(HandleScheduled); timeoutId = GLib.Idle.Add(handler); } else { GLib.TimeoutHandler handler; handler = new GLib.TimeoutHandler(HandleScheduled); timeoutId = GLib.Timeout.Add(time, handler); } } }
// Delegate Functions // Delegate Functions :: ThreadFunc /// <summary> /// Downloads the cover and sets it in the database. /// </summary> /// <remarks> /// This is the main method of the thread. /// </remarks> private void ThreadFunc() { try { pixbuf = getter.Download(url); pixbuf = getter.AddBorder(pixbuf); } catch { } // Check if cover has been modified while we were downloading if (Global.CoverDB.Covers [key] != null) { return; } if (pixbuf != null) { Global.CoverDB.SetCover(key, pixbuf); } // Also do this if it is null, as we need to remove the // downloading image GLib.IdleHandler idle = new GLib.IdleHandler(SignalIdle); GLib.Idle.Add(idle); }
public Delay(GLib.IdleHandler op) { this.op += op; this.interval = 0; }
public Delay(uint interval, GLib.IdleHandler op) { this.op += op; this.interval = interval; }
public void ScheduleRefresh (uint time) { lock (this) { if (timeoutId != 0) return; if (time == 0) { GLib.IdleHandler handler; handler = new GLib.IdleHandler (HandleScheduled); timeoutId = GLib.Idle.Add (handler); } else { GLib.TimeoutHandler handler; handler = new GLib.TimeoutHandler (HandleScheduled); timeoutId = GLib.Timeout.Add (time, handler); } } }
public Closure(GLib.IdleHandler idle_handler) { this.idle_handler = idle_handler; ++Count; }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build(); refreshHandler = new GLib.IdleHandler(refreshCameraImage); }
public Delay(GLib.IdleHandler op) { this.op = op; }
public DelayedOperation(GLib.IdleHandler op) { this.op = op; }
public void GenerateImage() { if (_map == null) { _image = null; return; } idleX = 0; idleY = 0; Func<bool> OnIdleGenerateImage = () => { int x = idleX; int y = idleY; if (idleY >= _map.MapHeight) return false; int roomWidth = (int)(_map.RoomWidth*16*scale); int roomHeight = (int)(_map.RoomHeight*16*scale); const System.Drawing.Drawing2D.InterpolationMode interpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; Graphics g = Graphics.FromImage(_image); g.InterpolationMode = interpolationMode; Image img = GenerateTileImage(x,y); g.DrawImage(img, (int)(x*roomWidth), (int)(y*roomHeight), (int)(roomWidth), (int)(roomHeight)); g.Dispose(); QueueDrawArea(x*roomWidth, y*roomHeight, roomWidth, roomHeight); idleX++; if (idleX >= _map.MapWidth) { idleY++; idleX = 0; } return true; }; int width = (int)(_map.RoomWidth*_map.MapWidth*16*scale); int height = (int)(_map.RoomHeight*_map.MapHeight*16*scale); _image = new Bitmap(width,height); SetSizeRequest(width, height); idleX = 0; idleY = 0; var handler = new GLib.IdleHandler(OnIdleGenerateImage); GLib.Idle.Remove(handler); GLib.Idle.Add(handler); }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build (); refreshHandler = new GLib.IdleHandler(refreshCameraImage); }
private void IdleRemove() { if (Idle != null) GLib.Idle.Remove (Idle); Idle = null; }
public Closure (GLib.IdleHandler idle_handler) { this.idle_handler = idle_handler; ++Count; }
public void RedrawAllTiles() { tileUpdaterIndex = 0; tileUpdaterRedraw = true; GLib.IdleHandler handler = new GLib.IdleHandler(TileUpdater); GLib.Idle.Remove(handler); GLib.Idle.Add(handler); }
protected override bool OnExposeEvent(Gdk.EventExpose ev) { Gdk.Window win = ev.Window; Gdk.Rectangle rect = ev.Area; Gdk.GC gc = this.Style.BaseGC(StateType.Normal); lock (this.drawLock){ if (this.toDraw != null) { //Raise events for the symbols... bool gotSymbol = false; //See if there's a new symbol if (this.symbols != null) { foreach (Symbol s in this.symbols) { if (s.Count > 0 && this.data != s.ToString()) { this.data = s.ToString(); //Don't raise it inside the expose event :) GLib.IdleHandler raiser = delegate(){ if (this.BarScanned != null) { this.BarScanned(this, new BarScannedArgs(s)); } return(false); }; GLib.Idle.Add(raiser); gotSymbol = true; } } } //Avoid beeping more than once.. if (gotSymbol) { if (!this.Mute) { System.Media.SystemSounds.Beep.Play(); } if (this.overlayingFrames == 0) { GLib.TimeoutHandler hdl = delegate(){ this.QueueDraw(); this.overlayingFrames -= 1; return(this.overlayingFrames > 0); }; GLib.Timeout.Add(35, hdl); } //Start drawing an overlay this.overlayingFrames = overlayFrameCount; } this.symbols = null; //Symbols have been handled //See if we want to request a resize if (this.reqHeight != this.toDrawHeight || this.reqWidth != this.toDrawWidth) { this.reqHeight = this.toDrawHeight; this.reqWidth = this.toDrawWidth; this.QueueResize(); } //Draw the gray image int w = Math.Min(rect.Size.Width, this.toDrawWidth); int h = Math.Min(rect.Size.Height, this.toDrawHeight); //Draw the image win.DrawGrayImage(gc, 0, 0, w, h, Gdk.RgbDither.Normal, this.toDraw, this.toDrawWidth); if (this.overlayingFrames > 0) { Pixbuf overlay_tmp = overlay; if (this.overlay.Width > w * 0.8 || this.overlay.Height > h * 0.8) { int overlayMaxSize = Math.Min(h * 80 / 100, w * 80 / 100); overlay_tmp = overlay.ScaleSimple(overlayMaxSize, overlayMaxSize, InterpType.Bilinear); } w = Math.Min(this.toDrawWidth, (int)overlay_tmp.Width); h = Math.Min(this.toDrawHeight, (int)overlay_tmp.Height); using (Gdk.Pixbuf pix = new Pixbuf(Colorspace.Rgb, true, 8, w, h)){ pix.Fill(0x00000000); //Fill with invisibility :) overlay_tmp.Composite(pix, 0, 0, w, h, 0, 0, 1, 1, InterpType.Bilinear, 255 / 35 * this.overlayingFrames); win.DrawPixbuf(gc, pix, 0, 0, (this.toDrawWidth - w) / 2, (this.toDrawHeight - h) / 2, w, h, RgbDither.Normal, 0, 0); } } } else { win.DrawRectangle(gc, true, rect); int w = Math.Min(this.toDrawWidth, (int)this.sourceMissing.Width); int h = Math.Min(this.toDrawHeight, (int)this.sourceMissing.Height); Rectangle img = new Rectangle((this.toDrawWidth - w) / 2, (this.toDrawHeight - h) / 2, w, h); Rectangle target = Rectangle.Intersect(img, rect); if (target != Rectangle.Zero) { win.DrawPixbuf(gc, this.sourceMissing, Math.Max(target.X - img.X, 0), Math.Max(target.Y - img.Y, 0), target.X, target.Y, target.Width, target.Height, RgbDither.Normal, 0, 0); } } } return(true); }
public Delay(uint interval, GLib.IdleHandler op) { this.op = op; this.interval = interval; }
public DelayedOperation(uint interval, GLib.IdleHandler op) { this.op = op; this.interval = interval; }
private void IdleAdd() { if (Idle == null) { Idle = new GLib.IdleHandler (OnIdle); GLib.Idle.Add (Idle); } }
internal static GLib.IdleHandler Wrap(GLib.IdleHandler h) { return(delegate { return h(); }); }
public override void InitializeService() { guiContext = new GuiSyncContext (); guiThreadId = AppDomain.GetCurrentThreadId(); handler = new GLib.IdleHandler (guiDispatcher); arrBackgroundQueue = new ArrayList (); arrGuiQueue = new ArrayList (); thrBackground = new Thread (new ThreadStart (backgroundDispatcher)); thrBackground.IsBackground = true; thrBackground.Priority = ThreadPriority.Lowest; thrBackground.Start (); DispatchDebug = Environment.GetEnvironmentVariable ("MONODEVELOP_DISPATCH_DEBUG") != null; }
/// <summary> /// The ReadyEvent delegate will be invoked on the current thread (which should /// be the Gtk thread) when another thread wakes us up by calling WakeupMain /// </summary> public ThreadNotify(ReadyEvent re) { this.re = re; idle = new GLib.IdleHandler(CallbackWrapper); }
/// <summary> /// The ReadyEvent delegate will be invoked on the current thread (which should /// be the Gtk thread) when another thread wakes us up by calling WakeupMain /// </summary> public ThreadNotify (ReadyEvent re) { this.re = re; idle = new GLib.IdleHandler (CallbackWrapper); }