public void SetStockFileInfos(StockFileInfo[] stockFileInfoArray) { for (int iIndex = 0; iIndex < stockFileInfoArray.Length; iIndex++) { StockFileInfo stockFileInfo = stockFileInfoArray[iIndex]; string securityInfo = GlobalSetting.GetStockCode(stockFileInfo.StockName, stockFileInfo.StockSymbol); ListViewItem listViewItem = new ListViewItem(stockFileInfo.StockName); ListViewItem.ListViewSubItem listViewSubItem1 = new ListViewItem.ListViewSubItem(listViewItem, stockFileInfo.StockSymbol); ListViewItem.ListViewSubItem listViewSubItem2 = new ListViewItem.ListViewSubItem(listViewItem, stockFileInfo.StockFilePath); listViewItem.SubItems.Add(listViewSubItem1); listViewItem.SubItems.Add(listViewSubItem2); bool bIsOK = true; foreach (ListViewItem item in this.ListViewStock.Items) { string securityInfo2 = GlobalSetting.GetStockCode(item.Text, item.SubItems[1].Text); if (securityInfo == securityInfo2) { bIsOK = false; break; } } if (bIsOK == true) { this.ListViewStock.Items.Add(listViewItem); } } }
private void ButtonLoad_Click(object sender, EventArgs e) { this.OpenFileDialogStock.InitialDirectory = GetRegistryOpenFilePath_Open(); if (this.OpenFileDialogStock.ShowDialog(this) == DialogResult.OK) { SetRegistryOpenFilePath_Open(this.OpenFileDialogStock.InitialDirectory); StockFileInfo[] stockFileInfoArray = GlobalSetting.LoadConfigSetting(this.OpenFileDialogStock.FileName); foreach (ListViewItem item in this.ListViewStock.Items) { m_ListDelete.Add(item); } for (int iIndex = 0; iIndex < stockFileInfoArray.Length; iIndex++) { StockFileInfo stockFileInfo = stockFileInfoArray[iIndex]; string securityInfo = GlobalSetting.GetStockCode(stockFileInfo.StockName, stockFileInfo.StockSymbol); ListViewItem listViewItem = new ListViewItem(stockFileInfo.StockName); ListViewItem.ListViewSubItem listViewSubItem1 = new ListViewItem.ListViewSubItem(listViewItem, stockFileInfo.StockSymbol); ListViewItem.ListViewSubItem listViewSubItem2 = new ListViewItem.ListViewSubItem(listViewItem, stockFileInfo.StockFilePath); listViewItem.SubItems.Add(listViewSubItem1); listViewItem.SubItems.Add(listViewSubItem2); bool bIsOK = true; foreach (ListViewItem item in this.ListViewStock.Items) { string securityInfo2 = GlobalSetting.GetStockCode(item.Text, item.SubItems[1].Text); if (securityInfo == securityInfo2) { bIsOK = false; break; } } if (bIsOK == true) { m_ListAdd.Add(listViewItem); this.ListViewStock.Items.Add(listViewItem); } } if (ButtonSaveChanged != null) { ButtonSaveChanged(this, EventArgs.Empty); } } }
public StockFileInfo[] GetStockFileInfos() { List <StockFileInfo> stockFileInfoList = new List <StockFileInfo>(); for (int iIndex = 0; iIndex < this.ListViewStock.Items.Count; iIndex++) { ListViewItem listViewItem = this.ListViewStock.Items[iIndex]; StockFileInfo stockFileInfo = new StockFileInfo(); stockFileInfo.StockName = listViewItem.Text; stockFileInfo.StockSymbol = listViewItem.SubItems[1].Text; stockFileInfo.StockFilePath = listViewItem.SubItems[2].Text; stockFileInfoList.Add(stockFileInfo); } return(stockFileInfoList.ToArray()); }
public static void SaveOptionFormInfo(string strConfigFile, OptionFormInfo optionFormInfo) { if (optionFormInfo == null) { return; } if (File.Exists(strConfigFile) == true) { File.Delete(strConfigFile); } XElement elementRoot = new XElement("Demo.Stock", new XAttribute("Ver", "0.0.1.0")); for (int iIndex = 0; iIndex < optionFormInfo.m_StockFileInfos.Length; iIndex++) { StockFileInfo stockFileInfo = optionFormInfo.m_StockFileInfos[iIndex]; XElement elementStockFileInfo = new XElement("StockFileInfo", new XAttribute("Name", stockFileInfo.StockName)); elementStockFileInfo.Add(new XAttribute("Symbol", stockFileInfo.StockSymbol)); elementStockFileInfo.Value = stockFileInfo.StockFilePath; elementRoot.Add(elementStockFileInfo); } XElement elementTriggerInfos = new XElement("TriggerInfos", new XAttribute("Ver", "0.0.1.0")); { elementTriggerInfos.Add(new XAttribute("AllowTrigger", optionFormInfo.m_TriggerInfos.m_AllowTrigger.ToString())); } elementRoot.Add(elementTriggerInfos); XDocument documentConfig = new XDocument(new XDeclaration("1.0", "utf - 8", "yes"), elementRoot); documentConfig.Save(strConfigFile); }
public static OptionFormInfo LoadOptionFormInfo(string strConfigFile) { if (File.Exists(strConfigFile) == false) { return(null); } XDocument documentConfig = XDocument.Load(strConfigFile); if (documentConfig == null) { return(null); } XElement elementRoot = documentConfig.Element((XName)"Demo.Stock"); if (elementRoot == null) { return(null); } XAttribute attributeVer = elementRoot.Attribute((XName)"Ver"); if (attributeVer == null) { return(null); } OptionFormInfo optionFormInfo = new OptionFormInfo(); ////////////////////////////////////////////////////////////////////////// // <Settings> IEnumerable <XElement> elementStockFileInfos = elementRoot.Elements((XName)"StockFileInfo"); if (elementStockFileInfos == null) { return(null); } List <StockFileInfo> stockFileInfoList = new List <StockFileInfo>(); foreach (var elementStockFileInfo in elementStockFileInfos) { XAttribute attributeName = elementStockFileInfo.Attribute((XName)"Name"); if (attributeName == null) { continue; } XAttribute attributeSymbol = elementStockFileInfo.Attribute((XName)"Symbol"); if (attributeSymbol == null) { continue; } StockFileInfo stockFileInfo = new StockFileInfo(); stockFileInfo.StockName = attributeName.Value; stockFileInfo.StockSymbol = attributeSymbol.Value; stockFileInfo.StockFilePath = elementStockFileInfo.Value; stockFileInfoList.Add(stockFileInfo); } optionFormInfo.m_StockFileInfos = stockFileInfoList.ToArray(); XElement elementScanBaseInfo = elementRoot.Element((XName)"TriggerInfos"); if (elementScanBaseInfo == null) { return(null); } else { XAttribute attributeAllowTrigger = elementScanBaseInfo.Attribute((XName)"AllowTrigger"); if (attributeAllowTrigger == null) { return(null); } else { optionFormInfo.m_TriggerInfos.m_AllowTrigger = bool.Parse(attributeAllowTrigger.Value); } } return(optionFormInfo); }