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);
                }
            }
        }
        private void ButtonAdd_Click(object sender, EventArgs e)
        {
            this.FolderBrowserDialog.SelectedPath = GetRegistryOpenFilePath();

            if (this.FolderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                SetRegistryOpenFilePath(this.FolderBrowserDialog.SelectedPath);

                MSFL.MSFLSecurityInfo[] msflSecurityInfoArray = null;

                if (GlobalSetting.TryLoadMsflSecurityInfo(this.FolderBrowserDialog.SelectedPath, out msflSecurityInfoArray) == true)
                {
                    OptionSub2From configASubForm = new OptionSub2From(msflSecurityInfoArray);

                    if (configASubForm.ShowDialog(this) == DialogResult.OK)
                    {
                        msflSecurityInfoArray = configASubForm.ToSecurityInfo();

                        for (int iIndex = 0; iIndex < msflSecurityInfoArray.Length; iIndex++)
                        {
                            MSFL.MSFLSecurityInfo msflSecurityInfo = msflSecurityInfoArray[iIndex];
                            string securityInfo = GlobalSetting.GetStockCode(msflSecurityInfo.szName, msflSecurityInfo.szSymbol);

                            ListViewItem listViewItem = new ListViewItem(msflSecurityInfo.szName);
                            ListViewItem.ListViewSubItem listViewSubItem1 = new ListViewItem.ListViewSubItem(listViewItem, msflSecurityInfo.szSymbol);
                            ListViewItem.ListViewSubItem listViewSubItem2 = new ListViewItem.ListViewSubItem(listViewItem, this.FolderBrowserDialog.SelectedPath);

                            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);
                            }
                            else
                            {
                                //MainForm.ShowPopupMessage( securityInfo, "已经存在" );
                                MessageBox.Show(securityInfo, "已经存在");
                            }
                        }

                        if (ButtonSaveChanged != null)
                        {
                            ButtonSaveChanged(this, EventArgs.Empty);
                        }
                    }
                }
                else
                {
                    //MainForm.ShowPopupMessage( "尝试读取股票信息失败", "可能不是MetaStock数据的存放位置" );
                    MessageBox.Show("尝试读取股票信息失败", "可能不是MetaStock数据的存放位置");
                }
            }
        }
示例#4
0
        private void ReloadOptionFormInfo()
        {
            this.SuspendLayout();
            {
                m_AllOptionControlInfo.Clear();
                m_CurrentOptionControl = null;

                List <Control> controlList = new List <Control>();
                foreach (Control control in this.Panel.Controls)
                {
                    if (control != m_SettingControl && control != m_SearchControl)
                    {
                        controlList.Add(control);
                    }
                }

                foreach (Control control in controlList)
                {
                    this.Panel.Controls.Remove(control);
                }

                this.TreeView.Nodes.Clear();

                this.m_AllOptionControlInfo.Add(m_TreeNodeSetting, m_SettingControl);
                this.m_AllOptionControlInfo.Add(m_TreeNodeSettingSub, m_SettingControl);

                this.TreeView.Nodes.Add(m_TreeNodeSetting);

                PlateInfo[] plateInfos = GlobalSetting.PlateInfos;
                for (int iIndex = 0; iIndex < plateInfos.Length; iIndex++)
                {
                    PlateInfo plateInfo = plateInfos[iIndex];

                    TreeNode newTreeNodePlate     = new TreeNode(plateInfo.Name);
                    TreeNode newTreeNodePlateSub  = new TreeNode("常规");
                    TreeNode newTreeNodePlateSub2 = new TreeNode("所有股票");

                    newTreeNodePlate.Nodes.Add(newTreeNodePlateSub);
                    newTreeNodePlate.Nodes.Add(newTreeNodePlateSub2);

                    OptionBControl optionBControl = new OptionBControl {
                        Dock = DockStyle.Fill, Visible = false
                    };

                    this.m_AllOptionControlInfo.Add(newTreeNodePlate, optionBControl);
                    this.m_AllOptionControlInfo.Add(newTreeNodePlateSub, optionBControl);

                    this.Panel.Controls.Add(optionBControl);

                    OptionFControl optionFControl = new OptionFControl {
                        Dock = DockStyle.Fill, Visible = false
                    };

                    this.m_AllOptionControlInfo.Add(newTreeNodePlateSub2, optionFControl);

                    this.Panel.Controls.Add(optionFControl);

                    for (int iIndex2 = 0; iIndex2 < plateInfo.VarietyInfos.Length; iIndex2++)
                    {
                        VarietyInfo varietyInfo = plateInfo.VarietyInfos[iIndex2];

                        TreeNode newTreeNodePlateSub3 = new TreeNode(varietyInfo.Name);
                        newTreeNodePlate.Nodes.Add(newTreeNodePlateSub3);

                        OptionCControl optionCControlSub3 = new OptionCControl {
                            Dock = DockStyle.Fill, Visible = false
                        };

                        this.m_AllOptionControlInfo.Add(newTreeNodePlateSub3, optionCControlSub3);

                        this.Panel.Controls.Add(optionCControlSub3);

                        for (int iIndex3 = 0; iIndex3 < varietyInfo.FileInfos.Length; iIndex3++)
                        {
                            Demo.Stock.X.Common.FileInfo fileInfo = varietyInfo.FileInfos[iIndex3];

                            StockManager stockManager = GlobalStockManager.GetStockManagerByPlateAndVariety(plateInfo.Name, varietyInfo.Name);
                            StockInfo    stockInfo    = stockManager.GetStockDataByStockCode(GlobalSetting.GetStockCode(fileInfo.StockName, fileInfo.StockSymbol));
                            if (stockInfo == null)
                            {
                                continue;
                            }

                            ListViewItem listViewItem = new ListViewItem(stockInfo.StockName, 0);
                            listViewItem.SubItems.Add(stockInfo.StockSymbol);
                            listViewItem.SubItems.Add(stockInfo.Periodicity.ToString());
                            listViewItem.SubItems.Add(stockInfo.FirstDate.ToShortDateString());
                            listViewItem.SubItems.Add(stockInfo.LastDate.ToShortDateString());
                            listViewItem.SubItems.Add(stockInfo.FirstTime.ToLongTimeString());
                            listViewItem.SubItems.Add(stockInfo.LastTime.ToLongTimeString());
                            listViewItem.SubItems.Add(stockInfo.StartTime.ToShortTimeString());
                            listViewItem.SubItems.Add(stockInfo.EndTime.ToShortTimeString());
                            listViewItem.SubItems.Add(stockInfo.CollectionDate.ToShortDateString());

                            optionCControlSub3.ListViewStockInfo.Items.Add(listViewItem);
                        }
                    }

                    this.TreeView.Nodes.Add(newTreeNodePlate);
                }

                // 搜索结果
                this.m_AllOptionControlInfo.Add(m_TreeNodeSearch, m_SearchControl);
                this.m_AllOptionControlInfo.Add(m_TreeNodeSearchSub, m_SearchControl);

                m_TreeNodeSearch.Nodes.Clear();
                m_TreeNodeSearch.Nodes.Add(m_TreeNodeSearchSub);

                this.TreeView.Nodes.Add(m_TreeNodeSearch);

                this.TreeView.SelectedNode = m_TreeNodeSetting;
            }
            this.ResumeLayout(false);
        }