Esempio n. 1
0
        public override void FinishedLaunching(UIApplication app)
        {
            RectangleF rect = UIScreen.MainScreen.ApplicationFrame;

            //Create a full-screen window
            window = new UIWindow(UIScreen.MainScreen.Bounds);
            window.BackgroundColor = UIColor.Black;

            //Create the OpenGL drawing view and add it to the window
            drawingView = new PaintingView(new RectangleF(rect.Location, rect.Size));
            window.AddSubview(drawingView);

            // Create a segmented control so that the user can choose the brush color.
            UISegmentedControl segmentedControl = new UISegmentedControl(new[] {
                UIImage.FromFile("Red.png"),
                UIImage.FromFile("Yellow.png"),
                UIImage.FromFile("Green.png"),
                UIImage.FromFile("Blue.png"),
                UIImage.FromFile("Purple.png"),
            });

            // Compute a rectangle that is positioned correctly for the segmented control you'll use as a brush color palette
            RectangleF frame = new RectangleF(rect.X + LeftMarginPadding, rect.Height - PaletteHeight - TopMarginPadding,
                                              rect.Width - (LeftMarginPadding + RightMarginPadding), PaletteHeight);

            segmentedControl.Frame = frame;
            // When the user chooses a color, the method changeBrushColor: is called.
            segmentedControl.ValueChanged += ChangeBrushColor;
            segmentedControl.ControlStyle  = UISegmentedControlStyle.Bar;
            // Make sure the color of the color complements the black background
            segmentedControl.TintColor = UIColor.DarkGray;
            // Set the third color (index values start at 0)
            segmentedControl.SelectedSegment = 2;

            // Add the control to the window
            window.AddSubview(segmentedControl);
            // Now that the control is added, you can release it
            // [segmentedControl release];

            float r, g, b;

            // Define a starting color
            HslToRgb(2.0f / PaletteSize, PaintingView.Saturation, PaintingView.Luminosity, out r, out g, out b);
            // Set the color using OpenGL
            GL.Color4(r, g, b, PaintingView.BrushOpacity);

            //Show the window
            window.MakeKeyAndVisible();
            // Look in the Info.plist file and you'll see the status bar is hidden
            // Set the style to black so it matches the background of the application
            app.SetStatusBarStyle(UIStatusBarStyle.BlackTranslucent, false);
            // Now show the status bar, but animate to the style.
            app.SetStatusBarHidden(false, true);

            //Configure and enable the accelerometer
            UIAccelerometer.SharedAccelerometer.UpdateInterval = 1.0f / AccelerometerFrequency;
            UIAccelerometer.SharedAccelerometer.Acceleration  += OnAccelerated;
        }
Esempio n. 2
0
		public override void FinishedLaunching (UIApplication app)
		{
			RectangleF rect = UIScreen.MainScreen.ApplicationFrame;

			//Create a full-screen window
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			window.BackgroundColor = UIColor.Black;

			//Create the OpenGL drawing view and add it to the window
			drawingView = new PaintingView (new RectangleF (rect.Location, rect.Size));
			window.AddSubview (drawingView);

			// Create a segmented control so that the user can choose the brush color.
			UISegmentedControl segmentedControl = new UISegmentedControl (new[]{
					UIImage.FromFile ("Red.png"),
					UIImage.FromFile ("Yellow.png"),
					UIImage.FromFile ("Green.png"),
					UIImage.FromFile ("Blue.png"),
					UIImage.FromFile ("Purple.png"),
			});

			// Compute a rectangle that is positioned correctly for the segmented control you'll use as a brush color palette
			RectangleF frame = new RectangleF (rect.X + LeftMarginPadding, rect.Height - PaletteHeight - TopMarginPadding,
				rect.Width - (LeftMarginPadding + RightMarginPadding), PaletteHeight);
			segmentedControl.Frame = frame;
			// When the user chooses a color, the method changeBrushColor: is called.
			segmentedControl.ValueChanged += ChangeBrushColor;
			segmentedControl.ControlStyle = UISegmentedControlStyle.Bar;
			// Make sure the color of the color complements the black background
			segmentedControl.TintColor = UIColor.DarkGray;
			// Set the third color (index values start at 0)
			segmentedControl.SelectedSegment = 2;

			// Add the control to the window
			window.AddSubview (segmentedControl);
			// Now that the control is added, you can release it
			// [segmentedControl release];

			float r, g, b;
			// Define a starting color
			HslToRgb (2.0f / PaletteSize, PaintingView.Saturation, PaintingView.Luminosity, out r, out g, out b);
			// Set the color using OpenGL
			GL.Color4 (r, g, b, PaintingView.BrushOpacity);

			//Show the window
			window.MakeKeyAndVisible ();
			// Look in the Info.plist file and you'll see the status bar is hidden
			// Set the style to black so it matches the background of the application
			app.SetStatusBarStyle (UIStatusBarStyle.BlackTranslucent, false);
			// Now show the status bar, but animate to the style.
			app.SetStatusBarHidden (false, true);

			//Configure and enable the accelerometer
			UIAccelerometer.SharedAccelerometer.UpdateInterval = 1.0f / AccelerometerFrequency;
			UIAccelerometer.SharedAccelerometer.Acceleration += OnAccelerated;
		}