コード例 #1
0
        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数据的存放位置");
                }
            }
        }
コード例 #2
0
        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数据的存放位置" );
            }
        }