/// <summary> /// Initialize with associated command line control /// </summary> /// <param name="commandLineControl"></param> public static QuickSearchPopup Initialize( MRUEdit commandLineControl, Form parentForm, ContentsTreeControl contentstree) { QuickSearchPopup qsp = null; AssertMx.IsNotNull(commandLineControl, "CommandLineControl"); AssertMx.IsNotNull(parentForm, "ParentForm"); foreach (Control c in parentForm.Controls) // see if already exists { if (c is QuickSearchPopup) { qsp = c as QuickSearchPopup; break; } } bool newPopup = false; if (qsp == null) // need to create new popup in parent form { qsp = new QuickSearchPopup(); parentForm.Controls.Add(qsp); newPopup = true; } qsp.Initialize2(commandLineControl, parentForm, contentstree, newPopup); return(qsp); }
//void mruEdit_Click(object sender, EventArgs e) //{ // MRUEdit mruEdit = sender as MRUEdit; // ProcSearchParam param = mruEdit.Tag as ProcSearchParam; // if(mruEdit.Properties.Items.Count == 0 ) // { // LoadListItems(mruEdit, param.Name.Substring(1)); // } //} public void searchForm_AddingMRUItem(object sender, DevExpress.XtraEditors.Controls.AddingMRUItemEventArgs e) { if (e == null) { return; } MRUEdit editor = sender as MRUEdit; if (editor != null) { ProcSearchParam param = editor.Tag as ProcSearchParam; ParameterList list = m_editorLists[editor.Name]; ParameterListItem item = list.Contains(param.Value.ToString()); if (item == null) { ParameterListItem newItem = Scout.Core.Data.CreateEntity <ParameterListItem>(m_session); newItem.Item = param.Value.ToString(); newItem.LastUsed = DateTime.Now; newItem.DateAdded = DateTime.Now; newItem.UserName = SCOUT.Core.Security.UserSecurity.CurrentUser.Login; newItem.ParameterList = list; } else { item.LastUsed = DateTime.Now; } Scout.Core.Data.Save(m_session); } }
private void txtBuscar_TextChanged(Object sender, EventArgs e) { try { edit.Text = txtBuscar.Text.ToString(); } catch (Exception) { FindControl find = null; foreach (Control ctrl in grdDeclaraciones.Controls) { if (ctrl.GetType() == typeof(FindControl)) { find = ctrl as FindControl; } } if (find != null) { LayoutControl layout = find.Controls[0] as LayoutControl; edit = (layout.Items[2] as LayoutControlItem).Control as MRUEdit; } edit.Text = txtBuscar.Text.ToString(); } }
public static void SaveMruList(ArrayList mruList, MRUEdit mruEdit, object objSettings) { if (mruEdit.Properties.Items.Count == 0 || objSettings == null) { return; } int cnt = 0; mruList.Clear(); foreach (string mruItem in mruEdit.Properties.Items) { if (cnt++ < 20) { mruList.Add(mruItem); } } MethodInfo miSave = objSettings.GetType().GetMethod("Save"); if (miSave == null) { return; } miSave.Invoke(objSettings, null); }
public static void SetFindControlImages(GridControl grid, bool forceAlignment) { FindControl fControl = null; foreach (Control ctrl in grid.Controls) { fControl = ctrl as FindControl; if (fControl != null) { break; } } if (fControl != null) { EditorButton btn = fControl.FindEdit.Properties.Buttons[0]; btn.Kind = XtraEditors.Controls.ButtonPredefines.Search; btn = new EditorButton(ButtonPredefines.Close); btn.Visible = false; fControl.FindEdit.Properties.Buttons.Add(btn); fControl.FindEdit.ButtonClick += (s, e) => { if (!e.Button.IsDefaultButton) { ButtonEdit edit = s as ButtonEdit; edit.Text = string.Empty; } }; fControl.FindEdit.EditValueChanged += (s, e) => { MRUEdit edit = s as MRUEdit; edit.Properties.BeginUpdate(); try { edit.Properties.Buttons[0].Visible = string.IsNullOrEmpty(edit.Text); edit.Properties.Buttons[1].Visible = !string.IsNullOrEmpty(edit.Text); } finally { edit.Properties.EndUpdate(); } }; if (forceAlignment) { //LayoutControl lc = fControl.FindEdit.Parent as LayoutControl; //lc.BeginUpdate(); ////lc.Root.AddItem(new EmptySpaceItem() { SizeConstraintsType = SizeConstraintsType.Custom, MinSize = new Size(1, 1) }, lc.Root.Items[0], XtraLayout.Utils.InsertType.Left); //try { // for(int i = lc.Root.Items.Count - 1; i >= 0; i--) { // LayoutControlItem item = lc.Root.Items[i] as LayoutControlItem; // if(item == null) continue; // if(item.Visibility == XtraLayout.Utils.LayoutVisibility.Never) // lc.Root.Remove(item); // else { // item.ControlAlignment = System.Drawing.ContentAlignment.MiddleRight; // } // } //} //finally { // lc.EndUpdate(); //} } } }
public static MRUEditElementBinder <TObject> To <TObject>(this IScreenToElementBinder <TObject, string> screenToElementBinder, MRUEdit mruEdit) { var element = new MRUEditElementBinder <TObject>(screenToElementBinder.PropertyBinder, mruEdit); screenToElementBinder.ScreenBinder.AddElement(element); return(element); }
public MRUEdit NewMRUEdit(string paramName) { MRUEdit mruEdit = new MRUEdit(); mruEdit.Properties.MaxItemCount = 10; mruEdit.Name = paramName + "Edit"; LoadListItems(mruEdit, paramName); mruEdit.AddingMRUItem += searchForm_AddingMRUItem; mruEdit.Validated += mruEdit_Validated; return(mruEdit); }
public static void SetMruList(ArrayList mruList, MRUEdit mruEdit) { if (mruList == null || mruList.Count == 0) { return; } for (int i = mruList.Count - 1; i >= 0; i--) { mruEdit.Properties.Items.Add(mruList[i]); } }
private void frmCitasAgendadas_Shown(object sender, EventArgs e) { FindControl find = null; foreach (Control ctrl in grdCitas.Controls) { if (ctrl.GetType() == typeof(FindControl)) { find = ctrl as FindControl; } } if (find != null) { LayoutControl layout = find.Controls[0] as LayoutControl; edit = (layout.Items[2] as LayoutControlItem).Control as MRUEdit; } }
private void LoadListItems(MRUEdit mruEdit, string name) { ParameterList list = ParameterList.GetListByParamName(m_session, name); if (list == null) { list = Scout.Core.Data.CreateEntity <ParameterList>(m_session); list.ParamName = name; } m_editorLists.Add(mruEdit.Name, list); foreach (ParameterListItem item in list.ListItemsSortedAtoZ) { mruEdit.Properties.Items.Add(item.Item); } }
private void CreateLayoutItems() { layoutControl.BeginUpdate(); try { searchEdit = new MRUEdit(); searchEdit.Name = "searchEdit"; searchEdit.EditValueChanged += OnSearchTextChanged; LayoutControlItem searchEditItem = layoutControl.AddItem("SearchEditItem", searchEdit); searchEditItem.TextVisible = false; searchEditItem.Name = "searchEditItem"; closeButton = new SimpleButton(); closeButton.MaximumSize = new Size(25, closeButton.Height); closeButton.Text = "X"; closeButton.Name = "closeButton"; closeButton.Click += OnCloseButtonClick; closeItem = layoutControl.AddItem("CloseItem", closeButton, searchEditItem, DevExpress.XtraLayout.Utils.InsertType.Left); closeItem.TextVisible = false; closeItem.Name = "closeItem"; findButton = new SimpleButton(); findButton.MaximumSize = new Size(50, findButton.Height); findButton.Text = "Find"; findButton.Name = "findButton"; findButton.Click += OnFindButtonClick; LayoutControlItem findItem = layoutControl.AddItem("FindItem", findButton, searchEditItem, DevExpress.XtraLayout.Utils.InsertType.Right); findItem.TextVisible = false; findItem.Name = "findItem"; clearButton = new SimpleButton(); clearButton.MaximumSize = new Size(50, clearButton.Height); clearButton.Text = "Clear"; clearButton.Name = "clearButton"; clearButton.Click += OnClearButtonClick; LayoutControlItem clearItem = layoutControl.AddItem("ClearItem", clearButton, findItem, DevExpress.XtraLayout.Utils.InsertType.Right); clearItem.TextVisible = false; clearItem.Name = "clearItem"; } finally { layoutControl.EndUpdate(); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); FindControl find = null; foreach (Control ctrl in grdDeclaraciones.Controls) { if (ctrl.GetType() == typeof(FindControl)) { find = ctrl as FindControl; } } if (find != null) { LayoutControl layout = find.Controls[0] as LayoutControl; edit = (layout.Items[2] as LayoutControlItem).Control as MRUEdit; } }
void Initialize2( MRUEdit clc, Form parentForm, ContentsTreeControl contentsTree, bool newPopup) { QuickSearchPopup qsp = this; // debug //if (newPopup) // just created? if (!Initialized) { Visible = false; //Width = 236; // set proper size //Height = 186; Point p = clc.PointToScreen(new Point(0, clc.Bottom)); Point p2 = parentForm.PointToClient(p); Left = p.X; // position below input control Top = p.Y + clc.Height * 2; BringToFront(); ContentsTree = contentsTree; RelatedStructuresControl rsp = RelatedStructuresControl; InitialStructurePanelWidth = StructurePanel.Width; //rsp.Width + 12; // initial StructurePanel width InitialStructurePanelWidthWithoutRelatedStructureOptions = rsp.MoleculeControl.Right + 10; //InitialStructurePanelWidth = 400; // debug InitialStructurePanelHeight = rsp.Top + rsp.MoleculeControl.Height + 15; // initial StructurePanel height to just below structure box StructurePanel.Dock = DockStyle.Fill; OtherCidsList.Visible = false; MoleculeControl strBox = RelatedStructuresControl.MoleculeControl; // make structure box wider to the left int newBoxLeft = 4; int dx = strBox.Left - newBoxLeft; // amount to widen structure box int w2 = strBox.Width + dx; int h2 = strBox.Height; RSM = new RelatedStructureControlManager(); RelatedStructuresControl.RSM = RSM; RSM.RSC = RelatedStructuresControl; RSM.HideUndefinedStructureList = true; // don't show structure panel until after search complete RelatedStructuresControl.RenderSearchResultsCompleteCallBack = RenderSearchResultsCompleteCallBack; RelatedStructuresControl.SetupCheckmarks(); Initialized = true; } CommandLineControl = clc; // associated command line comtrol clc.GotFocus += CommandLine_GotFocus; clc.KeyDown += CommandLine_KeyDown; // add command line events for us clc.KeyUp += CommandLine_KeyUp; clc.PreviewKeyDown += CommandLine_PreviewKeyDown; if (!Timer.Enabled) { Timer.Enabled = true; PreviousInput = ""; // need to clear to get redisplay of structure } return; }
public MRUEditElementBinder(IPropertyBinderNotifier <TObjectType, string> propertyBinder, MRUEdit mruEdit) : base(propertyBinder, mruEdit) { _mruEdit = mruEdit; }
private void createEditors(int rowIndex, bool applyToAllButton) { var layoutControl = new LayoutControl(); Controls.Add(layoutControl); layoutControl.Dock = DockStyle.Fill; layoutControl.AllowCustomization = false; foreach (MetaDataColumn col in _data.Columns) { LayoutControlItem colItem = layoutControl.Root.AddItem(); colItem.Name = col.DisplayName.FormatForLabel(); colItem.ControlName = col.DisplayName; BaseEdit editor; if (col.DataType == typeof(string)) { if (col.ListOfValues != null && col.ListOfValues.Count > 0) { if (col.IsListOfValuesFixed) { editor = new ImageComboBoxEdit(); var cb = editor as ImageComboBoxEdit; var imageListSmall = getImageList(col.ListOfImages, IconSizes.Size16x16); var imageListLarge = getImageList(col.ListOfImages, IconSizes.Size32x32); cb.Properties.SmallImages = imageListSmall; cb.Properties.LargeImages = imageListLarge; foreach (var s in col.ListOfValues) { cb.Properties.Items.Add(new ImageComboBoxItem(s.Value, s.Key, getImageIndex(imageListLarge, s.Key))); } cb.Properties.AutoComplete = true; cb.Properties.AllowNullInput = col.Required ? DefaultBoolean.False : DefaultBoolean.True; setEditorProperties(cb.Properties, col); cb.Properties.CloseUpKey = new KeyShortcut(Keys.Enter); cb.SelectedValueChanged += onSelectedValueChanged; } else { editor = new MRUEdit(); var cb = editor as MRUEdit; foreach (var s in col.ListOfValues) { cb.Properties.Items.Add(s.Value); } cb.Properties.AutoComplete = true; cb.Properties.AllowNullInput = col.Required ? DefaultBoolean.False : DefaultBoolean.True; setEditorProperties(cb.Properties, col); cb.Properties.CloseUpKey = new KeyShortcut(Keys.Enter); cb.SelectedValueChanged += onSelectedValueChanged; cb.Properties.AllowRemoveMRUItems = false; } } else { if (col.MaxLength > TEXT_LENGTH_FOR_MEMO_EDITOR) { editor = new MemoExEdit(); var me = editor as MemoExEdit; me.Properties.AllowNullInput = col.Required ? DefaultBoolean.False : DefaultBoolean.True; me.Properties.MaxLength = maxLengthFor(col); setEditorProperties(me.Properties, col); me.Properties.CloseUpKey = new KeyShortcut(Keys.Enter); } else { editor = new TextEdit(); var te = editor as TextEdit; te.Properties.AllowNullInput = col.Required ? DefaultBoolean.False : DefaultBoolean.True; te.Properties.MaxLength = maxLengthFor(col); setEditorProperties(te.Properties, col); } } } else if (col.DataType == typeof(DateTime)) { editor = new DateEdit(); var de = editor as DateEdit; de.Properties.ShowClear = !col.Required; setEditorProperties(de.Properties, col); de.Properties.CloseUpKey = new KeyShortcut(Keys.Enter); } else if (col.DataType == typeof(bool)) { editor = new CheckEdit(); var ce = editor as CheckEdit; ce.Properties.Caption = col.DisplayName; ce.Properties.GlyphAlignment = HorzAlignment.Far; ce.Properties.NullStyle = StyleIndeterminate.Inactive; ce.Properties.AllowGrayed = !col.Required; setEditorProperties(ce.Properties, col); } else if (col.DataType == typeof(double)) { editor = new TextEdit(); var te = editor as TextEdit; te.Properties.AllowNullInput = col.Required ? DefaultBoolean.False : DefaultBoolean.True; // te.Properties.MaxLength = col.MaxLength; setEditorProperties(te.Properties, col); te.Properties.Mask.MaskType = MaskType.RegEx; te.Properties.Mask.EditMask = RegularExpression.Numeric; } else if (col.DataType == typeof(int)) { editor = new SpinEdit(); var se = editor as SpinEdit; if (col.MinValue != null) { if (col.MinValueAllowed) { se.Properties.MinValue = (decimal)col.MinValue; } else { se.Properties.MinValue = (decimal)col.MinValue + 1; } } if (col.MaxValue != null) { if (col.MaxValueAllowed) { se.Properties.MaxValue = (decimal)col.MaxValue; } else { se.Properties.MaxValue = (decimal)col.MaxValue - 1; } } se.Properties.AllowNullInput = col.Required ? DefaultBoolean.False : DefaultBoolean.True; setEditorProperties(se.Properties, col); } else { editor = new TextEdit(); var te = editor as TextEdit; te.Properties.AllowNullInput = col.Required ? DefaultBoolean.False : DefaultBoolean.True; te.Properties.MaxLength = col.MaxLength; setEditorProperties(te.Properties, col); } if (col.Required) { editor.BackColor = Color.LightYellow; } editor.Validating += onEditorValidating; editor.TextChanged += OnEditorTextChanged; editor.EditValueChanged += OnEditorTextChanged; editor.Validated += onEditorValidated; editor.ToolTipController = new ToolTipController(); editor.SuperTip = new SuperToolTip(); editor.SuperTip.Items.AddTitle(col.DisplayName); editor.SuperTip.Items.Add(col.Description); //add information about ranges to the tool tip if (col.MinValue != null || col.MaxValue != null) { var lowerBound = col.MinValue == null ? INFINITY_SIGN : (col.MinValueAllowed) ? "[" : "]"; var lowerValue = col.MinValue == null ? String.Empty : col.MinValue.ToString(); var upperValue = col.MaxValue == null ? String.Empty : col.MaxValue.ToString(); var upperBound = col.MaxValue == null ? INFINITY_SIGN : (col.MaxValueAllowed) ? "]" : "["; var text = $"Valid values must be within range {lowerBound}{lowerValue};{upperValue}{upperBound}."; editor.SuperTip.Items.Add(text); } editor.Name = col.ColumnName; editor.DataBindings.Add(new Binding("EditValue", _data, col.ColumnName)); editor.DataBindings.DefaultDataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged; if (shouldSetDefaultValue(col)) { editor.EditValue = col.DefaultValue; } colItem.Control = editor; var btnColItem = layoutControl.Root.AddItem(); btnColItem.Move(colItem, InsertType.Right); var button = createThisMetaDataValueApplyToAllButton(editor); button.Enabled = !col.IsColumnUsedForGrouping; btnColItem.Control = button; btnColItem.TextVisible = false; } // bind to given row index if (_data.Rows.Count > 0 && rowIndex >= 0 && rowIndex < _data.Rows.Count) { BindingContext[_data].Position = rowIndex; } if (!applyToAllButton) { return; } _copyButton = new UxSimpleButton(); var copyItem = layoutControl.Root.AddItem(); copyItem.Control = _copyButton; _copyButton.Name = "btnApplyToAll"; _copyButton.Text = Captions.Importer.ApplyToAll; _copyButton.ToolTip = Captions.Importer.ApplyToAll; _copyButton.Image = ApplicationIcons.ApplyAll; _copyButton.Enabled = IsDataValid; _copyButton.Click += onCopyButtonClick; copyItem.TextVisible = false; }
/// <summary> /// Display any structure and related compounds for input string or /// Matching database contents /// </summary> /// <param name="inputString"></param> /// <param name="showRelatedCompounds"></param> public void ShowQuickSearchPopup( string inputString, bool updateRelatedCompounds) { string extCid = "", tok, tok2; MRUEdit clc = CommandLineControl; // be sure popup is properly positioned if (clc.FindForm() == SessionManager.Instance.ShellForm) // slightly different position for Shell form that other forms { Left = clc.Left; Top = clc.Bottom; } else { Point p = clc.PointToScreen(new Point(0, clc.Bottom)); // get screen coord for upper left corner of popup Point p2 = this.Parent.PointToClient(p); // convert screen coord back to relative Left = p2.X; // position below input control Top = p2.Y; } // See if input matches structure Molecule = null; if (StructurePopupEnabled && !String.IsNullOrEmpty(inputString)) { Cid = CompoundId.Normalize(inputString); extCid = CompoundId.Format(Cid); CidMt = CompoundId.GetRootMetaTableFromCid(Cid); Molecule = MoleculeUtil.SelectMoleculeForCid(Cid, CidMt); RelatedDataButton.Enabled = (CidMt != null && Lex.Eq(CidMt.Root.Name, MetaTable.PrimaryRootTable)); AllDataButtonStb.Enabled = QbUtil.IsMdbAssayDataViewAvailable(CidMt); } if (Molecule != null) { string txt = extCid; if (CidMt != null) { txt = CidMt.KeyMetaColumn.Label + " " + txt; } if (Lex.IsUndefined(Molecule.Id)) { Molecule.Id = txt; } if (SS.I.FindRelatedCpdsInQuickSearch) { txt += " and Related Structures"; } StructurePanel.Text = txt; RelatedStructuresControl.MoleculeControl.Molecule = Molecule; if (SS.I.FindRelatedCpdsInQuickSearch) { Width = InitialStructurePanelWidth; // assure correct width } else { Width = InitialStructurePanelWidthWithoutRelatedStructureOptions; RSM.ClearSearchStatus(); } if (!StructurePanel.Visible) // if structure not showing then set height to initial height { Height = InitialStructurePanelHeight; } StructurePanel.Location = new Point(0, 0); StructurePanel.Visible = true; //Size = StructurePanel.Size; ListControl.Visible = false; Visible = true; RenderId++; if (updateRelatedCompounds) { UpdateRelatedCidsDisplay(CidMt, Cid, Molecule, RenderId); } return; } // See if input matches database contents tree else if (ContentsPopupEnabled) { DoQuickSearchAndDisplayOfContentsTree(inputString); return; } HideQuickSearchPopup(); return; }
public static void FillWith(this MRUEdit mruEdit, IEnumerable <string> availableItems) { mruEdit.Properties.Items.Clear(); //Reverse to add them in the expected order availableItems.Reverse().Each(item => mruEdit.Properties.Items.Add(item)); }