Exemplo n.º 1
0
 /// <summary>
 /// Protected constructor
 /// </summary>
 /// <param name="data">The linked LogAnnotationComponent to use</param>
 /// <param name="sd">The subdaatset owning this instance</param>
 /// <param name="instanceID">The ID of this component</param>
 protected LogAnnotationComponentInstance(LogAnnotationComponent data, SubDataset sd, Int32 instanceID)
 {
     m_data       = data;
     m_instanceID = instanceID;
     m_sd         = sd;
 }
Exemplo n.º 2
0
        public void OnUpdateHeaders(LogAnnotationComponent component, List <int> oldHeaders)
        {
            bool changeHeaders = false;

            //Erase the headers as assigned
            foreach (Int32 h in oldHeaders)
            {
                for (int i = 0; i < m_assignedHeaders.Count;)
                {
                    if (m_assignedHeaders[i] == h)
                    {
                        m_assignedHeaders.RemoveAt(i);
                        break;
                    }
                    i++;
                }
            }

            //Add the assigned headers. Set as "-1" if the header is already taken
            List <Int32> currentHeaders = component.Headers;

            for (int i = 0; i < currentHeaders.Count; i++)
            {
                if (currentHeaders[i] != -1)
                {
                    Int32 oldVal = currentHeaders[i];

                    //If found: set header as -1
                    if (m_assignedHeaders.BinarySearch(currentHeaders[i]) >= 0)
                    {
                        currentHeaders[i] = -1;
                        changeHeaders     = true;
                    }

                    //We can "still" add it (even if, for the moment, it exists twice), because this function shall be called twice
                    int insertIT = m_assignedHeaders.BinarySearch(oldVal);
                    if (insertIT < 0)
                    {
                        insertIT = ~insertIT;
                    }
                    m_assignedHeaders.Insert(insertIT, oldVal);
                }
            }

            //Update internal data. Rechange the headers if required (then stop this function)
            foreach (var it in m_positions)
            {
                if (it.Key == component)
                {
                    if (changeHeaders)
                    {
                        it.Key.Headers = currentHeaders;
                        return; //This method shall be called again because we set the headers
                    }
                    else
                    {
                        it.Value.Clear();
                        it.Value.InsertRange(0, it.Key);
                        return;
                    }
                }
            }
        }