public void Add(Entry item) { var itemHash = item.GetHashCode(); foreach (FATabStripItem fatab in faTabStrip1.Items) { if (Convert.ToInt32(fatab.Tag) == itemHash) { faTabStrip1.SelectedItem = fatab; return; } } _storedEntries.Add(itemHash, item); var tab = new FATabStripItem { Tag = itemHash, Title = string.Format("[{0}] {1}", item.Category, item.Name) }; tab.Controls.Add(new EntryEditor(item) { Name = "EntryEditor", Dock = DockStyle.Fill }); faTabStrip1.AddTab(tab, true); }
/// <summary> /// Add a new entry to the DB /// </summary> /// <param name="message">Entry's message</param> /// <param name="user">User who created the new entry</param> public void AddEntry(string message, Model.User user) { Model.Entry currentEntry = new Model.Entry(); currentEntry.message = message; currentEntry.User = user; entryBusiness.AddEntry(currentEntry); if (entryBusiness.HasHashtags(message)) { List <Model.Hashtag> hashtags = new List <Model.Hashtag>(); hashtags = entryBusiness.GetHashtags(message); List <Model.Hashtag> newHashtags = new List <Model.Hashtag>(); List <Model.Entry_Hashtag> entry_hashtags = new List <Model.Entry_Hashtag>(); int lastId = hashtagBusiness.GetLastId() + 1; foreach (var hash in hashtags) { if (!(hashtagBusiness.Exists(hash.name))) { hash.ID = lastId; newHashtags.Add(hash); lastId++; } else { hash.ID = hashtagBusiness.GetHashtagIdByHashtagName(hash.name); } } hashtags.AddRange(hashtagBusiness.AddHashtag(newHashtags)); foreach (var hash in hashtags) { entryHashtagBusiness.AddEntryHashtag(currentEntry.ID, hash.ID); } } }
/// <summary> /// Add a new entry. /// </summary> /// <param name="entry">Entry to be stored.</param> /// <returns>Returns the same entry stored.</returns> public Model.Entry AddEntry(Model.Entry entry) { int id = this.GetLastId(); entry.ID = id + 1; entry.date = DateTime.Now; _db.Entries.Add(entry); _db.SaveChanges(); return(entry); }
public ActionResult NewEntry(Model.Entry NewEntry) { if (Session["user"] != null) { Model.User user = (Model.User)Session["user"]; hashtagManager.AddEntry(NewEntry.message, user); return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Login")); }
/// <summary> /// Allows to add items to ListView /// </summary> /// <param name="listView">target listview</param> /// <param name="item">current entry</param> /// <param name="isNew">Empty if new item</param> public static void AddListViewItem(ListView listView, Entry item, bool isNew) { var listViewItem = new ListViewItem(item.Name); listViewItem.SubItems.Add(item.Root); listViewItem.Tag = item.ID; if (!isNew) { listViewItem.SubItems.Add(item.DateChanged); listViewItem.SubItems.Add(item.Description); listViewItem.ToolTipText = item.Code; listViewItem.ImageIndex = 0; } listView.Items.Add(listViewItem); }
/// <summary> /// Allows to insert or update item in XML document by Key /// </summary> /// <param name="item"> </param> /// <param name="key"></param> /// <param name="id">unique key value</param> public Int64 InsertOrUpdateItem(Entry item, string key, Int64 id) { List<Entry> list = GetList(); if (list.Find(x => x.ID == id) == null) { item.ID = list.Count == 0 ? 1 : list.Select(x => x.ID).Max() + 2; list.Add(item); } else { list.Remove(list.Find(x => x.ID == id)); item.ID = id; list.Add(item); } using (var myWriter = new StreamWriter(FileName, false, Encoding.Default)) { new XmlSerializer(typeof (List<Entry>), new[] {typeof (Entry)}).Serialize(myWriter, list); } return item.ID; }
protected bool Equals(Entry other) { return Id == other.Id && string.Equals(Name, other.Name) && string.Equals(Password, other.Password) && string.Equals(Category, other.Category); }
private void SetClipboardContent(Entry selectedEntry) { DataPackage dataPackage = new DataPackage(); try { dataPackage.SetText(selectedEntry.Password); Clipboard.SetContent(dataPackage); } catch (Exception) { // ignored } }
public bool Remove(Entry item) { return _storedEntries.Remove(item.GetHashCode()); }
public bool Contains(Entry item) { return _storedEntries.ContainsValue(item); }
public EntryEditor(Entry entry) { InitializeComponent(); EntryItem = entry; }
private void InitDefaultSettings(Entry entry) { DefaultName = entry.Name; DefaultPassword = entry.Password; DefaultCategory = entry.Category; IsDirty = false; }
private void newToolStripButton_Click(object sender, EventArgs e) { var entry = new Entry { Name = "Empty", Category = "New" }; _repository.Save(entry); Changed(null); }