示例#1
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (e.Argument is DictionaryArgs)
            {
                DictionaryArgs args = (DictionaryArgs)e.Argument;

                if (args.Load)
                {
                    HashDictionary.LoadDictionary(args.Name);
                }
                else if (args.Save)
                {
                    HashDictionary.SaveDictionary(args.Name);
                }
                else if (args.Merge)
                {
                    HashDictionary.MergeDictionary(args.Name);
                }
            }
            else if (e.Argument is MythicLoadArgs)
            {
                MythicLoadArgs  args  = (MythicLoadArgs)e.Argument;
                MythicPackage[] packs = new MythicPackage[args.Names.Length];

                for (int i = 0; i < args.Names.Length; i++)
                {
                    packs[i] = MythicPackage.Read(args.Names[i]);
                }

                args.Result = packs;
            }
            else if (e.Argument is SpyProcessArgs)
            {
                SpyProcessArgs args = (SpyProcessArgs)e.Argument;

                m_Spy.Init(args.Process);
                m_Spy.MainLoop();
            }
            else if (e.Argument is SpyPathArgs)
            {
                SpyPathArgs args = (SpyPathArgs)e.Argument;

                m_Spy.Init(args.Path);
                m_Spy.MainLoop();
            }
            else if (e.Argument is UnpackArgs)
            {
                UnpackArgs args = (UnpackArgs)e.Argument;

                if (args.IsPackage)
                {
                    args.Package.Decompress(UnpackArgs.Path, args.Package.Info.Name);
                }
                else if (args.IsBlock)
                {
                    using (FileStream stream = File.OpenRead(args.Package.Info.FullName))
                    {
                        using (BinaryReader reader = new BinaryReader(stream))
                            args.Block.Decompress(reader, UnpackArgs.Path, args.Package.Info.Name);
                    }
                }
                else if (args.IsFile)
                {
                    using (FileStream stream = File.OpenRead(args.Package.Info.FullName))
                    {
                        using (BinaryReader reader = new BinaryReader(stream))
                            args.File.Decompress(reader, UnpackArgs.Path, String.Format("{0}_{1}", args.Package.Info.Name, args.Block.Index));
                    }
                }
            }
            else if (e.Argument is SearchArgs)
            {
                SearchArgs args = (SearchArgs)e.Argument;

                args.Found = 0;

                for (int i = args.From; i < args.To; i++)
                {
                    if (SearchKeyword(String.Format("{0}{1}{2}", args.Before, i.ToString("D" + args.Length), args.After), true))
                    {
                        args.Found += 1;
                    }
                }
            }

            e.Result = e.Argument;
        }
示例#2
0
		private void Unpack_Click( object sender, EventArgs e )
		{
			if ( Worker.IsBusy )
				return;

			if ( UnpackArgs.Path == null )
			{
				if ( SelectFolder.ShowDialog() == DialogResult.OK )
					UnpackArgs.Path = SelectFolder.SelectedPath;
				else
					return;
			}

			UnpackArgs args = null;
			MythicPackage p = null;
			MythicPackageBlock b = null;
			MythicPackageIndex idx = null;
			
			if ( TreeView.SelectedNode != null )
			{
				if ( TreeView.SelectedNode.Tag is MythicPackage )
				{
					p = (MythicPackage) TreeView.SelectedNode.Tag;

					if (  ListBox.SelectedIndex == -1 )
						args = new UnpackArgs( p );
				}
				else if ( TreeView.SelectedNode.Tag is MythicPackageBlock )
				{
					p = (MythicPackage) TreeView.SelectedNode.Parent.Tag;
					b = (MythicPackageBlock) TreeView.SelectedNode.Tag;

					if (  ListBox.SelectedIndex == -1 )
						args = new UnpackArgs( p, b );
				}
			}

			if ( ListBox.SelectedItem is MythicPackageIndex )
			{
				idx = (MythicPackageIndex) ListBox.SelectedItem;

				if ( p != null && b != null )
						args = new UnpackArgs( p, b, idx );
			}

			if ( args != null)
			{
				StatusLabel.Text = String.Format( "Unpacking in {0}", UnpackArgs.Path );
				Unpack.Enabled = false;
				Worker.RunWorkerAsync( args );
			}
		}
示例#3
0
        private void Unpack_Click(object sender, EventArgs e)
        {
            if (Worker.IsBusy)
            {
                return;
            }

            if (UnpackArgs.Path == null)
            {
                if (SelectFolder.ShowDialog() == DialogResult.OK)
                {
                    UnpackArgs.Path = SelectFolder.SelectedPath;
                }
                else
                {
                    return;
                }
            }

            UnpackArgs         args = null;
            MythicPackage      p    = null;
            MythicPackageBlock b    = null;
            MythicPackageIndex idx  = null;

            if (TreeView.SelectedNode != null)
            {
                if (TreeView.SelectedNode.Tag is MythicPackage)
                {
                    p = (MythicPackage)TreeView.SelectedNode.Tag;

                    if (ListBox.SelectedIndex == -1)
                    {
                        args = new UnpackArgs(p);
                    }
                }
                else if (TreeView.SelectedNode.Tag is MythicPackageBlock)
                {
                    p = (MythicPackage)TreeView.SelectedNode.Parent.Tag;
                    b = (MythicPackageBlock)TreeView.SelectedNode.Tag;

                    if (ListBox.SelectedIndex == -1)
                    {
                        args = new UnpackArgs(p, b);
                    }
                }
            }

            if (ListBox.SelectedItem is MythicPackageIndex)
            {
                idx = (MythicPackageIndex)ListBox.SelectedItem;

                if (p != null && b != null)
                {
                    args = new UnpackArgs(p, b, idx);
                }
            }

            if (args != null)
            {
                StatusLabel.Text = String.Format("Unpacking in {0}", UnpackArgs.Path);
                Unpack.Enabled   = false;
                Worker.RunWorkerAsync(args);
            }
        }