示例#1
0
        public MainVM(IProject project, LibManager libManager, SetupData setup)
        {
            this.project    = project;
            this.libManager = libManager;
            this.setup      = setup;

            projecTabVM    = new ProjectTabVM(project, libManager, setup);
            setupTabVM     = new SetupTabVM(project, setup);
            librariesTabVM = new LibrariesTabVM(project, libManager, setup);

            cmdFileOpen = new RelayCommand(doFileOpen);
            cmdFileNew  = new RelayCommand(doFileNew);
            cmdClose    = new RelayCommand(doClose);

            setupTabVM.PropertyChanged += (s, e) =>
            {
                projecTabVM.updateAll();
                projecTabVM.OnPropertyChanged("");
            };

            mruList = new ObservableCollection <MruItemVM>();
            foreach (var prj in setup.mru.projects)
            {
                mruList.Add(new MruItemVM(prj, this));
            }
            //var mruList = setup.mru.projects?.Select(p => new MruItemVM(p, this));
            //if(mruList != null)  mruList = new ObservableCollection<MruItemVM>(mruList);
        }
        public Image SmartScaleCrop(Image sourceImage, SmartScaleCropArguments args)
        {
            string fingerprint      = ImageOptimizationHelper.GetImageFingerprint(sourceImage);
            var    entry            = OptimizationManager.GetImageOptimizationLogEntrys().Where(e => e.Fingerprint == fingerprint).FirstOrDefault();
            int    focalPointX      = 0;
            int    focalPointY      = 0;
            int    focalPointWidth  = 0;
            int    focalPointHeight = 0;
            int    focalPointAnchor = 0;

            if (entry != null)
            {
                var sfImage = LibManager.GetImage(entry.ImageId);
                focalPointX      = sfImage.GetValue <int>("FocalPointX");
                focalPointY      = sfImage.GetValue <int>("FocalPointY");
                focalPointWidth  = sfImage.GetValue <int>("FocalPointWidth");
                focalPointHeight = sfImage.GetValue <int>("FocalPointHeight");
                focalPointAnchor = sfImage.GetValue <int>("FocalPointAnchor");

                if (focalPointX != 0 && focalPointY != 0)
                {
                    return(Process(sourceImage, focalPointX, focalPointY, focalPointWidth, focalPointHeight, focalPointAnchor, args));
                }
            }

            return(base.Crop(sourceImage, args));
        }
        /// <summary>
        /// Returns the total number of unoptimized images in the Sitefinity album with the specified Id
        /// </summary>
        /// <param name="albumId">Id of the album</param>
        /// <returns></returns>
        public virtual int GetItemsCount(Guid albumId)
        {
            var optimizedImageIds = new HashSet <Guid>(OptimizationManager.GetImageOptimizationLogEntrys().Where(e => e.OptimizedFileId != Guid.Empty).Select(e => e.ImageId));
            var images            = LibManager.GetAlbum(albumId).Images()
                                    .Where(i => i.Status == ContentLifecycleStatus.Master && !optimizedImageIds.Contains(i.Id));

            return(images.Count());
        }
示例#4
0
        public SaveWinVM(IProject project, LibManager libManager, SetupData setup)
        {
            cmdSave = new AsyncCommand(doSave);

            var taskList = CodeGenerator.getTasks(project, libManager, setup).Select(t => new TaskVM(t)).ToList();

            taskVMs      = new ListCollectionView(taskList);
            this.project = project;
        }
示例#5
0
 public static string generate(IProject project, LibManager libManager, SetupData setup)
 {
     if (project.buildSystem == BuildSystem.makefile)
     {
         return(Makefile_Make.generate(project, libManager, setup));
     }
     else
     {
         return(Makefile_Builder.generate(project, libManager, setup));
     }
 }
        /// <summary>
        /// Optimize all images in the Sitefinity album with the specified Id
        /// </summary>
        /// <param name="albumId">Id of the album to be optimized</param>
        public virtual void OptimizeAlbum(Guid albumId)
        {
            // Get all the unoptimized image items
            var optimizedImageIds = new HashSet <Guid>(OptimizationManager.GetImageOptimizationLogEntrys().Where(e => e.OptimizedFileId != Guid.Empty).Select(e => e.ImageId));
            var images            = LibManager.GetAlbum(albumId).Images()
                                    .Where(i => i.Status == ContentLifecycleStatus.Master && !optimizedImageIds.Contains(i.Id));

            foreach (Image image in images)
            {
                this.OptimizeImage(albumId, image.Id);
            }
        }
示例#7
0
        public Model(ProjectData project, SetupData setup)
        {
            this.project = project;
            this.setup   = setup;

            boards = new List <Board>();

            loadSettings();
            libManager = new LibManager(this.project, this.setup);
            if (!openProjectPath())
            {
                parseBoardsTxt();
                selectedBoard = boards?.FirstOrDefault();
                generateFiles();
            }
        }
示例#8
0
        public void Init()
        {
            LogClient.LogMessage("Loading PatchMod");
            if (!System.IO.Directory.Exists(PathHelpers.PatchModDepDirectory))
            {
                LogClient.LogMessage($"ERROR: Missing lib directory at {PathHelpers.PatchModDepDirectory}");
            }

            LibManager.LoadDeps();
            PathHelpers.CheckDirectories();
            LibManager.LoadPlugins();
            LogClient.LogMessage("PatchMod Loaded");
            Patcher.Patch();

            if (Patcher.PatchMessageSent)
            {
                LogClient.LogMessage($"Patches Complete");
            }

            if ((bool)PatchMod.Config["SyncEnabled", typeof(bool)])
            {
                SyncSource S = SyncProviderManager.GetSource((string)PatchMod.Config["SyncMode"]);
                if (S == null)
                {
                    LogClient.LogMessage($"Invalid Sync Source '{(string)PatchMod.Config["SyncMode"]}'");
                }
                else
                {
                    S.Source = (string)PatchMod.Config["SyncPath"];
                    S.Init();
                    LogClient.LogMessage($"Starting Sync...");
                    FileSync.SyncFrom(S);
                    if (S.FilesChanged)
                    {
                        LogClient.LogMessage($"Files synced from server. Acquired {S.NewFiles} new file/s from server.");
                    }
                    else
                    {
                        LogClient.LogMessage($"Files are up to date.");
                    }
                    S.Shutdown();
                }
            }
        }
示例#9
0
        public static string generate(IProject project, LibManager libManager, SetupData setup)
        {
            switch (project.target)
            {
            case Target.vsCode:
                return(TaskFile_vsCode.generate(project, setup));

            case Target.atom:
                return(TaskFile_ATOM.generate(project, setup));

            case Target.sublimeText:
                return("TBD");

            case Target.vsFolder:
                return("TBD");

            default:
                return("Error");
            }
        }
示例#10
0
        public MainVM(IProject project, LibManager libManager, SetupData setup)
        {
            this.project    = project;
            this.libManager = libManager;
            this.setup      = setup;

            projecTabVM    = new ProjectTabVM(project, libManager, setup);
            setupTabVM     = new SetupTabVM(project, setup);
            librariesTabVM = new LibrariesTabVM(project, libManager);

            cmdFileOpen = new RelayCommand(doFileOpen);
            cmdFileNew  = new RelayCommand(doFileNew);
            cmdClose    = new RelayCommand(doClose);

            setupTabVM.PropertyChanged += (s, e) =>
            {
                projecTabVM.updateFiles();
                projecTabVM.OnPropertyChanged("");
            };
        }
        /// <summary>
        /// Optimize a single Sitefinity image
        /// </summary>
        /// <param name="parentId">Id of the album that contains the image</param>
        /// <param name="imageId">Id of the master version of the image</param>
        public virtual void OptimizeImage(Guid albumId, Guid masterImageId)
        {
            Album album = LibManager.GetAlbum(albumId);

            // This saves us from having to care about BlobStorage later in the method
            var albumProvider = (LibrariesDataProvider)album.Provider;

            // This should exist!
            var image = album.Images().Where(i => i.Id == masterImageId && i.Status == ContentLifecycleStatus.Master).Single();

            // Pull the Stream of the image from the provider.
            Stream imageData = albumProvider.Download(image);

            using (MemoryStream ms = new MemoryStream())
            {
                // Can't trust the length of Stream. Copying to a MemoryStream
                imageData.CopyTo(ms);
                // Be kind...rewind
                ms.Seek(0, SeekOrigin.Begin);

                // Optimization methods may return the image in a different format than what was provided.
                // If that happens, we need to know about it.
                string optimizedExtension;
                Stream optimizedImage = this.CompressImageData(image, ms, out optimizedExtension);

                // There are different reasons why the optimizer would return null.
                // 1. An error occured (in which case the optimizer should throw or handle the exception)
                // 2. Some other mechanism is being used to handle the item updates (callbacks)
                if (optimizedImage != null)
                {
                    var oLogEntry = OptimizationManager.GetImageOptimizationLogEntrys().Where(e => e.ImageId == image.Id).FirstOrDefault();// .CreateImageOptimizationLogEntry();

                    //oLogEntry.ImageId = image.Id;
                    //oLogEntry.InitialFileExtension = image.Extension;
                    //oLogEntry.InitialTotalSize = image.TotalSize;

                    // Check out the master to get a temp version.
                    Image temp = LibManager.Lifecycle.CheckOut(image) as Image;

                    // Make the modifications to the temp version.
                    LibManager.Upload(temp, optimizedImage, optimizedExtension);

                    // Check in the temp version.
                    // After the check in the temp version is deleted.
                    LibManager.Lifecycle.CheckIn(temp);

                    oLogEntry.OptimizedFileId = image.FileId;

                    OptimizationManager.SaveChanges();

                    LibManager.SaveChanges();

                    // Check to see if this image is already published.
                    // If it is, we need to publish the "Master" to update "Live"
                    if (image.GetWorkflowState() == "Published")
                    {
                        var bag = new Dictionary <string, string>();
                        bag.Add("ContentType", typeof(Image).FullName);
                        WorkflowManager.MessageWorkflow(image.Id, typeof(Image), albumProvider.Name, "Publish", false, bag);
                    }
                }

                // Let concerned parties know that processing has completed for this item
                ImageOptimizedHandler tmp = OnImageOptimized;
                if (tmp != null)
                {
                    OnImageOptimized(this, EventArgs.Empty);
                }
            }
        }