maui-linux/Xamarin.Forms.Core/ToolbarItem.cs

61 строка
1.7 KiB
C#
Исходник Обычный вид История

2016-03-22 23:02:25 +03:00
using System;
using System.ComponentModel;
2016-03-22 23:02:25 +03:00
namespace Xamarin.Forms
{
public class ToolbarItem : MenuItem
{
static readonly BindableProperty OrderProperty = BindableProperty.Create("Order", typeof(ToolbarItemOrder), typeof(ToolbarItem), ToolbarItemOrder.Default, validateValue: (bo, o) =>
{
var order = (ToolbarItemOrder)o;
return order == ToolbarItemOrder.Default || order == ToolbarItemOrder.Primary || order == ToolbarItemOrder.Secondary;
});
static readonly BindableProperty PriorityProperty = BindableProperty.Create("Priority", typeof(int), typeof(ToolbarItem), 0);
public ToolbarItem()
{
}
public ToolbarItem(string name, string icon, Action activated, ToolbarItemOrder order = ToolbarItemOrder.Default, int priority = 0)
2016-03-22 23:02:25 +03:00
{
if (activated == null)
throw new ArgumentNullException("activated");
Text = name;
[WIP] Unify the image handling (#4915) * Initial code to get unifiied image handling - not yet tested - still using FileImageSource in some areas * Updated the button renderers and added tests for Android * Updated a few more of the Android renderers - also added an `IsEmpty` property to the ImageSource to indicate if this source actually contains data that can be used to try and load an image - added a few more "tests" - includes the changes for #4916 * A few more changes * Keep the default page for the sample app * Changing everything to ImageSource and going from there - Android, iOS, UWP and WPF are compiling - GTK, Mac and Tizen are not yet finished - Added a new interface for UWP to return an IconElement in addition to ImageSource (for app bar buttons) - not tested yet, nor are there any tests * Renamed the property to be more useful * All of Android is now async - still only minimal tests - also removed the bits that are in https://github.com/xamarin/Xamarin.Forms/pull/4948 * Update Xamarin.Forms.Platform.cs * A few fixes to whitespace and nameof() * Updated iOS and UWP wirth async image sources * A few fixes and WPF support * A few fixes for Android after the big merge * Updated a few more loaders: - ios - macos - tizen - gtk * Fix a few things after the merge * - cast type to FileImageSource * fix setting of title content if icon doesn't load * fix IButtonLayoutManager to return correct control * remove cast and add pack api * - fix timing issues with layout/invalidation * - remove aggresive element invalidations for now * first set of api changes * obsolete old apis and create new ones for ImageSource * obsolete messages and static ordering fix * add tests * switch default on windows to show images on tabs * - XStatic obsolete fix * fix NPC test and bring back alert check on uwp Fixes #3207 Fixes #4689
2019-04-26 23:46:13 +03:00
IconImageSource = icon;
2016-03-22 23:02:25 +03:00
Clicked += (s, e) => activated();
Order = order;
Priority = priority;
}
[Obsolete("Name is obsolete as of version 1.3.0. Please use Text instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
2016-03-22 23:02:25 +03:00
public string Name
{
get { return Text; }
set { Text = value; }
}
public ToolbarItemOrder Order
{
get { return (ToolbarItemOrder)GetValue(OrderProperty); }
set { SetValue(OrderProperty, value); }
}
public int Priority
{
get { return (int)GetValue(PriorityProperty); }
set { SetValue(PriorityProperty, value); }
}
[Obsolete("Activated is obsolete as of version 1.3.0. Please use Clicked instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
2016-03-22 23:02:25 +03:00
public event EventHandler Activated
{
add { Clicked += value; }
remove { Clicked -= value; }
}
}
}