private bool OpenStateFile(string fileName) { if (!File.Exists(fileName)) { MessageBox.Show("File not exist : " + fileName, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } BinSerializerTool bs = new BinSerializerTool(); currentDesc = bs.FromFile(fileName) as PostDesc; if (currentDesc == null) { MessageBox.Show("File format error : " + bs.LastError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (!File.Exists(currentDesc.CaseFileName)) { MessageBox.Show("Case file not exist : " + currentDesc.CaseFileName, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); currentDesc = null; return(false); } ptvMain.PostDesc = currentDesc; ReadCase(currentDesc.CaseFileName); return(true); }
private static void FillExpected() { PostDesc[] descs = new PostDesc[1]; descs[0].from = ForwarderName; descs[0].message = "forwarded message by " + Steve + "->" + BroadcasterName + ": " + TestMessage; Expected.Add(William, descs); Expected.Add(Bill, null); descs = new PostDesc[1]; descs[0].from = Steve + "->" + BroadcasterName; descs[0].message = TestMessage; Expected.Add(Paul, descs); Expected.Add(Mary, descs); Expected.Add(Steve, descs); }
private void mi_opencase_Click(object sender, EventArgs e) { OpenFileDialog d = new OpenFileDialog(); d.CheckFileExists = true; d.Filter = " *.tcs | *.tcs"; if (d.ShowDialog() == DialogResult.OK) { currentDesc = new PostDesc(); currentDesc.CaseFileName = d.FileName; ptvMain.PostDesc = currentDesc; ReadCase(d.FileName); StateModified = true; } }
public List <PostDesc> GetPostItem() { var doc = GetDocument(Url); if (doc == null) { return(null); } List <PostDesc> rel = new List <PostDesc>(); var nodes = doc.DocumentNode.SelectNodes("//*[contains(@id,'normalthread_')]/tr[1]/th/a[2]"); foreach (var item in nodes) { PostDesc p = new PostDesc(); string href = item.GetAttributeValue("href", ""); string title = item.InnerText; if (!title.Contains("P】")) { continue; } string id = ""; string[] hrefsplit = href.Split('-'); if (hrefsplit != null && hrefsplit.Length > 2) { id = hrefsplit[1]; } p.Id = Convert.ToInt32(id); p.Title = title; p.Url = "http://c.n.h.k.xbluntan.space/" + href; BackgroundWorker works = new BackgroundWorker(); //getpicworks.Add(p,) rel.Add(p); } return(rel); }
public MainWindow(string fileName = "") { /* * license = LicenseManager.Validate(typeof(MainWindow), this); * if (!(license as WebLicense).LicenseResult.Result.IsOK) * { * MessageBox.Show(@"Unable to communicate with license server, please check your network", "License error", MessageBoxButtons.OK, MessageBoxIcon.Error); * return; * } * if ((license as WebLicense).LicenseResult.Data.state == LicenseState.NotRegisted) * { * //MessageBox.Show("Software is not registered!", "License error", MessageBoxButtons.OK, MessageBoxIcon.Error); * new RegistForm().ShowDialog(); * return; * } * if ((license as WebLicense).LicenseResult.Data.state == LicenseState.Expired) * { * //MessageBox.Show("License is expired!", "License error", MessageBoxButtons.OK, MessageBoxIcon.Error); * new RegistForm().ShowDialog(); * return; * } */ license = (LocalLicense)LicenseManager.Validate(typeof(MainWindow), this); if (license.LicenseData == null) { //MessageBox.Show("license data is null"); new RegistForm("No license file found").ShowDialog(); return; } /* * if (license.LicenseData.UsedCount >= license.LicenseData.MaxCount) * { * MessageBox.Show("use count error " + license.LicenseData.MaxCount + " " + license.LicenseData.UsedCount); * * new RegistForm().ShowDialog(); * return; * } */ if (license.LicenseData.HardwareId != LocalInformation.HardwareId) { //MessageBox.Show("hardwareid is error"); new RegistForm("The license file is not for this device").ShowDialog(); return; } DateTime now = LocalLicenseUtil.GetNetDateTime(); if (now == new DateTime(0)) { now = DateTime.Now; } if (now > license.LicenseData.ExpiredDate) { //MessageBox.Show("expired date error " + now + " " + license.LicenseData.ExpiredDate); new RegistForm("The license expires, and the final use period is " + license.LicenseData.ExpiredDate).ShowDialog(); return; } GlobalParameters.FieldNames.Clear(); GlobalParameters.FieldNames.AddRange(new string[] { "p", "U", "k", "epsilon" }); caseReader = new TplcCaseReader(this); readCaseTask = new FoamTask <bool>(); readCaseTask.OnTaskFinished += OnReadCaseFinished; InitializeComponent(); tsimMain = new ToolStripItemManager(ts_main); tsimMain.Add("case_open", new List <ToolStripItem>() { mi_opencase, tsb_opencase }); tsimMain.Add("state_open", new List <ToolStripItem>() { mi_openstate, tsb_openstate }); tsimMain.Add("state_saveas", new List <ToolStripItem>() { mi_savestateas, tsb_savestateas }); tsimMain.Add("export", new List <ToolStripItem>() { mi_export, tsb_export }); tsimMain.Add("field", new List <ToolStripItem>() { tscb_field }); tsimMain.Add("range", new List <ToolStripItem>() { tstb_max, tstb_min }); tsimMain.Add("stop", new List <ToolStripItem>() { tsb_stop }); fdvMain.OnReadMeshFinished += OnLoadDataFinished; ptvMain.SelectedImageIndex = 0; ptvMain.IndexCutList = 3; ptvMain.IndexPatchList = 4; ptvMain.IndexPatch = 2; ptvMain.IndexCutter = 1; foreach (string f in GlobalParameters.FieldNames) { tscb_field.Items.Add(f); } tscb_field.SelectedIndex = 0; StateModified = false; if (fileName != "") { if (String.Compare(Path.GetExtension(fileName), ".tcs", true) == 0) { currentDesc = new PostDesc(); currentDesc.CaseFileName = fileName; ptvMain.PostDesc = currentDesc; ReadCase(fileName); StateModified = true; } else if (String.Compare(Path.GetExtension(fileName), ".tsf", true) == 0) { StateModified = false; OpenStateFile(fileName); } } }