public virtual void Run() { running = true; var oldsink = Program.MainForm.CurrentSink; try { Program.MainForm.CurrentSink = this; while (running) { Guppy.Wait(true); } } catch { throw; } finally { running = false; Program.MainForm.CurrentSink = oldsink; } }
bool RedrawBackbuffer(Painter frontpainter) { Drawing drw = CurrentDrawing; if (drw == null) //no drawing active, just clear { frontpainter.Clear(RGB.Gray); return(false); } //create backbuffer picture if to small or not existing Size2i siz = drawarea.PhysicalSize; if (backbuffer == null || backbuffer.Width < siz.Width || backbuffer.Height < siz.Height) { if (backbuffer != null) { backbuffer.Dispose(); } backbuffer = Guppy.CreatePicture(siz.Width, siz.Height, PictureMode.Software); } using (Painter backpainter = backbuffer.CreatePainter()) { backpainter.Clear(0); drw.Draw(backpainter); } overlay_needs_background = true; return(true); }
static void Main() { Guppy.Open(); /*Window win = new Window("Test window", WindowStyle.FrameMainWindow); * * canvas = new Canvas(win) {ExpandX=true,ExpandY=true}; * canvas.EvRedraw += canvas_EvRedraw; * canvas.EvMotion += canvas_EvMotion;*/ MainForm = new WinMain(); Guppy.Run(MainForm); }
void ExceptionManager_UnhandledException(GLib.UnhandledExceptionArgs args) { string msg = "Unhandled unknown exception"; Exception exc = args.ExceptionObject as Exception; if (exc != null) { msg = "Outer exception:\n" + exc.Message + "\n"; if (exc.InnerException != null) { msg += "Inner exception:\n" + exc.InnerException.Message + "\n"; } } Guppy.Message("UNHANDLED EXCEPTION", "An unhandled fatal exception occured in the program:\n" + msg); args.ExitApplication = false; }
public static void Main() { Guppy.Open(DriverMode.WinForms); Window mainwin = new Window("Guppy-Pad"); mainwin.Maximize(); toolbar = new TableLayout(mainwin) { Vertical = false, Gap = 0, ExpandY = false }; var btn = AddToolButton("document-new.png", "New"); btn.EvClicked += delegate { editor.Clear(); }; AddToolButton("document-open.png", "Open"); AddToolButton("document-save.png", "Save"); AddToolButton("document-save-as.png", "Save as"); new Separator(toolbar, true); AddToolButton("edit-undo.png", "Undo"); AddToolButton("edit-redo.png", "Redo"); new Button(toolbar, "Test").EvClicked += new GuppyEventHandler(Program_EvClicked); editor = new Memo(mainwin) { ExpandX = true, ExpandY = true }; editor.EvChanged += new GuppyEventHandler(EditorChanged); TableLayout statusbar = new TableLayout(mainwin) { Vertical = false, Margin = new Margin(4) }; statustext = new Label(statusbar, "Statusbar...") { ExpandX = true }; Guppy.Run(mainwin); }
static void Main(string[] args) { Guppy guppy = new Guppy(); Console.WriteLine("============GUPPY============"); Console.WriteLine(guppy.EatsFood()); Console.WriteLine($"Guppies are HUGE fish {guppy.PetFish}"); Console.WriteLine($"Guppies are cold blooded Animals {guppy.ColdBlooded}"); Owl owl = new Owl(); Console.WriteLine("============OWL============"); Console.WriteLine($"Owls have feathers {owl.Feathers}"); Console.WriteLine($"Owls can fly {owl.CanFly()}"); Console.WriteLine($"Owls have wings {owl.Wings}"); Sockeye sockeye = new Sockeye(); Console.WriteLine("============SOCKEYE============"); Console.WriteLine(sockeye.EatsFood()); Console.WriteLine($"Sockeyes lay eggs {sockeye.LaysEggs()}"); Console.WriteLine($"Sockeye are { sockeye.Scaley} "); Chinook chinook = new Chinook(); Console.WriteLine("============CHINOOK============"); Console.WriteLine(chinook.EatsFood()); Console.WriteLine($"Chinook fish can ingest food {chinook.Heterotrophy}"); Console.WriteLine($"Chinook fish have a tail { chinook.HasTail }"); AfricanPenguin africanpenguin = new AfricanPenguin(); Console.WriteLine("============AFRICAN PENGUIN============"); Console.WriteLine($"African Penguin has feathers {africanpenguin.Feathers}"); Console.WriteLine($"African Penguins can't fly {africanpenguin.CanFly()}"); Console.WriteLine($"African Penguin have Wings { africanpenguin.Wings}"); }
public static void Main() { Guppy.Open(DriverMode.WinForms); win = new Window("test") { Vertical = false, Margin = new Margin(10, 10, 10, 10) }; f1 = new Frame(win, "", false); new RadioButton(f1, "Röd"); new RadioButton(f1, "Grön"); new RadioButton(f1, "Gul"); f2 = new Frame(win, "", false); new RadioButton(f2, "Bananer"); new RadioButton(f2, "Äpplen"); new RadioButton(f2, "Appelsiner"); t = new Toggle(win, "Disabled", true); t.EvChanged += new GuppyEventHandler(t_EvChanged); Guppy.Run(win); }
static void Main(string[] args) { Guppy g = new Guppy("Hugo", "Sebi"); Katze k = new Katze("Lili", "David"); Goldfisch go = new Goldfisch("Goldi", "Kariko"); Kaninchen ka = new Kaninchen("Rainer", "Chris"); k.fortbewegen(); ka.streicheln(); go.schwimmen(); g.pflegen(); Fisch[] aquarium = new Fisch[5]; aquarium[0] = go; aquarium[1] = g; aquarium[2] = new Goldfisch("Justus", "Simon"); aquarium[3] = new Goldfisch("Jonas", "Anna"); aquarium[4] = new Guppy("Hannah", "Fabsi"); foreach (Fisch f in aquarium) { f.pflegen(); f.schwimmen(); if (f is Goldfisch) { ((Goldfisch)f).streicheln(); } Goldfisch g3; g3 = f as Goldfisch; if (g3 != null) { g3.streicheln(); } } Saeuger[] garten = new Saeuger[3]; garten[0] = new Katze("Karl", "Alex"); garten[1] = new Kaninchen("Nico", "Carlos"); garten[2] = new Katze("Mize", "Sarah"); foreach (Saeuger s in garten) { s.pflegen(); s.streicheln(); s.fortbewegen(); } Haustier[][] zoo = new Haustier[2][]; zoo[0] = garten; zoo[1] = aquarium; foreach (Haustier[] h in zoo) { foreach (Haustier h2 in h) { h2.pflegen(); } } Console.WriteLine(zoo[0][1]); foreach (Saeuger i in garten) { if (i is Katze) { ((Katze)i).fressen("Hack"); } else { ((Kaninchen)i).fressen("Gras"); } } Hausschwein manni = new Hausschwein("Manni", "Harald"); ((IFleischfresser)manni).fressen(""); }
void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { Guppy.Message("UNHANDLED EXCEPTION", "An unhandled fatal exception occured in the program:" + e.Exception.ToString()); }
public void GuppiesEatFood() { Guppy guppy = new Guppy(); Equals(guppy.EatsFood()); }
public void GuppyIsAnimal() { Guppy guppy = new Guppy(); Assert.True(guppy is Animal); }
void RedrawOverlay() { Drawing drw = CurrentDrawing; if (drw == null || backbuffer == null) { return; //no overlay if no drawing } //Point2i dcs = cursorpixel; Point2d cursor_wcs = CursorWorldPos; //make sure overlay area is as big as backbuffer if (overlay == null || overlay.Width < backbuffer.Width || overlay.Height < backbuffer.Height) { if (overlay != null) { overlay.Dispose(); } overlay = Guppy.CreatePicture(backbuffer.Width, backbuffer.Height, PictureMode.Software); } using (PainterExtentsRecorder exrec = new PainterExtentsRecorder()) //to remember area drawn to { using (Painter overlaypainter = overlay.CreatePainter()) { if (overlay_needs_background) { overlaypainter.Blit(backbuffer, 0, 0, backbuffer.Width, backbuffer.Height, 0, 0, backbuffer.Width, backbuffer.Height); overlay_needs_background = false; } using (PainterAggregate painter = new PainterAggregate(overlaypainter, exrec)) { //let the current sink do its job painter.Transform = CurrentDrawing.ViewTransform; CurrentSink.OnTracking(cursorpixel, cursor_wcs, painter); } Rectangle2i fliprect = Rectangle2i.Empty; //the part of screen to flip Rectangle2i newdirtyrect = fliprect; //the new dirty screen rectangle //compute slightly grown extents of area to show var er = exrec.RecordedExtents; if (!er.Empty) { newdirtyrect = new Rectangle2i((int)(er.XMin - 5), (int)(er.YMin - 5), (int)(er.XMax + 5), (int)(er.YMax + 5)); fliprect = newdirtyrect; } //include old dirty area in flipping rectangle if (!screen_dirty.IsEmpty) { fliprect = fliprect.Append(screen_dirty.XMin, screen_dirty.YMin); fliprect = fliprect.Append(screen_dirty.XMax, screen_dirty.YMax); } //flip if fliprect not empty. if (!fliprect.IsEmpty) { using (Painter frontpainter = drawarea.CreatePainter()) { int x = fliprect.XMin, y = fliprect.YMin, w = fliprect.Width, h = fliprect.Height; frontpainter.Blit(overlay, x, y, w, h, x, y, w, h); overlaypainter.Blit(backbuffer, x, y, w, h, x, y, w, h); } } //remove the temp graphics from the overlay buffer if (!screen_dirty.IsEmpty) { int x = screen_dirty.XMin, y = screen_dirty.YMin, w = screen_dirty.Width, h = screen_dirty.Height; overlaypainter.Color = RGB.Green; } screen_dirty = newdirtyrect; } } }