public override void ToggleTorch() { viewController.ToggleTorch(); }
private void Initialize() { Frame = new RectangleF(0, 0, (UIScreen.MainScreen.Bounds.Width), (UIScreen.MainScreen.Bounds.Height)); Opaque = false; BackgroundColor = UIColor.Clear; //Add(_mainView); if (this.OverlayView != null) { this.OverlayView.Frame = Frame; this.AddSubview(this.OverlayView); } else { //Setup Overlay var overlaySize = new SizeF(this.Frame.Width, this.Frame.Height - 44); var topBg = new UIView(new RectangleF(0, 0, this.Frame.Width, (overlaySize.Height - picFrame.Height) / 2)); topBg.Frame = new RectangleF(0, 0, this.Frame.Width, this.Frame.Height * 0.30f); topBg.BackgroundColor = UIColor.Black; topBg.Alpha = 0.6f; var bottomBg = new UIView(new RectangleF(0, topBg.Frame.Height + picFrame.Height, this.Frame.Width, topBg.Frame.Height)); bottomBg.Frame = new RectangleF(0, this.Frame.Height * 0.70f, this.Frame.Width, this.Frame.Height * 0.30f); bottomBg.BackgroundColor = UIColor.Black; bottomBg.Alpha = 0.6f; //var grad = new MonoTouch.CoreAnimation.CAGradientLayer(); //grad.Frame = bottomBg.Bounds; //grad.Colors = new CGColor[] { new CGColor()UIColor.Black, UIColor.FromWhiteAlpha(0.0f, 0.6f) }; //bottomBg.Layer.InsertSublayer(grad, 0); // [v.layer insertSublayer:gradient atIndex:0]; var redLine = new UIView(new RectangleF(0, this.Frame.Height * 0.5f - 2.0f, this.Frame.Width, 4.0f)); redLine.BackgroundColor = UIColor.Red; redLine.Alpha = 0.4f; this.AddSubview(redLine); this.AddSubview(topBg); this.AddSubview(bottomBg); var textTop = new UILabel() { Frame = new RectangleF(0, this.Frame.Height * 0.10f, this.Frame.Width, 42), Text = Scanner.TopText, Font = UIFont.SystemFontOfSize(13), TextAlignment = UITextAlignment.Center, TextColor = UIColor.White, Lines = 2, BackgroundColor = UIColor.Clear }; this.AddSubview(textTop); var textBottom = new UILabel() { Frame = new RectangleF(0, this.Frame.Height * 0.825f - 32f, this.Frame.Width, 64), Text = Scanner.BottomText, Font = UIFont.SystemFontOfSize(13), TextAlignment = UITextAlignment.Center, TextColor = UIColor.White, Lines = 3, BackgroundColor = UIColor.Clear }; this.AddSubview(textBottom); InvokeOnMainThread(delegate { // Setting tool bar var toolBar = new UIToolbar(new RectangleF(0, UIScreen.MainScreen.Bounds.Height - 44, 320, 44)); toolBar.Items = new UIBarButtonItem[] { new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Done, delegate { _parentViewController.BarCodeScanned(null); //DismissViewController(); }), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Light", UIBarButtonItemStyle.Done, delegate { //TODO: Flash _parentViewController.ToggleTorch(); }), }; toolBar.TintColor = UIColor.Black; Add(toolBar); }); //_textCue = new UILabel () //{ // Frame = new RectangleF(0,topBg.Frame.Bottom - 50,this.Frame.Width,21), // Text = "Adjust barcode according to arrows", // Font = UIFont.SystemFontOfSize(13), // TextAlignment = UITextAlignment.Center, // TextColor = UIColor.Clear, // Opaque = true, //BackgroundColor = UIColor.Clear// UIColor.FromRGBA(0,0,0,0), //}; //_greenBottomArrow = new UIImageView (UIImage.FromBundle ("Images/green_down_arrow.png")); //_greenBottomArrow.Frame = new RectangleF (0, topBg.Frame.Bottom - 19, this.Frame.Width, 19); //_greenTopArrow = new UIImageView (UIImage.FromBundle ("Images/green_up_arrow.png")); //_greenTopArrow.Frame = new RectangleF (0, bottomBg.Frame.Top, 320, 19); //_whiteBottomArrow = new UIImageView (UIImage.FromBundle ("Images/white_down_arrow.png")); //_whiteBottomArrow.Frame = new RectangleF (0, topBg.Frame.Bottom - 19, 320, 19); //_whiteTopArrow = new UIImageView (UIImage.FromBundle ("Images/white_up_arrow.png")); //_whiteTopArrow.Frame = new RectangleF (0, bottomBg.Frame.Top, 320, 19); //AddSubview (_textCue); //AddSubview (_greenBottomArrow); //AddSubview (_greenTopArrow); //AddSubview (_whiteBottomArrow); //AddSubview (_whiteTopArrow); //_greenBottomArrow.Image.Dispose (); //_greenTopArrow.Image.Dispose (); //_textCue.Dispose (); //_whiteBottomArrow.Image.Dispose (); //_whiteTopArrow.Image.Dispose (); //_mainView.Image.Dispose (); } // initalise flags //_isGreen = false; //SetArrows(false, false); UIApplication.SharedApplication.SetStatusBarHidden(false, false); UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.BlackOpaque, false); }