} // eo TexturePicker /// <summary> /// Creates a window with buttons to select a new image. /// </summary> /// <param name='paths'> /// Paths to load images from. /// </param> /// <param name='functionHandler'> /// How to handle the new image selection. /// </param> public static void TexturePicker(string[] paths, ImageSelectedHandler functionHandler) { TexturePickerEditor picker = (TexturePickerEditor)EditorWindow.GetWindow(typeof(TexturePickerEditor), true, "Texture Picker"); picker.Setup(paths, functionHandler); } // eo TexturePicker
public WrappedItemSelectionTemplate(ImageSelectedHandler parentHandler) : base() { _parentHandler = parentHandler; // ... View = st; }
} // eo TexturePreviewWithSelection public static void TexturePicker(string path, ImageSelectedHandler functionHandler) { EditorUtilities.TexturePicker(new string[] { path }, functionHandler); } // eo TexturePicker
public static void TexturePreviewWithSelection(string label, Texture selectedImage, float yPosition, string textureFilePaths, ImageSelectedHandler functionHandler) { TexturePreviewWithSelection(label, selectedImage, yPosition, new string[] { textureFilePaths }, functionHandler); } // eo TexturePreviewWithSelection
} // eo TexturePreviewWithSelection /// <summary> /// Shows a texture with a label and a button to select a new image /// from a list of images loaded from the paths specified. This allows /// a selection of an image from a subset of images, unlike the UnityEditor.ObjectField /// that pulls all images from /Assets/ /// </summary> /// <param name='label'> /// Label to display. /// </param> /// <param name='selectedImage'> /// Selected image that shows in the interface. /// </param> /// <param name='yPosition'> /// How far down in the interface to show this tool. /// </param> /// <param name='textureFilePaths'> /// Texture file paths containing the images to load. /// </param> /// <param name='functionHandler'> /// The function to handle the selection of a new texture. /// </param> public static void TexturePreviewWithSelection(string label, Texture selectedImage, float yPosition, string[] textureFilePaths, ImageSelectedHandler functionHandler) { EditorGUILayout.BeginVertical(GUILayout.Height(125)); { EditorGUILayout.LabelField(label); EditorGUI.DrawPreviewTexture(new Rect(50, yPosition, 100, 100), selectedImage); // used to center the select texture button EditorGUILayout.BeginVertical(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Select Texture", GUILayout.MaxWidth(100))) { EditorUtilities.TexturePicker(textureFilePaths, functionHandler); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); } // eo TexturePreviewWithSelection
} // eo Setup /// <summary> /// Attempts to setup the editor by reading in all textures specified /// by the various paths. Supports multiple paths of textures. /// </summary> /// <param name='paths'> /// Paths of textures to read in. /// </param> public void Setup(string[] paths, ImageSelectedHandler functionHandler) { m_isSetup = true; ReadInAllTextures(paths); m_handler = functionHandler; } // eo Setup
/// <summary> /// Attempts to setup the editor by reading in textures from specified path. /// </summary> /// <param name='path'> /// Path to load images from. /// </param> public void Setup(string path, ImageSelectedHandler functionHandler) { string[] paths = new string[] { path }; Setup(paths, functionHandler); } // eo Setup
public WrappedItemSelectionTemplate(ImageSelectedHandler parentHandler) : base() { _parentHandler = parentHandler; List <ListItems> items = new List <ListItems>(); if (Application.Current.Properties.ContainsKey("SelectedPage")) { if (Application.Current.Properties["SelectedPage"].ToString() == "recording") { items = RecordingListPage.items; } else { items = RecordingDetailsPage.items; } } Grid objGrid = new Grid(); // objGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); objGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(75, GridUnitType.Absolute), }); objGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); objGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(75, GridUnitType.Absolute), }); // Column 1:- Image objImage = new Image(); objImage.SetBinding(Image.SourceProperty, new Binding("Item.Image")); objGrid.Children.Add(objImage, 0, 0); StackLayout objStackLayoutCol2 = new StackLayout(); objGrid.Children.Add(objStackLayoutCol2, 1, 0); Label name = new Label() { Text = "Name", Style = (Style)Application.Current.Resources["LabelStyle"], }; Label date = new Label() { Text = "Date", Style = (Style)Application.Current.Resources["LabelStyleTiny"] }; name.SetBinding(Label.TextProperty, new Binding("Item.Name")); date.SetBinding(Label.TextProperty, new Binding("Item.Date")); objStackLayoutCol2.Children.Add(name); objStackLayoutCol2.Children.Add(date); objStackLayoutCol2.Padding = new Thickness(10); Image objImageView = new Image(); objImageView.Source = Device.OnPlatform("Icons/ic_mode_edit.png", "Search.png", "Images/Search.png"); //ImageSource.FromFile("Search.png"); StackLayout stv = new StackLayout(); stv.Children.Add(objImageView); stv.Padding = new Thickness(10); stv.HorizontalOptions = LayoutOptions.Center; stv.VerticalOptions = LayoutOptions.Center; objImageView.SetBinding(Image.SourceProperty, "IsSelected", converter: new TickConverter()); objImage.StyleId = items[i].Id.ToString(); i++; if (i == items.Count) { i = 0; } var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.Tapped += OnImageBtnTapped; objImage.GestureRecognizers.Add(tapGestureRecognizer); objGrid.Children.Add(stv, 2, 0); var moreAction = new MenuItem { Text = "More" }; moreAction.SetBinding(MenuItem.CommandParameterProperty, new Binding(".")); moreAction.Clicked += (sender, e) => { var mi = ((MenuItem)sender); }; var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true }; // red background deleteAction.Icon = Device.OnPlatform("Icons/cancel.png", "cancel.png", "Images/cancel.png"); deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding(".")); deleteAction.Clicked += (sender, e) => { var mi = ((MenuItem)sender); }; // // add context actions to the cell // ContextActions.Add(moreAction); ContextActions.Add(deleteAction); StackLayout st = new StackLayout(); st.Children.Add(objGrid); st.Children.Add(new BoxView() { Color = Color.FromHex("#A4B3C1"), WidthRequest = 100, HeightRequest = 1 }); View = st; }