protected override void SetBindingContext() { typePicker = ControlFactory.CreatePicker(); typePicker.SelectedIndexChanged += TypePicker_SelectedIndexChanged; typePicker.SelectedItemChanged += Picker_SelectedItemChanged; projectPicker = ControlFactory.CreatePicker(); projectPicker.HorizontalOptions = LayoutOptions.FillAndExpand; projectPicker.SelectedItemChanged += Picker_SelectedItemChanged; // Create a filter for showing projects only if the time entry can be edited. if (this.ViewModel.CanEdit()) { filterIcon = ControlFactory.CreateIcon(LabelHandler.FILTER_SYMBOL, ControlFactory.Small_Label_Icon); } projectTaskPicker = ControlFactory.CreatePicker(); projectTaskPicker.HorizontalOptions = LayoutOptions.FillAndExpand; projectTaskPicker.SelectedItemChanged += Picker_SelectedItemChanged; transactionDatePicker = ControlFactory.CreateDatePicker("Time.msdyn_date_utc", DateTime.MaxValue, "D"); // Use a one-way binding from view model to view because of the custom formatting that we have. We want the user to be able to type anything in the text box // but on losing focus from the field, we validate and store the duration in the view model. durationEntry = ControlFactory.CreateEntry("Time.msdyn_duration", BindingMode.OneWay, Keyboard.Default, null, "", new DurationTo24HourStringConverter()); durationEntry.Unfocused += DurationEntry_Unfocused; internalDescriptionEditor = ControlFactory.CreateEditor("Time.msdyn_description"); internalDescriptionEditor.TextChanged += this.createEditorTextChangedHandler(msdyn_timeentry.DescriptionLength); externalDescriptionEditor = ControlFactory.CreateEditor("Time.msdyn_externalDescription"); externalDescriptionEditor.TextChanged += this.createEditorTextChangedHandler(msdyn_timeentry.DescriptionLength); this.BindingContext = ViewModel; }
public VaultListViewCell(Action <VaultListPageModel.Cipher> moreClickedAction, bool groupingOrCipherBinding = false) { string bindingPrefix = null; if (groupingOrCipherBinding) { SetBinding(GroupingOrCipherParameterProperty, new Binding(".")); bindingPrefix = string.Concat(nameof(VaultListPageModel.GroupingOrCipher.Cipher), "."); Button.Command = new Command(() => moreClickedAction?.Invoke(GroupingOrCipherParameter?.Cipher)); } else { SetBinding(CipherParameterProperty, new Binding(".")); Button.Command = new Command(() => moreClickedAction?.Invoke(CipherParameter)); } Label.SetBinding(Label.TextProperty, bindingPrefix + nameof(VaultListPageModel.Cipher.Name)); Detail.SetBinding(Label.TextProperty, bindingPrefix + nameof(VaultListPageModel.Cipher.Subtitle)); LabelIcon.SetBinding(VisualElement.IsVisibleProperty, bindingPrefix + nameof(VaultListPageModel.Cipher.Shared)); LabelIcon2.SetBinding(VisualElement.IsVisibleProperty, bindingPrefix + nameof(VaultListPageModel.Cipher.HasAttachments)); Button.Image = "more.png"; Button.BackgroundColor = Color.Transparent; LabelIcon.Source = "share.png"; LabelIcon2.Source = "paperclip.png"; BackgroundColor = Color.White; }
public Texture2D GetIcon(LabelIcon icon) { if (labelIcons == null) { labelIcons = GetTextures("sv_label_", string.Empty, 0, 8); } return(labelIcons[(int)icon].image as Texture2D); }
public static void SetIcon(GameObject gObj, LabelIcon icon) { if (labelIcons == null) { labelIcons = GetTextures("sv_label_", string.Empty, 0, 8); } SetIcon(gObj, labelIcons[(int)icon].image as Texture2D); }
public static void AddTargetIcon(GameObject g, LabelIcon icon) { Texture2D tex = EditorGUIUtility.IconContent("sv_label_" + (int)icon).image as Texture2D; Type editorGUIUtilityType = typeof(EditorGUIUtility); BindingFlags bindingFlags = BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic; object[] args = new object[] { g, tex }; editorGUIUtilityType.InvokeMember("SetIconForObject", bindingFlags, null, null, args); }
protected override void OnElementChanged(ElementChangedEventArgs <Label> e) { base.OnElementChanged(e); TextView native = Control as TextView; LabelIcon newElement = e.NewElement as LabelIcon; if (native != null && newElement != null) { var fontFamily = string.IsNullOrEmpty(newElement.FontFamily) ? "Fonts/DynamicsSymbol.ttf" : e.NewElement.FontFamily.TrimStart('/').Replace("Assets/", string.Empty); native.Typeface = TypefaceHelper.GetTypeface(Forms.Context, fontFamily); } }
protected override void OnElementChanged(ElementChangedEventArgs <Label> e) { base.OnElementChanged(e); var native = (UILabel)Control; LabelIcon newElement = e.NewElement as LabelIcon; if (native != null && newElement != null) { var fontFamily = string.IsNullOrEmpty(newElement.FontFamily) ? "Dynamics Symbol" : e.NewElement.FontFamily; native.Font = UIFont.FromName(fontFamily, native.Font.PointSize); } }
/// <summary> /// Change current filter and open the look up /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected async void FilterProject(object sender, EventArgs e) { LabelIcon filterIcon = sender as LabelIcon; if (filterIcon != null) { FilterQuery filter = await this.SetProjectFilterName(filterIcon, true); if (filter != null) { ControlFactory.SetItems(projectPicker, filter.Result); } } }
public static void SetLabelIcon(GameObject _object, LabelIcon _label_icon) { if (_LabelIcons == null) { _LabelIcons = GetTextrues("sv_label_", string.Empty, 0, 8); } if (_label_icon == LabelIcon.None) { RemoveIcon(_object); } else { InternalSetIcon(_object, _LabelIcons[(int)_label_icon].image as Texture2D); } }
public VaultListViewCell(Action <VaultListPageModel.Login> moreClickedAction) { SetBinding(LoginParameterProperty, new Binding(".")); Label.SetBinding <VaultListPageModel.Login>(Label.TextProperty, l => l.Name); Detail.SetBinding <VaultListPageModel.Login>(Label.TextProperty, l => l.Username); LabelIcon.SetBinding <VaultListPageModel.Login>(VisualElement.IsVisibleProperty, l => l.Shared); Button.Image = "more"; Button.Command = new Command(() => moreClickedAction?.Invoke(LoginParameter)); Button.BackgroundColor = Color.Transparent; LabelIcon.Source = "share"; BackgroundColor = Color.White; }
public static void SetIcon(GameObject gObj, LabelIcon icon) { if (labelIcons == null) { labelIcons = GetTextures("sv_label_", string.Empty, 0, 8); } if (icon == LabelIcon.None) { RemoveIcon(gObj); } else { Internal_SetIcon(gObj, labelIcons[(int)icon].image as Texture2D); } }
public static GUIContent[] GetGUIContents(LabelIcon labelIcon) { var methodInfo = GetMethodInfo_IconContent(); object[] parameters = new object[] { "sv_label_" + labelIcon.ToString() }; int length = (int)LabelIcon.Length; GUIContent[] contents = new GUIContent[length]; for (int i = 0; i < length; i++) { contents[i] = methodInfo.Invoke(null, parameters) as GUIContent; } return(contents); }
public VaultListViewCell(Action <VaultListPageModel.Cipher> moreClickedAction) { SetBinding(CipherParameterProperty, new Binding(".")); Label.SetBinding(Label.TextProperty, nameof(VaultListPageModel.Cipher.Name)); Detail.SetBinding(Label.TextProperty, nameof(VaultListPageModel.Cipher.Subtitle)); LabelIcon.SetBinding(VisualElement.IsVisibleProperty, nameof(VaultListPageModel.Cipher.Shared)); LabelIcon2.SetBinding(VisualElement.IsVisibleProperty, nameof(VaultListPageModel.Cipher.HasAttachments)); Button.Image = "more.png"; Button.Command = new Command(() => moreClickedAction?.Invoke(CipherParameter)); Button.BackgroundColor = Color.Transparent; LabelIcon.Source = "share.png"; LabelIcon2.Source = "paperclip.png"; BackgroundColor = Color.White; }
/// <summary> /// Create an Icon /// </summary> /// <param name="icon"></param> /// <param name="style">Style of the icon, by default it will be Label_Icon</param> /// <returns></returns> public static LabelIcon CreateIcon(string icon = null, string style = Label_Icon) { LabelIcon label = new LabelIcon(); label.Text = icon; if (style != null) { label.Style = (Style)Application.Current.Resources[style.ToString()]; if (style == Label_Icon || style == Small_Label_Icon || style == Medium_Label_Icon) { label.FontFamily = Device.OnPlatform( "Dynamics Symbol", null, //render "Assets/Fonts/DynamicsSymbol.ttf#Dynamics Symbol" ); } } return(label); }
public static void SetIconForObject(GameObject obj, LabelIcon icon) { SetIconForObject(obj, IconHelper.LabelIcons[(int)icon].image as Texture2D); }
public TimePreview(TimeCollectionViewModel timeCollectionViewModel = null) { Orientation = StackOrientation.Vertical; Padding = 0; Spacing = 0; this.BackgroundColor = BaseApp.PAGE_BACKGROUND_COLOR; StackLayout rootLayout = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 10, Padding = 6, Orientation = StackOrientation.Horizontal, }; this.Children.Add(rootLayout); if (timeCollectionViewModel != null) { selectedIcon = ControlFactory.CreateIcon(null, ControlFactory.Medium_Label_Icon); selectedIcon.TextColor = Color.Black; selectedIcon.FontSize = Device.OnPlatform(10, 12, 16); selectedIcon.VerticalOptions = LayoutOptions.CenterAndExpand; selectedIcon.HorizontalOptions = LayoutOptions.Start; selectedIcon.SetBinding(LabelIcon.IsVisibleProperty, new Binding() { Source = timeCollectionViewModel, Path = "MultiselectModeEnabled" }); selectedIcon.SetBinding(LabelIcon.TextProperty, "Selected", converter: new BooleanToSelectedIconConverter()); rootLayout.Children.Add(selectedIcon); } entryTypeIcon = ControlFactory.CreateIcon(null, ControlFactory.Medium_Label_Icon); entryTypeIcon.SetBinding(Label.TextProperty, new Binding("msdyn_type", BindingMode.OneWay, new TimeEntryTypeToIconConverter())); entryTypeIcon.SetBinding(Label.TextColorProperty, new Binding(".", BindingMode.OneWay, new TimeEntryToColorConverter())); entryTypeIcon.VerticalOptions = LayoutOptions.Center; projectNameLabel = ControlFactory.CreateLabel(".", valueConverter: new TimeEntryToTitleConverter()); projectNameLabel.HorizontalOptions = LayoutOptions.FillAndExpand; projectNameLabel.VerticalOptions = LayoutOptions.FillAndExpand; timeLabel = ControlFactory.CreateLabel("msdyn_duration", "{0}", null, new DurationToStringConverter()); timeLabel.XAlign = TextAlignment.End; timeLabel.MinimumWidthRequest = 100; statusLabel = ControlFactory.CreateLabel("msdyn_entryStatus", "{0}", ControlFactory.Label_Indicator, new OptionSetConverter <msdyn_timeentry_msdyn_entrystatus>()); statusLabel.XAlign = TextAlignment.End; statusLabel.VerticalOptions = LayoutOptions.End; StackLayout timeAndStatusLayout = new StackLayout { HorizontalOptions = LayoutOptions.End, Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand, Padding = 0, Spacing = 0, Children = { timeLabel, statusLabel } }; rootLayout.Children.Add(entryTypeIcon); rootLayout.Children.Add(projectNameLabel); rootLayout.Children.Add(timeAndStatusLayout); rootLayout.Children.Add(new Grid { Padding = 0, WidthRequest = Device.OnPlatform <double>(15, 0, 0), BackgroundColor = Color.Transparent }); this.Children.Add(new Grid { Padding = 0, HeightRequest = 1, BackgroundColor = Color.FromHex("dddddd") }); }
public static void SetIcon(GameObject gameObject, LabelIcon labelIcon) { SetIcon(gameObject, $"sv_label_{(int) labelIcon}"); }
public ExpensePreview() { this.BackgroundColor = BaseApp.PAGE_BACKGROUND_COLOR; RowSpacing = 2; RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = 6 }, // 0.Margin new RowDefinition { Height = GridLength.Auto }, // 1.Icon, preview, amount new RowDefinition { Height = GridLength.Auto }, // 2.Icon, date, status new RowDefinition { Height = 6 }, // 3.Margin new RowDefinition { Height = 1 } // 4.Separator }; ColumnSpacing = 1; ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = 25 }, // 0.margin or indicator new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }, // 1.icon new ColumnDefinition { Width = 10 }, // 2.margin new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }, // 3.preview and date new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, // 4.amount and status new ColumnDefinition { Width = 15 } // 5.margin }; // Create views with bindings for displaying each property. amountLabel = ControlFactory.CreateLabel("FormattedTransactionAmount", null, ControlFactory.Label_BigAmount); previewLabel = ControlFactory.CreateLabel("msdyn_ExpenseCategory.Name"); transactionDateLabel = ControlFactory.CreateLabel("msdyn_TransactionDate", "{0:D}", ControlFactory.Label_Subtitle); statusLabel = ControlFactory.CreateLabel("msdyn_ExpenseStatus", "{0}", ControlFactory.Label_Indicator, new OptionSetConverter <msdyn_expense_msdyn_expensestatus>()); separator = new BoxView(); separator.HeightRequest = 1; separator.Color = Color.FromHex("#FFE1E3E4"); LabelIcon attachment = ControlFactory.CreateIcon(LabelHandler.ATTACH_SYMBOL, ControlFactory.Small_Label_Icon); attachment.Opacity = 0.8; attachment.SetBinding(Image.IsVisibleProperty, "HasReceipts"); expenseTypeIcon = ControlFactory.CreateIcon(null, ControlFactory.Label_Icon); expenseTypeIcon.SetBinding(Label.TextProperty, new Binding("ExpenseCategory.msdyn_ExpenseType", BindingMode.OneWay, new ExpenseTypeToIconConverter())); expenseTypeIcon.SetBinding(Label.TextColorProperty, new Binding("ExpenseCategory.msdyn_ExpenseType", BindingMode.OneWay, new ExpenseTypeToColorConverter())); int row = 1; this.Children.Add(attachment, 0, 1, row, row + 2); this.Children.Add(expenseTypeIcon, 1, 2, row, row + 2); this.Children.Add(previewLabel, 3, row); this.Children.Add(amountLabel, 4, row); row++; this.Children.Add(transactionDateLabel, 3, row); this.Children.Add(statusLabel, 4, row); row = row + 2; this.Children.Add(separator, 0, 6, row, row + 1); }
public static void SetIcon(this GameObject gameObject, LabelIcon labelIcon) { IconManager.SetIcon(gameObject, labelIcon); }
public static void SetIconForObject(GameObject go, LabelIcon icon) { SetIconForObject(go, IconHelper.LabelIcons[(int)icon].image as Texture2D); }
/// <summary> /// Sets the label of the project filter /// </summary> /// <param name="filterIcon">Label with the filter symbol</param> /// <param name="switchFilter">True if before setting the name it should switch</param> /// <returns>Current Filter</returns> protected async System.Threading.Tasks.Task <FilterQuery> SetProjectFilterName(LabelIcon filterIcon, bool switchFilter = false) { if (filterIcon != null) { FilterQuery filter = await this.ViewModel.GetFilterProject(switchFilter); if (filter != null) { filterIcon.Text = String.Format("{0} {1}", LabelHandler.FILTER_SYMBOL, filter.Name); return(filter); } } return(null); }
protected override void CreateContent(StackLayout details) { LabelIcon filterIcon = ControlFactory.CreateIcon(LabelHandler.FILTER_SYMBOL, ControlFactory.Small_Label_Icon); SetProjectFilterName(filterIcon); object[] expenseDetailsRows = { new Xamarin.Forms.View[] { ControlFactory.CreateStaticLabel(AppResources.Project), filterIcon, }, projectPicker, null, ControlFactory.CreateStaticLabel(AppResources.Category), categoryPicker, null, ControlFactory.CreateStaticLabel(AppResources.Date), transactionDatePicker, null, new Xamarin.Forms.View[] { ControlFactory.CreateStaticLabel(AppResources.Amount), ControlFactory.CreateStaticLabel(AppResources.Currency) }, new Xamarin.Forms.View[] { amountEntry, currencyPicker }, null, ControlFactory.CreateStaticLabel(AppResources.SalesTax), salesTaxEntry, null, ControlFactory.CreateStaticLabel(AppResources.Description), descriptionEditor }; TapGestureRecognizer filterTapGestureRecognizer = new TapGestureRecognizer() { NumberOfTapsRequired = 1 }; filterTapGestureRecognizer.Tapped += FilterProject; filterIcon.GestureRecognizers.Add(filterTapGestureRecognizer); // Add Expense preview at top of the page Grid expensePreview = new ExpensePreview(); expensePreview.SetBinding <ExpenseViewModel>(Grid.BindingContextProperty, vm => vm.Expense, BindingMode.OneWay); expensePreview.RowDefinitions[0].Height = 0; // Remove default margin at top expensePreview.RowDefinitions.Add(new RowDefinition { Height = 10 }); //Margin bottom details.Children.Add(expensePreview); // Add expense details Grid expenseDetails = new Grid(); expenseDetails.ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = 10 }, // 0.Margin new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, // 1. 1st column new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, // 2. 2nd column new ColumnDefinition { Width = 10 } // 3.margin }; expenseDetails.ColumnSpacing = 2; expenseDetails.RowSpacing = 0; ControlFactory.AutoFill(expenseDetails, expenseDetailsRows, 1, 2); details.Children.Add(new ScrollView() { Content = expenseDetails }); }
public static GUIContent GetGUIContent(LabelIcon labelIcon) { var methodInfo = GetMethodInfo_IconContent(); return(methodInfo.Invoke(null, new object[] { "sv_label_" + labelIcon.ToString() }) as GUIContent); }
/// <summary> /// 设置游戏对象的 Selection Icon /// </summary> /// <param name="gameObject"></param> /// <param name="labelIcon">Selection Icon 类型:带文字</param> public static void SetSelectionIcon(UnityEngine.Object obj, LabelIcon labelIcon) { SetSelectionIcon(obj, GetGUIContent(labelIcon).image as Texture2D); }