Beispiel #1
0
        public void SetSurfaceAtPoint(DockySurface surface, Gdk.Point point)
        {
            if (surface == currentSurface && point == currentPoint)
            {
                window.QueueDraw();
                return;
            }

            ResetBackgroundBuffer();
            currentSurface = surface;
            currentPoint   = point;

            if (surface == null)
            {
                Hide();
                return;
            }

            window.SetSizeRequest(surface.Width, surface.Height);

            Gdk.Point center  = Gdk.Point.Zero;
            int       padding = 5;

            switch (Gravity)
            {
            case DockPosition.Top:
                center = new Gdk.Point(point.X - surface.Width / 2, point.Y + padding);
                break;

            case DockPosition.Left:
                center = new Gdk.Point(point.X + padding, point.Y - surface.Height / 2);
                break;

            case DockPosition.Right:
                center = new Gdk.Point(point.X - surface.Width - padding, point.Y - surface.Height / 2);
                break;

            case DockPosition.Bottom:
                center = new Gdk.Point(point.X - surface.Width / 2, point.Y - surface.Height - padding);
                break;
            }

            Gdk.Rectangle monitor_geo = window.Screen.GetMonitorGeometry(Monitor);
            center.X = Math.Max(monitor_geo.X, Math.Min(center.X, monitor_geo.X + monitor_geo.Width - surface.Width));
            center.Y = Math.Max(monitor_geo.Y, Math.Min(center.Y, monitor_geo.Y + monitor_geo.Height - surface.Height));

            if (Visible)
            {
                window.QueueDraw();
            }
            window.Move(center.X, center.Y);
        }
Beispiel #2
0
        public void Dispose()
        {
            if (window == null)
            {
                return;
            }

            DestroyCursors();
            ResetCursor();

            window.MotionNotifyEvent  -= OnMotionNotifyEvent;
            window.EnterNotifyEvent   -= OnEnterNotifyEvent;
            window.LeaveNotifyEvent   -= OnLeaveNotifyEvent;
            window.ButtonPressEvent   -= OnButtonPressEvent;
            window.ButtonReleaseEvent -= OnButtonReleaseEvent;
            window.SizeAllocated      -= OnSizeAllocated;

            window.Decorated = true;
            window.QueueDraw();
            window = null;
        }
Beispiel #3
0
 static bool update_handler()
 {
     if (started)
     {
         seconds = seconds + 1.0;
         update_physics(1.0);
         Console.WriteLine("{0}: velocity {1}, accel {2}, height {3}, fuel {4}, engine on {5}",
                           seconds, velocity, accel, height, fuel, rocket_on);
     }
     w.QueueDraw();   // post a draw event which is processed by the Expose_Event handler below
     return(true);
 }
Beispiel #4
0
    /*
     *  update_handler - returns true to indicate it needs to be called again.
     *                   This function is automatically called by the event
     *                   subsystem every 1/10th of a second.  We check to
     *                   see if the second has changed and if so we redraw
     *                   the clock by queuing a draw event.
     */

    private static bool update_handler()
    {
        Console.WriteLine("update!");

        if (going_right && gun_xvalue < 1.0)
        {
            gun_xvalue += 0.1;
        }
        if (going_left && gun_xvalue > 0.0)
        {
            gun_xvalue -= 0.1;
        }

        win.QueueDraw();
        return(true);
    }
Beispiel #5
0
        public void Run()
        {
            var poof_file = DockServices.Paths.SystemDataFolder.GetChild("poof.png");

            if (!poof_file.Exists)
            {
                return;
            }

            poof = new Pixbuf(poof_file.Path);

            window = new Gtk.Window(Gtk.WindowType.Toplevel);
            window.AppPaintable = true;
            window.Resizable    = false;
            window.KeepAbove    = true;
            window.CanFocus     = false;
            window.TypeHint     = WindowTypeHint.Splashscreen;
            window.SetCompositeColormap();

            window.Realized += delegate { window.GdkWindow.SetBackPixmap(null, false); };

            window.SetSizeRequest(size, size);
            window.ExposeEvent += HandleExposeEvent;

            GLib.Timeout.Add(30, delegate {
                if (AnimationState == 1)
                {
                    window.Hide();
                    window.Destroy();
                    poof.Dispose();
                    return(false);
                }
                else
                {
                    window.QueueDraw();
                    return(true);
                }
            });

            window.Move(x, y);
            window.ShowAll();
            run_time = DateTime.UtcNow;
        }
Beispiel #6
0
		public void Run ()
		{
			var poof_file = DockServices.Paths.SystemDataFolder.GetChild ("poof.png");
			if (!poof_file.Exists)
				return;
			
			poof = new Pixbuf (poof_file.Path);
			
			window = new Gtk.Window (Gtk.WindowType.Toplevel);
			window.AppPaintable = true;
			window.Resizable = false;
			window.KeepAbove = true;
			window.CanFocus = false;
			window.TypeHint = WindowTypeHint.Splashscreen;
			window.SetCompositeColormap ();
			
			window.Realized += delegate { window.GdkWindow.SetBackPixmap (null, false); };
			
			window.SetSizeRequest (size, size);
			window.ExposeEvent += HandleExposeEvent;
			
			GLib.Timeout.Add (30, delegate {
				if (AnimationState == 1) {
					window.Hide ();
					window.Destroy ();
					poof.Dispose ();
					return false;
				} else {
					window.QueueDraw ();
					return true;
				}
			});
			
			window.Move (x, y);
			window.ShowAll ();
			run_time = DateTime.UtcNow; 
		}
Beispiel #7
0
        /// <summary>
        /// shows both left and right camera images within the GUI
        /// </summary>
        /// <param name="left_image">left image bitmap</param>
        /// <param name="right_image">right image bitmap</param>
        protected override void DisplayImages(Bitmap left_image, Bitmap right_image)
        {
            usage.Update("Display Images, SurveyorVisionStereoGtk, DisplayImages");
            if (display_image[0] != null)
            {
                if ((show_left_image) &&
                    (calibration_pattern != null))
                {
                    try
                    {
                        GtkBitmap.setBitmap(calibration_pattern, display_image[0], ref buffer);
                    }
                    catch
                    {
                    }

                    if (calibration_survey != null)
                    {
                        CalibrationSurvey survey = calibration_survey[1];
                        if (survey != null)
                        {
                            if ((survey.minimum_rms_error < 3) &&
                                ((prev_minimum_rms_error >= 3) || (prev_minimum_rms_error == 0)))
                            {
                                PlaySound("beep.wav");
                            }
                            prev_minimum_rms_error = survey.minimum_rms_error;
                        }
                    }
                }
                else
                {
                    DisplayImage(display_image[0], left_image, true);
                }
            }

            if (display_image[1] != null)
            {
                if ((!show_left_image) &&
                    (calibration_pattern != null))
                {
                    try
                    {
                        GtkBitmap.setBitmap(calibration_pattern, display_image[1], ref buffer);
                    }
                    catch
                    {
                    }

                    if (calibration_survey != null)
                    {
                        CalibrationSurvey survey = calibration_survey[0];
                        if (survey != null)
                        {
                            if ((survey.minimum_rms_error < 3) &&
                                ((prev_minimum_rms_error >= 3) || (prev_minimum_rms_error == 0)))
                            {
                                PlaySound("beep.wav");
                            }
                            prev_minimum_rms_error = survey.minimum_rms_error;
                        }
                    }
                }
                else
                {
                    DisplayImage(display_image[1], right_image, false);
                }
            }

            if (window != null)
            {
                if (!IsWindows())
                {
                    // Here we need to update the GUI after receiving the right camera image
                    // Since we're running in a separate thread from the GUI we have to
                    // call it in a special way
                    RunOnMainThread.Run(this, "UpdateGUI", new object[] { window, calibration_window });

                    Gdk.Threads.Enter();
                    window.QueueDraw();
                    Gdk.Threads.Leave();
                }
            }
        }
Beispiel #8
0
        public CoverArtPanel(AudioPlayer audioPlayer, params ITrackSelector[] trackSelectors)
            : base(false, 0)
        {
            ButtonBox buttonBox = new HButtonBox();
            _selectedButton = new ToggleButton("Selected");
            _playingButton = new ToggleButton("Playing");
            buttonBox.Add(_playingButton);
            buttonBox.Add(_selectedButton);
            PackStart(buttonBox, false, false, 0);

            EventBox eventBox = new EventBox();
            eventBox.Add(_picture);
            eventBox.ButtonPressEvent += (o, args) =>
                {
                    var window = new Gtk.Window(WindowType.Toplevel);
                    var pixbuf = _currentPixbuf.Copy();
                    AutoScalingImage image = new AutoScalingImage();
                    window.Add(image);
                    int left, top, right, bottom;
                    window.GetFrameDimensions(out left, out top, out right, out bottom);
                    int windowHeightWithFullImage = pixbuf.Height + top + bottom;
                    if (windowHeightWithFullImage > Screen.Height)
                        window.SetDefaultSize(((pixbuf.Width + left + right) * Screen.Height) / windowHeightWithFullImage, Screen.Height);
                    else
                        window.SetDefaultSize(pixbuf.Width + left + right, pixbuf.Height + top + bottom);
                    window.AllowShrink = true;
                    image.Pixbuf = pixbuf;

                    Track track = _selectedButton.Active ? _selectedTrack : _playingTrack;
                    window.Title = String.Format("{0} - {1}",
                        string.Join("; ", track.Album.Artists.Select(a => a.Name)),
                        track.Album.Title);
                    window.ShowAll();
                    image.QueueResize();

                    window.SizeAllocated += (o1, allocatedArgs) =>
                        {
                            Console.WriteLine("window: {0}", window.Allocation);
                            Console.WriteLine("args: {0}", allocatedArgs.Allocation);
                            if (window.Allocation.Width != allocatedArgs.Allocation.Width ||
                                window.Allocation.Height != allocatedArgs.Allocation.Height)
                            {
                                image.SizeAllocate(allocatedArgs.Allocation);
                                image.QueueResize();
                                image.QueueDraw();
                                window.QueueDraw();
                            }
                        };
                };

            PackStart(eventBox, true, true, 0);

            _selectedButton.Toggled += SelectedButtonOnToggled;
            _playingButton.Toggled += PlayingButtonOnToggled;

            foreach (var trackSelector in trackSelectors)
            {
                if (trackSelector.HasFocus)
                    _selectedTrack = trackSelector.CurrentTrack;
                trackSelector.SelectedTrack += TrackSelectorOnSelectedTrack;
            }

            audioPlayer.TrackChanged += AudioPlayerOnTrackChanged;

            _selectedButton.Shown += (sender, args) => _selectedButton.Active = true;

            ShowAll();
        }