当前位置: 首页>>代码示例>>C#>>正文


C# ProgressCallback类代码示例

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


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


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