• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ProgressCallback类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ProgressCallback的典型用法代码示例。如果您正苦于以下问题:C# ProgressCallback类的具体用法?C# ProgressCallback怎么用?C# ProgressCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ProgressCallback类属于命名空间,在下文中一共展示了ProgressCallback类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Load

 public override ThingList Load(BinaryReader BR, ProgressCallback ProgressCallback)
 {
     ThingList TL = new ThingList();
     if (ProgressCallback != null)
     {
         ProgressCallback(I18N.GetText("FTM:CheckingFile"), 0);
     }
     if ((BR.BaseStream.Length % 0x20) != 0 || BR.BaseStream.Position != 0)
     {
         return TL;
     }
     long EntryCount = BR.BaseStream.Length / 0x20;
     if (ProgressCallback != null)
     {
         ProgressCallback(I18N.GetText("FTM:LoadingData"), 0);
     }
     try
     {
         int ZoneID = -1;
         for (int i = 0; i < EntryCount; ++i)
         {
             Things.MobListEntry MLE = new Things.MobListEntry();
             if (!MLE.Read(BR))
             {
                 TL.Clear();
                 break;
             }
             uint ThisID = (uint)MLE.GetFieldValue("id");
             if (i == 0 && (ThisID != 0 || MLE.GetFieldText("name") != "none"))
             {
                 TL.Clear();
                 break;
             }
             else if (i > 0)
             {
                 // Entire file should be for 1 specific zone
                 int ThisZone = (int)(ThisID & 0x000FF000);
                 if (ZoneID < 0)
                 {
                     ZoneID = ThisZone;
                 }
                 else if (ThisZone != ZoneID)
                 {
                     TL.Clear();
                     break;
                 }
             }
             if (ProgressCallback != null)
             {
                 ProgressCallback(null, (double)(i + 1) / EntryCount);
             }
             TL.Add(MLE);
         }
     }
     catch
     {
         TL.Clear();
     }
     return TL;
 }
开发者ID:Gravenet,项目名称:POLUtils,代码行数:60,代码来源:MobList.cs


示例2: WriteLog

        /// <summary>
        /// Writes the log.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="callback">The callback for UI updates.</param>
        public void WriteLog(IExecutionContext context, Stream stream, ProgressCallback callback)
        {
            using (BinaryWriter s = new BinaryWriter(stream, Encoding.ASCII))
            {
                s.Write("[PacketLogConverter v1]");

                foreach (PacketLog log in context.LogManager.Logs)
                {
                    for (int i = 0; i < log.Count; i++)
                    {
                        if (callback != null && (i & 0xFFF) == 0) // update progress every 4096th packet
                            callback(i + 1, log.Count);

                        Packet packet = log[i];
                        if (context.FilterManager.IsPacketIgnored(packet))
                            continue;

                        byte[] buf = packet.GetBuffer();
                        s.Write((ushort) buf.Length);
                        s.Write(packet.GetType().FullName);
                        s.Write((ushort) packet.Code);
                        s.Write((byte) packet.Direction);
                        s.Write((byte) packet.Protocol);
                        s.Write(packet.Time.Ticks);
                        s.Write(buf);
                    }
                }
            }
        }
开发者ID:Dawn-of-Light,项目名称:PacketLogConverter,代码行数:35,代码来源:PacketLogConverterV1LogWriter.cs


示例3: Load

 public override ThingList Load(BinaryReader BR, ProgressCallback ProgressCallback)
 {
     ThingList TL = new ThingList();
       if (ProgressCallback != null)
     ProgressCallback(I18N.GetText("FTM:CheckingFile"), 0);
       if (BR.BaseStream.Length < 0x40 || BR.BaseStream.Position != 0)
     return TL;
     FFXIEncoding E = new FFXIEncoding();
       if (E.GetString(BR.ReadBytes(8)) != "d_msg".PadRight(8, '\0'))
     return TL;
     ushort Flag1 = BR.ReadUInt16();
       if (Flag1 != 0 && Flag1 != 1)
     return TL;
     ushort Flag2 = BR.ReadUInt16();
       if (Flag2 != 0 && Flag2 != 1)
     return TL;
       if (BR.ReadUInt32() != 3 || BR.ReadUInt32() != 3)
     return TL;
     uint FileSize = BR.ReadUInt32();
       if (FileSize != BR.BaseStream.Length)
     return TL;
     uint HeaderBytes = BR.ReadUInt32();
       if (HeaderBytes != 0x40)
     return TL;
       if (BR.ReadUInt32() != 0)
     return TL;
     int BytesPerEntry = BR.ReadInt32();
       if (BytesPerEntry < 0)
     return TL;
     uint DataBytes = BR.ReadUInt32();
       if (FileSize != (HeaderBytes + DataBytes) || (DataBytes % BytesPerEntry) != 0)
     return TL;
     uint EntryCount = BR.ReadUInt32();
       if (EntryCount * BytesPerEntry != DataBytes)
     return TL;
       if (BR.ReadUInt32() != 1 || BR.ReadUInt64() != 0 || BR.ReadUInt64() != 0)
     return TL;
       if (ProgressCallback != null)
     ProgressCallback(I18N.GetText("FTM:LoadingData"), 0);
       for (uint i = 0; i < EntryCount; ++i) {
       BinaryReader EntryBR = new BinaryReader(new MemoryStream(BR.ReadBytes(BytesPerEntry)));
     EntryBR.BaseStream.Position = 0;
       bool ItemAdded = false;
     {
     Things.DMSGStringBlock SB = new Things.DMSGStringBlock();
       if (SB.Read(EntryBR, E, i)) {
     TL.Add(SB);
     ItemAdded = true;
       }
     }
     EntryBR.Close();
     if (!ItemAdded) {
       TL.Clear();
       break;
     }
     if (ProgressCallback != null)
       ProgressCallback(null, (double) (i + 1) / EntryCount);
       }
       return TL;
 }
开发者ID:Zastai,项目名称:POLUtils,代码行数:60,代码来源:DMSGStringTable3.cs


示例4: WriteLog

        /// <summary>
        /// Writes the log.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="callback">The callback for UI updates.</param>
        public void WriteLog(IExecutionContext context, Stream stream, ProgressCallback callback)
        {
            TimeSpan baseTime = new TimeSpan(0);
            using (StreamWriter s = new StreamWriter(stream))
            {
                foreach (PacketLog log in context.LogManager.Logs)
                {
                    // Log file name
                    s.WriteLine();
                    s.WriteLine();
                    s.WriteLine("Log file: " + log.StreamName);
                    s.WriteLine("==============================================");

                    for (int i = 0; i < log.Count; i++)
                    {
                        // Update progress every 4096th packet
                        if (callback != null && (i & 0xFFF) == 0)
                            callback(i, log.Count - 1);

                        Packet packet = log[i];
                        if (context.FilterManager.IsPacketIgnored(packet))
                            continue;

                        s.WriteLine(packet.ToHumanReadableString(baseTime, true));
                    }
                }
            }
        }
开发者ID:Dawn-of-Light,项目名称:PacketLogConverter,代码行数:34,代码来源:ShortLogWriter.cs


示例5: LoadAll

 public static ThingList LoadAll(string FileName, ProgressCallback ProgressCallback, bool FirstMatchOnly)
 {
     ThingList Results = new ThingList();
       if (ProgressCallback != null)
     ProgressCallback(I18N.GetText("FTM:OpeningFile"), 0);
     BinaryReader BR = null;
       try {
     BR = new BinaryReader(new FileStream(FileName, FileMode.Open, FileAccess.Read), Encoding.ASCII);
       } catch { }
       if (BR == null || BR.BaseStream == null)
     return Results;
       foreach (FileType FT in FileType.AllTypes) {
       ProgressCallback SubCallback = null;
     if (ProgressCallback != null) {
       SubCallback = new ProgressCallback(delegate (string Message, double PercentCompleted) {
       string SubMessage = null;
     if (Message != null)
       SubMessage = String.Format("[{0}] {1}", FT.Name, Message);
     ProgressCallback(SubMessage, PercentCompleted);
       });
     }
       ThingList SubResults = FT.Load(BR, SubCallback);
     if (SubResults != null) {
       Results.AddRange(SubResults);
       if (FirstMatchOnly && Results.Count > 0)
     break;
     }
     BR.BaseStream.Seek(0, SeekOrigin.Begin);
       }
       return Results;
 }
开发者ID:Zastai,项目名称:POLUtils,代码行数:31,代码来源:FileType.cs


示例6: RegisterIntegerSaveProgress

        public static void RegisterIntegerSaveProgress(this ZipFile zip, ProgressCallback callback)
        {
            int total = 0;
            zip.SaveProgress += (sender, eventArgs) =>
            {
                if (eventArgs.EntriesTotal != 0
                    && total == 0)
                {
                    total = eventArgs.EntriesTotal;
                }

                if (eventArgs.EntriesSaved == 0)
                {
                    return;
                }

                int progress;
                if (total == 0)
                {
                    progress = 0;
                }
                else
                {
                    progress = eventArgs.EntriesSaved;
                }

                callback(zip, progress, total);
            };
        }
开发者ID:tgmayfield,项目名称:zip-dir-strip,代码行数:29,代码来源:ZipSaveHelper.cs


示例7: Download

        public Download(string url, string file, FileDownloaded completionCallback, ProgressCallback progressCallback, Files f)
        {
            try
            {
                m_Url = url;
                m_CompletionCallback = completionCallback;
                try
                {
                    m_Stream = new FileStream( file, FileMode.OpenOrCreate, FileAccess.Write );
                }
                catch (IOException e)
                {
                    file = String.Concat( file, ".new" );
                    m_Stream = new FileStream( file, FileMode.OpenOrCreate, FileAccess.Write );
                }

                m_ProgressCallback = progressCallback;
                m_File = f;
                m_Thread = new Thread(new ThreadStart(DownloadFile));
                m_Thread.Start();
            }
            catch (Exception)
            {
                throw;
            }
        }
开发者ID:FreeReign,项目名称:UOMachine,代码行数:26,代码来源:Download.cs


示例8: Load

 public override ThingList Load(BinaryReader BR, ProgressCallback ProgressCallback)
 {
     ThingList TL = new ThingList();
     if (ProgressCallback != null)
     {
         ProgressCallback(I18N.GetText("FTM:CheckingFile"), 0);
     }
     if ((BR.BaseStream.Length % 0x400) != 0 || BR.BaseStream.Position != 0)
     {
         return TL;
     }
     long EntryCount = BR.BaseStream.Length / 0x400;
     if (ProgressCallback != null)
     {
         ProgressCallback(I18N.GetText("FTM:LoadingData"), 0);
     }
     for (int i = 0; i < EntryCount; ++i)
     {
         Things.SpellInfo SI = new Things.SpellInfo();
         if (!SI.Read(BR))
         {
             TL.Clear();
             break;
         }
         if (ProgressCallback != null)
         {
             ProgressCallback(null, (double)(i + 1) / EntryCount);
         }
         TL.Add(SI);
     }
     return TL;
 }
开发者ID:Gravenet,项目名称:POLUtils,代码行数:32,代码来源:SpellInfo.cs


示例9: WriteLog

        /// <summary>
        /// Writes the log.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="callback">The callback for UI updates.</param>
        public void WriteLog(IExecutionContext context, Stream stream, ProgressCallback callback)
        {
            using (StreamWriter s = new StreamWriter(stream))
            {
                foreach (PacketLog log in context.LogManager.Logs)
                {
                    for (int i = 0; i < log.Count; i++)
                    {
                        if (callback != null && (i & 0xFFF) == 0) // update progress every 4096th packet
                            callback(i, log.Count - 1);

                        StoC_0x02_InventoryUpdate invUpdate = log[i] as StoC_0x02_InventoryUpdate;
                        if (invUpdate == null) continue;

                        foreach (StoC_0x02_InventoryUpdate.Item item in invUpdate.Items)
                        {
                            if (item.name != null && item.name != "")
                                s.WriteLine(
                                    "level={0,-2} value1:{1,-3} value2:{2,-3} damageType:{3} objectType:{4,-2} weight:{5,-3} model={6,-5} color:{7,-3} effect:{8,-3} name={9}",
                                    item.level, item.value1, item.value2, item.damageType, item.objectType, item.weight, item.model, item.color,
                                    item.effect, item.name);
                        }
                    }
                }
            }
        }
开发者ID:Dawn-of-Light,项目名称:PacketLogConverter,代码行数:32,代码来源:InventoryItemsSampleWriter.cs


示例10: CopyStream

        public static void CopyStream(Stream source, Stream destination, ProgressCallback callback)
        {
            if (callback == null)
            {
                CopyStream(source, destination);
                return;
            }
            
            if (source == null)
                throw new ArgumentNullException("source");

            if (destination == null)
                throw new ArgumentNullException("destination");

            int count;
            byte[] buffer = new byte[2048];

            double percent = source.Length / 100d;
            double read = 0;

            while ((count = source.Read(buffer, 0, buffer.Length)) != 0)
            {
                read += count;
                destination.Write(buffer, 0, count);

                callback((int)(read / percent));
            }
        }
开发者ID:tomasdeml,项目名称:roamie,代码行数:28,代码来源:StreamUtility.cs


示例11: Load

 public override ThingList Load(BinaryReader BR, ProgressCallback ProgressCallback)
 {
     ThingList TL = new ThingList();
     if (ProgressCallback != null)
     {
         ProgressCallback(I18N.GetText("FTM:CheckingFile"), 0);
     }
     if (BR.BaseStream.Length < 0x38 || BR.BaseStream.Position != 0)
     {
         return TL;
     }
     FFXIEncoding E = new FFXIEncoding();
     // Read past the marker (32 bytes)
     if ((E.GetString(BR.ReadBytes(10)) != "XISTRING".PadRight(10, '\0')) || BR.ReadUInt16() != 2)
     {
         return TL;
     }
     foreach (byte B in BR.ReadBytes(20))
     {
         if (B != 0)
         {
             return TL;
         }
     }
     // Read The Header
     uint FileSize = BR.ReadUInt32();
     if (FileSize != BR.BaseStream.Length)
     {
         return TL;
     }
     uint EntryCount = BR.ReadUInt32();
     uint EntryBytes = BR.ReadUInt32();
     uint DataBytes = BR.ReadUInt32();
     BR.ReadUInt32(); // Unknown
     BR.ReadUInt32(); // Unknown
     if (EntryBytes != EntryCount * 12 || FileSize != 0x38 + EntryBytes + DataBytes)
     {
         return TL;
     }
     if (ProgressCallback != null)
     {
         ProgressCallback(I18N.GetText("FTM:LoadingData"), 0);
     }
     for (uint i = 0; i < EntryCount; ++i)
     {
         Things.XIStringTableEntry XSTE = new Things.XIStringTableEntry();
         if (!XSTE.Read(BR, E, i, EntryBytes, DataBytes))
         {
             TL.Clear();
             break;
         }
         if (ProgressCallback != null)
         {
             ProgressCallback(null, (double)(i + 1) / EntryCount);
         }
         TL.Add(XSTE);
     }
     return TL;
 }
开发者ID:Gravenet,项目名称:POLUtils,代码行数:59,代码来源:XIStringTable.cs


示例12: Load

 public override ThingList Load(BinaryReader BR, ProgressCallback ProgressCallback)
 {
     ThingList TL = new ThingList();
       if (ProgressCallback != null)
     ProgressCallback(I18N.GetText("FTM:CheckingFile"), 0);
       if (BR.BaseStream.Length < 0x40 || BR.BaseStream.Position != 0)
     return TL;
     FFXIEncoding E = new FFXIEncoding();
       // Skip (presumably) fixed portion of the header
       if ((E.GetString(BR.ReadBytes(8)) != "d_msg".PadRight(8, '\0')) || BR.ReadUInt16() != 1 || BR.ReadUInt16() != 1 || BR.ReadUInt32() != 3 || BR.ReadUInt32() != 3)
     return TL;
       // Read the useful header fields
     uint FileSize = BR.ReadUInt32();
       if (FileSize != BR.BaseStream.Length)
     return TL;
     uint HeaderBytes = BR.ReadUInt32();
       if (HeaderBytes != 0x40)
     return TL;
     uint EntryBytes = BR.ReadUInt32();
       if (BR.ReadUInt32() != 0)
     return TL;
     uint DataBytes  = BR.ReadUInt32();
       if (FileSize != HeaderBytes + EntryBytes + DataBytes)
     return TL;
     uint EntryCount = BR.ReadUInt32();
       if (EntryBytes != EntryCount * 8)
     return TL;
       if (BR.ReadUInt32() != 1 || BR.ReadUInt64() != 0 || BR.ReadUInt64() != 0)
     return TL;
       if (ProgressCallback != null)
     ProgressCallback(I18N.GetText("FTM:LoadingData"), 0);
       for (uint i = 0; i < EntryCount; ++i) {
     BR.BaseStream.Position = HeaderBytes + i * 8;
       int Offset = ~BR.ReadInt32();
       int Length = ~BR.ReadInt32();
     if (Length < 0 || Offset < 0 || Offset + Length > DataBytes) {
       TL.Clear();
       break;
     }
     BR.BaseStream.Position = HeaderBytes + EntryBytes + Offset;
       BinaryReader EntryBR = new BinaryReader(new MemoryStream(BR.ReadBytes(Length)));
       bool ItemAdded = false;
     {
     Things.DMSGStringBlock SB = new Things.DMSGStringBlock();
       if (SB.Read(EntryBR, E, i)) {
     TL.Add(SB);
     ItemAdded = true;
       }
     }
     EntryBR.Close();
     if (!ItemAdded) {
       TL.Clear();
       break;
     }
     if (ProgressCallback != null)
       ProgressCallback(null, (double) (i + 1) / EntryCount);
       }
       return TL;
 }
开发者ID:Zastai,项目名称:POLUtils,代码行数:59,代码来源:DMSGStringTable2.cs


示例13: Load

 public override ThingList Load(BinaryReader BR, ProgressCallback ProgressCallback)
 {
     ThingList TL = new ThingList();
     if (ProgressCallback != null)
     {
         ProgressCallback(I18N.GetText("FTM:CheckingFile"), 0);
     }
     if (BR.BaseStream.Length < 4)
     {
         return TL;
     }
     uint FileSizeMaybe = BR.ReadUInt32();
     if (FileSizeMaybe != (0x10000000 + BR.BaseStream.Length - 4))
     {
         return TL;
     }
     uint FirstTextPos = (BR.ReadUInt32() ^ 0x80808080);
     if ((FirstTextPos % 4) != 0 || FirstTextPos > BR.BaseStream.Length || FirstTextPos < 8)
     {
         return TL;
     }
     if (ProgressCallback != null)
     {
         ProgressCallback(I18N.GetText("FTM:LoadingData"), 0);
     }
     uint EntryCount = FirstTextPos / 4;
     // The entries are usually, but not always, sequential in the file.
     // Because we need to know how long one entry is (no clear end-of-message marker), we need them in
     // sequential order.
     List<uint> Entries = new List<uint>((int)EntryCount + 1);
     Entries.Add(FirstTextPos);
     for (int i = 1; i < EntryCount; ++i)
     {
         Entries.Add(BR.ReadUInt32() ^ 0x80808080);
     }
     Entries.Add((uint)BR.BaseStream.Length - 4);
     Entries.Sort();
     for (uint i = 0; i < EntryCount; ++i)
     {
         if (Entries[(int)i] < 4 * EntryCount || 4 + Entries[(int)i] >= BR.BaseStream.Length)
         {
             TL.Clear();
             break;
         }
         Things.DialogTableEntry DTE = new Things.DialogTableEntry();
         if (!DTE.Read(BR, i, Entries[(int)i], Entries[(int)i + 1]))
         {
             TL.Clear();
             break;
         }
         if (ProgressCallback != null)
         {
             ProgressCallback(null, (double)(i + 1) / EntryCount);
         }
         TL.Add(DTE);
     }
     return TL;
 }
开发者ID:Gravenet,项目名称:POLUtils,代码行数:58,代码来源:DialogTable.cs


示例14: InitialCache

 /// <summary>
 /// Initalizes the cache to contain a specified amount of scintilla editors.
 /// The callback onProgress is called after each editor is created.
 /// </summary>
 /// <param name="amount"></param>
 /// <param name="onProgress"></param>
 public bool InitialCache(int amount, ProgressCallback onProgress)
 {
     for (int i = 0; i < amount; i += 1)
     {
         this.p_Scintillas.Push(new ScintillaNet.Scintilla());
         onProgress(i + 1);
     }
     return true;
 }
开发者ID:rudybear,项目名称:moai-ide,代码行数:15,代码来源:Scintilla.cs


示例15: FindHexString

 public static ulong FindHexString(IDataStream stream, String searchString, ulong start, ProgressCallback callback)
 {
     searchString = searchString.Replace(" ", "");
     Byte[] search = new Byte[searchString.Length / 2];
     for (int i = 0; i < search.Length; i++) {
         search[i] = Byte.Parse(searchString.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber);
     }
     return FindBytes(stream, search, start, callback);
 }
开发者ID:JoeyScarr,项目名称:kickass,代码行数:9,代码来源:SearchUtil.cs


示例16: WriteLog

        /// <summary>
        /// Writes the log.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="callback">The callback for UI updates.</param>
        public void WriteLog(IExecutionContext context, Stream stream, ProgressCallback callback)
        {
            StringBuilder header = new StringBuilder("<", 64);
            StringBuilder rawData = new StringBuilder(64);
            ArrayList lineBytes = new ArrayList();

            using (BinaryWriter s = new BinaryWriter(stream, Encoding.ASCII))
            {
                foreach (PacketLog log in context.LogManager.Logs)
                {
                    for (int i = 0; i < log.Count; i++)
                    {
                        if (callback != null && (i & 0xFFF) == 0) // update progress every 4096th packet
                            callback(i, log.Count - 1);

                        Packet packet = log[i];
                        if (context.FilterManager.IsPacketIgnored(packet))
                            continue;

                        header.Length = 1;

                        AppendHeader(header, packet);

                        s.Write(header.ToString().ToCharArray());
                        s.Write((byte) 0x0D);
                        s.Write((byte) 0x0A);

                        packet.Position = 0;
                        while (packet.Position < packet.Length)
                        {
                            int byteCount = rawData.Length = 0;
                            lineBytes.Clear();
                            for (; byteCount < 16 && packet.Position < packet.Length; byteCount++)
                            {
                                int b = packet.ReadByte();
                                rawData.Append(b.ToString("X2")).Append(' ');
                                lineBytes.Add((byte) b);
                            }

                            s.Write(string.Format("{0,-50}", rawData).ToCharArray());
                            for (int j = 0; j < lineBytes.Count; j++)
                            {
                                byte lineByte = (byte) lineBytes[j];
                                if (lineByte < 32)
                                    lineByte = (byte) '.';
                                s.Write(lineByte);
                            }
                            s.Write((byte) 0x0D);
                            s.Write((byte) 0x0A);
                        }

                        s.Write((byte) 0x0D);
                        s.Write((byte) 0x0A);
                    }
                }
            }
        }
开发者ID:Dawn-of-Light,项目名称:PacketLogConverter,代码行数:63,代码来源:DaocLoggerV3TextLogWriter.cs


示例17: Progress

        public Progress(Form parentForm)
        {
            if (parentForm == null)
                throw new ArgumentNullException("parentForm");

            m_parentForm = parentForm;
            m_progressForm = new ProgressForm();
            m_progressCallback = new ProgressCallback(ProgressCallback);
        }
开发者ID:Dawn-of-Light,项目名称:PacketLogConverter,代码行数:9,代码来源:Progress.cs


示例18: GetPicture

 static unsafe extern ErrorCode GetPicture(
     byte* buf,
     int len,
     ApiFlags flag,
     [Out] out BITMAPINFO** pHBInfo,
     [Out] out byte** pHBm,
     ProgressCallback lpPrgressCallback,
     int lData
     );
开发者ID:hazychill,项目名称:oog,代码行数:9,代码来源:TlgImageCreator.cs


示例19: WriteLog

        /// <summary>
        /// Writes the log.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="callback">The callback for UI updates.</param>
        public void WriteLog(IExecutionContext context, Stream stream, ProgressCallback callback)
        {
            TimeSpan baseTime = new TimeSpan(0);
            ArrayList oids = new ArrayList();
            Hashtable bitsByOid = new Hashtable();
            using (StreamWriter s = new StreamWriter(stream))
            {
                foreach (PacketLog log in context.LogManager.Logs)
                {
                    for (int i = 0; i < log.Count; i++)
                    {
                        if (callback != null && (i & 0xFFF) == 0) // update progress every 4096th packet
                            callback(i, log.Count - 1);

                        StoC_0xA1_NpcUpdate npcUpdate = log[i] as StoC_0xA1_NpcUpdate;
                        if (npcUpdate == null) continue;
                        if ((npcUpdate.Temp & 0xF000) == 0) continue;
                        if ((npcUpdate.Temp & 0x0FFF) != 0) continue;

                        s.WriteLine(npcUpdate.ToHumanReadableString(baseTime, true));
                        if (!oids.Contains(npcUpdate.NpcOid))
                            oids.Add(npcUpdate.NpcOid);
                        ArrayList bitsList = (ArrayList) bitsByOid[npcUpdate.NpcOid];
                        if (bitsList == null)
                        {
                            bitsList = new ArrayList();
                            bitsByOid[npcUpdate.NpcOid] = bitsList;
                        }
                        int bits = npcUpdate.Temp >> 12;
                        if (!bitsList.Contains(bits))
                            bitsList.Add(bits);
                    }

                    int regionId;
                    int zoneId;
                    SortedList oidInfo = ShowKnownOidAction.MakeOidList(log.Count - 1, log, out regionId, out zoneId);
                    s.WriteLine("\n\noids for region {0}, zone {1}\n", regionId, zoneId);
                    foreach (DictionaryEntry entry in oidInfo)
                    {
                        ushort oid = (ushort) entry.Key;
                        if (!oids.Contains(oid)) continue;
                        ShowKnownOidAction.ObjectInfo objectInfo = (ShowKnownOidAction.ObjectInfo) entry.Value;
                        s.Write("0x{0:X4}: ", oid);
                        s.Write(objectInfo.ToString());
                        foreach (int bits in (ArrayList) bitsByOid[oid])
                        {
                            s.Write("\t0b{0}", Convert.ToString(bits, 2));
                        }
                        s.WriteLine();
                    }
                }
            }
        }
开发者ID:Dawn-of-Light,项目名称:PacketLogConverter,代码行数:59,代码来源:NpcUpdateUnkSpeedBitsWriter.cs


示例20: loadAscii

        /// <summary>
        ///  ascii version of the image loader. works fine. 
        /// but is dog-slow (when debugging only).  Would go faster if it read the whole file in at once instead
        /// of line by line? 
        /// </summary>
        /// <param name="filename">file containing the image to load.</param>
        /// <returns>string</returns>
        private void loadAscii(Stream file, out string segmentationPoints, ProgressCallback callback)
        {
            using (StreamReader sr = new StreamReader(file))
            {
                // grok out the magic number etc, which are in plain text.
                String line = sr.ReadLine();
                if (line != "P2")
                    throw new ApplicationException("unsupported PGM filetype, try type P2 or P5 only.");

                // spin through comments if any.
                segmentationPoints = string.Empty;
                while ((line = sr.ReadLine()).StartsWith("#"))
                    if (Regex.IsMatch(line, frmMain.SegmentPointRegex))
                        segmentationPoints = line.Substring(line.IndexOf("("));

                // parse out the width and height.
                string[] pieces;
                pieces = line.Split(' ');
                int imgCols = Int32.Parse(pieces[0]);
                int imgRows = Int32.Parse(pieces[1]);

                // Initialize the image with the size just read in.
                bitmap = new Bitmap(imgCols, imgRows);
                using (DirectBitmapWriter dba = new DirectBitmapWriter(bitmap))
                {

                    // get the max gray value.
                    maximumGrayValue = Int32.Parse(sr.ReadLine());

                    // Prepare to receive pixels: first row, first column
                    int pixelRow = 0, pixelColumn = 0;
                    while (pixelRow < imgRows)
                    {
                        // Each line will contain only a few of the pixels on a single row of the image.
                        line = sr.ReadLine();
                        string[] colEntries = line.Split(' ');
                        for (int ii = 0; ii < colEntries.Length; ii++)
                        {
                            if (colEntries[ii].Length == 0) continue; // skip "  " double spaces
                            byte thisColor = byte.Parse(colEntries[ii]);
                            dba.SetGrayPixel(pixelColumn, pixelRow, thisColor);
                            if (++pixelColumn == imgCols)
                            {
                                pixelColumn = 0;
                                pixelRow++;
                                callback(pixelRow * 100 / imgRows);
                            }
                        }
                    }
                }
            }
        }
开发者ID:jrasm91,项目名称:cs312,代码行数:59,代码来源:GrayBitmap.cs



注:本文中的ProgressCallback类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ProgressEventArgs类代码示例发布时间:2022-05-24
下一篇:
C# ProgressBar类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap