private void buttonBack_Click(object sender, EventArgs e)
 {
     if (_currentContainer.Parent != null)
     {
         _currentContainer = _currentContainer.Parent;
     }
     FillCatalog();
 }
        private void buttonOpen_Click(object sender, EventArgs e)
        {
            AbstractContainer toOpen = GetContainerForSelectedRow();

            if (!(toOpen is FolderContainer))
            {
                throw new ArgumentException("Only Folders can be opened.");
            }
            _currentContainer = toOpen as FolderContainer;
            FillCatalog();
        }
        private void buttonCreateEmptyFolder_Click(object sender, EventArgs e)
        {
            CreateEmptyFolderForem form = new CreateEmptyFolderForem();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            _currentContainer.Add(FolderContainer.CreateEmpty(form.Name));
            Save();
            FillCatalog();
        }
        private void createNewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CreateNewMmeForm form = new CreateNewMmeForm();

            if (form.ShowDialog() == DialogResult.OK)
            {
                _mmeFileInfo      = new FileInfo(form.FullName);
                _rootContainer    = FolderContainer.Create(form.FileInfos);
                _currentContainer = _rootContainer;
                SaveFirst();
                (new KeyShowForm(_secretKey)).ShowDialog();
                FillCatalog();
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Checks the components.
 /// </summary>
 protected override void CheckComponents()
 {
     if (_drawer == null)
         _drawer = new SceneEntityDrawer (PANEL_TITLE);
     if (_favDrawer == null)
         _favDrawer = new SceneEntityDrawer (PANEL_TITLE);
     if (_screenshotDrawer == null)
         _screenshotDrawer = new ScreenshotDrawer ();
     if (_scrolls == null)
         _scrolls = new ScrollableContainer (PANEL_TITLE, true);
     if (_folders == null)
         _folders = new FolderContainer (PANEL_TITLE, true);
     if (_database == null)
         _database = SceneDatabaseProvider.GetDatabase (this);
 }
        private void InitRootContainer(string mmeFilePath, string key)
        {
            byte[] container;
            try
            {
                container = Security.Decrypt(mmeFilePath, key);
            }
            catch (CryptographicException e)
            {
                throw;
            }
            Serializer <FolderContainer> serializer = new Serializer <FolderContainer>();

            _rootContainer = serializer.Deserialize(container);
        }
        private void OpenMmeFile()
        {
            OpenFileDialog openDialog = new OpenFileDialog();

            openDialog.DefaultExt   = constants.MME_FILE_EXTENTION.Remove(0, 1);
            openDialog.AddExtension = true;
            openDialog.Filter       = constants.MME_FILE_FILTER;
            if (openDialog.ShowDialog() == DialogResult.OK)
            {
                string key = TryAskForKey(openDialog.FileName);
                if (key == null)
                {
                    return;
                }

                _secretKey           = key;
                textBoxFilePath.Text = openDialog.FileName;
                _mmeFileInfo         = new FileInfo(openDialog.FileName);
                _currentContainer    = _rootContainer;
                FillCatalog();
            }
        }
 public FolderViewModel(FolderContainer component) : base(component)
 {
 }
        private void tgv_MouseDown(object sender, MouseEventArgs e)
        {
            DevExpress.XtraTreeList.TreeListHitInfo hInfo = tgv.CalcHitInfo(new Point(e.X, e.Y));
            TreeListNode node = hInfo.Node;

            if (node == null ||
                hInfo.Column == null ||
                !(hInfo.Column.AbsoluteIndex == 2 || hInfo.Column.AbsoluteIndex == 4))
            {
                return;
            }
            tgv.FocusedNode = node;
            string action;

            switch (hInfo.Column.AbsoluteIndex)
            {
            case 2:
                action = node.GetValue(2).ToString();

                if (!string.IsNullOrEmpty(action) && action == "System.Drawing.Bitmap")
                {
                    object image = node.GetValue(2);

                    if (image == GreenArrow)
                    {
                        action = "Import >";
                    }
                    else if (image == BlueArrow)
                    {
                        action = "Apply Change >";
                    }
                }
                break;

            case 4:
                action = node.GetValue(4).ToString();

                if (!string.IsNullOrEmpty(action) && action == "System.Drawing.Bitmap")
                {
                    action = "Remove";
                }
                break;

            default:
                return;
            }
            if (string.IsNullOrEmpty(action))
            {
                return;
            }
            TreeListNode ownerNode = node;

            while (ownerNode != null && ownerNode.Tag == null)
            {
                ownerNode = ownerNode.ParentNode;
            }
            if (ownerNode == null)
            {
                return;
            }
            switch (action)
            {
            case "Import >":
                if (node.Tag == null)
                {
                    // Parent is a FileContainer
                    string parentText = node.ParentNode.GetValue(0).ToString();

                    FileContainer fc           = (FileContainer)node.ParentNode.Tag;
                    string        propertyName = node.GetValue(1).ToString();

                    switch (propertyName)
                    {
                    case "":
                        break;

                    default:
                        throw new NotImplementedException("Not coded yet.");
                    }

                    Populate();
                }
                else if (node.Tag.GetType() == typeof(FolderContainer))
                {
                    Stack <FolderContainer> folderStack = new Stack <FolderContainer>();
                    TreeListNode            parentNode  = node;
                    bool         matchingAncestorFound  = false;
                    OutputFolder myTopFolder            = null;

                    while (parentNode.ParentNode != null)
                    {
                        FolderContainer fc = (FolderContainer)parentNode.Tag;

                        if (fc.MyFolder != null)
                        {
                            matchingAncestorFound = true;
                            myTopFolder           = fc.MyFolder;
                            break;
                        }
                        folderStack.Push(fc);
                        parentNode = parentNode.ParentNode;
                    }
                    if (!matchingAncestorFound)
                    {
                        FolderContainer fc             = folderStack.Pop();
                        OutputFolder    topLevelFolder = fc.TheirFolder;
                        myTopFolder = new OutputFolder(topLevelFolder.Name, topLevelFolder.Id);
                        myTopFolder.IteratorType = topLevelFolder.IteratorType;
                        frmTemplateSyncWizard.MyProject.AddTopLevelFolder(myTopFolder);
                    }
                    while (folderStack.Count > 0)
                    {
                        FolderContainer fc          = folderStack.Pop();
                        OutputFolder    theirFolder = fc.TheirFolder;
                        OutputFolder    newFolder   = new OutputFolder(theirFolder.Name, theirFolder.Id);
                        newFolder.IteratorType = theirFolder.IteratorType;
                        myTopFolder.Folders.Add(newFolder);
                    }
                    Populate();
                }
                else                         // FileContainer
                {
                    OutputFile   theirFile      = ((FileContainer)node.Tag).TheirFile;
                    OutputFolder folder         = null;
                    bool         isTopLevelNode = node.ParentNode.ParentNode == null;

                    if (!isTopLevelNode)
                    {
                        folder = ((FolderContainer)node.ParentNode.Tag).MyFolder;
                    }
                    OutputFile newFile = new OutputFile(theirFile.Name, theirFile.FileType, theirFile.ScriptName, theirFile.Id);
                    newFile.StaticFileIterator = theirFile.StaticFileIterator;
                    newFile.StaticFileName     = theirFile.StaticFileName;

                    // Copy new function as well, if it doesn't already exist
                    if (!string.IsNullOrEmpty(theirFile.ScriptName))
                    {
                        FunctionInfo myFunction = frmTemplateSyncWizard.MyProject.FindFunctionSingle(theirFile.ScriptName);

                        if (myFunction == null)
                        {
                            FunctionInfo theirFunction = frmTemplateSyncWizard.TheirProject.FindFunctionSingle(theirFile.ScriptName);
                            frmTemplateSyncWizard.MyProject.AddFunction(theirFunction);
                            newFile.IteratorFunction = frmTemplateSyncWizard.MyProject.FindFunctionSingle(theirFile.ScriptName);
                        }
                    }
                    if (!isTopLevelNode)
                    {
                        folder.Files.Add(newFile);
                    }
                    else
                    {
                        frmTemplateSyncWizard.MyProject.AddTopLevelFile(newFile);
                    }
                    Populate();
                }
                break;

            case "Apply Change >":
                string propertyName2 = node.GetValue(0).ToString();

                if (node.ParentNode.Tag.GetType() == typeof(FolderContainer))
                {
                    FolderContainer fc2 = (FolderContainer)node.ParentNode.Tag;

                    switch (propertyName2)
                    {
                    case "Iterator Type":
                        fc2.MyFolder.IteratorType = fc2.TheirFolder.IteratorType;
                        break;

                    default:
                        throw new NotImplementedException("Not coded yet: " + propertyName2);
                    }
                }
                else if (node.ParentNode.Tag.GetType() == typeof(FileContainer))
                {
                    FileContainer fileContainer = (FileContainer)node.ParentNode.Tag;

                    switch (propertyName2)
                    {
                    case "File Type":
                        fileContainer.MyFile.FileType = fileContainer.TheirFile.FileType;
                        break;

                    case "Script Name":
                        fileContainer.MyFile.ScriptName = fileContainer.TheirFile.ScriptName;
                        break;

                    case "Static File Iterator":
                        fileContainer.MyFile.StaticFileIterator = fileContainer.TheirFile.StaticFileIterator;
                        break;

                    case "Static File Name":
                        fileContainer.MyFile.StaticFileName = fileContainer.TheirFile.StaticFileName;
                        break;

                    default:
                        throw new NotImplementedException("Not coded yet: " + propertyName2);
                    }
                }
                else
                {
                    throw new NotImplementedException("Not coded yet:" + node.ParentNode.Tag.GetType().FullName);
                }
                break;

            case "Remove":
                // Parent is a FileContainer
                string parentText2 = node.ParentNode.GetValue(0).ToString();


                if (node.Tag.GetType() == typeof(FolderContainer))
                {
                    ((FolderContainer)node.ParentNode.Tag).MyFolder.RemoveFolder(((FolderContainer)node.Tag).MyFolder);
                }
                else if (node.Tag.GetType() == typeof(FileContainer))
                {
                    ((FolderContainer)node.ParentNode.Tag).MyFolder.RemoveFile(((FileContainer)node.Tag).MyFile);
                }
                else
                {
                    throw new NotImplementedException("Not coded yet: " + node.Tag.GetType().FullName);
                }

                Populate();
                break;

            default:
                throw new NotImplementedException("ActionType not handled yet: " + action);
            }
        }
Exemplo n.º 10
0
        private TreeListNode AddFolderNode(TreeListNode treenode, OutputFolder folderTheirs, OutputFolder folderMine)
        {
            TreeListNode folderNode = null;

            if (folderMine != null && folderTheirs != null && folderMine.Name == "root" && folderTheirs.Name == "root" && treenode.ParentNode == null)
            {
                folderNode = treenode;
            }
            bool differenceExists = false;

            if (folderTheirs != null && folderMine != null)
            {
                FolderContainer folderContainer = new FolderContainer(folderMine, folderTheirs, folderTheirs.Name);

                if (folderNode == null)
                {
                    folderNode = AddNodeBoth(Images.IMG_OPEN_FOLDER, "", folderTheirs.Name, folderMine.Name, treenode, folderContainer, false);
                }
                if (folderTheirs.IteratorType != folderMine.IteratorType)
                {
                    differenceExists = true;
                    AddNodeBoth(Images.IMG_DOT, "Iterator Type", folderTheirs.IteratorType, folderMine.IteratorType, folderNode, null, true);
                }
                if (folderTheirs.Name != folderMine.Name)
                {
                    differenceExists = true;
                    AddNodeBoth(Images.IMG_DOT, "Name", folderTheirs.Name, folderMine.Name, folderNode, null, true);
                }
                #region Output Names
                TreeListNode outputNamesNode = AddNodeBoth(Images.IMG_DOT, "Output Names", "", "", folderNode, null, false);

                if (outputNamesNode.Nodes.Count > 0)
                {
                    differenceExists = true;
                }
                else
                {
                    folderNode.Nodes.Remove(outputNamesNode);
                }
                #endregion
                // Process sub-folders and files
                foreach (OutputFolder subFolderMine in folderMine.Folders)
                {
                    bool found = false;

                    foreach (OutputFolder subFolderTheirs in folderTheirs.Folders)
                    {
                        if (!FoldersAreDifferent(subFolderMine, subFolderTheirs))
                        {
                            found = true;
                            AddFolderNode(folderNode, subFolderTheirs, subFolderMine);
                            break;
                        }
                    }
                    if (!found)
                    {
                        AddFolderNode(folderNode, null, subFolderMine);
                    }
                }
                foreach (OutputFolder subFolderTheirs in folderTheirs.Folders)
                {
                    bool found = false;

                    foreach (OutputFolder subFolderMine in folderMine.Folders)
                    {
                        if (!FoldersAreDifferent(subFolderMine, subFolderTheirs))
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        AddFolderNode(folderNode, subFolderTheirs, null);
                    }
                }
                foreach (OutputFile fileTheirs in folderTheirs.Files)
                {
                    bool found = false;

                    foreach (OutputFile fileMine in folderMine.Files)
                    {
                        if (!FilesAreDifferent(fileMine, fileTheirs))
                        {
                            found = true;
                            AddFileNode(folderNode, fileTheirs, fileMine);
                            break;
                        }
                    }
                    if (!found)
                    {
                        AddFileNode(folderNode, fileTheirs, null);
                    }
                }
                foreach (OutputFile fileMine in folderMine.Files)
                {
                    bool found = false;

                    foreach (OutputFile fileTheirs in folderTheirs.Files)
                    {
                        if (!FilesAreDifferent(fileMine, fileTheirs))
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        AddFileNode(folderNode, null, fileMine);
                    }
                }
                if (folderNode.Nodes.Count == 0 && !differenceExists)
                {
                    if (folderNode.ParentNode != null)
                    {
                        folderNode.ParentNode.Nodes.Remove(folderNode);
                    }
                }
                else if (!differenceExists)
                {
                    folderNode.SetValue(0, folderMine.Name);
                    folderNode.SetValue(1, "");
                    folderNode.SetValue(3, "");
                }
            }
            else if (folderTheirs != null)
            {
                FolderContainer folderContainer = new FolderContainer(null, folderTheirs, folderTheirs.Name);

                if (folderNode == null)
                {
                    folderNode = AddNodeTheirs(Images.IMG_CLOSED_FOLDER, "", folderTheirs.Name, "", treenode, folderContainer, true);
                }
            }
            else if (folderMine != null)
            {
                FolderContainer folderContainer = new FolderContainer(folderMine, null, folderMine.Name);

                if (folderNode == null)
                {
                    folderNode = AddNodeMine(Images.IMG_CLOSED_FOLDER, "", "", folderMine.Name, treenode, folderContainer, true);
                }
            }
            return(folderNode);
        }