コード例 #1
0
ファイル: Frame_Dlg.cs プロジェクト: kimilwon/PSeatRelax-2-
        /// <summary>
        /// Occurs when the SelectedIndices collection changes. The selection
        /// will be assigned to the Property-Control 'pgGFTDef'.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An EventArgs that contains no event data.</param>
        private void lvGFT_SelectedIndexChanged(object sender, EventArgs e)
        {
            int nCnt, nIdx, i;

            if (!m_fAutomatic)
            {
                m_fAutomatic = true;
                // Get the count of selected elements
                // in the ListView 'lvGFT'.
                // Each element is assigned with an
                // element in the CGlobalFrameTable.
                nCnt = lvGFT.SelectedItems.Count;
                if (nCnt == 1)
                {
                    // If only one element is selected
                    // it can be assigned directly to the
                    // Property-Control.
                    nIdx = lvGFT.SelectedItems[0].Index;
                    // Assign the CFrameDefinition element
                    // from the CGlobalFrameTable.
                    pgGFTDef.SelectedObject = m_pGFT[nIdx];
                }
                else if (nCnt > 1)
                {
                    // If more than one element are selected
                    // in the ListView means that the user
                    // want to change at least one property of
                    // all elements to a new value with
                    // the Property-Control.
                    // So get first the selected elements and the
                    // assigned objects from the CGlobalFrameTable
                    // into a local Array of elements.
                    CFrameDefinition[] lDefFrames = new CFrameDefinition[nCnt];
                    for (i = 0; i < nCnt; i++)
                    {
                        nIdx          = lvGFT.SelectedItems[i].Index;
                        lDefFrames[i] = m_pGFT[nIdx];
                    }
                    // Assign the local array of elements
                    // from the CGlobalFrameTable.
                    pgGFTDef.SelectedObjects = lDefFrames;
                }
                m_fAutomatic = false;
            }
            return;
        }
コード例 #2
0
 /// <summary>
 /// Adds an CFrameDefinition object to the end of the CGlobalFrameTable.
 /// </summary>
 /// <param name="AFrameDefinition">The CFrameDefinition object to be added to the end of the CGlobalFrameTable.</param>
 /// <returns>Returns the Index of position in the list.</returns>
 private int AddFrameDefinition(CFrameDefinition AFrameDefinition)
 {
     // Check the parameter at first.
     if (AFrameDefinition == null)
     {
         // Delivered object invalid. Do not add it.
         return(-1);
     }
     else
     {
         // Add the delivered object (CFrameDefinition) to the list.
         m_lFrameDefinitions.Add(AFrameDefinition);
     }
     // Return the position of the new added object.
     // It should be added at the end so the position
     // must be the last entry in the list.
     return(m_lFrameDefinitions.Count - 1);
 }
コード例 #3
0
        /// <summary>
        /// Adds an CFrameDefinition object with the defined values to the end of the CGlobalFrameTable.
        /// </summary>
        /// <param name="AId">The Frame ID of the CFrameDefinition object to be added to the end of the CGlobalFrameTable.</param>
        /// <param name="ALength">The Frame Length of the CFrameDefinition object to be added to the end of the CGlobalFrameTable.</param>
        /// <param name="AChecksumType">The Frame Checksum Type of the CFrameDefinition object to be added to the end of the CGlobalFrameTable.</param>
        /// <param name="ADirection">The Frame Direction of the CFrameDefinition object to be added to the end of the CGlobalFrameTable.</param>
        /// <returns>Returns the Index of position in the list.</returns>
        private int AddFrameDefinition(int AId, int ALength, Peak.Lin.TLINChecksumType AChecksumType, Peak.Lin.TLINDirection ADirection)
        {
            // Check the Frame-ID for adding.
            // Only ID's from 0 to 63 are allowed to add.
            if ((AId < 0) || (AId > 63))
            {
                // ID is invalid. Do not add it.
                return(-1);
            }
            else
            {
                // The delivered Frame-ID is valid.
                CFrameDefinition lFD;
                byte             lbID;

                // Create a Frame Definition object.
                // and assigned the delivered values to it.
                lFD                 = new CFrameDefinition();
                lFD.m_pParent       = this;
                lFD.m_nID           = AId;
                lFD.m_nLength       = ALength;
                lFD.m_nChecksumType = AChecksumType;
                lFD.m_bDirection    = ADirection;
                // Calculate the Protected-ID with
                // the delivered Frame-ID.
                lbID = Convert.ToByte(AId);
                Peak.Lin.PLinApi.GetPID(ref lbID);
                // Assign the calculated Protected-ID.
                lFD.m_nProtectedID = lbID;
                // Add the created object to the list.
                m_lFrameDefinitions.Add(lFD);
            }
            // Return the position of the new added object.
            // It should be added at the end so the position
            // must be the last entry in the list.
            return(m_lFrameDefinitions.Count - 1);
        }
コード例 #4
0
 /// <summary>
 /// Retrieves the index within the CGlobalFrameTable of the specified item.
 /// </summary>
 /// <param name="Item">An object representing the item to locate in the CGlobalFrameTable.</param>
 /// <returns>The index of the specified item.</returns>
 internal int IndexOf(CFrameDefinition Item)
 {
     // Get the index of Item in the list.
     return(m_lFrameDefinitions.IndexOf(Item));
 }