Exemplo n.º 1
0
        private void PreviewAdd(MediaItemViewModel item, string path)
        {
            if (_removed.Contains(item))
            {
                _removed.Remove(item);
            }
            else
            {
                FileStream fileStream;

                try
                {
                    fileStream = File.OpenRead(path);
                }
                catch (Exception exc)
                {
                    OnError(exc);
                    return;
                }

                _added.Add(item);
                _streams[item] = Tuple.Create(path, fileStream);
            }

            Files.Add(item);
            OnPropertyChanged(nameof(Files));

            HasPendingChanges = IsChanged();
        }
Exemplo n.º 2
0
        private MediaItemViewModel CreateItem(string item)
        {
            var named = new MediaItemViewModel(new Named(item), _name, () => Wrap(item));

            named.Model.PropertyChanged += Named_PropertyChanged;

            return(named);
        }
Exemplo n.º 3
0
        private void PreviewRemove(MediaItemViewModel name)
        {
            if (_added.Contains(name))
            {
                _added.Remove(name);
                _streams[name].Item2.Dispose();
                _streams.Remove(name);
            }
            else
            {
                _removed.Add(name);
            }

            Files.Remove(name);
            OnPropertyChanged(nameof(Files));
        }
Exemplo n.º 4
0
        private void SelectAtomObject_Do(string mediaType, MediaItemViewModel file, bool asAnswer)
        {
            var index = CurrentPosition;

            if (index == -1)
            {
                index = Count - 1;
            }

            OwnerDocument.BeginChange();

            try
            {
                if (asAnswer)
                {
                    if (!_isComplex)
                    {
                        AddMarker_Executed(null);
                        index = Count - 1;
                    }
                }
                else if (string.IsNullOrWhiteSpace(this[index].Model.Text))
                {
                    RemoveAt(index--);
                }

                var atom = new AtomViewModel(new Atom {
                    Type = mediaType, Text = ""
                });
                Insert(index + 1, atom);

                OwnerDocument.Document.SetLink(atom.Model, file.Model.Name);
                OwnerDocument.ActiveItem = null;
            }
            catch (Exception exc)
            {
                OwnerDocument.OnError(exc);
            }
            finally
            {
                OwnerDocument.CommitChange();
            }
        }