예제 #1
0
        /// <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);
        }
예제 #2
0
파일: Area.cs 프로젝트: turbo3001/LynnaLab
 public void DrawAllTiles()
 {
     tileUpdaterIndex  = 0;
     tileUpdaterRedraw = false;
     GLib.IdleHandler handler = new GLib.IdleHandler(TileUpdater);
     GLib.Idle.Add(handler);
 }
예제 #3
0
        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);
        }
예제 #4
0
 /// <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);
         }
     }
 }
예제 #5
0
                // 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);
                }
예제 #6
0
        // 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);
        }
예제 #7
0
 /// <summary>
 /// Simple threadsafe redraw method
 /// </summary>
 private void ThreadSafeRedraw()
 {
     GLib.IdleHandler hdl = delegate(){
         this.QueueDraw();
         return(false);
     };
     GLib.Idle.Add(hdl);
 }
예제 #8
0
        /// <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);
        }
예제 #9
0
        // 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;
        }
예제 #10
0
        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;
        }
예제 #11
0
        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;
        }
예제 #12
0
		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);
		}
예제 #13
0
        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);
        }
예제 #14
0
        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);
                }
            }
        }
예제 #15
0
            // 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);
            }
예제 #16
0
 public Delay(GLib.IdleHandler op)
 {
     this.op      += op;
     this.interval = 0;
 }
예제 #17
0
 public Delay(uint interval, GLib.IdleHandler op)
 {
     this.op      += op;
     this.interval = interval;
 }
예제 #18
0
		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);
				}
			}
		}
예제 #19
0
 public Closure(GLib.IdleHandler idle_handler)
 {
     this.idle_handler = idle_handler;
     ++Count;
 }
예제 #20
0
 public MainWindow() : base(Gtk.WindowType.Toplevel)
 {
     Build();
     refreshHandler = new GLib.IdleHandler(refreshCameraImage);
 }
예제 #21
0
파일: Delay.cs 프로젝트: iainlane/f-spot
 public Delay(GLib.IdleHandler op)
 {
     this.op = op;
 }
예제 #22
0
 public DelayedOperation(GLib.IdleHandler op)
 {
     this.op = op;
 }
예제 #23
0
파일: Minimap.cs 프로젝트: Drenn1/LynnaLab
        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);
        }
예제 #24
0
 public MainWindow()
     : base(Gtk.WindowType.Toplevel)
 {
     Build ();
     refreshHandler = new GLib.IdleHandler(refreshCameraImage);
 }
예제 #25
0
 private void IdleRemove()
 {
     if (Idle != null)
         GLib.Idle.Remove (Idle);
     Idle = null;
 }
예제 #26
0
			public Closure (GLib.IdleHandler idle_handler)
			{
				this.idle_handler = idle_handler;
				++Count;
			}
예제 #27
0
파일: Area.cs 프로젝트: Drenn1/LynnaLab
 public void RedrawAllTiles()
 {
     tileUpdaterIndex = 0;
     tileUpdaterRedraw = true;
     GLib.IdleHandler handler = new GLib.IdleHandler(TileUpdater);
     GLib.Idle.Remove(handler);
     GLib.Idle.Add(handler);
 }
예제 #28
0
        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);
        }
예제 #29
0
파일: Delay.cs 프로젝트: iainlane/f-spot
 public Delay(uint interval, GLib.IdleHandler op)
 {
     this.op = op;
     this.interval = interval;
 }
예제 #30
0
 public DelayedOperation(uint interval, GLib.IdleHandler op)
 {
     this.op = op;
     this.interval = interval;
 }
예제 #31
0
 private void IdleAdd()
 {
     if (Idle == null) {
         Idle = new GLib.IdleHandler (OnIdle);
         GLib.Idle.Add (Idle);
     }
 }
예제 #32
0
 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;
        }
예제 #34
0
 public DelayedOperation(uint interval, GLib.IdleHandler op)
 {
     this.op       = op;
     this.interval = interval;
 }
예제 #35
0
 /// <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);
 }
예제 #36
0
		/// <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);
		}
예제 #37
0
 public DelayedOperation(GLib.IdleHandler op)
 {
     this.op = op;
 }