public void Execute()
        {
            BackgroundModel background = backgroundCollection.Get(args.Value);

            string parentProfileNames = GetParentProfileNames(background);

            if (parentProfileNames != null)
            {
                MessageBoxView.Show("Can't delete this background", $"This background is used by one or more profiles ({parentProfileNames}), you can't delete it.");
                return;
            }

            backgroundCollection.Remove(background);

            if (screenModel.Background == background)
            {
                // Default background can't be deleted so there's always at least 1 item in the list.
                screenModel.SetBackground(backgroundCollection.Items[0]);
            }

            database.DeleteBackground(background);

            string dirPath = locationModel.GetGraphicBasePath(background.DirectoryType);

            File.Delete(Path.Combine(dirPath, background.FileName));
        }
        public void Execute()
        {
            string fileName = Path.GetFileName(args.FilePath);

            if (File.Exists(Path.Combine(locationModel.LocalDirectoryBackgrounds, fileName)))
            {
                fileName = GetUnusedName(locationModel.LocalDirectoryBackgrounds, fileName);
            }

            string destinationFileName = $"{Path.GetFileNameWithoutExtension(fileName)}.jpg";
            string destinationPath     = Path.Combine(locationModel.LocalDirectoryBackgrounds, destinationFileName);

            BitmapImage originalBitmap = new BitmapImage(new Uri(args.FilePath));

            if (!args.CropArea.IsEmpty)
            {
                SaveJpeg(CropBitmap(originalBitmap, args.CropArea), destinationPath);
            }
            else
            {
                SaveJpeg(originalBitmap, destinationPath);
            }

            BackgroundModel background = BackgroundFactory.NewBackgroundModel(args.Name, destinationFileName, BaseDirectoryType.BACKGROUNDS_DIRECTORY, false, args.Layout);

            database.AddBackground(background);
            collection.Add(background);
            screenModel.SetBackground(background);

            Injector.ExecuteCommand <ValidatePlaceholderCollectionCommand>(new CollectionEventArgs <PlaceholderModel>(0, placeholderCollection, placeholderCollection.Items.ToArray()));
        }
Example #3
0
        public void Execute()
        {
            List <BackgroundModel> backgrounds = database.GetAllBackgrounds();

            if (backgrounds.Count == 0)
            {
                BackgroundModel defaultBackground = BackgroundFactory.NewBackgroundModel("Default", "background.png", BaseDirectoryType.GRAPHICAL_ASSETS, true, ScreenLayoutType.SINGLE);
                backgroundCollection.AddRange(new List <BackgroundModel>(new BackgroundModel[] { defaultBackground }));
                database.AddBackground(defaultBackground);
                screenModel.SetBackground(defaultBackground);
            }
            else
            {
                backgroundCollection.AddRange(backgrounds);
                screenModel.SetBackground(backgrounds[0]);
            }
        }
Example #4
0
        public void Execute()
        {
            ScreenLayoutType currentLayout = screenModel.Layout;
            BackgroundModel  background    = backgroundCollection.Get(args.ItemId);

            screenModel.SetBackground(background);

            bool layoutFixed = false;

            if (currentLayout == ScreenLayoutType.TRIPLE && background.Layout == ScreenLayoutType.SINGLE)
            {
                layoutFixed = ScreenUtils.PromptUserIfOutsideOfCenterScreenPlaceholders(placeholderCollection, preferences, database);
            }

            if (!layoutFixed)
            {
                Injector.ExecuteCommand <ValidatePlaceholderCollectionCommand>(new CollectionEventArgs <PlaceholderModel>(0, placeholderCollection, placeholderCollection.Items.ToArray()));
            }
        }
        public void Execute()
        {
            ProfileModel            profile      = profileCollection.Get(args.ItemId);
            List <PlaceholderModel> placeholders = layoutIO.LoadProfileLayout(profile);

            if (placeholders == null)
            {
                return;
            }
            // TODO gestion des erreurs, chargemetn de fichiers, bitmaps...
            BackgroundModel background = backgroundCollection.Get(profile.BackgroundId);

            selectionModel.Unselect();
            screen.SetBackground(background);
            placeholderCollection.Clear();
            placeholderCollection.AddRange(placeholders);
            assetFactory.SetMotec(motecCollection.Get(profile.MotecId));
            selectedProfile.SelectProfile(profile);
            layoutIO.DispatchSaveStatus();
        }