Esempio n. 1
0
        public void UpdateItem(ecProto.ecTag tag)
        {
            ecProto.ecTagInt itag = (ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SIZE_DONE);
            if (itag != null)
            {
                m_size_done = itag.Value64();
            }
            itag = (ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SIZE_XFER);
            if (itag != null)
            {
                m_size_xfered = itag.Value64();
            }

            itag = (ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SPEED);
            if (itag != null)
            {
                m_speed = (Int32)itag.Value64();
            }

            itag = (ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SOURCE_COUNT);
            if (itag != null)
            {
                m_src_count = (Int32)itag.Value64();
            }

            itag = (ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SOURCE_COUNT_A4AF);
            if (itag != null)
            {
                m_a4af_src_count = (Int32)itag.Value64();
            }

            itag = (ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SOURCE_COUNT_NOT_CURRENT);
            if (itag != null)
            {
                m_non_current_src_count = (Int32)itag.Value64();
            }

            itag = (ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SOURCE_COUNT_XFER);
            if (itag != null)
            {
                m_xfer_src_count = (Int32)itag.Value64();
            }

            ecProto.ecTagCustom gapstat  = (ecProto.ecTagCustom)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_GAP_STATUS);
            ecProto.ecTagCustom partstat = (ecProto.ecTagCustom)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_PART_STATUS);
            m_decoder.Decode(gapstat.Value(), partstat.Value());

            ecProto.ecTagCustom reqstat = (ecProto.ecTagCustom)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_REQ_STATUS);
            BinaryReader        br      = new BinaryReader(new MemoryStream(reqstat.Value()));

            m_req_parts = new GapBuffer(reqstat.Value(), reqstat.Value().Length);
            DrawLine();
        }
Esempio n. 2
0
        public void DrawLine()
        {
            GapBuffer status_gaps = new GapBuffer(m_decoder.m_gap_status.Buffer, m_decoder.m_gap_status.Length);

            byte[] part_info = m_decoder.m_part_status.Buffer;

            int colored_gaps_size = 0;

            for (int j = 0; j < status_gaps.m_buffer.Length; j++)
            {
                Int64 gap_start = status_gaps.m_buffer[j].m_start;
                Int64 gap_end   = status_gaps.m_buffer[j].m_end;
                Int64 start     = gap_start / FILE_PARTSIZE;
                Int64 end       = (gap_end / FILE_PARTSIZE) + 1;

                //
                // Order is RGB
                //
                Int32 color = 0xff0000;
                for (Int64 i = start; i < end; i++)
                {
                    if (part_info[i] != 0)
                    {
                        int blue = 210 - (22 * (part_info[i] - 1));
                        if (blue < 0)
                        {
                            blue = 0;
                        }
                        color = (blue << 8) | 255;
                    }
                    Int64 fill_gap_begin = ((i == start) ? gap_start : FILE_PARTSIZE * i);
                    Int64 fill_gap_end   = ((i == (end - 1)) ? gap_end : FILE_PARTSIZE * (i + 1));

                    if ((m_color_gap_buff.m_buffer[colored_gaps_size].m_end == fill_gap_begin) &&
                        (m_color_gap_buff.m_buffer[colored_gaps_size].m_color == color))
                    {
                        m_color_gap_buff.m_buffer[colored_gaps_size].m_end = fill_gap_end;
                    }
                    else
                    {
                        colored_gaps_size++;
                        m_color_gap_buff.m_buffer[colored_gaps_size].m_start = fill_gap_begin;
                        m_color_gap_buff.m_buffer[colored_gaps_size].m_end   = fill_gap_end;
                        m_color_gap_buff.m_buffer[colored_gaps_size].m_color = color;
                    }
                }
            }
            //
            // Now actual drawing
            //
            int width = m_color_line.Length;

            for (int i = 0; i < width; i++)
            {
                m_color_line[i].Color = 0x7f7f7f;
            }
            if (m_filesize < width)
            {
                //
                // if file is that small, draw it in single step
                //
                if (m_req_parts.m_buffer.Length != 0)
                {
                    for (int i = 0; i < width; i++)
                    {
                        // yellow
                        m_color_line[i].Color = 0xffd000;
                    }
                }
                else if (m_color_gap_buff.m_buffer.Length != 0)
                {
                    for (int i = 0; i < width; i++)
                    {
                        m_color_line[i].Color = m_color_gap_buff.m_buffer[i].m_color;
                    }
                }
            }
            else
            {
                Int32 factor = (Int32)(m_filesize / width);
                for (int i = 1; i <= colored_gaps_size; i++)
                {
                    Int32 start = (Int32)(m_color_gap_buff.m_buffer[i].m_start / factor);
                    Int32 end   = (Int32)(m_color_gap_buff.m_buffer[i].m_end / factor);
                    for (Int32 j = start; j < end; j++)
                    {
                        m_color_line[j].Color = m_color_gap_buff.m_buffer[i].m_color;
                    }
                }
                foreach (FileGap g in m_req_parts.m_buffer)
                {
                    Int32 start = (Int32)(g.m_start / factor);
                    Int32 end   = (Int32)(g.m_end / factor);
                    for (Int32 j = start; j < end; j++)
                    {
                        m_color_line[j].Color = 0xffd000;
                    }
                }
            }
        }