示例#1
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            viewController          = new UIViewController();
            theSwitch               = new UISwitch(new RectangleF((window.Frame.Width - 75) / 2, (window.Frame.Height - 30) / 2, 75, 30));
            theSwitch.ValueChanged += delegate(object sender, EventArgs e) {
                SentText(theSwitch.On ? "On" : "Off");
                Console.WriteLine("Switch changed");
            };
            rscMgr          = new RscMgr();
            rscMgr.Delegate = new RedParkDelegate(rscMgr);
            rscMgr.Baud     = 9600;
            Console.WriteLine("Baud {0}", rscMgr.Baud);
            rscMgr.SetParity(ParityType.None);
            rscMgr.SetStopBits(StopBitsType.One);

            viewController.View.AddSubview(theSwitch);
            window.RootViewController = viewController;
            window.MakeKeyAndVisible();
            return(true);
        }
 public MainViewController()
 {
     sb              = new StringBuilder();
     MainView        = new MainView(this);
     View            = MainView;
     rscMgr          = new RscMgr();
     rscMgr.Delegate = new RedParkDelegate(this);
     rscMgr.Baud     = 9600;
     Console.WriteLine("Baud {0}", rscMgr.Baud);
     rscMgr.SetParity(ParityType.None);
     rscMgr.SetStopBits(StopBitsType.One);
     NSNotificationCenter.DefaultCenter.AddObserver("UIKeyboardDidShowNotification", (notification) => {
         var value = notification.UserInfo["UIKeyboardFrameBeginUserInfoKey"] as NSValue;
         MainView.KeyBoardHeight = value.RectangleFValue.Height;
         MainView.LayoutSubviews();
     });
     NSNotificationCenter.DefaultCenter.AddObserver("UIKeyboardDidHideNotification", (notification) => {
         var value = notification.UserInfo["UIKeyboardFrameBeginUserInfoKey"] as NSValue;
         Console.WriteLine(value.RectangleFValue);
         MainView.KeyBoardHeight = 0f;
         MainView.LayoutSubviews();
     });
 }