/// <summary> /// Begin in-place editing of given cell /// </summary> /// <param name="c">Control used as cell editor</param> /// <param name="Item">ListViewItem to edit</param> /// <param name="SubItem">SubItem index to edit</param> private void StartEditing(PwEntry pe, ListViewItem Item, int SubItem, bool ContinueEdit) { if (!this.GetEnable()) { return; } mutEdit.WaitOne(); if (Item.Index == -1) { mutEdit.ReleaseMutex(); return; } //if (_editingControl != null) //{ // mutEdit.ReleaseMutex(); // return; //} m_host.MainWindow.EnsureVisibleEntry(pe.Uuid); Util.SelectEntry(pe, true, true); int colID = SubItem; AceColumn col = Util.GetAceColumn(colID); AceColumnType colType = col.Type; PaddedTextBox c = m_textBoxComment; // Set Multiline property //TODO separate function switch (colType) { case AceColumnType.Notes: case AceColumnType.CustomString: c.Multiline = true; break; case AceColumnType.PluginExt: //TODO c.Multiline = false; break; default: c.Multiline = false; break; } // Set editing allowed //TODO separate function switch (colType) { case AceColumnType.CreationTime: case AceColumnType.LastAccessTime: case AceColumnType.LastModificationTime: case AceColumnType.ExpiryTime: case AceColumnType.Uuid: case AceColumnType.Attachment: case AceColumnType.ExpiryTimeDateOnly: case AceColumnType.Size: case AceColumnType.HistoryCount: // No editing allowed c.ReadOnly = true; break; case AceColumnType.PluginExt: //TODO No editing allowed c.ReadOnly = true; break; default: // Editing allowed c.ReadOnly = false; break; } // Read SubItem text and set textbox property // TODO Optionally PasswordChar *** during editing for protected strings // Read entry c.Text = Util.GetEntryFieldEx(pe, SubItem, false); // Set control location, bounding, padding SetEditBox(c, GetSubItemBounds(Item, SubItem), SubItem); //c.ScrollToTop(); c.SelectAll(); _editingControl = c; _editItem = Item; _editSubItem = SubItem; if (ContinueEdit == false) { //c.Invalidate(); c.Visible = true; c.BringToFront(); c.Select(); c.Focus(); m_host.MainWindow.EnsureVisibleEntry(pe.Uuid); // Check sub plugin state if (!m_bEnabled) { // Function has to be enabled AddHandler(); } } // Should be in the textbox c.Leave += new EventHandler(_editControl_Leave); c.LostFocus += new EventHandler(_editControl_LostFocus); c.KeyPress += new KeyPressEventHandler(_editControl_KeyPress); mutEdit.ReleaseMutex(); }