コード例 #1
0
        private void Process_LoadNewDocument(ProcessForm processForm)
        {
            if (m_DirNumber != 0)
            {
                MSFL.MSFL1_CloseDirectory(m_DirNumber);

                m_SecurityDictionary.Clear();
                m_DirNumber = 0;
            }

            do
            {
                int iErr = MSFL.MSFL1_OpenDirectory(m_strSelectedPath, ref m_DirNumber, MSFL.MSFL_DIR_FORCE_USER_IN);
                if (iErr != (int)MSFL.MSFL_ERR.MSFL_NO_ERR)
                {
                    break;
                }

                MSFL.MSFLDirectoryStatus msflDirectoryStatus = new MSFL.MSFLDirectoryStatus();
                msflDirectoryStatus.dwTotalSize = (uint)Marshal.SizeOf(msflDirectoryStatus);

                iErr = MSFL.MSFL1_GetDirectoryStatus(m_DirNumber, string.Empty, ref msflDirectoryStatus);
                if (iErr != (int)MSFL.MSFL_ERR.MSFL_NO_ERR)
                {
                    break;
                }

                //MSFL.DisplayMSFLError( iErr );

                List <MSFL.MSFLSecurityInfo> listMSFLSecurityInfo = new List <MSFL.MSFLSecurityInfo>(1024);

                MSFL.MSFLSecurityInfo msflSecurityInfo = new MSFL.MSFLSecurityInfo();
                msflSecurityInfo.dwTotalSize = (uint)Marshal.SizeOf(msflSecurityInfo);

                if (msflDirectoryStatus.bExists &&          // if it exists
                    msflDirectoryStatus.bOpen &&            // AND if it's open
                    msflDirectoryStatus.bMetaStockDir)      // AND if it's a MetaStock directory...
                {
                    StringBuilder dateString = new StringBuilder(MSFL.MSFL_MAX_NAME_LENGTH + 1);

                    iErr = MSFL.MSFL1_GetFirstSecurityInfo(m_DirNumber, ref msflSecurityInfo);
                    while (iErr == (int)MSFL.MSFL_ERR.MSFL_NO_ERR || iErr == (int)MSFL.MSFL_Messages.MSFL_MSG_LAST_SECURITY_IN_DIR)
                    {
                        //m_SecurityDictionary.Add( listViewItem, msflSecurityInfo.hSecurity );

                        listMSFLSecurityInfo.Add(msflSecurityInfo);

                        if (iErr == (int)MSFL.MSFL_Messages.MSFL_MSG_LAST_SECURITY_IN_DIR)
                        {
                            break;
                        }

                        msflSecurityInfo             = new MSFL.MSFLSecurityInfo();
                        msflSecurityInfo.dwTotalSize = (uint)Marshal.SizeOf(msflSecurityInfo);

                        iErr = MSFL.MSFL1_GetNextSecurityInfo(msflSecurityInfo.hSecurity, ref msflSecurityInfo);
                    }
                }

                MSFL.MSFLSecurityInfo[] msflSecurityInfoArray = listMSFLSecurityInfo.ToArray();
                if (msflSecurityInfoArray.Length <= 0)
                {
                    break;
                }

                KLineViewFormSubForm klineViewFormSubForm = new KLineViewFormSubForm(msflSecurityInfoArray);
                if (klineViewFormSubForm.ShowDialog() == DialogResult.OK)
                {
                    msflSecurityInfoArray = klineViewFormSubForm.ToSecurityInfo();
                    if (msflSecurityInfoArray.Length > 0)
                    {
                        for (int iIndex = 0; iIndex < msflSecurityInfoArray.Length; iIndex++)
                        {
                            MSFL.MSFLSecurityInfo msflSecurityInfoIndex = msflSecurityInfoArray[iIndex];
                            KLineViewFormDocument frmDocument           = new KLineViewFormDocument(msflSecurityInfoIndex);
                            frmDocument.MdiParent = this;
                            frmDocument.Text      = msflSecurityInfoIndex.szName + "[" + msflSecurityInfoIndex.szSymbol + "]";
                            frmDocument.Show();
                        }
                    }
                }
            } while (false);

            processForm.EndProcessForm();
        }
コード例 #2
0
        private void Process_LoadNewDocument( ProcessForm processForm )
        {
            if ( m_DirNumber != 0 )
            {
                MSFL.MSFL1_CloseDirectory( m_DirNumber );

                m_SecurityDictionary.Clear();
                m_DirNumber = 0;
            }

            do
            {
                int iErr = MSFL.MSFL1_OpenDirectory( m_strSelectedPath, ref m_DirNumber, MSFL.MSFL_DIR_FORCE_USER_IN );
                if ( iErr != (int)MSFL.MSFL_ERR.MSFL_NO_ERR )
                    break;

                MSFL.MSFLDirectoryStatus msflDirectoryStatus = new MSFL.MSFLDirectoryStatus();
                msflDirectoryStatus.dwTotalSize = (uint)Marshal.SizeOf( msflDirectoryStatus );

                iErr = MSFL.MSFL1_GetDirectoryStatus( m_DirNumber, string.Empty, ref msflDirectoryStatus );
                if ( iErr != (int)MSFL.MSFL_ERR.MSFL_NO_ERR )
                    break;

                //MSFL.DisplayMSFLError( iErr );

                List<MSFL.MSFLSecurityInfo> listMSFLSecurityInfo = new List<MSFL.MSFLSecurityInfo>( 1024 );

                MSFL.MSFLSecurityInfo msflSecurityInfo = new MSFL.MSFLSecurityInfo();
                msflSecurityInfo.dwTotalSize = (uint)Marshal.SizeOf( msflSecurityInfo );

                if ( msflDirectoryStatus.bExists &&         // if it exists
                    msflDirectoryStatus.bOpen &&            // AND if it's open
                    msflDirectoryStatus.bMetaStockDir )     // AND if it's a MetaStock directory...
                {
                    StringBuilder dateString = new StringBuilder( MSFL.MSFL_MAX_NAME_LENGTH + 1 );

                    iErr = MSFL.MSFL1_GetFirstSecurityInfo( m_DirNumber, ref msflSecurityInfo );
                    while ( iErr == (int)MSFL.MSFL_ERR.MSFL_NO_ERR || iErr == (int)MSFL.MSFL_Messages.MSFL_MSG_LAST_SECURITY_IN_DIR )
                    {
                        //m_SecurityDictionary.Add( listViewItem, msflSecurityInfo.hSecurity );

                        listMSFLSecurityInfo.Add( msflSecurityInfo );

                        if ( iErr == (int)MSFL.MSFL_Messages.MSFL_MSG_LAST_SECURITY_IN_DIR )
                            break;

                        msflSecurityInfo = new MSFL.MSFLSecurityInfo();
                        msflSecurityInfo.dwTotalSize = (uint)Marshal.SizeOf( msflSecurityInfo );

                        iErr = MSFL.MSFL1_GetNextSecurityInfo( msflSecurityInfo.hSecurity, ref msflSecurityInfo );
                    }
                }

                MSFL.MSFLSecurityInfo[] msflSecurityInfoArray = listMSFLSecurityInfo.ToArray();
                if ( msflSecurityInfoArray.Length <= 0 )
                    break;

                KLineViewFormSubForm klineViewFormSubForm = new KLineViewFormSubForm( msflSecurityInfoArray );
                if ( klineViewFormSubForm.ShowDialog() == DialogResult.OK )
                {
                    msflSecurityInfoArray = klineViewFormSubForm.ToSecurityInfo();
                    if ( msflSecurityInfoArray.Length > 0 )
                    {
                        for ( int iIndex = 0; iIndex < msflSecurityInfoArray.Length; iIndex++ )
                        {
                            MSFL.MSFLSecurityInfo msflSecurityInfoIndex = msflSecurityInfoArray[iIndex];
                            KLineViewFormDocument frmDocument = new KLineViewFormDocument( msflSecurityInfoIndex );
                            frmDocument.MdiParent = this;
                            frmDocument.Text = msflSecurityInfoIndex.szName + "[" + msflSecurityInfoIndex.szSymbol + "]";
                            frmDocument.Show();
                        }
                    }
                }
            } while ( false );

            processForm.EndProcessForm();
        }