private void 監視清單ToolStripMenuItem_Click(object sender, EventArgs e) { FrmList monList = new FrmList(_stockMgr); monList.MdiParent = this; monList.Show(); }
private void mdiStockTool_Load(object sender, EventArgs e) { try { XmlDocument xmlConfig = new XmlDocument(); xmlConfig.Load("StockTool.config"); XmlElement config = (XmlElement)xmlConfig.GetElementsByTagName("configuration")[0]; XmlElement startup = (XmlElement)config.GetElementsByTagName("startup")[0]; XmlNodeList size = startup.GetElementsByTagName("size"); if (size.Count > 0) { int width = int.Parse(((XmlElement)size[0]).GetAttribute("width")); int height = int.Parse(((XmlElement)size[0]).GetAttribute("height")); Size = new Size(width, height); } XmlNodeList startmonlists = startup.GetElementsByTagName("monlist"); for (int i = 0; i < startmonlists.Count; i++) { string path = ((XmlElement)startmonlists[i]).GetAttribute("path").Trim(); TimeSpan on, off, utcOffset, curTime = DateTime.UtcNow.TimeOfDay; utcOffset = TimeSpan.Parse(((XmlElement)startmonlists[i]).GetAttribute("utc_offset")); on = TimeSpan.Parse(((XmlElement)startmonlists[i]).GetAttribute("on")) - utcOffset; off = TimeSpan.Parse(((XmlElement)startmonlists[i]).GetAttribute("off")) - utcOffset; on = on.Subtract(new TimeSpan(on.Days, 0, 0, 0)); off = off.Subtract(new TimeSpan(off.Days, 0, 0, 0)); if ((on < off && curTime > on && curTime < off) || (on > off && (curTime > on || curTime < off))) { FrmList monList = new FrmList(_stockMgr, path); monList.MdiParent = this; monList.Show(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Console.WriteLine(DateTime.Now.ToString() + " Loading config file error"); } }
private void OpenFile(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); openFileDialog.Filter = "監視清單 (*.list)|*.list|所有檔案 (*.*)|*.*"; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { string FileName = openFileDialog.FileName; if (FileName.EndsWith(".list")) { FrmList monList = new FrmList(_stockMgr,FileName); monList.MdiParent = this; monList.Show(); } } }
private void MdiStockTool_DragDrop(object sender, DragEventArgs e) { string[] filenames = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in filenames) { if (file.EndsWith(".list")) { FrmList monList = new FrmList(_stockMgr, file); monList.MdiParent = this; monList.Show(); } } }