本文整理汇总了C#中Xamarin类的典型用法代码示例。如果您正苦于以下问题:C# Xamarin类的具体用法?C# Xamarin怎么用?C# Xamarin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Xamarin类属于命名空间,在下文中一共展示了Xamarin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnElementChanged
protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<View> e)
{
base.OnElementChanged (e);
if (e.OldElement == null && e.NewElement != null) {
//map created the first time
page = GetContainingPage (e.NewElement);
navPage = (page.Parent as myNavPage);
navPage.Popped += OnPagePopped;
//return;
}
var formsMap = (ExtendedMap)Element;
var androidMapView = (MapView)Control;
if (myMarkers == null)
myMarkers = new List<Marker> ();
if (androidMapView != null && androidMapView.Map != null) {
androidMapView.Map.InfoWindowClick += MapOnInfoWindowClick;
}
//if (formsMap != null) {
// ((ObservableCollection<Pin>)formsMap.Pins).CollectionChanged += OnCollectionChanged;
//}
}
示例2: OnElementChanged
protected override void OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs<Xamarin.Forms.Button> e)
{
base.OnElementChanged (e);
if (e.NewElement != null) {
Control.TouchUpInside += delegate(object sender, EventArgs e2) {
var formsView = new CommonFormsView ();
var rect = new CGRect (0, 0, 400, 400);
var iOSView = FormsViewToNativeiOS.ConvertFormsToNative (formsView, rect);
var viewController = new UIViewController();
viewController.Add(iOSView);
viewController.View.Frame = rect;
var popoverController = new UIPopoverController(viewController);
popoverController.ContentViewController.View.BackgroundColor = viewController.View.BackgroundColor;
popoverController.PopoverContentSize = rect.Size;
var frame = UIApplication.SharedApplication.KeyWindow.RootViewController.View.Frame;
popoverController.PresentFromRect (Control.Frame, UIApplication.SharedApplication.KeyWindow.RootViewController.View, 0, true);
};
}
}
示例3: OnElementChanged
protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.Editor> e)
{
base.OnElementChanged(e);
if (e.OldElement != null || this.Element == null)
return;
updateBackground();
}
示例4: OnElementChanged
protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<View> e)
{
base.OnElementChanged(e);
var formsMap = (Xam.Plugin.MapExtend.Abstractions.MapExtend)Element;
var androidMapView = (Android.Gms.Maps.MapView)Control;
if (formsMap != null)
{
//((System.Collections.ObjectModel.ObservableCollection<Xamarin.Forms.Maps.Pin>)formsMap.Pins).CollectionChanged += OnPinsCollectionChanged;
((ObservableRangeCollection<Position>)formsMap.polilenes).CollectionChanged += OnPolCollectionChanged;
((ObservableRangeCollection<PinExtend>)formsMap.EPins).CollectionChanged += OnEPinCollectionChanged;
androidMapView.Map.MarkerDragEnd += Map_MarkerDragEnd;
androidMapView.Map.MapLongClick += (s, a) =>
{
formsMap.Pins.Add(new Pin
{
Label = "Meu Endereço",
Position = new Position(a.Point.Latitude, a.Point.Longitude)
}
);
};
}
}
示例5: OnElementChanged
/// <summary>
/// Mapの生成時に呼び出される
/// </summary>
/// <param name="e">E.</param>
protected override void OnElementChanged(Xamarin.Forms.Platform.iOS.ElementChangedEventArgs<View> e)
{
base.OnElementChanged(e);
if (Element == null)
return;
// Elementをキャストして、共通クラスで定義したMapを取得
var formsMap = (CustomMap)Element;
// ↑で取得したマップから、初期の中心座標を取得
var position = formsMap.firstPosition;
// カメラ位置(中心座標と表示領域)を設定
var camera = CameraPosition.FromCamera(position.Latitude, position.Longitude, 10);
// マップを作成
var mapView = MapView.FromCamera(CoreGraphics.CGRect.Empty, camera);
// 現在地を表示
mapView.MyLocationEnabled = true;
// 現在位置へ移動ボタンを表示
mapView.Settings.MyLocationButton = true;
// コントロールに作成したMapViewを設定
// これにより、ここで生成したMapViewがFormsのマップの代わりに扱われるようになる
SetNativeControl(mapView);
}
示例6: OnElementChanged
protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<TimePicker> e)
{
base.OnElementChanged(e);
this.Control.SetTextColor(AppConstants.ColorDarkGrey.ToAndroid());
this.Control.SetTextSize(Android.Util.ComplexUnitType.Pt, 10);
}
示例7: GetSpanColor
/// <summary>
/// Gets the color of the span.
/// </summary>
/// <param name="color">The color.</param>
/// <param name="defaultColors">The default colors.</param>
/// <returns>Android.Graphics.Color.</returns>
public Android.Graphics.Color GetSpanColor(Xamarin.Forms.Color color, ColorStateList defaultColors)
{
if (color == Xamarin.Forms.Color.Default)
return new Android.Graphics.Color(defaultColors.DefaultColor);
return color.ToAndroid();
}
示例8: PushPage
public virtual async Task PushPage (Xamarin.Forms.Page page, FreshBasePageModel model, bool modal = false, bool animated = true)
{
if (modal)
await Navigation.PushModalAsync (new NavigationPage(page), animated);
else
await ((NavigationPage)_tabbedNavigationPage.CurrentPage).PushAsync (page, animated);
}
示例9: XFPopupDlg
public XFPopupDlg(Page _parent, Xamarin.Forms.View _content, bool _cancelable, String _title, bool _rightClose, String _ok, String _ko)
{
var g = GenDialog (_content, _cancelable, _title, _rightClose, _ok, _ko);
var svr = DependencyService.Get<IXFPopupSrvc> ();
dlgNative = svr.CreateDialog(_parent, g, _cancelable);
}
示例10: OnElementChanged
private static String SAMPLE = dir + "Video_2014_5_7__15_33_44.mpg";//"Video_2014_5_8__9_12_35.mpg";//"Video_2014_5_6__15_55_19.mpg";//
protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.View> e)
{
Android.Util.Log.Debug(this.GetType().Name, "OnElementChanged()");
Android.Util.Log.Debug("Android API-int: ", Android.OS.Build.VERSION.Sdk);
Android.Util.Log.Debug("Android API build: ", ""+Android.OS.Build.VERSION.SdkInt);
Android.Util.Log.Debug("Android API: ", Android.OS.Build.VERSION.Codename);
//first call into this method, the render was just created?
if (e.OldElement == null)
{
surf = new SurfaceView(Context);
myV = e.NewElement;//capture our Xamarin View.
Android.Util.Log.Debug("X =", myV.X.ToString());
myV.SizeChanged += myV_SizeChanged;
myV.PropertyChanged += myV_PropertyChanged;
base.SetNativeControl(surf);
surf.Holder.AddCallback(this);
}
}
示例11: GetCell
public override UIKit.UITableViewCell GetCell(Xamarin.Forms.Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv)
{
var cell = base.GetCell(item, reusableCell, tv);
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
return cell;
}
示例12: HandleSubMenu
private static async void HandleSubMenu(Xamarin.Forms.MenuItem item, object parameter)
{
var cascadeMenuItem = item as CascadeMenuItem;
var menu = cascadeMenuItem.SubMenu;
if (menu == null || !menu.Any()) return;
var element = cascadeMenuItem.Page;
if (element != null)
{
var result = await element.DisplayActionSheet(item.Text, cancel: null, destruction: null,
buttons: menu
.Select(i => i.Text)
.ToArray());
if (result != null)
{
var selectedItem = menu.First(x => x.Text == result);
if (selectedItem.Command?.CanExecute(selectedItem) == true)
{
selectedItem.Command.Execute(parameter);
}
}
}
}
示例13: PushPage
public async virtual Task PushPage (Xamarin.Forms.Page page, FreshBasePageModel model, bool modal = false, bool animate = true)
{
if (modal)
await Navigation.PushModalAsync (CreateContainerPage (page), animate);
else
await Navigation.PushAsync (page, animate);
}
示例14: OnElementChanged
protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.DatePicker> e)
{
base.OnElementChanged(e);
this.Control.SetTextColor(Android.Graphics.Color.Black);
this.Control.SetTextSize(Android.Util.ComplexUnitType.Pt, 12);
}
示例15: GetCellCore
protected override View GetCellCore (Xamarin.Forms.Cell item, View convertView, ViewGroup parent, Context context)
{
var viewModel = (FullScheduleCellViewModel)item.BindingContext;
LayoutInflater layoutInflater = LayoutInflater.FromContext (context);
// creates the text color to be used depending on the track of the session
var textColor = ((Xamarin.Forms.Color)new TrackTextColorConverter ()
.Convert (viewModel.Track, typeof(Xamarin.Forms.Color),
null, CultureInfo.CurrentCulture))
.ToAndroid ();
var view = convertView;
//if (view == null)
view = layoutInflater.Inflate (Resource.Layout.FullScheduleCell, null);
SetupTitle (view, viewModel, textColor, true);
SetupLocation (view, viewModel, textColor, true);
SetupTrack (view, viewModel, textColor, true);
if(viewModel.IsOptional)
SetupSelectButton (view, viewModel, textColor);
// set the background color of the cell to the appropriate track color
Color background = ((Xamarin.Forms.Color)new TrackBackgroundColorConverter ()
.Convert (viewModel.Track, typeof(Xamarin.Forms.Color), null, CultureInfo.CurrentCulture)).ToAndroid ();
view.SetBackgroundColor (background);
return view;
}