private void frmDeckView_FormClosing(object sender, FormClosingEventArgs e) { DB2Config config = DB2Config.GetInstance(); if (string.Equals(config.GetSetting("SaveLayout"), "True", StringComparison.OrdinalIgnoreCase)) { SaveLayout("DeckViewLayout.xml"); if (listViewEx1.View == View.Details) { config.SetSetting("DeckView1", "List"); } else { config.SetSetting("DeckView1", "Ico"); } if (listViewEx2.View == View.Details) { config.SetSetting("DeckView2", "List"); } else { config.SetSetting("DeckView2", "Ico"); } if (listViewEx3.View == View.Details) { config.SetSetting("DeckView3", "List"); } else { config.SetSetting("DeckView3", "Ico"); } } }
private void frmCardView_Load(object sender, EventArgs e) { LoadMenu(); listViewEx1.LargeImageList = Global.frmMainHolder.imageList1; listViewEx1.SmallImageList = Global.frmMainHolder.imageList2; sorter.AddField("ID", SortField.INT, false); sorter.AddField("atkValue", SortField.INT); sorter.AddField("defValue", SortField.INT); sorter.AddField("name2", SortField.STRING); sorter.AddField("japName2", SortField.STRING); sorter.AddField("cardType2", SortField.STRING, false); sorter.AddField("element", SortField.STRING); sorter.AddField("tribe", SortField.STRING); sorter.AddField("level", SortField.INT); DB2Config config = DB2Config.GetInstance(); if (string.Equals(config.GetSetting("SaveLayout"), "True", StringComparison.OrdinalIgnoreCase)) { if (string.Equals(config.GetSetting("CardView"), "List", StringComparison.OrdinalIgnoreCase)) { listViewEx1.View = View.Details; } else { listViewEx1.View = View.LargeIcon; } } }
private void listViewEx1_ItemDrag(object sender, ItemDragEventArgs e) { if (!string.Equals(DB2Config.GetInstance().GetSetting("NoDrag"), "True", StringComparison.OrdinalIgnoreCase) && e.Button == MouseButtons.Left) { Application.DoEvents(); VirtualListView ListViewEx = (VirtualListView)sender; ListViewItem item = (ListViewItem)e.Item;//listViewEx1.GetItemAt(e.X, e.Y); if (item == null) { return; } if (item.Selected == false) { item.Selected = true; listViewEx1.Update(); } DragCard dragcard = new DragCard(); int id = int.Parse(item.SubItems[8].Text); dragcard.Card = CardLibrary.GetInstance().GetCardByID(id); dragcard.FromObject = ListViewEx; ListViewEx.DoDragDrop(dragcard, DragDropEffects.Copy); } }
public int GetImageIndex(int id) { if (string.Equals(DB2Config.GetInstance().GetSetting("NotShowIco"), "True", StringComparison.OrdinalIgnoreCase)) { return(0); } else { object o = null; lock (IndexMapper) { o = IndexMapper[id]; } if (o == null) { lock (NeedShow) { NeedShow.Push(new PicInfo(id, true)); } return(0); } else { return((int)o); } } }
private void LoadDeck() { OpenFileDialog opdlg = new OpenFileDialog(); opdlg.Filter = "卡组文件(*.txt;*.deck)|*.txt;*.deck|所有文件(*.*)|*.*"; opdlg.InitialDirectory = DB2Config.GetInstance().GetSetting("DeckPath"); if (opdlg.ShowDialog() == DialogResult.OK) { filename = opdlg.FileName; string err = deck.LoadFile(filename); //UpdateDeckTotal(); if (err == null) { MessageBox.Show("卡组读入完毕!"); string deckname = Regex.Replace(opdlg.FileName, @".[^.]*$", ""); deckname = Regex.Replace(deckname, @"^.*\\", ""); this.Text = string.Format("{0}", deckname); deck.Sort(sorter.GetSortFields()); ShowDeck(); } else { MessageBox.Show(err); } } dockContainerItem1.Text = string.Format("主卡组({0:D2})", MainCards.Length); dockContainerItem2.Text = string.Format("副卡组({0:D2})", SideCards.Length); dockContainerItem3.Text = string.Format("额外卡组({0:D2})", FusionCards.Length); CountCards(); }
//根据卡片ID返回略缩图序号 public int GetLargeIcoIndex(int id) { if (string.Equals(DB2Config.GetInstance().GetSetting("NotShowIco"), "True", StringComparison.OrdinalIgnoreCase)) { //如果不显示略缩图,直接返回默认略缩图序号0 return(0); } else { //如果显示略缩图 object o = null; int index = cardLibrary.GetCardIndexByID(id); //获取略缩图序号 lock (IndexMapper) { o = IndexMapper[index]; } //返回略缩图序号 if (o == null) { //如果还没有载入,将该请求压栈,返回0 lock (NeedShow) { NeedShow.Push(new PicInfo(index, true)); } return(0); } else { return((int)o); } } }
private void DoLoadEnd() { //System.Windows.Forms.MessageBox.Show("载入图标完成!"); if (string.Equals(DB2Config.GetInstance().GetSetting("NoVirtualMode"), "True", StringComparison.OrdinalIgnoreCase)) { MethodInvoker Invoker = new MethodInvoker(Global.frmMainHolder.LoadPicEnd); Global.frmMainHolder.BeginInvoke(Invoker); } }
//int RefreshTime = 0; private void LoadPic() { int loadedcount = 0; while (loadedcount < Capacity) { PicInfo picinfo; lock (NeedShow) { picinfo = NeedShow.Pop(); } object o = null; lock (IndexMapper) { o = IndexMapper[picinfo.Id]; } if (o == null) { int currentindex = Load(picinfo.Id); lock (IndexMapper) { IndexMapper[picinfo.Id] = currentindex; } loadedcount++; if (picinfo.IsNeedShow) { NeedRefresh = true; //Global.frmMainHolder.BeginInvoke(new cardinvoke(Global.frmMainHolder.PicLoaded), new Object[] { picinfo.Index }); } else { if (NeedRefresh && !IsRefreshing) { IsRefreshing = true; Global.frmMainHolder.BeginInvoke(PicInvoker); NeedRefresh = false; IsRefreshing = false; System.Threading.Thread.Sleep(refreshinterval); } } } } //System.Windows.Forms.MessageBox.Show("ÔØÈëͼ±êÍê³É£¡"); if (string.Equals(DB2Config.GetInstance().GetSetting("NoVirtualMode"), "True", StringComparison.OrdinalIgnoreCase)) { MethodInvoker Invoker = new MethodInvoker(Global.frmMainHolder.LoadPicEnd); Global.frmMainHolder.BeginInvoke(Invoker); } }
public void LoadDeck() { OpenFileDialog opdlg = new OpenFileDialog(); opdlg.Filter = "卡组文件(*.txt;*.deck;*.ydk)|*.txt;*.deck;*.ydk|所有文件(*.*)|*.*"; opdlg.InitialDirectory = DB2Config.GetInstance().GetSetting("DeckPath"); if (opdlg.ShowDialog() == DialogResult.OK) { string filename = opdlg.FileName; LoadDeck(filename); } CountCards(); }
private void frmConfig_Load(object sender, EventArgs e) { DB2Config config = DB2Config.GetInstance(); CLConfig clconfig = CLConfig.GetInstance(); if (string.Equals(config.GetSettingNext("NotShowIco"), "True", StringComparison.OrdinalIgnoreCase)) { checkBoxX1.Checked = true; } if (string.Equals(config.GetSettingNext("NoVirtualMode"), "True", StringComparison.OrdinalIgnoreCase)) { checkBoxX2.Checked = true; } if (string.Equals(clconfig.GetSetting("AllowForbiddenCard"), "True", StringComparison.OrdinalIgnoreCase)) { checkBoxX3.Checked = true; } if (string.Equals(config.GetSettingNext("NoDrag"), "True", StringComparison.OrdinalIgnoreCase)) { checkBoxX4.Checked = true; } if (!string.Equals(clconfig.GetSettingNext("AllowDIY"), "True", StringComparison.OrdinalIgnoreCase)) { checkBoxX5.Checked = false; } if (!string.Equals(config.GetSetting("SaveLayout"), "True", StringComparison.OrdinalIgnoreCase)) { checkBoxX6.Checked = false; } textBox1.Text = config.GetSetting("ImagePath"); textBox2.Text = config.GetSetting("IcoPath"); textBox3.Text = config.GetSetting("NBXPath"); textBox4.Text = config.GetSetting("DeckPath"); textBox5.Text = config.GetSetting("DIYImagePath"); }
public PicLoader(int capacity, string dirPath, string diyPath) { if (!string.Equals(DB2Config.GetInstance().GetSetting("NotShowIco"), "True", StringComparison.OrdinalIgnoreCase)) { refreshinterval = Tools.Config.GetIntValue(DB2Config.GetInstance().GetSetting("RefreshInterval"), 200); loadpicinterval = Tools.Config.GetIntValue(DB2Config.GetInstance().GetSetting("LoadPicInterval"), 20); loadoncenum = Tools.Config.GetIntValue(DB2Config.GetInstance().GetSetting("LoadPicOnceNum"), 10); Global.loadPicEnd = false; Capacity = capacity; DirPath = dirPath; DIYPath = diyPath; if (DirPath[DirPath.Length - 1] != '\\') { DirPath += "\\"; } if (DIYPath[DIYPath.Length - 1] != '\\') { DIYPath += "\\"; } NeedShow = new Stack <PicInfo>(); mutex = new Mutex(); for (int i = capacity; i > 0; i--) { NeedShow.Push(new PicInfo(i, false)); } IndexMapper = new Hashtable(capacity + 1); Thread WorkThread = new Thread(new ThreadStart(LoadPic)); WorkThread.IsBackground = true; WorkThread.Priority = ThreadPriority.BelowNormal; WorkThread.Start(); } else { //MethodInvoker Invoker = new MethodInvoker(Global.frmMainHolder.LoadPicEnd); //Global.frmMainHolder.BeginInvoke(Invoker); Global.loadPicEnd = true; } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string appPath = Application.ExecutablePath; for (int i = appPath.Length - 1; i >= 0; i--) { if (appPath[i] == '\\') { Global.appPath = appPath.Substring(0, i); break; } } if (string.Equals(DB2Config.GetInstance().GetSetting("FirstTimeRun"), "True", StringComparison.OrdinalIgnoreCase)) { string icodir = DB2Config.GetInstance().GetSetting("IcoPath"); string testicofile = icodir + "1.jpg"; if (!System.IO.File.Exists(testicofile)) { DB2Config.GetInstance().SetSetting("FirstTimeRun", "False"); if (MessageBox.Show("您是第一次运行本程序,为了完整的体验本程序的所有功能,请先运行辅助转换工具(ConveterTools.exe)生成略缩图。是否生成略缩图?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { System.Diagnostics.Process.Start(Application.StartupPath + "\\ConveterTools.exe"); } catch { } return; } } } Application.Run(new frmMain()); //Application.Run(new frmDeckView()); }
//构造函数(略缩图数量, 略缩图路径, DIY略缩图路径) public PicLoader(int capacity, string icoPath, string diyIcoPath) { DB2Config config = DB2Config.GetInstance(); if (!string.Equals(config.GetSetting("NotShowIco"), "True", StringComparison.OrdinalIgnoreCase)) { //读取参数 refreshinterval = MyTools.Config.GetIntValue(config.GetSetting("RefreshInterval"), 200); loadpicinterval = MyTools.Config.GetIntValue(config.GetSetting("LoadPicInterval"), 20); loadoncenum = MyTools.Config.GetIntValue(config.GetSetting("LoadPicOnceNum"), 10); //初始化 Global.loadPicEnd = false; Capacity = capacity; IcoPath = FileTools.DirToPath(FileTools.RelativeToAbsolutePath(icoPath)); DIYIcoPath = FileTools.DirToPath(FileTools.RelativeToAbsolutePath(diyIcoPath)); NeedShow = new Stack <PicInfo>(); IndexMapper = new Hashtable(capacity + 1); //将所有载入略缩图请求压栈 for (int i = capacity - 1; i >= 0; i--) { NeedShow.Push(new PicInfo(i, false)); } //在新线程载入略缩图 Thread WorkThread = new Thread(new ThreadStart(LoadPic)); WorkThread.IsBackground = true; WorkThread.Priority = ThreadPriority.BelowNormal; WorkThread.Start(); } else { DoLoadEnd(); } }
private void frmDeckView_Load(object sender, EventArgs e) { DB2Config config = DB2Config.GetInstance(); SaveLayout("DefaultDeckViewLayout.xml"); if (string.Equals(config.GetSetting("SaveLayout"), "True", StringComparison.OrdinalIgnoreCase)) { LoadLayout("DeckViewLayout.xml"); } // // columnHeader1 // this.columnHeader1.Text = "中文名"; this.columnHeader1.Width = 128; // // columnHeader2 // this.columnHeader2.Text = "日文名"; this.columnHeader2.Width = 125; // // columnHeader3 // this.columnHeader3.Text = "卡种"; this.columnHeader3.Width = 65; // // columnHeader4 // this.columnHeader4.Text = "种族"; // // columnHeader5 // this.columnHeader5.Text = "属性"; this.columnHeader5.Width = 42; // // columnHeader6 // this.columnHeader6.Text = "星级"; this.columnHeader6.Width = 42; // // columnHeader7 // this.columnHeader7.Text = "攻击"; // // columnHeader8 // this.columnHeader8.Text = "防御"; // // columnHeader9 // this.columnHeader9.Text = "自编号"; this.columnHeader9.Width = 51; this.listViewEx1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader1, this.columnHeader2, this.columnHeader3, this.columnHeader4, this.columnHeader5, this.columnHeader6, this.columnHeader7, this.columnHeader8, this.columnHeader9 }); listViewEx1.LargeImageList = Global.frmMainHolder.imageList1; listViewEx2.LargeImageList = Global.frmMainHolder.imageList1; listViewEx3.LargeImageList = Global.frmMainHolder.imageList1; listViewEx1.SmallImageList = Global.frmMainHolder.imageList2; listViewEx2.SmallImageList = Global.frmMainHolder.imageList2; listViewEx3.SmallImageList = Global.frmMainHolder.imageList2; sorter.AddField("cardType2", SortField.INT, false, false); sorter.AddField("atkValue", SortField.INT); sorter.AddField("defValue", SortField.INT); sorter.AddField("ID", SortField.DOC, true, false); sorter.AddField("name2", SortField.STRING, true); sorter.AddField("japName2", SortField.STRING, true); sorter.AddField("element", SortField.STRING); sorter.AddField("tribe", SortField.STRING); sorter.AddField("level", SortField.INT); if (string.Equals(config.GetSetting("SaveLayout"), "True", StringComparison.OrdinalIgnoreCase)) { if (string.Equals(config.GetSetting("DeckView1"), "List", StringComparison.OrdinalIgnoreCase)) { listViewEx1.View = View.Details; } else { listViewEx1.View = View.LargeIcon; } if (string.Equals(config.GetSetting("DeckView2"), "List", StringComparison.OrdinalIgnoreCase)) { listViewEx2.View = View.Details; } else { listViewEx2.View = View.LargeIcon; } if (string.Equals(config.GetSetting("DeckView3"), "List", StringComparison.OrdinalIgnoreCase)) { listViewEx3.View = View.Details; } else { listViewEx3.View = View.LargeIcon; } } }
private void buttonX1_Click(object sender, EventArgs e) { DB2Config config = DB2Config.GetInstance(); CLConfig clconfig = CLConfig.GetInstance(); if (checkBoxX1.Checked) { config.SetSettingNext("NotShowIco", "True"); } else { config.SetSettingNext("NotShowIco", "False"); } if (checkBoxX2.Checked) { config.SetSettingNext("NoVirtualMode", "True"); } else { config.SetSettingNext("NoVirtualMode", "False"); } if (checkBoxX3.Checked) { clconfig.SetSetting("AllowForbiddenCard", "True"); } else { clconfig.SetSetting("AllowForbiddenCard", "False"); } if (checkBoxX4.Checked) { config.SetSetting("NoDrag", "True"); } else { config.SetSetting("NoDrag", "False"); } if (checkBoxX5.Checked) { clconfig.SetSetting("AllowDIY", "True"); } else { clconfig.SetSetting("AllowDIY", "False"); } if (checkBoxX6.Checked) { config.SetSetting("SaveLayout", "True"); } else { config.SetSetting("SaveLayout", "False"); } config.SetSetting("ImagePath", textBox1.Text); config.SetSetting("IcoPath", textBox2.Text); config.SetSetting("NBXPath", textBox3.Text); config.SetSetting("DeckPath", textBox4.Text); config.SetSetting("DIYImagePath", textBox5.Text); this.Close(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string appPath = Application.ExecutablePath; for (int i = appPath.Length - 1; i >= 0; i--) { if (appPath[i] == '\\') { Global.appPath = appPath.Substring(0, i); break; } } Patch1(); if (string.Equals(DB2Config.GetInstance().GetSetting("FirstTimeRun"), "True", StringComparison.OrdinalIgnoreCase)) { string icodir = DB2Config.GetInstance().GetSetting("IcoPath"); string testicofile = icodir + "1.jpg"; if (!System.IO.File.Exists(testicofile)) { DB2Config.GetInstance().SetSetting("FirstTimeRun", "False"); if (MessageBox.Show("您是第一次运行本程序,为了完整的体验本程序的所有功能,请先运行辅助转换工具(ConveterTools.exe)生成略缩图。是否生成略缩图?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { System.Diagnostics.Process.Start(Application.StartupPath + "\\ConveterTools.exe"); } catch { } return; } } } BaseCardLibrary.Search.CardLibrary cardLibrary = BaseCardLibrary.Search.CardLibrary.GetInstance(); Global.DataVersion = Global.InternalVersion * 100000 + cardLibrary.GetNonDIYCount(); //为SoftMgr设置初始信息 mAppInterface.SetProgramInfo("DeckBuilder", Global.appPath, Global.DataVersion); //获取目录信息 mAppInterface.GetCardImgDirEx(ref PicLoader.commonImagePath); PicLoader.commonImagePath = FileTools.DirToPath(PicLoader.commonImagePath); PicLoader.imagePath = DB2Config.GetInstance().GetSetting("ImagePath"); PicLoader.imagePath = FileTools.DirToPath(PicLoader.imagePath); mAppInterface.GetDIYCardImgDirEx(ref PicLoader.commonDiyImagePath); PicLoader.commonDiyImagePath = FileTools.DirToPath(PicLoader.commonDiyImagePath); PicLoader.diyImagePath = DB2Config.GetInstance().GetSetting("DIYImagePath"); PicLoader.diyImagePath = FileTools.DirToPath(PicLoader.diyImagePath); PicLoader.icoPath = DB2Config.GetInstance().GetSetting("IcoPath"); PicLoader.diyIcoPath = DB2Config.GetInstance().GetSetting("IcoPath"); Application.Run(new frmMain()); //Application.Run(new frmDeckView()); }