private void Edit() { if (Global.AddLink == null && Global.EditLink == null) { Link lnk = (Link)dgLinks.SelectedItem; if (lnk != null) { EditLink el = new EditLink(); Global.EditLink = el; el.Init(lnk); el.Show(); } } }
private void Link(string ttl, string url) { if (Global.AddLink == null && Global.EditLink == null) { try { Link lnk = Global.DataBase.Link.Where(l => l.Url == url).FirstOrDefault(); if (lnk == null) { lnk = new Link(); lnk.Name = ttl.Substring(0, Math.Min(ttl.Length, 50)); lnk.Url = url; lnk.Description = string.Empty; lnk.Added = false; lnk.Time = 0; AddLink al = new AddLink(); Global.AddLink = al; } if (!lnk.Added) { lnk.Type = Library.GetDictValue(Global.Cache, "type"); lnk.Path = Library.GetDictValue(Global.Cache, "path"); lnk.Active = true; AddLink al = new AddLink(); Global.AddLink = al; al.Init(lnk); al.Show(); } else { EditLink el = new EditLink(); Global.EditLink = el; el.Init(lnk); el.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } }