Ejemplo n.º 1
0
        public static bool CreateProject(ProjectArgs args, IBasicPanel <Project> control, ref string message)
        {
            string path = Path.Combine(control.FSWorker.WorkDirectory, args.Project);

            using (var transaction = new TransactionScope())
            {
                if (!TransactionDirectory.CreateDirectory(path, ref message))
                {
                    Transaction.Current.Rollback();
                    return(false);
                }
                if (!TransactionDirectory.CreateDirectory(Path.Combine(path, SubFolder), ref message))
                {
                    Transaction.Current.Rollback();
                    return(false);
                }
                transaction.Complete();
            }
            string name = new DirectoryInfo(path).Name;

            if (!Save(control.Save(args.Project, control.SaveItemManager.DoSave(args)), Path.Combine(path, name + ProjectExtension), ref message))
            {
                Directory.Delete(path, true);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
 public FileSystemQueue(IBasicPanel <T> control)
 {
     CallStack        = new List <FileSystemTask>();
     Control          = control as IBasicPanel <Project>;
     QueueThread      = new Thread(StartWork);
     QueueThread.Name = "Thread of FileSystemQueue";
     QueueThread.Start();
 }
Ejemplo n.º 3
0
        public static bool RenameFile(FileArgs args, IBasicPanel <Project> control, ref string message)
        {
            string path = Path.Combine(control.FSWorker.WorkDirectory, args.Project, BrowseSystem.SubFolder);

            TransactionFile.MoveFile(Path.Combine(path, args.RenamedArgs.From),
                                     Path.Combine(path, args.RenamedArgs.To), ref message);
            return(Save(control.Save(args.Project, control.SaveItemManager.DoSave(args)),
                        Path.Combine(control.FSWorker.WorkDirectory, args.Project, args.Project + ProjectExtension), ref message));
        }
Ejemplo n.º 4
0
        public static bool CreateFile(FileArgs args, IBasicPanel <Project> control, ref string message)
        {
            string path = Path.Combine(control.FSWorker.WorkDirectory, args.Project, BrowseSystem.SubFolder);

            foreach (string file in args.Files)
            {
                if (!TransactionFile.CreateFile(Path.Combine(path, file + Extension), ref message))
                {
                    return(false);
                }
            }
            return(Save(control.Save(args.Project, control.SaveItemManager.DoSave(args)),
                        Path.Combine(control.FSWorker.WorkDirectory, args.Project, args.Project + ProjectExtension), ref message));
        }
Ejemplo n.º 5
0
        public static bool RenameProject(ProjectArgs args, IBasicPanel <Project> control, ref string message)
        {
            string             path        = Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.From);
            ComplexTransaction transaction = new ComplexTransaction();

            transaction.AddOperation(() =>
                                     TransactionDirectory.CopyDirectory(path,
                                                                        Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To)), () =>
            {
                if (!TransactionDirectory.RemoveDirectory(
                        Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To)))
                {
                    Transaction.Current.Rollback();
                }
            });
            transaction.AddOperation(() =>
            {
                TransactionDirectory.RemoveDirectory(path);
            }, new List <string> {
                path
            });
            transaction.AddOperation(() =>
            {
                TransactionFile.DeleteFiles(
                    new FileArgs(
                        new List <string>
                {
                    Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To,
                                 args.RenamedArgs.From + ProjectExtension)
                }, args.RenamedArgs.From, Happened.Deleted,
                        (b, s, arg) => { }));
            }, new List <string>
            {
                Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To,
                             args.RenamedArgs.From + ProjectExtension)
            });
            transaction.DoOperation();
            return(Save(control.Save(args.RenamedArgs.To, control.SaveItemManager.DoSave(args)),
                        Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To,
                                     args.RenamedArgs.To + ProjectExtension), ref message));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// This method is used to initialize the UI panel
        /// </summary>
        /// <param name="panel">The panel interface reference</param>
        public void setPanel(IBasicPanel panel)
        {
            if (panel == null)
            {
                return;
            }

            panelInterface = panel;

            CreateModules(panel.GetModules);

            SetPosition(panel.Position);

            transform.localScale *= panel.Scale;

            Fade(1, true);

            SetAlpha(panel.Alpha);

            SetOldAlpha();
        }
Ejemplo n.º 7
0
 public FileSystemWorker(IBasicPanel <T> control)
 {
     MainControl = control;
     AttachToControl();
     Queue = new FileSystemQueue <T>(control);
 }
Ejemplo n.º 8
0
 public SaveItemManager(IBasicPanel <T> control)
 {
     Control = control;
 }
Ejemplo n.º 9
0
 public static bool RemoveFile(FileArgs args, IBasicPanel <Project> control, ref string message)
 {
     TransactionFile.DeleteFiles(args);
     return(Save(control.Save(args.Project, control.SaveItemManager.DoSave(args)),
                 Path.Combine(control.FSWorker.WorkDirectory, args.Project, args.Project + ProjectExtension), ref message));
 }