public Pubnub_MessagingSpeedTest(string channelName, string cipher, bool enableSSL, Pubnub pubnub) : base(UITableViewStyle.Plain, null) { Channel = channelName; Ssl = enableSSL; Cipher = cipher; this.pubnub = pubnub; string strSsl = ""; if (Ssl) { strSsl = ", SSL"; } string strCip = ""; if (!String.IsNullOrWhiteSpace(Cipher)) { strCip = ", Cipher"; } string head = String.Format("Ch: {0} {1} {2}", Channel, strSsl, strCip); bool bIphone = true; string hardwareVer = DeviceHardware.Version.ToString().ToLower(); if (hardwareVer.IndexOf("ipad") >= 0) { bIphone = false; } InitArrays(); perfHeader = new PerformanceHeader(); secOutput = new Section(perfHeader.View); sdHeader = new SdHeader(speedTestNames, speedTestSorted); sdHeader.View.Tag = 101; graphHeader = new GraphHeader(); graphHeader.View.Tag = 102; UISegmentedControl segmentedControl = new UISegmentedControl(); segmentedControl.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; segmentedControl.Frame = new CGRect(10, 20, UIScreen.MainScreen.Bounds.Width - 20, 40); segmentedControl.InsertSegment("Graph", 0, false); segmentedControl.InsertSegment("SD", 1, false); segmentedControl.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; segmentedControl.AddSubview(graphHeader.View); segmentedControl.ValueChanged += (sender, e) => { var selectedSegmentId = (sender as UISegmentedControl).SelectedSegment; if (segmentedControl.SelectedSegment == 0) { if (segmentedControl.ViewWithTag(101) != null) { segmentedControl.ViewWithTag(101).RemoveFromSuperview(); } graphHeader.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; segmentedControl.AddSubview(graphHeader.View); } else if (segmentedControl.SelectedSegment == 1) { if (segmentedControl.ViewWithTag(102) != null) { segmentedControl.ViewWithTag(102).RemoveFromSuperview(); } sdHeader.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; segmentedControl.AddSubview(sdHeader.View); } }; segmentedControl.SelectedSegment = 0; segmentedControl.ControlStyle = UISegmentedControlStyle.Plain; secOutput.Add(segmentedControl); Section sectionSegmentedControl = new Section(); //sectionSegmentedControl.Add(segmentedControl); root = new RootElement(head) { new Section("PubNub speed test"), secOutput, //sectionSegmentedControl }; Root = root; this.Root.UnevenRows = true; dvc = new DialogViewController(UITableViewStyle.Plain, root, true); dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, delegate { pubnub.EndPendingRequests(); runSpeedtest = false; speedTestThread.Join(1000); AppDelegate.navigation.PopToRootViewController(true); }); dvc.TableView.ScrollEnabled = true; dvc.TableView.SeparatorColor = UIColor.Clear; dvc.TableView.SeparatorStyle = UITableViewCellSeparatorStyle.None; dvc.TableView.BackgroundView = null; dvc.TableView.BackgroundColor = UIColor.White; AppDelegate.navigation.PushViewController(dvc, true); LaunchSpeedTest(); }
public Pubnub_MessagingSpeedTest (string channelName, string cipher, bool enableSSL, Pubnub pubnub) : base (UITableViewStyle.Plain, null) { Channel = channelName; Ssl = enableSSL; Cipher = cipher; this.pubnub = pubnub; string strSsl = ""; if (Ssl) { strSsl = ", SSL"; } string strCip = ""; if (!String.IsNullOrWhiteSpace (Cipher)) { strCip = ", Cipher"; } string head = String.Format ("Ch: {0} {1} {2}", Channel, strSsl, strCip); bool bIphone = true; string hardwareVer = DeviceHardware.Version.ToString ().ToLower (); if (hardwareVer.IndexOf ("ipad") >= 0) { bIphone = false; } InitArrays(); perfHeader = new PerformanceHeader(); secOutput = new Section(perfHeader.View); sdHeader = new SdHeader(speedTestNames, speedTestSorted); sdHeader.View.Tag = 101; graphHeader = new GraphHeader(); graphHeader.View.Tag = 102; UISegmentedControl segmentedControl = new UISegmentedControl(); segmentedControl.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; segmentedControl.Frame = new RectangleF(10, 20, UIScreen.MainScreen.Bounds.Width - 20, 40); segmentedControl.InsertSegment("Graph", 0, false); segmentedControl.InsertSegment("SD", 1, false); segmentedControl.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; segmentedControl.AddSubview(graphHeader.View); segmentedControl.ValueChanged += (sender, e) => { var selectedSegmentId = (sender as UISegmentedControl).SelectedSegment; if (segmentedControl.SelectedSegment == 0) { if(segmentedControl.ViewWithTag(101) != null) { segmentedControl.ViewWithTag(101).RemoveFromSuperview(); } graphHeader.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; segmentedControl.AddSubview(graphHeader.View); } else if (segmentedControl.SelectedSegment == 1) { if(segmentedControl.ViewWithTag(102) != null) { segmentedControl.ViewWithTag(102).RemoveFromSuperview(); } sdHeader.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; segmentedControl.AddSubview(sdHeader.View); } }; segmentedControl.SelectedSegment = 0; segmentedControl.ControlStyle = UISegmentedControlStyle.Plain; secOutput.Add(segmentedControl); Section sectionSegmentedControl = new Section(); //sectionSegmentedControl.Add(segmentedControl); root = new RootElement (head) { new Section("PubNub speed test"), secOutput, //sectionSegmentedControl }; Root = root; this.Root.UnevenRows = true; dvc = new DialogViewController (UITableViewStyle.Plain, root, true); dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, delegate { pubnub.EndPendingRequests (); runSpeedtest = false; speedTestThread.Join(1000); AppDelegate.navigation.PopToRootViewController(true); }); dvc.TableView.ScrollEnabled = true; dvc.TableView.SeparatorColor = UIColor.Clear; dvc.TableView.SeparatorStyle = UITableViewCellSeparatorStyle.None; dvc.TableView.BackgroundView = null; dvc.TableView.BackgroundColor = UIColor.White; AppDelegate.navigation.PushViewController (dvc, true); LaunchSpeedTest (); }