/******************************************************************************* Function Name : OnButtonSelect Input(s) : - Output : - Functionality : This function will add the selected hardware in to the selected hardware list. Member of : CHardwareListing Author(s) : Raja N Date Created : 25.2.2005 Modifications : *******************************************************************************/ void CHardwareListing::OnButtonSelect() { int nSelected = m_nSelectedItem; // Insert the selected item in to the selected list int nItem = m_omSelectedHwList.GetItemCount(); CString omStrChannel;//(STR_EMPTY); CString omStrHardware; int nArrayIndex = -1; // Get the data // Format channel information omStrChannel.Format( defSTR_CHANNEL_NAME_FORMAT, defSTR_CHANNEL_NAME, nItem + 1 ); // Get the Hardware name omStrHardware = m_omHardwareList.GetItemText( nSelected, 0 ); // Get the array index nArrayIndex = (INT)m_omHardwareList.GetItemData( nSelected ); int nImageIndex = defDISCONNECTED_IMAGE_INDEX; // Insert the new item in to the selected list m_omSelectedHwList.InsertItem( nItem, omStrChannel, nImageIndex ); // Set the Hardware Name m_omSelectedHwList.SetItemText( nItem, 1, omStrHardware ); // Set the array index m_omSelectedHwList.SetItemData( nItem, nArrayIndex ); // Remove the item from the list m_omHardwareList.DeleteItem( nSelected ); //Sort Hardware Items vSortHardwareItems(); // Set the focus to the first item m_omHardwareList.SetItemState( 0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); // Update Button Status vEnableDisableButtons(); }
/******************************************************************************* Function Name : OnButtonRemove Input(s) : - Output : - Functionality : This function will remove the selected item from the selected hardware list. This will also insert the same in to the available list Member of : CHardwareListing Author(s) : Raja N Date Created : 21.2.2005 Modifications : Raja N on 17.03.2005 Added code to change channel ID of rest of items when a channel is deleted from the selected channel list *******************************************************************************/ void CHardwareListing::OnButtonRemove() { // Get the selected item from the list POSITION sPos = m_omSelectedHwList.GetFirstSelectedItemPosition(); if( sPos != NULL ) { int nSelectedItem = m_omSelectedHwList.GetNextSelectedItem(sPos); int nArrayIndex = (INT)m_omSelectedHwList.GetItemData( nSelectedItem ); int nImageIndex; nImageIndex = defDISCONNECTED_IMAGE_INDEX; // Insert this item in to the available list // Calculate new item index int nItemCount = m_omHardwareList.GetItemCount(); // Insert the new entry m_omHardwareList.InsertItem( nItemCount, m_omSelectedHwList.GetItemText( nSelectedItem, 1), nImageIndex ); // Set the hardware list index as item data. m_omHardwareList.SetItemData( nItemCount, nArrayIndex ); //Sort Hardware Items vSortHardwareItems(); // Remove the item from the selected list m_omSelectedHwList.DeleteItem( nSelectedItem ); // Change the channel text approp. int nItem = m_omSelectedHwList.GetItemCount(); // Check whether update is required or not if( nSelectedItem < nItem ) { // Format string CString omStrChannel; int nItemsToUpdate = nItem - nSelectedItem; // Loopt through list of items for( int nIndex = 0; nIndex < nItemsToUpdate; nIndex++ ) { // Update format string omStrChannel.Format( defSTR_CHANNEL_NAME_FORMAT, defSTR_CHANNEL_NAME, nSelectedItem + nIndex + 1 ); // Update Text m_omSelectedHwList.SetItemText( nSelectedItem + nIndex, 0, omStrChannel ); } } // Update UI button status vEnableDisableButtons(); } }
/******************************************************************************* Function Name : OnButtonSelect Input(s) : - Output : - Functionality : This function will add the selected hardware in to the selected hardware list. Member of : CHardwareListingCAN Author(s) : Raja N Date Created : 25.2.2005 Modifications : *******************************************************************************/ void CHardwareListingCAN::vMoveItemToSelectedList() { POSITION sPos = m_omHardwareList.GetFirstSelectedItemPosition(); // Insert the selected item in to the selected list if( nullptr!=sPos ) { int nSelected = m_omHardwareList.GetNextSelectedItem(sPos); int nItem = m_omSelectedHwList.GetItemCount(); CString omStrChannel;//(""); CString omStrHardware; int nArrayIndex = -1; // Get the data // Format channel information omStrChannel.Format( defSTR_CHANNEL_NAME_FORMAT, defSTR_CHANNEL_NAME, nItem + 1 ); // Get the Hardware name omStrHardware = m_omHardwareList.GetItemText( nSelected, 0 ); // Get the array index nArrayIndex = (INT)m_omHardwareList.GetItemData( nSelected ); int nImageIndex = defDISCONNECTED_IMAGE_INDEX; // Insert the new item in to the selected list m_omSelectedHwList.InsertItem( nItem, omStrHardware, nImageIndex ); // Set the Hardware Name m_omSelectedHwList.SetItemText( nItem, 1, omStrChannel); // Set the array index m_omSelectedHwList.SetItemData( nItem, nArrayIndex ); InitializeControllerDetails(nItem); // Remove the item from the list m_omHardwareList.DeleteItem( nSelected ); //Sort Hardware Items vSortHardwareItems(); // Set the focus to the first item m_omHardwareList.SetItemState(nSelected, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); m_omSelectedHwList.SetItemState(nItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); // Update Button Status vEnableDisableButtons(); } else { m_omHardwareList.SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); } }
/******************************************************************************* Function Name : OnButtonRemove Input(s) : - Output : - Functionality : This function will remove the selected item from the selected hardware list. This will also insert the same in to the available list Member of : CHardwareListingCAN Author(s) : Raja N Date Created : 21.2.2005 Modifications : Raja N on 17.03.2005 Added code to change channel ID of rest of items when a channel is deleted from the selected channel list *******************************************************************************/ void CHardwareListingCAN::vMoveItemFromSelectedList() { // Get the selected item from the list POSITION sPos = m_omSelectedHwList.GetFirstSelectedItemPosition(); if( nullptr!=sPos ) { int nSelectedItem = m_omSelectedHwList.GetNextSelectedItem(sPos); int nArrayIndex = (INT)m_omSelectedHwList.GetItemData( nSelectedItem ); int nImageIndex; nImageIndex = defDISCONNECTED_IMAGE_INDEX; // Insert this item in to the available list // Calculate new item index int nItemCount = m_omHardwareList.GetItemCount(); // Insert the new entry m_omHardwareList.InsertItem( nItemCount, m_omSelectedHwList.GetItemText( nSelectedItem, 0), nImageIndex ); // Set the hardware list index as item data. m_omHardwareList.SetItemData( nItemCount, nArrayIndex ); int nSelectedItemCount = m_omSelectedHwList.GetItemCount(); //Sort Hardware Items vSortHardwareItems(); if (m_pControllerDetails != nullptr) { for (int nIndex = nSelectedItem; nIndex<nSelectedItemCount - 1; nIndex++) { m_pControllerDetails[nIndex] = m_pControllerDetails[nIndex + 1]; } } UpdateData(FALSE); //Set the values over the UI if (m_pControllerDetails != nullptr) { m_omEditBaudRate.SetWindowText(m_pControllerDetails[nSelectedItem].m_omStrBaudrate.c_str()); CString omCANFDDataBitRate; m_chkCANFD.EnableWindow(m_pControllerDetails[nSelectedItem].m_bSupportCANFD); m_chkCANFD.SetCheck(m_pControllerDetails[nSelectedItem].m_bcanFDEnabled); CButton* pChkCANFD = (CButton*)GetDlgItem(IDC_CHECK_CANFD); if (nullptr != pChkCANFD) { if (pChkCANFD->GetCheck() == BST_CHECKED) { omCANFDDataBitRate.Format("%u", m_pControllerDetails[nSelectedItem].m_unDataBitRate); m_omCANFDEditBaudRate.SetWindowText(omCANFDDataBitRate); } } } UpdateData(TRUE); // Remove the item from the selected list m_omSelectedHwList.DeleteItem( nSelectedItem ); // Change the channel text approp. int nItem = m_omSelectedHwList.GetItemCount(); // Check whether update is required or not if( nSelectedItem < nItem ) { // Format string CString omStrChannel; int nItemsToUpdate = nItem - nSelectedItem; // Loopt through list of items for( int nIndex = 0; nIndex < nItemsToUpdate; nIndex++ ) { // Update format string omStrChannel.Format( defSTR_CHANNEL_NAME_FORMAT, defSTR_CHANNEL_NAME, nSelectedItem + nIndex + 1 ); // Update Text m_omSelectedHwList.SetItemText( nSelectedItem + nIndex, 1, omStrChannel ); } } m_omSelectedHwList.SetItemState( nSelectedItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); // Update UI button status vEnableDisableButtons(); } else { m_omSelectedHwList.SetItemState( 0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); } }