public FormPopUpSearch(Control callbackControl, string startText = "") { InitializeComponent(); // Remember colors _correctColor = txtSearchString.BackColor; _wrongColor = _correctColor.MixWith(Color.DarkRed, 0.55); // Set up parameters _currentIndex = -1; _searchItems.Clear(); _callbackControl = callbackControl; // TODO: Support other control types? if (_callbackControl is DarkUI.Controls.DarkComboBox) { DarkUI.Controls.DarkComboBox callbackCombo = (DarkUI.Controls.DarkComboBox)_callbackControl; foreach (var item in callbackCombo.Items) { _searchItems.Add(item.ToString()); } } // Set pop-up width to parent control width Size = new Size(_callbackControl.Size.Width, MinimumSize.Height); // In case we invoke pop-up from another text control, we can pass existing string here if (startText.Length != 0) { txtSearchString.Text = startText; txtSearchString.Select(0, 0); txtSearchString.SelectionStart = txtSearchString.Text.Length; } // Start intro animation _animProgress = 0.0f; _animTimer.Tick += UpdateTimer; _animTimer.Start(); }
private void lstInvEquipment_CellEditStarting(object sender, CellEditEventArgs e) { if (e.Column.Text == "前缀") { var cb = new DarkUI.Controls.DarkComboBox { Bounds = e.CellBounds, DropDownStyle = ComboBoxStyle.DropDownList, Sorted = false, }; var modList = ObjectCache.GetObjectTypeList <ItemModifier>(); cb.Items.Add(new InvItemModInfo(defaultNoneName, null)); cb.Items.AddRange(modList.OrderBy(x => x.StringId).Select(mod => new InvItemModInfo(mod.StringId, mod)).ToArray()); var lastSelIdx = (int)e.RowObject; var lastSelElem = this.Player.PartyBelongedTo.ItemRoster.GetElementCopyAtIndex(lastSelIdx); var lastMod = lastSelElem.EquipmentElement.ItemModifier; cb.SelectedIndex = cb.FindStringExact(lastSelElem.EquipmentElement.ItemModifier?.StringId ?? defaultNoneName); cb.SelectedIndexChanged += (cb_sender, cbe) => { var modInfo = (cb.SelectedItem as InvItemModInfo)?.item; if (modInfo == lastMod) { return; } var y = new ItemRosterElement(lastSelElem.EquipmentElement.Item, lastSelElem.Amount, modInfo); //this.Player.PartyBelongedTo.ItemRoster.SetElementAtIndex(lastSelIdx, y); }; e.Control = cb; } else if (!e.Column.CheckBoxes && !(e.Column.Renderer is DarkUI.Support.CheckStateRenderer)) { e.AutoDispose = false; e.Control = new DarkUI.Controls.DarkNumericUpDown { Bounds = e.CellBounds }.DefaultEditor(e.Value); } }