Example #1
0
        /// <summary>
        /// Saves the given query
        /// </summary>
        public async void Save(SearchContext original)
        {
            var model = (SearchContext)original.Clone();

            model.Executor = null;
            var viewmodel = new DialogSaveViewModel(model.Title, Properties.Settings.Default.Bookmarks.Select(v => v.Title).ToList());

            if ((bool)await DialogHost.Show(viewmodel))
            {
                model.Title = viewmodel.Title;
                var existing = Properties.Settings.Default.Bookmarks.FirstOrDefault(q => q.Title == model.Title);
                if (existing != null)
                {
                    var index = Properties.Settings.Default.Bookmarks.IndexOf(existing);
                    Properties.Settings.Default.Bookmarks.RemoveAt(index);
                    Properties.Settings.Default.Bookmarks.Insert(index, model);
                }
                else
                {
                    Properties.Settings.Default.Bookmarks.Add(model);
                }

                Properties.Settings.Default.Save();
                UpdateBookmarks();
            }
        }
Example #2
0
        /// <summary>
        /// Edits the given query
        /// </summary>
        /// <param name="model">The query to delete</param>
        public async void Edit(SearchContext model)
        {
            var viewmodel = new DialogSaveViewModel(model.Title, Properties.Settings.Default.Bookmarks.Select(v => v.Title).ToList());

            if ((bool)await DialogHost.Show(viewmodel))
            {
                model.Title = viewmodel.Title;
                Properties.Settings.Default.Save();
                UpdateBookmarks();
            }
        }