예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceItem"/> class.
 /// </summary>
 /// <param name="ri">The ri.</param>
 public ResourceItem(ResourceItem ri)
 {
     m_originalResourcePath = ri.m_originalResourcePath;
     m_headerpath = ri.m_headerpath;
     m_contentpath = ri.m_contentpath;
     m_resourcePath = ri.m_resourcePath;
     m_entryType = ri.m_entryType;
     m_isFolder = ri.m_isFolder;
     m_items = new List<ResourceDataItem>();
     foreach (ResourceDataItem rdi in ri.m_items)
         m_items.Add(new ResourceDataItem(rdi));
 }
예제 #2
0
        private void OKBtn_Click(object sender, EventArgs e)
        {
            SavePackageDialog.FileName = m_filename;
            if (SavePackageDialog.ShowDialog(this) != DialogResult.OK)
                return;

            //Preparation: Update all resources with the correct path, and build a list with them
            List<ResourceItem> items = new List<ResourceItem>();

            try
            {
                ResourceTree.PathSeparator = "/";
                ResourceTree.Nodes[0].Text = "Library:/";

                Queue<TreeNode> nl = new Queue<TreeNode>();
                foreach (TreeNode n in ResourceTree.Nodes[0].Nodes)
                    nl.Enqueue(n);

                while (nl.Count > 0)
                {
                    TreeNode n = nl.Dequeue();
                    foreach (TreeNode tn in n.Nodes)
                        nl.Enqueue(tn);

                    if (n.Tag as ResourceItem != null && (n.Tag as ResourceItem).EntryType != EntryTypeEnum.Deleted)
                    {
                        ResourceItem ri = new ResourceItem(n.Tag as ResourceItem);
                        ri.ResourcePath = n.FullPath + (ri.IsFolder ? "/" : "");
                        if (string.IsNullOrEmpty(ri.OriginalResourcePath))
                            ri.OriginalResourcePath = ri.ResourcePath;

                        items.Add(ri);
                    }
                }
            }
            finally
            {
                ResourceTree.Nodes[0].Text = "Library://";
            }

            try
            {
                if (PackageProgress.RebuildPackage(this, _conn, m_filename, items, SavePackageDialog.FileName, InsertDeleteCommands.Checked) != DialogResult.OK)
                    return;
            }
            catch (Exception ex)
            {
                if (ex is System.Reflection.TargetInvocationException && ex.InnerException != null)
                    ex = ex.InnerException;

                string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                MessageBox.Show(this, string.Format(Strings.PackageBuildError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            finally
            {
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
예제 #3
0
        private void AddResourceButton_Click(object sender, EventArgs e)
        {
            var dlg = new AddResourceEntryDialog();
            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                int imageindex = RepositoryIcons.GetImageIndexForResourceType((ResourceTypes)Enum.Parse(typeof(ResourceTypes), Path.GetExtension(dlg.ResourceName).Replace(".", "")));
                TreeNode n = new TreeNode(dlg.ResourceName, imageindex, imageindex);
                ResourceItem i = new ResourceItem("", dlg.HeaderFilepath, dlg.ContentFilepath);
                i.EntryType = EntryTypeEnum.Added;
                n.Tag = i;

                if (ResourceTree.SelectedNode == null || ResourceTree.SelectedNode.Parent == null)
                    ResourceTree.Nodes[0].Nodes.Add(n);
                else if (ResourceTree.SelectedNode.Tag as ResourceItem != null)
                {
                    if ((ResourceTree.SelectedNode.Tag as ResourceItem).IsFolder)
                        ResourceTree.SelectedNode.Nodes.Add(n);
                    else if (ResourceTree.SelectedNode.Parent == null)
                        ResourceTree.Nodes[0].Nodes.Add(n);
                    else
                        ResourceTree.SelectedNode.Parent.Nodes.Add(n);
                }

                n.EnsureVisible();
                ResourceTree.SelectedNode = n;
                ResourceTree.Focus();
            }
        }