示例#1
0
        // This method is invoked when the application has loaded its UI and its ready to run
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            RectangleF rect = UIScreen.MainScreen.ApplicationFrame;

            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("Images/Red.png"),
                UIImage.FromFile("Images/Yellow.png"),
                UIImage.FromFile("Images/Green.png"),
                UIImage.FromFile("Images/Blue.png"),
                UIImage.FromFile("Images/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);


            // 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;

            //Show the window
            window.MakeKeyAndVisible();

            return(true);
        }
示例#2
0
		// This method is invoked when the application has loaded its UI and its ready to run
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			RectangleF rect = UIScreen.MainScreen.ApplicationFrame;

			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 ("Images/Red.png"),
					UIImage.FromFile ("Images/Yellow.png"),
					UIImage.FromFile ("Images/Green.png"),
					UIImage.FromFile ("Images/Blue.png"),
					UIImage.FromFile ("Images/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);

			
			// 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;
			
			//Show the window
			window.MakeKeyAndVisible ();
	
			return true;
		}
示例#3
0
        // This method is invoked when the application has loaded its UI and its ready to run
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            CGRect rect = UIScreen.MainScreen.ApplicationFrame;

            window.BackgroundColor = UIColor.Black;

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

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

            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                // we want the original colors, which is not the default iOS7 behaviour, so we need to
                // replace them with ones having the right UIImageRenderingMode
                for (int i = 0; i < images.Length; i++)
                {
                    images [i] = images [i].ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
                }
            }
            var segmentedControl = new UISegmentedControl(images);

            // Compute a rectangle that is positioned correctly for the segmented control you'll use as a brush color palette
            var frame = new CGRect(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;
            // 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);

            // 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.Default, 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;

            //Show the window
            window.MakeKeyAndVisible();

            return(true);
        }
		// This method is invoked when the application has loaded its UI and its ready to run
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			CGRect rect = UIScreen.MainScreen.ApplicationFrame;

			window.BackgroundColor = UIColor.Black;

			//Create the OpenGL drawing view and add it to the window
			drawingView = new PaintingView (new CGRect (rect.Location, rect.Size));
			var viewController = new UIViewController {
				View = drawingView
			};
			window.RootViewController = viewController;

			// Create a segmented control so that the user can choose the brush color.
			var images = new[] {
				UIImage.FromFile ("Images/Red.png"),
				UIImage.FromFile ("Images/Yellow.png"),
				UIImage.FromFile ("Images/Green.png"),
				UIImage.FromFile ("Images/Blue.png"),
				UIImage.FromFile ("Images/Purple.png")
			};
			if (UIDevice.CurrentDevice.CheckSystemVersion (7, 0)) {
				// we want the original colors, which is not the default iOS7 behaviour, so we need to
				// replace them with ones having the right UIImageRenderingMode
				for (int i = 0; i < images.Length; i++)
					images [i] = images [i].ImageWithRenderingMode (UIImageRenderingMode.AlwaysOriginal);
			}
			var segmentedControl = new UISegmentedControl (images);

			// Compute a rectangle that is positioned correctly for the segmented control you'll use as a brush color palette
			var frame = new CGRect (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;
			// 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);

			// 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.Default, 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;

			//Show the window
			window.MakeKeyAndVisible ();

			return true;
		}