コード例 #1
0
        void CreateSegmentedControl ()
        {
//            _segmentedControl = new UISegmentedControl (new object[] { "one", "two", "three", "four" });
//            _segmentedControl.ControlStyle = UISegmentedControlStyle.Bezeled;
//            _segmentedControl.TintColor = UIColor.Black;
//            _segmentedControl.SetImage (UIImage.FromFile ("Star.png"), 0);
//            _segmentedControl.SelectedSegment = 0;
//            _segmentedControl.Frame = new RectangleF (10, 10, View.Frame.Width - 20, 50);
            
            _testLabel = new UILabel { Frame = new RectangleF (10, 200, 100, 50) };
            
            _segmentedControl = new UISegmentedControl (new object[] { UIImage.FromFile ("Star.png"), "two", "three", "four" });
            _segmentedControl.ControlStyle = UISegmentedControlStyle.Bezeled;
            _segmentedControl.TintColor = UIColor.Black;
            _segmentedControl.Frame = new RectangleF (10, 10, View.Frame.Width - 20, 50);
            
            _segmentedControl.ValueChanged += (o, e) =>
            {
                _text = _segmentedControl.TitleAt (_segmentedControl.SelectedSegment) ?? "title not set";
                _testLabel.Text = _text;
            };
            
            _segmentedControl.SelectedSegment = 0;
            _segmentedControl.AddSubview (_testLabel);
            
            View.AddSubview (_segmentedControl);
        }
コード例 #2
0
        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 ();

        }