Ejemplo n.º 1
0
        private BitmapImage SetUpImage(string fileName, out string imagePath)
        {
            imagePath = EmoteItem.CopyImage(fileName);

            BitmapImage bitmapImage = CreateImage(imagePath);

            return(bitmapImage);
        }
Ejemplo n.º 2
0
        private void AcceptImage()
        {
            AddToCollections(_browsedItem);

            _vm.DialogViewModel.IsAddDialogOpen = false;
            _vm.DialogViewModel.WatermarkName   = DialogViewModel.DefaultWatermark;
            _vm.NewEmote   = new EmoteItem();
            _vm.ErrorLabel = ItemError.None;
            _browsedItem   = null;
        }
Ejemplo n.º 3
0
        public void AddToCollections(EmoteItem item)
        {
            _vm.Emotes.Add(item);
            if (!string.IsNullOrWhiteSpace(item?.ImagePath))
            {
                Settings.SavedEmotes.Add((item.Id, item.Name, item.ImagePath, item.ActualImagePath, item.SizeMode));
                return;
            }

            if (!string.IsNullOrWhiteSpace(_browsedItem?.ImagePath))
            {
                Settings.SavedEmotes.Add(
                    (_browsedItem.Id, _browsedItem.Name, _browsedItem.ImagePath, _browsedItem.ActualImagePath, _browsedItem.SizeMode));
            }

            throw new NullReferenceException("Image path is empty.");
        }
Ejemplo n.º 4
0
        public void SelectImage(string parameter = "")
        {
            CheckError();
            if (_vm.ErrorLabel != ItemError.None)
            {
                return;
            }

            if (HandleAcceptParameter(parameter))
            {
                return;
            }

            if (_vm.ErrorLabel != ItemError.None)
            {
                return;
            }

            if (!ChooseFile(out string filePath))
            {
                return;
            }

            int         id          = _vm.Emotes.Count;
            BitmapImage bitmapImage = SetUpImage(filePath, out string tempActualPath);
            string      name        = _vm.NewEmote.Name;

            if (name != SortName())
            {
                _vm.DialogViewModel.WatermarkName = SortName();
                name = _vm.DialogViewModel.WatermarkName;
            }

            bitmapImage = null;
            EmoteItem.RenameImage(name, tempActualPath);
            bitmapImage = CreateImage(filePath);
            var item = new EmoteItem(id, name, filePath, bitmapImage);

            if (HandleBrowserParameter(parameter, item))
            {
                return;
            }

            AddToCollections(item);
        }
Ejemplo n.º 5
0
        private bool HandleBrowserParameter(string parameter, EmoteItem item)
        {
            if (parameter != "Browse")
            {
                return(false);
            }

            _browsedItem = item;
            if (_vm.NewEmote == null)
            {
                _vm.NewEmote = item;
            }
            else
            {
                _vm.NewEmote.ImagePath = item.ImagePath;
            }
            return(true);
        }