void FillFrameRates(NSComboBox combo) { combo.RemoveAll(); combo.Add(new NSString((23.976).ToString(CultureInfo.CurrentUICulture))); combo.Add(new NSString((24).ToString(CultureInfo.CurrentUICulture))); combo.Add(new NSString((25).ToString(CultureInfo.CurrentUICulture))); combo.Add(new NSString((29.97).ToString(CultureInfo.CurrentUICulture))); combo.Add(new NSString((30).ToString(CultureInfo.CurrentUICulture))); }
void TestOverrideThrow(bool eventFirst, bool shouldThrow) { NSComboBox b = new NSComboBox(new CGRect(0, 0, 200, 25)); if (eventFirst) { b.SelectionChanged += (sender, e) => Console.WriteLine("Change"); } else { b.Delegate = new NSComboBoxDelegate(); } bool didThrow = false; try { if (eventFirst) { b.Delegate = new NSComboBoxDelegate(); } else { b.SelectionChanged += (sender, e) => Console.WriteLine("Change"); } } catch (System.InvalidOperationException) { didThrow = true; } if (shouldThrow != didThrow) { Assert.Fail("TestOverrideThrow ({0}, {1}) did not have expected thrown status", eventFirst, shouldThrow); } }
public override IView ConvertTo(FigmaNode currentNode, ProcessedNode parent, FigmaRendererService rendererService) { var view = new NSComboBox(); var figmaInstance = (FigmaInstance)currentNode; var controlType = figmaInstance.ToControlType(); switch (controlType) { case NativeControlType.ComboBoxSmall: case NativeControlType.ComboBoxSmallDark: view.ControlSize = NSControlSize.Small; break; case NativeControlType.ComboBoxStandard: case NativeControlType.ComboBoxStandardDark: view.ControlSize = NSControlSize.Regular; break; } if (controlType.ToString().EndsWith("Dark", StringComparison.Ordinal)) { view.Appearance = NSAppearance.GetAppearance(NSAppearance.NameDarkAqua); } return(new View(view)); }
public ComboBoxImp(ComboBox owner) { this.owner = owner; combo = new NSComboBox(); combo.Bordered = false; combo.UsesSingleLineMode = false; combo.LineBreakMode = NSLineBreakMode.Clipping; combo.BezelStyle = NSTextFieldBezelStyle.Rounded; combo.Alignment = NSTextAlignment.Natural; combo.Enabled = owner.Enabled; combo.Font = owner.Font.ToNSFont(); combo.DoCommandBySelector = ComboDoCommandBySelector; combo.Changed += ComboTextFieldChanged; combo.WillPopUp += ComboWillPopUp; combo.WillDismiss += ComboWillDismiss; combo.Completes = true; combo.VisibleItems = 10; combo.UsesDataSource = true; combo.DataSource = this; combo.GetCompletions = ComboGetCompletions; if (owner.selected_index >= 0 && owner.selected_index < combo.Count) combo.SelectItem(owner.selected_index); combo.SelectionChanged += ComboSelectionChanged; }
public static void SetDataSourceEx <T>(this NSComboBox comboBox, IEnumerable <T> dataSource, Func <T, string> getValue, bool includeEmptyRow = true) { comboBox.UsesDataSource = true; comboBox.DataSource = ComboBoxDataSourceEx.FromData(dataSource, getValue, includeEmptyRow); comboBox.ReloadData(); comboBox.StringValue = string.Empty; }
public static void ClearDataSource(this NSComboBox comboBox) { comboBox.UsesDataSource = true; comboBox.StringValue = string.Empty; comboBox.DataSource = CocoaTool.GenerateComboBoxDataSourceFromEnum <EmptyEnum>(); comboBox.ReloadData(); }
public EditableComboTextFieldAndRemoveButton(params NSString[] comboBoxValues) { DividerStyle = NSSplitViewDividerStyle.Thin; IsVertical = true; NSComboBox comboBox = new NSComboBox { Editable = false, Selectable = false, Bordered = false, }; comboBox.SetFrameSize(new CoreGraphics.CGSize(200f, 17f)); comboBox.Add(comboBoxValues); AddSubview(comboBox); AddSubview(new EditableTextView { Bordered = false, StringValue = "", PlaceholderString = "New Filter", }); AddSubview(new NSButton { Bordered = false, Image = NSImage.ImageNamed("NSRemoveTemplate"), }); SetHoldingPriority(0, 490); SetHoldingPriority(1, 490); SetHoldingPriority(2, 490); }
protected override IView OnConvertToView(FigmaNode currentNode, ViewNode parentNode, ViewRenderService rendererService) { var combobox = new NSComboBox(); var frame = (FigmaFrame)currentNode; frame.TryGetNativeControlVariant(out var controlVariant); combobox.ControlSize = ViewHelper.GetNSControlSize(controlVariant); combobox.Font = ViewHelper.GetNSFont(controlVariant); FigmaNode optionsGroup = frame.Options(); FigmaText placeholderText = optionsGroup?.GetChildren() .OfType <FigmaText>() .FirstOrDefault(s => s.name == ComponentString.PLACEHOLDER && s.visible); if (placeholderText != null && !placeholderText.characters.Equals(ComponentString.PLACEHOLDER, StringComparison.InvariantCultureIgnoreCase)) { combobox.PlaceholderString = rendererService.GetTranslatedText(placeholderText); } FigmaText text = frame.children .OfType <FigmaText> () .FirstOrDefault(s => s.name == ComponentString.TITLE); if (text != null && !string.IsNullOrEmpty(text.characters)) { combobox.StringValue = rendererService.GetTranslatedText(text); } return(new View(combobox)); }
void TestDelegates(NSComboBox b) { NSTextField f = (NSTextField)b; Assert.IsNotNull(b.Delegate, "NSComboBox delegate null"); Assert.IsNotNull(f.Delegate, "NSTextField delegate null"); Assert.AreEqual(b.Delegate.GetHashCode(), f.Delegate.GetHashCode(), "Delegates are not equal"); }
public override string CompletedString(NSComboBox comboBox, string uncompletedString) { if (CompletedStringFunc != null) { return(CompletedStringFunc(comboBox, uncompletedString)); } return(uncompletedString); }
public override int ItemCount(NSComboBox comboBox) { if (ItemCountFunc != null) { return(ItemCountFunc(comboBox)); } return(default(int)); }
public override int IndexOfItem(NSComboBox comboBox, string value) { if (IndexOfItemFunc != null) { return(IndexOfItemFunc(comboBox, value)); } return(default(int)); }
public override NSObject ObjectValueForItem(NSComboBox comboBox, int index) { if (index == -1) { index = 0; } return(NSObject.FromObject(varieties [index])); }
public override NSObject ObjectValueForItem(NSComboBox comboBox, int index) { if (ObjectValueForItemFunc != null) { return(ObjectValueForItemFunc(comboBox, index)); } return(default(NSObject)); }
public override int ItemCount(NSComboBox comboBox) { if (cbox == null) { return(0); } return(cbox.Items.Count); }
partial void PropertyChosen(NSComboBox sender) { this.addressSelected = this.PropertyChooser.StringValue; if (this.addressSelected.Length > 1) { this.loan = new clsLoan(this.loanList[this.addressSelected]); } this.Update(); }
public static NSComboBox NewRatingComboBox(CGRect frame, NSFont font) { var comboBox = new NSComboBox(frame); comboBox.Add(FilmRating.Values.Select(str => new NSString(str)).ToArray()); comboBox.Alignment = NSTextAlignment.Right; comboBox.Font = font; comboBox.AutoresizesSubviews = true; return(comboBox); }
public static void ReadCustomMap(string dir, NSComboBox list) { string[] files = Directory.GetFiles(Directory.GetCurrentDirectory() + dir); foreach (string file in files) { string name = Between(file, @"MapMods\", ".map"); list.Items.Add(name); } }
public sealed override string CompletedString(NSComboBox comboBox, string uncompletedString) { var retval = uncompletedString; var match = Data.FirstOrDefault(datum => GetValueFunc(datum).ToUpper().StartsWith(uncompletedString.ToUpper())); if (match != null) { retval = GetValueFunc(match); } return(retval); }
private void RemoveComboBox() { if (this.comboBox == null) { return; } UnhookSelectionChangeAndClearItems(); this.comboBox.RemoveFromSuperview(); this.comboBox.Dispose(); this.comboBox = null; }
public static void LoadCustomMap(string dir, string map, NSComboBox list) { // Functions.do_screen_fade_out(400); string[] files = Directory.GetFiles(Directory.GetCurrentDirectory() + dir); string foundFile = ""; bool found = false; foreach (string file in files) { string name = Between(file, @"MapMods\", ".map"); if (name == map) { foundFile = file; found = true; break; } } string[] lines = File.ReadAllLines(foundFile); foreach (string line in lines) { string[] split = line.Split(' '); int hash = Convert.ToInt32(split[0]); float[] coords = { float.Parse(split[1]), float.Parse(split[2]), float.Parse(split[3]) - 1f }; float[] rot = { float.Parse(split[4]), float.Parse(split[5]), float.Parse(split[6]) }; int mapO = Hook.Call(Addresses.Natives.create_object, hash, coords, 1, 1, 0); Hook.Call(Addresses.Natives.set_entity_rotation, mapO, rot, 2, 1); Hook.Call(Addresses.Natives.freeze_entity_position, mapO, 1); } string first = lines[0]; string[] firsts = first.Split(' '); float[] fcoords = { float.Parse(firsts[1]), float.Parse(firsts[2]), float.Parse(firsts[3]) }; MessageBox.Show("Custom Map Loaded! Press OK To Teleport!\n(All Credits Go To Original Map Creators)", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); int PedID = Functions.player_ped_id(); int VehicleStatus = Functions.is_ped_in_any_vehicle(PedID); if (VehicleStatus == 1) { Functions.set_entity_coords(Functions.get_vehicle_ped_is_in(PedID), fcoords); } else { Functions.set_entity_coords(PedID, fcoords); } // Functions.do_screen_fade_in(400); }
public override NSObject ObjectValueForItem(NSComboBox comboBox, nint index) { if (index >= 0) { return(NSObject.FromObject(Opleidingen[(int)index].OpleidingNaam)); } else { return(null); } }
public override string CompletedString(NSComboBox comboBox, string uncompletedString) { foreach (ClubModel club in Clubs) { if (club.ClubNaam.StartsWith(uncompletedString, StringComparison.InvariantCultureIgnoreCase)) { return(club.ClubNaam); } } return(uncompletedString); }
public override NSObject ObjectValueForItem(NSComboBox comboBox, nint index) { var itemname = plants[(int)index].Name; NSMutableAttributedString str = new NSMutableAttributedString(itemname); var range = new NSRange(0, itemname.Length); str.BeginEditing(); str.AddAttribute(NSStringAttributeKey.ForegroundColor, NSColor.White, range); str.EndEditing(); return(NSObject.FromObject(str)); }
public override nint IndexOfItem(NSComboBox comboBox, string value) { for (int i = 0; i < owner.items.Count; ++i) { var item = owner.items[i]; var title = owner.GetItemText(item); if (title == value) return (nint)i; } return - 1; }
public override string CompletedString(NSComboBox comboBox, string uncompletedString) { foreach (ApparaatModel app in Apparaten) { if (app.ApparaatNaam.StartsWith(uncompletedString, StringComparison.InvariantCultureIgnoreCase)) { return(app.ApparaatNaam); } } return(uncompletedString); }
public override string CompletedString(NSComboBox comboBox, string uncompletedString) { foreach (OpleidingModel om in Opleidingen) { if (om.OpleidingNaam.StartsWith(uncompletedString, StringComparison.InvariantCultureIgnoreCase)) { return(om.OpleidingNaam); } } return(uncompletedString); }
public override NSObject ObjectValueForItem(NSComboBox comboBox, nint index) { if (index >= 0) { return(NSObject.FromObject(Clubs[(int)index].ClubNaam)); } else { return(null); } }
public void SetSelectedValue(NSComboBox combobox, object value) { var DisplayMember = cbox.DisplayMember; var ValueMember = cbox.ValueMember; if (string.IsNullOrEmpty(DisplayMember)) { combobox.SelectItem(cbox.Items.IndexOf(value)); return; } combobox.SelectItem(cbox.Items.IndexOf(value)); }
private void RemoveComboBox() { if (this.comboBox == null) { return; } this.comboBox.SelectionChanged -= ComboBox_SelectionChanged; this.comboBox.RemoveAll(); this.comboBox.RemoveFromSuperview(); this.comboBox.Dispose(); this.comboBox = null; }
public override nint IndexOfItem (NSComboBox comboBox, string value) { return countries.FindIndex (n => n.Equals (value, StringComparison.InvariantCultureIgnoreCase)); }
public override string CompletedString (NSComboBox comboBox, string uncompletedString) { bool shouldClose = false; bool found = false; string field = ""; // Has a Table, ID and display field been specified? if (TableName != "" && IDField != "" && DisplayField != "") { // Is the database already open? if (Conn.State != ConnectionState.Open) { shouldClose = true; Conn.Open (); } // Escape search string uncompletedString = uncompletedString.Replace ("'", ""); // Execute query using (var command = Conn.CreateCommand ()) { // Create new command command.CommandText = $"SELECT {DisplayField} FROM [{TableName}] WHERE {DisplayField} LIKE @VAL"; // Populate parameters command.Parameters.AddWithValue ("@VAL", uncompletedString + "%"); // Get the results from the database using (var reader = command.ExecuteReader ()) { while (reader.Read ()) { // Read the display field from the query field = (string)reader [0]; } } } // Should we close the connection to the database if (shouldClose) { Conn.Close (); } } // Return results return field; }
public override string CompletedString (NSComboBox comboBox, string uncompletedString) { return countries.Find (n => n.StartsWith (uncompletedString, StringComparison.InvariantCultureIgnoreCase)); }
public override NSObject ObjectValueForItem (NSComboBox comboBox, nint index) { NSString value = new NSString (""); bool shouldClose = false; // Has a Table, ID and display field been specified? if (TableName != "" && IDField != "" && DisplayField != "") { // Is the database already open? if (Conn.State != ConnectionState.Open) { shouldClose = true; Conn.Open (); } // Execute query using (var command = Conn.CreateCommand ()) { // Create new command command.CommandText = $"SELECT {DisplayField} FROM [{TableName}] ORDER BY {DisplayField} ASC LIMIT 1 OFFSET {index}"; // Get the results from the database using (var reader = command.ExecuteReader ()) { while (reader.Read ()) { // Read the display field from the query value = new NSString((string)reader [0]); } } } // Should we close the connection to the database if (shouldClose) { Conn.Close (); } } // Return results return value; }
public override nint IndexOfItem (NSComboBox comboBox, string value) { bool shouldClose = false; bool found = false; string field = ""; nint index = NSRange.NotFound; // Has a Table, ID and display field been specified? if (TableName != "" && IDField != "" && DisplayField != "") { // Is the database already open? if (Conn.State != ConnectionState.Open) { shouldClose = true; Conn.Open (); } // Execute query using (var command = Conn.CreateCommand ()) { // Create new command command.CommandText = $"SELECT {DisplayField} FROM [{TableName}] ORDER BY {DisplayField} ASC"; // Get the results from the database using (var reader = command.ExecuteReader ()) { while (reader.Read () && !found) { // Read the display field from the query field = (string)reader [0]; ++index; // Is this the value we are searching for? if (value == field) { // Yes, exit loop found = true; } } } } // Should we close the connection to the database if (shouldClose) { Conn.Close (); } } // Return results return index; }
public void SetSelectedValue (NSComboBox combobox, object value) { var DisplayMember = cbox.DisplayMember; var ValueMember = cbox.ValueMember; if (string.IsNullOrEmpty (DisplayMember)) { combobox.SelectItem (cbox.Items.IndexOf (value)); return; } combobox.SelectItem (cbox.Items.IndexOf (value)); }
public override NSObject ObjectValueForItem(NSComboBox comboBox, int index) { if (index == -1) index = 0; return NSObject.FromObject (varieties [index]); }
public override int IndexOfItem (NSComboBox comboBox, string value) { return cbox.Items.IndexOf (value); }
public override int ItemCount (NSComboBox comboBox) { return _filenames.Count; }
public override int ItemCount (NSComboBox comboBox) { return list.Count; }
public object GetSelectedValue (NSComboBox comboBox) { var DisplayMember = cbox.DisplayMember; var ValueMember = cbox.ValueMember; object l = cbox.Items[comboBox.SelectedIndex]; if (!string.IsNullOrEmpty (DisplayMember)) { //Use Display Property if they didnt set ValueMember var valueMember = string.IsNullOrEmpty (ValueMember) ? DisplayMember : ValueMember; return Util.GetPropertyValue (l, valueMember); } else { return l.ToString (); } }
public override int ItemCount (NSComboBox comboBox) { if (cbox == null) return 0; return cbox.Items.Count; }
public override NSObject ObjectValueForItem (NSComboBox comboBox, int index) { return (NSString)list [index]; }
public override int ItemCount(NSComboBox comboBox) { return varieties.Count; }
public override nint ItemCount (NSComboBox comboBox) { return countries.Count; }
public override NSObject ObjectValueForItem (NSComboBox comboBox, int index) { return NSObject.FromObject ((_filenames [index]).Name); }
public override NSObject ObjectValueForItem (NSComboBox comboBox, nint index) { return NSObject.FromObject (countries [(int)index]); }
public override nint ItemCount (NSComboBox comboBox) { return RecordCount; }
public int IndexOfItem (NSComboBox ComboBox, object value) { return cbox.Items.IndexOf (value); }
public override NSObject ObjectValueForItem (NSComboBox comboBox, int index) { if (cbox == null) return null; if (string.IsNullOrEmpty (cbox.DisplayMember)) returnString = new NSString (cbox.Items[index].ToString ()); else returnString = new NSString (Util.GetPropertyStringValue (cbox.Items[index], cbox.DisplayMember)); return returnString; }