Beispiel #1
0
        private void btnAdd_OnClick(object sender, RoutedEventArgs e)
        {
            string title = tbTitle.Text;

            if (string.IsNullOrEmpty(title))
            {
                MessageBox.Show("Please input Title field");
                return;
            }

            string url = tbUrl.Text;

            if (string.IsNullOrEmpty(url))
            {
                MessageBox.Show("Please input URL field");
                return;
            }

            string action = tbActionword.Text;

            if (string.IsNullOrEmpty(action))
            {
                MessageBox.Show("Please input ActionWord field");
                return;
            }


            if (!update)
            {
                if (CommonStorage.Instance.UserSetting.WebSearches.Exists(o => o.ActionWord == action))
                {
                    MessageBox.Show("ActionWord has existed, please input a new one.");
                    return;
                }
                CommonStorage.Instance.UserSetting.WebSearches.Add(new WebSearch()
                {
                    ActionWord = action,
                    Enabled    = cbEnable.IsChecked ?? false,
                    IconPath   = tbIconPath.Text,
                    Url        = url,
                    Title      = title
                });
                MessageBox.Show(string.Format("Add {0} web search successfully!", title));
            }
            else
            {
                updateWebSearch.ActionWord = action;
                updateWebSearch.IconPath   = tbIconPath.Text;
                updateWebSearch.Enabled    = cbEnable.IsChecked ?? false;
                updateWebSearch.Url        = url;
                updateWebSearch.Title      = title;
                MessageBox.Show(string.Format("Update {0} web search successfully!", title));
            }
            CommonStorage.Instance.Save();
            settingWidow.ReloadWebSearchView();
            Close();
        }