本文整理汇总了C#中UISegmentedControl.InsertSegment方法的典型用法代码示例。如果您正苦于以下问题:C# UISegmentedControl.InsertSegment方法的具体用法?C# UISegmentedControl.InsertSegment怎么用?C# UISegmentedControl.InsertSegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UISegmentedControl
的用法示例。
在下文中一共展示了UISegmentedControl.InsertSegment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCell
public override UITableViewCell GetCell (UITableView tv)
{
sc = new UISegmentedControl () {
BackgroundColor = UIColor.Clear,
Tag = 1,
};
sc.Selected = true;
sc.InsertSegment (choices [0].Text, 0, false);
sc.InsertSegment (choices [1].Text, 1, false);
sc.Frame = new RectangleF (570f, 8f, 150f, 26f);
sc.SelectedSegment = choices.FindIndex (e => e.Id == val.Id);
sc.AddTarget (delegate {
Value = choices [sc.SelectedSegment];
}, UIControlEvent.ValueChanged);
var cell = tv.DequeueReusableCell (CellKey);
// if (cell == null) {
cell = new UITableViewCell (UITableViewCellStyle.Default, CellKey);
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
cell.AddSubview (sc);
// }
// else
// RemoveTag (cell, 1);
cell.TextLabel.Font = UIFont.BoldSystemFontOfSize (17);
//cell.Frame.Height = 44;
cell.TextLabel.Text = Caption;
if (this.IsMandatory)
cell.TextLabel.Text += "*";
return cell;
}
示例2: ToolbarConfigurationItem
public UIBarButtonItem ToolbarConfigurationItem()
{
var current = model.Ordering;
toolbarControl = new UISegmentedControl();
toolbarControl.InsertSegment("name", 0, false);
toolbarControl.InsertSegment("time", 1, false);
toolbarControl.SelectedSegment = (current == BuildOrder.BuildName) ? 0 : 1;
toolbarControl.ControlStyle = UISegmentedControlStyle.Bar;
toolbarControl.Frame = new System.Drawing.RectangleF(0, 10, 100, 30);
toolbarControl.UserInteractionEnabled = true;
toolbarControl.ValueChanged += delegate {
switch (toolbarControl.SelectedSegment) {
case 0:
model.Ordering = BuildOrder.BuildName;
break;
default:
model.Ordering = BuildOrder.BuildTime;
break;
}
InvokeOnMainThread(UpdateUI);
};
return new UIBarButtonItem(toolbarControl);
}
示例3: Initialize
private void Initialize ()
{
Title = Locale.GetText ("");
_mapView = new MKMapView ();
_mapView.AutoresizingMask = UIViewAutoresizing.All;
_mapView.MapType = MKMapType.Standard;
_mapView.ShowsUserLocation = true;
_sgMapType = new UISegmentedControl ();
_sgMapType.AutoresizingMask = UIViewAutoresizing.FlexibleMargins;
_sgMapType.Opaque = true;
_sgMapType.Alpha = 0.75f;
_sgMapType.ControlStyle = UISegmentedControlStyle.Bar;
_sgMapType.InsertSegment ("Map", 0, true);
_sgMapType.InsertSegment ("Satellite", 1, true);
_sgMapType.InsertSegment ("Hybrid", 2, true);
_sgMapType.SelectedSegment = 0;
_sgMapType.ValueChanged += (s, e) => {
switch (_sgMapType.SelectedSegment) {
case 0:
_mapView.MapType = MKMapType.Standard;
break;
case 1:
_mapView.MapType = MKMapType.Satellite;
break;
case 2:
_mapView.MapType = MKMapType.Hybrid;
break;
}
};
}
示例4: ToolbarConfigurationItem
public UIBarButtonItem ToolbarConfigurationItem()
{
var current = model.TimePeriod;
toolbarControl = new UISegmentedControl();
toolbarControl.InsertSegment("24h", 0, false);
toolbarControl.InsertSegment("week", 1, false);
toolbarControl.InsertSegment("month", 2, false);
toolbarControl.SelectedSegment = (current == TimePeriod.PastDay) ? 0 : (current == TimePeriod.PastWeek) ? 1 : 2;
toolbarControl.ControlStyle = UISegmentedControlStyle.Bar;
toolbarControl.Frame = new System.Drawing.RectangleF(0, 10, 130, 30);
toolbarControl.UserInteractionEnabled = true;
toolbarControl.ValueChanged += delegate {
switch (toolbarControl.SelectedSegment) {
case 0:
model.TimePeriod = TimePeriod.PastDay;
break;
case 1:
model.TimePeriod = TimePeriod.PastWeek;
break;
default:
model.TimePeriod = TimePeriod.PastMonth;
break;
}
ViewWillAppear(true);
};
return new UIBarButtonItem(toolbarControl);
}
示例5: Styles
public Styles()
{
this.SfGrid = new SfDataGrid ();
viewmodel = new GridGettingStartedViewModel ();
this.SfGrid.AutoGeneratingColumn += GridAutoGenerateColumns;
this.SfGrid.ItemsSource = viewmodel.OrdersInfo;
this.SfGrid.ShowRowHeader = false;
this.SfGrid.HeaderRowHeight = 45;
this.SfGrid.RowHeight = 45;
this.SfGrid.SelectionMode = SelectionMode.Multiple;
this.SfGrid.GridViewCreated += SfGrid_GridViewCreated;
this.SfGrid.GroupColumnDescriptions.Add (new GroupColumnDescription(){ColumnName ="CustomerID"});
this.SfGrid.AlternatingRowColor = UIColor.FromRGB (25, 25, 25);
segmentControl = new UISegmentedControl();
segmentControl.ControlStyle = UISegmentedControlStyle.Bezeled;
segmentControl.InsertSegment("Dark", 0,true);
segmentControl.InsertSegment("Blue", 1, true);
segmentControl.InsertSegment("Red", 2, true);
segmentControl.InsertSegment("Green", 3, true);
segmentControl.SelectedSegment = 0;
segmentControl.ValueChanged += SegmentControl_ValueChanged;
this.control = this;
this.AddSubview (segmentControl);
this.AddSubview (SfGrid);
}
示例6: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
Title = "Mi Ubicacion";
mapView = new MKMapView(View.Bounds);
mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
//mapView.MapType = MKMapType.Standard; // this is the default
//mapView.MapType = MKMapType.Satellite;
mapView.MapType = MKMapType.Hybrid;
mapView.ZoomEnabled = true;
View.AddSubview(mapView);
// this is all that's required to show the blue dot indicating user-location
mapView.ShowsUserLocation = true;
Console.WriteLine ("initial loc:"+mapView.UserLocation.Coordinate.Latitude + "," + mapView.UserLocation.Coordinate.Longitude);
mapView.DidUpdateUserLocation += (sender, e) => {
if (mapView.UserLocation != null) {
Console.WriteLine ("userloc:"+mapView.UserLocation.Coordinate.Latitude + "," + mapView.UserLocation.Coordinate.Longitude);
CLLocationCoordinate2D coords = mapView.UserLocation.Coordinate;
MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(1), MilesToLongitudeDegrees(1, coords.Latitude));
mapView.Region = new MKCoordinateRegion(coords, span);
}
};
if (!mapView.UserLocationVisible) {
// user denied permission, or device doesn't have GPS/location ability
Console.WriteLine ("userloc not visible, show cupertino");
CLLocationCoordinate2D coords = new CLLocationCoordinate2D(37.33233141,-122.0312186); // cupertino
MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(20), MilesToLongitudeDegrees(20, coords.Latitude));
mapView.Region = new MKCoordinateRegion(coords, span);
}
int typesWidth=260, typesHeight=30, distanceFromBottom=60;
mapTypes = new UISegmentedControl(new RectangleF((View.Bounds.Width-typesWidth)/2, View.Bounds.Height-distanceFromBottom, typesWidth, typesHeight));
mapTypes.InsertSegment("Mapa", 0, false);
mapTypes.InsertSegment("Satelite", 1, false);
mapTypes.InsertSegment("Hibrido", 2, false);
mapTypes.SelectedSegment = 0; // Road is the default
mapTypes.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin;
mapTypes.ValueChanged += (s, e) => {
switch(mapTypes.SelectedSegment) {
case 0:
mapView.MapType = MKMapType.Standard;
break;
case 1:
mapView.MapType = MKMapType.Satellite;
break;
case 2:
mapView.MapType = MKMapType.Hybrid;
break;
}
};
View.AddSubview(mapTypes);
}
示例7: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
_tipLabel = new UILabel ();
_calculateButton = new UIButton (UIButtonType.Custom);
_priceField = new UITextField ();
_tipPercentages = new UISegmentedControl ();
View.AddSubview (_priceField);
View.AddSubview (_calculateButton);
View.AddSubview (_tipLabel);
View.AddSubview (_tipPercentages);
_priceField.TranslatesAutoresizingMaskIntoConstraints = false;
_priceField.KeyboardType = UIKeyboardType.DecimalPad;
_priceField.BorderStyle = UITextBorderStyle.RoundedRect;
_priceField.Placeholder = "Enter Total Amount:";
View.AddConstraint (NSLayoutConstraint.Create (View, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _priceField, NSLayoutAttribute.TopMargin, 1, -28));
View.AddConstraint (NSLayoutConstraint.Create (View, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, _priceField, NSLayoutAttribute.CenterX, 1, 0));
View.AddConstraint (NSLayoutConstraint.Create (View, NSLayoutAttribute.Width, NSLayoutRelation.Equal, _priceField, NSLayoutAttribute.Width, 1, 40));
View.AddConstraint (NSLayoutConstraint.Create (_priceField, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, 35));
_calculateButton.TranslatesAutoresizingMaskIntoConstraints = false;
_calculateButton.SetTitle ("Calculate", UIControlState.Normal);
_calculateButton.SetTitleColor (UIColor.White, UIControlState.Normal);
_calculateButton.SetTitleColor (UIColor.Blue, UIControlState.Highlighted);
_calculateButton.BackgroundColor = UIColor.Green;
_calculateButton.TouchUpInside += (sender, e) => CalculateCurrentTip();
View.AddConstraint(NSLayoutConstraint.Create(_priceField, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, _calculateButton, NSLayoutAttribute.Top, 1, -8));
View.AddConstraint (NSLayoutConstraint.Create (_calculateButton, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, View, NSLayoutAttribute.CenterX, 1, 0));
View.AddConstraint (NSLayoutConstraint.Create (_calculateButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, View, NSLayoutAttribute.Width, 1, -40));
_tipPercentages.TranslatesAutoresizingMaskIntoConstraints = false;
_tipPercentages.InsertSegment ("10%", 0, false);
_tipPercentages.InsertSegment ("15%", 1, false);
_tipPercentages.InsertSegment ("20%", 2, false);
_tipPercentages.InsertSegment ("25%", 3, false);
_tipPercentages.SelectedSegment = 2;
_tipPercentages.ValueChanged += (sender, e) => CalculateCurrentTip();
View.AddConstraint (NSLayoutConstraint.Create (_calculateButton, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, _tipPercentages, NSLayoutAttribute.Top, 1, -8));
View.AddConstraint (NSLayoutConstraint.Create (_tipPercentages, NSLayoutAttribute.Width, NSLayoutRelation.Equal, View, NSLayoutAttribute.Width, 1, -40));
View.AddConstraint (NSLayoutConstraint.Create (_tipPercentages, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, View, NSLayoutAttribute.CenterX, 1, 0));
_tipLabel.TranslatesAutoresizingMaskIntoConstraints = false;
_tipLabel.TextColor = UIColor.Blue;
_tipLabel.Text = string.Format (TipFormat, 0);
_tipLabel.TextAlignment = UITextAlignment.Center;
View.AddConstraint (NSLayoutConstraint.Create (_tipLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _tipPercentages, NSLayoutAttribute.Bottom, 1, 8));
View.AddConstraint (NSLayoutConstraint.Create (_tipLabel, NSLayoutAttribute.Width, NSLayoutRelation.Equal, View, NSLayoutAttribute.Width, 1, -40));
View.AddConstraint (NSLayoutConstraint.Create (_tipLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, View, NSLayoutAttribute.CenterX, 1, 0));
View.BackgroundColor = UIColor.Yellow;
View.AddGestureRecognizer (new UITapGestureRecognizer (() => _priceField.ResignFirstResponder ()));
}
示例8: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
try{
this.Title = "Ubicación de la tienda";
mapView = new MKMapView(View.Bounds);
mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
View.AddSubview(mapView);
//Mostramos la ubicacion del usuario.
mapView.ShowsUserLocation = true;
MKUserLocation usr = mapView.UserLocation;
usr.Title = "Tú estas aqui";
var annotation = new BasicMapAnnotation (new CLLocationCoordinate2D (Double.Parse(tienda.tienda_latitud), Double.Parse(tienda.tienda_longitud)), tienda.tienda_nombre,tienda.tienda_direccion);
mapView.AddAnnotation (annotation);
// establecemos la region a mostrar, poniendo a Chihuahua como region
var coords = new CLLocationCoordinate2D(28.6352778, -106.08888890000003); // Chihuahua
var span = new MKCoordinateSpan(MilesToLatitudeDegrees (10), MilesToLongitudeDegrees (10, coords.Latitude));
// se establece la region.
mapView.Region = new MKCoordinateRegion (coords, span);
//Mostrar los diferentes tipos de mapas
int typesWidth=260, typesHeight=30, distanceFromBottom=60;
mapTypes = new UISegmentedControl(new CGRect((View.Bounds.Width-typesWidth)/2, View.Bounds.Height-distanceFromBottom, typesWidth, typesHeight));
mapTypes.InsertSegment("Mapa", 0, false);
mapTypes.InsertSegment("Satelite", 1, false);
mapTypes.InsertSegment("Ambos", 2, false);
mapTypes.SelectedSegment = 0; // Road is the default
mapTypes.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin;
mapTypes.ValueChanged += (s, e) => {
switch(mapTypes.SelectedSegment) {
case 0:
mapView.MapType = MKMapType.Standard;
break;
case 1:
mapView.MapType = MKMapType.Satellite;
break;
case 2:
mapView.MapType = MKMapType.Hybrid;
break;
}
};
View.AddSubview(mapTypes);
} catch(Exception e){
Console.WriteLine (e.ToString());
UIAlertView alert = new UIAlertView () {
Title = "Ups =(", Message = "Algo salio mal, verifica tu conexión a internet e intentalo de nuevo."
};
alert.AddButton("Aceptar");
alert.Show ();
}
}
示例9: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
Title = "Pyramids of Giza";
mapView = new MKMapView(View.Bounds);
mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
View.AddSubview(mapView);
var coords = new CLLocationCoordinate2D(29.976111, 31.132778); // pyramids of giza, egypt
var span = new MKCoordinateSpan(MilesToLatitudeDegrees(.75), MilesToLongitudeDegrees(.75, coords.Latitude));
// set the coords and zoom on the map
mapView.MapType = MKMapType.Satellite;
mapView.Region = new MKCoordinateRegion(coords, span);
mapView.OverlayRenderer = (m, o) => {
if(circleRenderer == null)
{
circleRenderer = new MKCircleRenderer(o as MKCircle);
circleRenderer.FillColor = UIColor.Purple;
circleRenderer.Alpha = 0.5f;
}
return circleRenderer;
};
circleOverlay = MKCircle.Circle (coords, 200);
mapView.AddOverlay (circleOverlay);
#region Not related to this sample
int typesWidth=260, typesHeight=30, distanceFromBottom=60;
mapTypes = new UISegmentedControl(new CGRect((View.Bounds.Width-typesWidth)/2, View.Bounds.Height-distanceFromBottom, typesWidth, typesHeight));
mapTypes.InsertSegment("Road", 0, false);
mapTypes.InsertSegment("Satellite", 1, false);
mapTypes.InsertSegment("Hybrid", 2, false);
mapTypes.SelectedSegment = 1; // Road is the default
mapTypes.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin;
mapTypes.ValueChanged += (s, e) => {
switch(mapTypes.SelectedSegment) {
case 0:
mapView.MapType = MKMapType.Standard;
break;
case 1:
mapView.MapType = MKMapType.Satellite;
break;
case 2:
mapView.MapType = MKMapType.Hybrid;
break;
}
};
View.AddSubview(mapTypes);
#endregion
}
示例10: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
_segmentedControl = new UISegmentedControl();
_segmentedControl.InsertSegment("Segment 1", 0, true);
_segmentedControl.InsertSegment("Segment 2", 1, true);
View.AddSubview(_segmentedControl);
View.SetStyleClass("sample-background");
_segmentedControl.SetStyleId("sample-segmented");
}
示例11: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
Title = "MapView";
mapView = new MKMapView(View.Bounds);
mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
//mapView.MapType = MKMapType.Standard; // this is the default
//mapView.MapType = MKMapType.Satellite;
//mapView.MapType = MKMapType.Hybrid;
View.AddSubview(mapView);
int typesWidth=260, typesHeight=30, distanceFromBottom=60;
mapTypes = new UISegmentedControl(new CGRect((View.Bounds.Width-typesWidth)/2, View.Bounds.Height-distanceFromBottom, typesWidth, typesHeight));
mapTypes.InsertSegment("Road", 0, false);
mapTypes.InsertSegment("Satellite", 1, false);
mapTypes.InsertSegment("Hybrid", 2, false);
mapTypes.SelectedSegment = 0; // Road is the default
mapTypes.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin;
mapTypes.ValueChanged += (s, e) => {
switch(mapTypes.SelectedSegment) {
case 0:
mapView.MapType = MKMapType.Standard;
break;
case 1:
mapView.MapType = MKMapType.Satellite;
break;
case 2:
mapView.MapType = MKMapType.Hybrid;
break;
}
};
View.AddSubview(mapTypes);
// create our location and zoom
//CLLocationCoordinate2D coords = new CLLocationCoordinate2D(40.77, -73.98); // new york
//CLLocationCoordinate2D coords = new CLLocationCoordinate2D(33.93, -118.40); // los angeles
//CLLocationCoordinate2D coords = new CLLocationCoordinate2D(51.509, -0.1); // london
CLLocationCoordinate2D coords = new CLLocationCoordinate2D(48.857, 2.351); // paris
MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(20), MilesToLongitudeDegrees(20, coords.Latitude));
// set the coords and zoom on the map
mapView.Region = new MKCoordinateRegion(coords, span);
}
示例12: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
picker = new ScanditSDK.SIBarcodePicker (appKey);
picker.OverlayController.DidScanBarcode += (object sender, SIOverlayControllerDidScanEventArgs e) => {
picker.StopScanning ();
ProcessBarcode (convertToNumber(e.Barcode ["barcode"].ToString ().ToUpper()));
};
picker.OverlayController.DidManualSearch += (object sender, SIOverlayControllerDidManualSearchEventArgs e) => {
ProcessBarcode (convertToNumber(e.Text.ToUpper()));
};
picker.OverlayController.ShowSearchBar (true);
picker.OverlayController.SetSearchBarKeyboardType (UIKeyboardType.ASCIICapable);
picker.OverlayController.setSearchBarActionButtonCaption ("Search");
View.AddSubview (picker.View);
Shared.Database db = new Shared.Database();
db.Initialize();
int campusID = db.getCampusID();
classPicker = new UIPickerView ();
List<Area> Classes = dl.getSecureAreas (campusID).ToList();
classPicker.Model = new Shared.ClassPickerViewModel (Classes);
View.AddSubview (classPicker);
eventPicker = new UIPickerView ();
List<Event> Events = dl.getUpcomingEvents (campusID).ToList ();
eventPicker.Model = new Shared.EventPickerViewModel (Events);
View.AddSubview (eventPicker);
checkInOut = new UISegmentedControl ();
checkInOut.InsertSegment ("Check IN", 0, true);
checkInOut.InsertSegment ("Check OUT", 1, true);
checkInOut.SelectedSegment = 0;
View.AddSubview (checkInOut);
note = new UILabel ();
note.Text = "Select the class and event you are checking kids INTO or OUT of:";
View.AddSubview (note);
picker.StartScanning ();
ConfigureSizing ();
}
示例13: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
this.Title = "Programmatic Segmented Controls";
segControl1 = new UISegmentedControl ();
segControl1.ControlStyle = UISegmentedControlStyle.Bordered;
segControl1.InsertSegment ("One", 0, false);
segControl1.InsertSegment ("Two", 1, false);
segControl1.SetWidth (100f, 1);
segControl1.SelectedSegment = 1;
segControl1.Frame = new System.Drawing.RectangleF (20, 20, 280, 44);
this.View.AddSubview (segControl1);
segControl1.ValueChanged += delegate(object sender, EventArgs e) {
Console.WriteLine ("Item " + (sender as UISegmentedControl).SelectedSegment.ToString () + " selected");
};
}
示例14: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
Title = "Programmatic Segmented Controls";
segControl = new UISegmentedControl {
Frame = new CGRect (20, 20, 280, 44),
ControlStyle = UISegmentedControlStyle.Bordered,
SelectedSegment = 1,
};
segControl.InsertSegment ("One", 0, false);
segControl.InsertSegment ("Two", 1, false);
segControl.SetWidth (100f, 1);
View.AddSubview (segControl);
segControl.ValueChanged += (object sender, EventArgs e) => {
var selectedSegment = ((UISegmentedControl)sender).SelectedSegment;
Console.WriteLine (string.Format ("Item {0} selected", selectedSegment));
};
}
示例15: MakeSegmentedControl
public UISegmentedControl MakeSegmentedControl()
{
seg = new UISegmentedControl(new RectangleF(0, 0, 200, 25));
seg.InsertSegment("Highlights", 0, false);
seg.InsertSegment("Popular", 1, false);
seg.SelectedSegment = 0;
seg.ControlStyle = UISegmentedControlStyle.Bar;
seg.ValueChanged += delegate(object sender, EventArgs e) {
if (seg.SelectedSegment == 0)
{
(TableView.Source as DataSource).LoadPrograms(IplayerConst.HighlightsFeedUrl);
} else {
(TableView.Source as DataSource).LoadPrograms(IplayerConst.MostPopularFeedUrl);
}
};
return seg;
}