/// <summary> /// 初始化加载 /// </summary> private void Window_Loaded(object sender, RoutedEventArgs e) { //关闭图片 img.Source = new BitmapImage(new Uri(BLL.DataFetch.Path + "Resources/Close_click.png")); HwndSource hWndSource, hPause, hBeginAndEnd; WindowInteropHelper wih = new WindowInteropHelper(this); hWndSource = HwndSource.FromHwnd(wih.Handle); hPause = HwndSource.FromHwnd(wih.Handle); hBeginAndEnd = HwndSource.FromHwnd(wih.Handle); //添加处理程序 hWndSource.AddHook(MainWindowProc); hPause.AddHook(MainWindowProc); hBeginAndEnd.AddHook(MainWindowProc); Identification = HotKey.GlobalAddAtom("Alt-D"); //暂停播放 Pause = HotKey.GlobalAddAtom("Alt-Q"); //停止开始 BeginAndEnd = HotKey.GlobalAddAtom("Alt-W"); HotKey.RegisterHotKey(wih.Handle, Identification, HotKey.KeyModifiers.Alt, (int)System.Windows.Forms.Keys.D); HotKey.RegisterHotKey(wih.Handle, Pause, HotKey.KeyModifiers.Alt, (int)System.Windows.Forms.Keys.Q); HotKey.RegisterHotKey(wih.Handle, BeginAndEnd, HotKey.KeyModifiers.Alt, (int)System.Windows.Forms.Keys.W); //判断配置项是否为null if (config == null) { config = ConfigReadWrite.GetConfig(); } //记载配置项 LoadConfiguration(); }
/// <summary> /// 主题保存 /// </summary> private void ThemePreservation(object sender, RoutedEventArgs e) { switch (((MenuItem)sender).Name) { case "Default": { config.Theme = "正常模式"; break; } case "Eyehelp": { config.Theme = "护眼模式"; break; } case "Night": { config.Theme = "黑夜模式"; break; } case "transparent": { config.Theme = "透明模式"; break; } } LoadConfiguration(); ConfigReadWrite.SetConfig(config); }
public MainWindow() { InitializeComponent(); string path = AppDomain.CurrentDomain.BaseDirectory; //this.Icon = BitmapFrame.Create(new Uri(path + "Resources/favicon.ico")); //获取配置项 config = ConfigReadWrite.GetConfig(); about.Text = "本软件只是娱乐之作,所有数据来源皆来自于网络,如果有侵犯到他人的权益,请于我进行联系,我会第一时间删除源站,谢谢合作!\n\n本软件默认有两个源:笔趣阁、追书网,用户可以自定义增加更多的源站,如果你有更好的源站,可以推荐给我,我会第一时间集成进去。\n\n本软件初始发布于吾爱破解,如果你在使用的过程中有发现BUG或者其他不合理的地方,请进行留言。本软件只作用于学习研究,请在下载内24小时内删除本软件。"; //字体 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; //刷新数据 RefreshData(); //绑定书源 SourceStation.ItemsSource = lb; SourceStation.Text = config.SourceStation; //禁用养肥区 fatten.IsEnabled = false; }
/// <summary> /// 窗口大小改变时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ReadingPage_Resize(object sender, SizeChangedEventArgs e) { //这里也要实时修改控件所处的相对位置 img.Margin = new Thickness(this.Width - img.Width - 10, 5, 6, this.Height - img.Height - 5); //标题 newTitle.Margin = new Thickness(10, 5, 0, 0); if (this.Width != 470 || this.Height != 650) { //记忆保存此次设置的大小 config.Width_height = this.Width + "," + this.Height; ConfigReadWrite.SetConfig(config); } }
public MainWindow() { InitializeComponent(); //190731增加,这里新增加一个判断,判断是否存在指定列,如果不存在将进行增加列操作 if (!DataFetch.ColumnExistence("BookSource", "Code")) { SQLiteDBHelper.ExecuteDataTable("ALTER TABLE BookSource ADD COLUMN Code Text; ", null); } string path = AppDomain.CurrentDomain.BaseDirectory; //this.Icon = BitmapFrame.Create(new Uri(path + "Resources/favicon.ico")); //获取配置项 config = ConfigReadWrite.GetConfig(); about.Text = "本软件只是娱乐之作,所有数据来源皆来自于网络,如果有侵犯到他人的权益,请于我进行联系,我会第一时间删除源站,谢谢合作!\n\n本软件默认有五个源,用户可以自定义增加更多的源站,如果你有更好的源站,可以推荐给我,我会第一时间集成进去。\n\n本软件初始发布于吾爱破解,如果你在使用的过程中有发现BUG或者其他不合理的地方,请进行留言。本软件只作用于学习研究,请在下载内24小时内删除本软件。"; //字体 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; //更新书源状态 //DataFetch.UpdateSourceState(); //刷新数据 RefreshData(); //绑定书源 SourceStation.ItemsSource = lb; SourceStation.Text = config.SourceStation; //默认显示养肥区 FertilizingArea.Visibility = Visibility.Visible; fatten.IsEnabled = true; //绑定养肥区 fatten.ItemsSource = config.GetFattenNumber; fatten.Text = config.FattenNumber.ToString(); GetFatten(); }
/// <summary> /// 保存配置项 /// </summary> private void SaveConfiguration(object sender, SelectionChangedEventArgs e) { ComboBox comboBox = (ComboBox)sender; if (comboBox.SelectedItem.ToString().Length > 0) { var msg = comboBox.SelectedItem; switch (comboBox.Name) { case "Typeface": { config.Typeface = msg.ToString(); //about this.FontFamily = new FontFamily(config.Typeface); break; } case "TypefaceSize": { config.FontSize = Convert.ToInt32(msg); break; } case "theme": { config.Theme = msg.ToString(); break; } case "SourceStation": { if (msg is BookSource) { config.SourceStation = ((BookSource)msg).Title; } break; } case "fatten": { config.FattenNumber = Convert.ToInt32(msg); break; } } ConfigReadWrite.SetConfig(config); } }
/// <summary> /// 构造函数入口 /// </summary> /// <param name="book">书籍信息</param> /// <param name="mainWindow">主窗口对象</param> /// <param name="config">配置项</param> public ReadingPage(Book book, MainWindow mainWindow = null, Config config = null) { InitializeComponent(); this.book = book; this.mainWindow = mainWindow; this.config = config; //获取目录 BLL.DataFetch.GetList(book); bookSource = BLL.DataFetch.GetBookSource(book.Source); //主要为遍历目录 int i = 0; foreach (KeyValuePair <string, string> kvp in book.ListUrl) { if (kvp.Key.Trim().Length > 2) { i++; NewId.Add(i, kvp.Key); } } if (book.Read == 0) { Jump(1); } else { Jump((int)book.Read); } this.Closed += BeforeClosing; config = ConfigReadWrite.GetConfig(); LoadConfiguration(); //newText.IsEnabled = false; //窗口大小改变时 this.SizeChanged += new SizeChangedEventHandler(ReadingPage_Resize); //设置定时器(朗读) timer = new DispatcherTimer(); timer.Interval = new TimeSpan(10000000); //时间间隔为一秒 timer.Tick += new EventHandler(timer_Tick); }
/// <summary> /// 用户登录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void skinButton_login_Click(object sender, EventArgs e) { ConfigReadWrite wr = new ConfigReadWrite(); string name = skinComboBox_name.Text; string password = skinTextBox_password.Text; if (name == "") { MessageBox.Show("用户名不能为空", "提示"); return; } if (password == "") { MessageBox.Show("密码不能为空", "提示"); return; } JObject job = pFormAll.login(name, password); if (job == null) { return; } if (job["code"].ToString() != "1") { MessageBox.Show("错误:" + job["msg"].ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //登录错误提示 if (MessageBox.Show("是否替换本地用户!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { wr.openServerName(name); wr.openServerPassword(password); wr.userToken(job["result"]["token"].ToString()); Config.websocket.stop(); //关闭 Config.websocket.start(); //重新启动 this.Close(); } else { MessageBox.Show("账号有效", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); } }
/// <summary> /// 构造函数入口 /// </summary> /// <param name="book">书籍信息</param> /// <param name="mainWindow">主窗口对象</param> /// <param name="config">配置项</param> public ReadingPage(Book book, MainWindow mainWindow = null, Config config = null) { InitializeComponent(); this.book = book; this.mainWindow = mainWindow; this.config = config; //获取目录 BLL.DataFetch.GetList(book); bookSource = BLL.DataFetch.GetBookSource(book.Source); //主要为遍历目录 int i = 0; foreach (KeyValuePair <string, string> kvp in book.ListUrl) { if (kvp.Key.Trim().Length > 2) { i++; NewId.Add(i, kvp.Key); } } if (book.Read == 0) { Jump(1); } else { Jump((int)book.Read); } this.Closed += BeforeClosing; config = ConfigReadWrite.GetConfig(); LoadConfiguration(); //newText.IsEnabled = false; }