コード例 #1
0
        void CopyCurrentRuleToClipboard()
        {
            if (CurrentRule != null)
            {
                MemoryStream        ms = new System.IO.MemoryStream();
                CountedStreamWriter sw = new CountedStreamWriter(ms);
                CurrentRule.Write(sw);
                sw.Flush();
                ms.Position = 0;
                using (StreamReader reader = new StreamReader(ms, Encoding.ASCII))
                {
                    string contents = reader.ReadToEnd();
                    if (!String.IsNullOrEmpty(contents))
                    {
                        //Need to make sure corrupt rules don't get pasted.
                        System.Security.Cryptography.SHA256Managed c = new System.Security.Cryptography.SHA256Managed();
                        System.Text.UTF8Encoding e = new UTF8Encoding();
                        byte[] rep     = e.GetBytes(contents);
                        string hashstr = Convert.ToBase64String(c.ComputeHash(rep));

                        Clipboard.SetText(hashstr + "#" + contents);
                    }
                }
            }
        }
コード例 #2
0
        void DoSave()
        {
            FileChanged = false;
            CountedStreamWriter pf = new CountedStreamWriter(FileName);

            LootRules.Write(pf);
            pf.Close();
        }
コード例 #3
0
        public override void LoadProfile(string filename, bool newprofile)
        {
            try
            {
#if DEBUGMSG
                neededid = 0;
                noid     = 0;
#endif

                if (newprofile)
                {
                    LootRules = new cLootRules();
                    using (System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None))
                    {
                        using (CountedStreamWriter sr = new CountedStreamWriter(fs))
                        {
                            LootRules.Write(sr);
                        }
                    }

                    WriteToChat("Created blank profile " + filename + ".");
                }
                else
                {
                    if (!System.IO.File.Exists(filename))
                    {
                        return;
                    }

                    LootRules = new cLootRules();
                    using (System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
                    {
                        using (System.IO.StreamReader sr = new System.IO.StreamReader(fs))
                        {
                            if (LootRules.Read(sr, -1))
                            {
                                WriteToChat("Load profile " + filename + " successful (file version " + LootRules.UTLFileVersion.ToString() + ").");
                            }
                            else
                            {
                                WriteToChat("Load profile " + filename + " returned an error. Your entire profile may not have loaded properly.");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler(ex);
            }
        }
コード例 #4
0
        private void exportRangesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.SaveFileDialog od = new System.Windows.Forms.SaveFileDialog();
            od.DefaultExt       = ".ucr";
            od.Filter           = "VTClassic Combine Ranges|*.ucr";
            od.InitialDirectory = GetVTankProfileDirectory();
            od.ShowDialog();

            if (od.FileName != "")
            {
                using (CountedStreamWriter pf = new CountedStreamWriter(od.FileName))
                {
                    SalvageBlock.Write(pf);
                }
            }
        }
コード例 #5
0
        public void Write(CountedStreamWriter inf)
        {
            foreach (IUTLFileBlockHandler h in FileBlocks)
            {
                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                CountedStreamWriter    sw = new CountedStreamWriter(ms);
                h.Write(sw);
                sw.Flush();

                inf.WriteLine(h.BlockTypeID);
                inf.WriteLine(((int)sw.Count).ToString(System.Globalization.CultureInfo.InvariantCulture));

                ms.Position = 0;
                System.IO.StreamReader sr = new System.IO.StreamReader(ms);
                inf.Write(sr.ReadToEnd());
            }
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: obfuscators-2019/VirindiTank
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     if (CurrentRule != null)
     {
         MemoryStream        ms = new System.IO.MemoryStream();
         CountedStreamWriter sw = new CountedStreamWriter(ms);
         CurrentRule.Write(sw);
         sw.Flush();
         ms.Position = 0;
         using (StreamReader reader = new StreamReader(ms, Encoding.ASCII))
         {
             string contents = reader.ReadToEnd();
             if (!String.IsNullOrEmpty(contents))
             {
                 Clipboard.SetText(contents);
             }
         }
     }
 }
コード例 #7
0
ファイル: Form1.cs プロジェクト: IbespwnAC/MagTools
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     if (CurrentRule != null)
     {
         MemoryStream ms = new System.IO.MemoryStream();
         CountedStreamWriter sw = new CountedStreamWriter(ms);
         CurrentRule.Write(sw);
         sw.Flush();
         ms.Position = 0;
         using (StreamReader reader = new StreamReader(ms, Encoding.ASCII))
         {
             string contents = reader.ReadToEnd();
             if (!String.IsNullOrEmpty(contents))
             {
                 Clipboard.SetText(contents);
             }
         }
     }
 }
コード例 #8
0
ファイル: Form1.cs プロジェクト: IbespwnAC/MagTools
 void DoSave()
 {
     FileChanged = false;
     CountedStreamWriter pf = new CountedStreamWriter(FileName);
     LootRules.Write(pf);
     pf.Close();
 }
コード例 #9
0
        public void Write(CountedStreamWriter inf)
        {
            foreach (IUTLFileBlockHandler h in FileBlocks)
            {
                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                CountedStreamWriter sw = new CountedStreamWriter(ms);
                h.Write(sw);
                sw.Flush();

                inf.WriteLine(h.BlockTypeID);
                inf.WriteLine(((int)sw.Count).ToString(System.Globalization.CultureInfo.InvariantCulture));

                ms.Position = 0;
                System.IO.StreamReader sr = new System.IO.StreamReader(ms);
                inf.Write(sr.ReadToEnd());
            }
        }
コード例 #10
0
ファイル: LootCore.cs プロジェクト: IbespwnAC/MagTools
        public override void LoadProfile(string filename, bool newprofile)
        {
            try
            {
#if DEBUGMSG
                neededid = 0;
                noid = 0;
#endif

                if (newprofile)
                {
                    LootRules = new cLootRules();
                    using (System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None))
                    {
                        using (CountedStreamWriter sr = new CountedStreamWriter(fs))
                        {
                            LootRules.Write(sr);
                        }
                    }

                    WriteToChat("Created blank profile " + filename + ".");
                }
                else
                {
                    if (!System.IO.File.Exists(filename)) return;

                    LootRules = new cLootRules();
                    using (System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
                    {
                        using (System.IO.StreamReader sr = new System.IO.StreamReader(fs))
                        {
                            if (LootRules.Read(sr, -1))
                                WriteToChat("Load profile " + filename + " successful (file version " + LootRules.UTLFileVersion.ToString() + ").");
                            else
                                WriteToChat("Load profile " + filename + " returned an error. Your entire profile may not have loaded properly.");
                        }
                    }

                }
            }
            catch (Exception ex)
            {
                ExceptionHandler(ex);
            }
        }
コード例 #11
0
ファイル: Form_SalvageTab.cs プロジェクト: IbespwnAC/MagTools
        private void exportRangesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.SaveFileDialog od = new System.Windows.Forms.SaveFileDialog();
            od.DefaultExt = ".ucr";
            od.Filter = "VTClassic Combine Ranges|*.ucr";
            od.InitialDirectory = GetVTankProfileDirectory();
            od.ShowDialog();

            if (od.FileName != "")
            {
                using (CountedStreamWriter pf = new CountedStreamWriter(od.FileName))
                {
                    SalvageBlock.Write(pf);
                }
            }
        }