static void Main() { ColorTriangle t1 = new ColorTriangle("Blue", "right", 8.0, 12.0); ColorTriangle t2 = new ColorTriangle("Red", "isosceles", 2.0, 2.0); Console.WriteLine("Info for t1: "); t1.ShowStyle(); t1.ShowDim(); t1.ShowColor(); Console.WriteLine("Area is " + t1.Area()); Console.WriteLine(); Console.WriteLine("Info for t2: "); t2.ShowStyle(); t2.ShowDim(); t2.ShowColor(); Console.WriteLine("Area is " + t2.Area()); }
public static void Main() { ColorTriangle t1 = new ColorTriangle("синий", "прямоугольный", 8.0, 12.0); ColorTriangle t2 = new ColorTriangle("красный", "равнобедренный", 2.0, 2.0); Console.WriteLine("Информация о t1: "); t1.showStyle(); t1.showDim(); t1.showColor(); Console.WriteLine("Площадь равна " + t1.area()); Console.WriteLine(); Console.WriteLine("Информация о t2: "); t2.showStyle(); t2.showDim(); t2.showColor(); Console.WriteLine("Площадь равна " + t2.area()); }
private static int Main(string[] args) { // * Init GTK. Gtk.Application.Init ("Color", ref args); // * Init GtkGLExt. GtkGL.Application.Init (ref args); // * Display mode. GdkGL.ConfigMode mode = GdkGL.ConfigMode.Index; for (int i = 0; i < args.Length; i++) { if (args[i] == "--rgb") mode = GdkGL.ConfigMode.Rgb; } // * Query OpenGL extension version. int major, minor; Query.Version (out major, out minor); Console.WriteLine ("\nOpenGL extension version - {0}.{1}", major, minor); // * Configure OpenGL-capable visual. // Try double-buffered visual GdkGL.Config glconfig = new GdkGL.Config (mode | GdkGL.ConfigMode.Depth | GdkGL.ConfigMode.Double); if (glconfig == null) { Console.WriteLine ("*** Cannot find the double-buffered visual.\n*** Trying single-buffered visual."); glconfig = new GdkGL.Config (mode | GdkGL.ConfigMode.Depth); if (glconfig == null) { Console.WriteLine ("*** Cannot find any OpenGL-capable visual."); return 1; } } GlUtilities.WriteOutConfig (glconfig); bool is_rgba = glconfig.IsRgba; // Top-level window. Window window = new Window (WindowType.Toplevel); window.Title = "color"; // Perform the resizes immediately window.ResizeMode = ResizeMode.Immediate; // Get automatically redrawn if any of their children changed allocation. window.ReallocateRedraws = true; window.DeleteEvent += new DeleteEventHandler (Window_Delete); // VBox. VBox vbox = new VBox (false, 0); window.Add (vbox); vbox.Show (); // Drawing area for drawing OpenGL scene. ColorTriangle drawing_area = new ColorTriangle (glconfig); drawing_area.SetSizeRequest (200, 200); vbox.PackStart (drawing_area, true, true, 0); drawing_area.Show (); // Simple quit button. Button button = new Button ("Quit"); button.Pressed += new EventHandler (Button_Click); vbox.PackStart (button, false, false, 0); button.Show (); // * Show window. window.Show (); // * Allocate colors. if (!is_rgba) { Gdk.Colormap colormap = glconfig.Colormap; Console.WriteLine ("\nAllocate colors."); // Allocate writable color cells. bool[] success = new bool [NUM_COLORS]; int not_allocated = colormap.AllocColors (colors, NUM_COLORS, false, false, success); for (int i = 0; i < NUM_COLORS; i++) Console.WriteLine ("{0}", success[i]); Console.WriteLine ("Not allocated = {0}", not_allocated); for (int i = 0; i < NUM_COLORS; i++) Console.WriteLine ("colors[{0}] = [ {1}, {2}, {3}, {4} ]", i, colors[i].Pixel, colors[i].Red, colors[i].Green, colors[i].Blue ); Console.WriteLine ("\nQuery colors."); for (int i = 0; i < NUM_COLORS; i++) { Gdk.Color color = new Gdk.Color (); color.Pixel = colors[i].Pixel; colormap.QueryColor (colors[i].Pixel, ref color); Console.WriteLine ("colors[{0}] = { {1}, {2}, {3}, {4} }", i, colors[i].Pixel, color.Red, color.Green, color.Blue); } Console.WriteLine (); } // * Main loop. Gtk.Application.Run (); return 0; }