Esempio n. 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();
        }
Esempio n. 2
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FolderBrowserDialogView.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (m_DirNumber != 0)
            {
                MSFL.MSFL1_CloseDirectory(m_DirNumber);

                this.ListViewSecurity.VirtualListSize = 0;
                this.ListViewSecurity.Items.Clear();
                this.ListViewPrice.VirtualListSize = 0;
                this.ListViewPrice.Items.Clear();
                m_SecurityDictionary.Clear();

                m_DirNumber = 0;
            }

            int iErr = MSFL.MSFL1_OpenDirectory(this.FolderBrowserDialogView.SelectedPath, ref m_DirNumber, MSFL.MSFL_DIR_FORCE_USER_IN);

            if (iErr != (int)MSFL.MSFL_ERR.MSFL_NO_ERR)
            {
                return;
            }

            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)
            {
                return;
            }

            //MSFL.DisplayMSFLError( iErr );

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

            List <ListViewItem> listViewItemList = new List <ListViewItem>(2048);

            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)
                {
                    ListViewItem listViewItem = new ListViewItem(msflSecurityInfo.szName);
                    ListViewItem.ListViewSubItem subListViewItem1 = new ListViewItem.ListViewSubItem(listViewItem, msflSecurityInfo.szSymbol);
                    ListViewItem.ListViewSubItem subListViewItem2 = new ListViewItem.ListViewSubItem(listViewItem, msflSecurityInfo.cPeriodicity.ToString());

                    iErr = MSFL.MSFL1_FormatDate(dateString, (ushort)dateString.Capacity, msflSecurityInfo.lFirstDate);
                    ListViewItem.ListViewSubItem subListViewItem3 = new ListViewItem.ListViewSubItem(listViewItem, dateString.ToString());

                    iErr = MSFL.MSFL1_FormatDate(dateString, (ushort)dateString.Capacity, msflSecurityInfo.lLastDate);
                    ListViewItem.ListViewSubItem subListViewItem4 = new ListViewItem.ListViewSubItem(listViewItem, dateString.ToString());

                    iErr = MSFL.MSFL1_FormatTime(dateString, (ushort)dateString.Capacity, msflSecurityInfo.lFirstTime, true);
                    ListViewItem.ListViewSubItem subListViewItem5 = new ListViewItem.ListViewSubItem(listViewItem, dateString.ToString());

                    iErr = MSFL.MSFL1_FormatTime(dateString, (ushort)dateString.Capacity, msflSecurityInfo.lLastTime, true);
                    ListViewItem.ListViewSubItem subListViewItem6 = new ListViewItem.ListViewSubItem(listViewItem, dateString.ToString());

                    iErr = MSFL.MSFL1_FormatTime(dateString, (ushort)dateString.Capacity, msflSecurityInfo.lStartTime, false);
                    ListViewItem.ListViewSubItem subListViewItem7 = new ListViewItem.ListViewSubItem(listViewItem, dateString.ToString());

                    iErr = MSFL.MSFL1_FormatTime(dateString, (ushort)dateString.Capacity, msflSecurityInfo.lEndTime, false);
                    ListViewItem.ListViewSubItem subListViewItem8 = new ListViewItem.ListViewSubItem(listViewItem, dateString.ToString());

                    iErr = MSFL.MSFL1_FormatDate(dateString, (ushort)dateString.Capacity, msflSecurityInfo.lCollectionDate);
                    ListViewItem.ListViewSubItem subListViewItem9 = new ListViewItem.ListViewSubItem(listViewItem, dateString.ToString());

                    listViewItem.SubItems.Add(subListViewItem1);
                    listViewItem.SubItems.Add(subListViewItem2);
                    listViewItem.SubItems.Add(subListViewItem3);
                    listViewItem.SubItems.Add(subListViewItem4);
                    listViewItem.SubItems.Add(subListViewItem5);
                    listViewItem.SubItems.Add(subListViewItem6);
                    listViewItem.SubItems.Add(subListViewItem7);
                    listViewItem.SubItems.Add(subListViewItem8);
                    listViewItem.SubItems.Add(subListViewItem9);

                    m_SecurityDictionary.Add(listViewItem, msflSecurityInfo.hSecurity);

                    //this.ListViewSecurity.Items.Add( listViewItem );
                    listViewItemList.Add(listViewItem);

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

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

                m_SecurityArray = listViewItemList.ToArray();
                this.ListViewSecurity.VirtualListSize = m_SecurityArray.Length;
            }
        }