コード例 #1
0
        /// <summary>
        /// 保存&更新书源
        /// </summary>
        private void Keep_Click(object sender, RoutedEventArgs e)
        {
            BookSource bookSource = new BookSource();

            bookSource.Title                   = sourceName.Text.Trim();
            bookSource.Url                     = sourceUrl.Text.Trim();
            bookSource.SearchUrl               = SearchUrl.Text;
            bookSource.AddressRangeRegular     = AddressRangeRegular.Text.Replace("'", "''");
            bookSource.AddressCuttingRegular   = AddressCuttingRegular.Text.Replace("'", "''");
            bookSource.AddressRegular          = AddressRegular.Text.Replace("'", "''");
            bookSource.BookNameRegular         = BookNameRegular.Text.Replace("'", "''");
            bookSource.AuthorRegular           = AuthorRegular.Text.Replace("'", "''");
            bookSource.UpdateRegular           = UpdateRegular.Text.Replace("'", "''");
            bookSource.NewestRegular           = NewestRegular.Text.Replace("'", "''");
            bookSource.DetailsRegular          = DetailsRegular.Text.Replace("'", "''");
            bookSource.StateRegular            = StateRegular.Text.Replace("'", "''");
            bookSource.DirectoryScopeRegular   = DirectoryScopeRegular.Text.Replace("'", "''");
            bookSource.DirectoryCuttingRegular = DirectoryCuttingRegular.Text.Replace("'", "''");
            bookSource.DirectoryTieleRegular   = DirectoryTieleRegular.Text.Replace("'", "''");
            bookSource.DirectoryUrlRegular     = DirectoryUrlRegular.Text.Replace("'", "''");
            bookSource.ContentTitleRegular     = ContentTitleRegular.Text.Replace("'", "''");
            bookSource.ContentRegular          = ContentRegular.Text.Replace("'", "''");
            bookSource.ImageRegular            = ImageRegular.Text.Replace("'", "''");
            bookSource.State                   = 1;


            //这个是更新原有源
            if (((Button)sender).Content.ToString() != "保存当前书源")
            {
                int id = Convert.ToInt32(Keep.Tag);
                bookSource.Id = id;
                string Msg  = DataFetch.SourceUpdate(bookSource) ? "更新成功~" : "更新失败!";
                Tips   tips = new Tips(Msg);
                tips.Show();
                //加载书源
                ListSource.ItemsSource = DataFetch.GetBookSources();
            }
            else //这个是增加新源
            {
                if (state_search && state_details && state_Catalog && state_Text)
                {
                    if (sourceName.Text.Trim().Length > 0 && sourceName.Text != "请输入新书源名~" && sourceUrl.Text.Trim().Length > 0 && sourceUrl.Text != "请输入新书源URL~")
                    {
                        string Msg = DataFetch.SourceAdd(bookSource) ? "添加成功~" : "添加失败!";
                        new Tips(Msg).Show();
                    }
                    else
                    {
                        new Tips("请输入书源名和书源链接!").Show();
                    }
                }
                else
                {
                    new Tips("请将其他页面的内容全部填写完毕,并保证准确无误后在进行提交!").Show();
                }
            }
            //加载书源
            ListSource.ItemsSource = DataFetch.GetBookSources();
            Empty();
        }
コード例 #2
0
ファイル: TempData.cs プロジェクト: blue03/HappyReading
 /// <summary>
 /// 初始化
 /// </summary>
 public static void Initialization()
 {
     if (BookSourceS == null)
     {
         BookSourceS = DataFetch.GetBookSources();
     }
 }
コード例 #3
0
        /// <summary>
        /// 导入书源
        /// </summary>
        private void Import_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new Microsoft.Win32.OpenFileDialog()
            {
                Filter = "BookSource (*.json)|*.json"
            };

            var result = openFileDialog.ShowDialog();

            if (result == true)
            {
                try
                {
                    StreamReader sr          = new StreamReader(openFileDialog.FileName, Encoding.UTF8);
                    var          Book_Source = JsonHelper.DeserializeJsonToObject <BookSource>(sr.ReadToEnd());
                    sr.Close();
                    if (Book_Source.Title.Length > 1 && Book_Source.Url.Length > 1)
                    {
                        string Msg = DataFetch.SourceAdd(Book_Source) ? "添加成功~" : "添加失败!";
                        new Tips(Msg).Show();
                        //加载书源
                        ListSource.ItemsSource = DataFetch.GetBookSources();
                    }
                    else
                    {
                        new Tips("错误的书源").Show();
                    }
                }
                catch (Exception ex)
                {
                    new Tips("书源异常:" + ex.Message).Show();
                }
            }
        }
コード例 #4
0
        public BookSourceAdd(MainWindow mainWindow)
        {
            InitializeComponent();
            //加载书源
            ListSource.ItemsSource = DataFetch.GetBookSources();

            this.Closed    += BeforeClosing;
            this.mainWindow = mainWindow;
        }
コード例 #5
0
        public MainWindow()
        {
            InitializeComponent();

            string path = AppDomain.CurrentDomain.BaseDirectory;

            //this.Icon = BitmapFrame.Create(new Uri(path + "Resources/favicon.ico"));

            //获取配置项
            config = ConfigReadWrite.GetConfig();

            //添加书源
            lb = DataFetch.GetBookSources();

            //绑定书源
            BookSourceName.ItemsSource = lb;
            BookSourceName.Text        = config.SourceStation;
            //this.BookSourceName.SelectedIndex = 0;


            //获取所有书籍
            this.DataContext = DataFetch.GetBooks();


            //启动时更新书籍
            Update();

            //启动时更新养肥区
            UpdateFatten();


            //字体
            Typeface.ItemsSource = Tool.GetTypeface();
            Typeface.Text        = config.Typeface;

            //绑定字体大小
            TypefaceSize.ItemsSource = config.GetTypefaceSize;
            TypefaceSize.Text        = config.FontSize.ToString();

            //绑定主题
            theme.ItemsSource = config.GetTheme;
            theme.Text        = config.Theme;

            //绑定书源
            SourceStation.ItemsSource = lb;
            SourceStation.Text        = config.SourceStation;

            //禁用养肥区
            fatten.IsEnabled = false;


            about.Text = "本软件只是娱乐之作,所有数据来源皆来自于网络,如果有侵犯到他人的权益,请于我进行联系,我会第一时间删除源站,谢谢合作!\n\n本软件默认有两个源:笔趣阁、追书网,用户可以自定义增加更多的源站,如果你有更好的源站,可以推荐给我,我会第一时间集成进去。\n\n本软件初始发布于吾爱破解,如果你在使用的过程中有发现BUG或者其他不合理的地方,请进行留言。本软件只作用于学习研究,请在下载内24小时内删除本软件。";
        }
コード例 #6
0
        /// <summary>
        /// 删除书源
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            BookSource bookSource = ListSource.SelectedItem as BookSource;

            if (bookSource != null && bookSource is BookSource)
            {
                if (MessageBox.Show("确定要删除书源【" + bookSource.Title + "】? 本操作不可以逆转,请谨慎操作~", "提示", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes)
                {
                    DataFetch.DeleteBookSource((int)bookSource.Id);
                    //加载书源
                    ListSource.ItemsSource = DataFetch.GetBookSources();
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// 检测书源可用率
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Testing_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("状态码如果为1代表书源站正常访问,如果为0代表不可访问", "提示");


            App.Current.Dispatcher.Invoke((Action)(() =>
            {
                //更新书源状态
                DataFetch.UpdateSourceState();
                //加载书源
                ListSource.ItemsSource = DataFetch.GetBookSources(0);
                TempData.UpdateBookSourceS();
            }));
        }
コード例 #8
0
        /// <summary>
        /// 刷新数据
        /// </summary>
        public void RefreshData()
        {
            //添加书源
            lb = DataFetch.GetBookSources();
            lb.Add(new BookSource {
                Id = -5, Title = "全部搜索"
            });

            //绑定书源
            BookSourceName.ItemsSource = lb;
            BookSourceName.Text        = config.SourceStation;

            //获取所有书籍
            this.DataContext = DataFetch.GetBooks();

            //启动时更新书籍
            Update();

            //启动时更新养肥区
            UpdateFatten();
        }
コード例 #9
0
        /// <summary>
        /// 检测书源可用率
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Testing_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("状态码如果为1代表书源站正常访问,如果为0代表不可访问", "提示");
            Thread thread = new Thread(new ThreadStart(delegate
            {
                //遍历源站
                foreach (BookSource bookSource in DataFetch.GetBookSources())
                {
                    //1代表网站可以访问,0代表不可以访问
                    int state = GetHtml.GetUnicom(bookSource.Url) ? 1 : 0;
                    DataFetch.UpdateState((int)bookSource.Id, state);
                }

                this.Dispatcher.Invoke(new Action(() =>
                {
                    //加载书源
                    ListSource.ItemsSource = DataFetch.GetBookSources();
                }));
            }));

            thread.IsBackground = true;
            thread.Start();
        }
コード例 #10
0
 public BookSourceAdd()
 {
     InitializeComponent();
     //加载书源
     ListSource.ItemsSource = DataFetch.GetBookSources();
 }
コード例 #11
0
ファイル: TempData.cs プロジェクト: blue03/HappyReading
 /// <summary>
 /// 更新全部书源
 /// </summary>
 public static void UpdateBookSourceS()
 {
     BookSourceS = DataFetch.GetBookSources();
 }