示例#1
0
 public SaveForm(HaRepackerMainPanel panel, WzNode wzNode)
 {
     InitializeComponent();
     this.wzNode = wzNode;
     this.wzf = (WzFile)wzNode.Tag;
     this.panel = panel;
 }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="otherWzFileToLoadAt"></param>
        /// <param name="path"></param>
        /// <param name="encVersion"></param>
        /// <param name="version"></param>
        /// <param name="panel"></param>
        /// <param name="currentDispatcher">Dispatcher thread</param>
        /// <returns></returns>
        private WzFile LoadWzFile(string path, WzMapleVersion encVersion, short version, HaRepackerMainPanel panel, Dispatcher currentDispatcher = null)
        {
            WzFile newFile;

            if (!OpenWzFile(path, encVersion, version, out newFile))
            {
                return(null);
            }
            WzNode node = new WzNode(newFile);

            // execute in main thread
            if (currentDispatcher != null)
            {
                currentDispatcher.BeginInvoke((Action)(() =>
                {
                    panel.DataTree.Nodes.Add(node);
                    SortNodesRecursively(node);
                }));
            }
            else
            {
                panel.DataTree.Nodes.Add(node);
                SortNodesRecursively(node);
            }
            return(newFile);
        }
示例#3
0
文件: WzNode.cs 项目: Aeopp/Github
 public bool AddObject(WzObject obj, UndoRedoManager undoRedoMan)
 {
     if (CanNodeBeInserted(this, obj.Name))
     {
         TryParseImage();
         if (addObjInternal(obj))
         {
             WzNode node = new WzNode(obj);
             Nodes.Add(node);
             if (node.Tag is WzImageProperty)
             {
                 ((WzImageProperty)node.Tag).ParentImage.Changed = true;
             }
             undoRedoMan.AddUndoBatch(new System.Collections.Generic.List <UndoRedoAction> {
                 UndoRedoManager.ObjectAdded(this, node)
             });
             node.EnsureVisible();
             return(true);
         }
         else
         {
             Warning.Error("Could not insert property, make sure all types are correct");
             return(false);
         }
     }
     else
     {
         MessageBox.Show("Cannot insert object \"" + obj.Name + "\" because an object with the same name already exists. Skipping.", "Skipping Object", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(false);
     }
 }
示例#4
0
 public void InsertWzFileUnsafe(WzFile f, HaRepackerMainPanel panel)
 {
     wzFiles.Add(f);
     WzNode node = new WzNode(f);
     panel.DataTree.Nodes.Add(node);
     SortNodesRecursively(node);
 }
示例#5
0
 public static WzNode GetChildNode(WzNode parentNode, string name)
 {
     foreach (WzNode node in parentNode.Nodes)
         if (node.Text == name) 
             return node;
     return null;
 }
示例#6
0
 private void SortNodesRecursively(WzNode parent)
 {
     if (UserSettings.Sort)
     {
         parent.TreeView.Sort();
     }
 }
示例#7
0
        public void InsertWzFileUnsafe(WzFile f, HaRepackerMainPanel panel)
        {
            wzFiles.Add(f);
            WzNode node = new WzNode(f);

            panel.DataTree.Nodes.Add(node);
            SortNodesRecursively(node);
        }
示例#8
0
 public static bool CanNodeBeInserted(WzNode parentNode, string name)
 {
     IWzObject obj = (IWzObject)parentNode.Tag;
     if (obj is IPropertyContainer) return ((IPropertyContainer)obj)[name] == null;
     else if (obj is WzDirectory) return ((WzDirectory)obj)[name] == null;
     else if (obj is WzFile) return ((WzFile)obj).WzDirectory[name] == null;
     else return false;
 }
示例#9
0
 public SaveForm(HaRepackerMainPanel panel, WzNode wzNode)
 {
     InitializeComponent();
     encryptionBox.Items.Add(HaRepacker.Properties.Resources.EncTypeGMS);
     encryptionBox.Items.Add(HaRepacker.Properties.Resources.EncTypeMSEA);
     encryptionBox.Items.Add(HaRepacker.Properties.Resources.EncTypeNone);
     this.wzNode = wzNode;
     this.wzf = (WzFile)wzNode.Tag;
     this.panel = panel;
 }
示例#10
0
文件: WzNode.cs 项目: xnum/hasuite
 public static WzNode GetChildNode(WzNode parentNode, string name)
 {
     foreach (WzNode node in parentNode.Nodes)
     {
         if (node.Text == name)
         {
             return(node);
         }
     }
     return(null);
 }
示例#11
0
文件: WzNode.cs 项目: xnum/hasuite
 public bool MoveWzObjectInto(WzNode newParent)
 {
     if (CanNodeBeInserted(newParent, Text))
     {
         addObjInternal((IWzObject)newParent.Tag);
         return(true);
     }
     else
     {
         MessageBox.Show("Cannot insert object \"" + Text + "\" because an object with the same name already exists. Skipping.", "Skipping Object", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(false);
     }
 }
示例#12
0
        private WzFile LoadWzFile(string path, WzMapleVersion encVersion, short version, HaRepackerMainPanel panel)
        {
            WzFile newFile;

            if (!OpenWzFile(path, encVersion, version, out newFile))
            {
                return(null);
            }
            WzNode node = new WzNode(newFile);

            panel.DataTree.Nodes.Add(node);
            SortNodesRecursively(node);
            return(newFile);
        }
示例#13
0
文件: WzNode.cs 项目: xnum/hasuite
 public bool AddNode(WzNode node)
 {
     if (CanNodeBeInserted(this, node.Text))
     {
         TryParseImage();
         this.Nodes.Add(node);
         addObjInternal((IWzObject)node.Tag);
         return(true);
     }
     else
     {
         MessageBox.Show("Cannot insert node \"" + node.Text + "\" because a node with the same name already exists. Skipping.", "Skipping Node", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(false);
     }
 }
示例#14
0
        /// <summary>
        /// Loads the Data.wz file
        /// </summary>
        /// <param name="path"></param>
        /// <param name="encVersion"></param>
        /// <param name="panel"></param>
        /// <returns></returns>
        public WzImage LoadDataWzHotfixFile(string path, WzMapleVersion encVersion, HaRepackerMainPanel panel)
        {
            FileStream fs = File.Open(path, FileMode.Open);

            WzImage img = new WzImage(Path.GetFileName(path), fs, encVersion);

            img.ParseImage(true);

            WzNode node = new WzNode(img);

            panel.DataTree.Nodes.Add(node);
            if (UserSettings.Sort)
            {
                SortNodesRecursively(node);
            }
            return(img);
        }
示例#15
0
文件: WzNode.cs 项目: xnum/hasuite
        public static bool CanNodeBeInserted(WzNode parentNode, string name)
        {
            IWzObject obj = (IWzObject)parentNode.Tag;

            if (obj is IPropertyContainer)
            {
                return(((IPropertyContainer)obj)[name] == null);
            }
            else if (obj is WzDirectory)
            {
                return(((WzDirectory)obj)[name] == null);
            }
            else if (obj is WzFile)
            {
                return(((WzFile)obj).WzDirectory[name] == null);
            }
            else
            {
                return(false);
            }
        }
示例#16
0
 public ContextMenuStrip CreateMenu(WzNode node, WzObject Tag)
 {
     ContextMenuStrip menu = null;
     if (Tag is WzImage || Tag is IPropertyContainer)
     {
         if (Tag is WzSubProperty)
         {
             menu = new ContextMenuStrip();
             menu.Items.AddRange(new ToolStripItem[] { AddPropsSubMenu, /*export, import,*/Remove });
         }
         else
         {
             menu = new ContextMenuStrip();
             menu.Items.AddRange(new ToolStripItem[] { AddPropsSubMenu, /*export, import,*/Remove });
         }
     }
     else if (Tag is WzImageProperty)
     {
         menu = new ContextMenuStrip();
         menu.Items.AddRange(new ToolStripItem[] { /*export, import,*/Remove });
     }
     else if (Tag is WzDirectory)
     {
         menu = new ContextMenuStrip();
         menu.Items.AddRange(new ToolStripItem[] { AddDirsSubMenu, /*export, import,*/Remove });
     }
     else if (Tag is WzFile)
     {
         menu = new ContextMenuStrip();
         menu.Items.AddRange(new ToolStripItem[] { AddDirsSubMenu, SaveFile, Unload, Reload });
     }
     currNode = node;
     return menu;
 }
示例#17
0
 private void InsertWzNodeCallback(WzNode node, WzNode parent)
 {
     WzNode child = WzNode.GetChildNode(parent, node.Text);
     if (child != null)
     {
         if (ShowReplaceDialog(node.Text))
             child.Delete();
         else return;
     }
     parent.AddNode(node);
 }
示例#18
0
 public bool AddObject(IWzObject obj, UndoRedoManager undoRedoMan)
 {
     if (CanNodeBeInserted(this, obj.Name))
     {
         TryParseImage();
         addObjInternal(obj);
         WzNode node = new WzNode(obj);
         Nodes.Add(node);
         if (node.Tag is IWzImageProperty) ((IWzImageProperty)node.Tag).ParentImage.Changed = true;
         undoRedoMan.AddUndoBatch(new System.Collections.Generic.List<UndoRedoAction> { UndoRedoManager.ObjectAdded(this, node) });
         node.EnsureVisible();
         return true;
     }
     else
     {
         MessageBox.Show("Cannot insert object \"" + obj.Name + "\" because an object with the same name already exists. Skipping.", "Skipping Object", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return false;
     }
 }
示例#19
0
 public bool AddNode(WzNode node)
 {
     if (CanNodeBeInserted(this, node.Text))
     {
         TryParseImage();
         this.Nodes.Add(node);
         addObjInternal((IWzObject)node.Tag);
         return true;
     }
     else
     {
         MessageBox.Show("Cannot insert node \"" + node.Text + "\" because a node with the same name already exists. Skipping.", "Skipping Node", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return false;
     }
 }
示例#20
0
 public bool MoveInto(WzNode newParent)
 {
     if (CanNodeBeInserted(newParent, Text))
     {
         addObjInternal((IWzObject)newParent.Tag);
         Parent.Nodes.Remove(this);
         newParent.Nodes.Add(this);
         return true;
     }
     else
     {
         MessageBox.Show("Cannot insert object \"" + Text + "\" because an object with the same name already exists. Skipping.", "Skipping Object", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return false;
     }
 }
示例#21
0
 public UndoRedoAction(WzNode item, WzNode parent, UndoRedoType type)
 {
     this.item   = item;
     this.parent = parent;
     this.type   = type;
 }
示例#22
0
 public static UndoRedoAction ObjectRemoved(WzNode parent, WzNode item)
 {
     return(new UndoRedoAction(item, parent, UndoRedoType.ObjectRemoved));
 }
示例#23
0
 private void InsertWzNodeThreadSafe(WzNode node, WzNode parent)
 {
     if (MainPanel.InvokeRequired) MainPanel.Invoke(new InsertWzNode(InsertWzNodeCallback), node, parent);
     else InsertWzNodeCallback(node, parent);
 }
示例#24
0
 private void WzImporterThread(object param)
 {
     ChangeApplicationState(false);
     object[] arr = (object[])param;
     ProgressingWzSerializer deserializer = (ProgressingWzSerializer)arr[0];
     string[] files = (string[])arr[1];
     WzNode parent = (WzNode)arr[2];
     byte[] iv = (byte[])arr[3];
     IWzObject parentObj = (IWzObject)parent.Tag;
     if (parentObj is WzFile) parentObj = ((WzFile)parentObj).WzDirectory;
     UpdateProgressBar(MainPanel.mainProgressBar, files.Length, true, true);
     foreach (string file in files)
     {
         List<IWzObject> objs;
         try
         {
             if (deserializer is WzXmlDeserializer)
                 objs = ((WzXmlDeserializer)deserializer).ParseXML(file);
             else
                 objs = new List<IWzObject> { ((WzImgDeserializer)deserializer).WzImageFromIMGFile(file, iv, Path.GetFileName(file)) };
         }
         catch (ThreadAbortException)
         {
             return;
         }
         catch (Exception e)
         {
             Warning.Error("The file \"" + file + "\" is invalid and will be skipped. Error: " + e.Message);
             UpdateProgressBar(MainPanel.mainProgressBar, 1, false, false);
             continue;
         }
         foreach (IWzObject obj in objs)
         {
             if (((obj is WzDirectory || obj is WzImage) && parentObj is WzDirectory) || (obj is IWzImageProperty && parentObj is IPropertyContainer))
             {
                 WzNode node = new WzNode(obj);
                 InsertWzNodeThreadSafe(node, parent);
             }
         }
         UpdateProgressBar(MainPanel.mainProgressBar, 1, false, false);
     }
     threadDone = true;
 }
示例#25
0
 private void SortNodesRecursively(WzNode parent)
 {
     parent.TreeView.Sort();
 }
示例#26
0
 private WzFile LoadWzFile(string path, WzMapleVersion encVersion, short version, HaRepackerMainPanel panel)
 {
     WzFile newFile;
     if (!OpenWzFile(path, encVersion, version, out newFile)) return null;
     WzNode node = new WzNode(newFile);
     panel.DataTree.Nodes.Add(node);
     SortNodesRecursively(node);
     return newFile;
 }
示例#27
0
 public UndoRedoAction(WzNode item, WzNode parent, UndoRedoType type)
 {
     this.item = item;
     this.parent = parent;
     this.type = type;
 }
示例#28
0
 public static UndoRedoAction ObjectRemoved(WzNode parent, WzNode item)
 {
     return new UndoRedoAction(item, parent, UndoRedoType.ObjectRemoved);
 }
示例#29
0
 private void SortNodesRecursively(WzNode parent)
 {
     parent.TreeView.Sort();
 }