Exemple #1
0
        private void LinkAtomObject(string mediaType, bool asAnswer)
        {
            var index = CurrentPosition;

            if (index == -1 || index >= Count)
            {
                if (Count == 0)
                {
                    return;
                }

                index = Count - 1;
            }

            var uri = PlatformManager.Instance.AskText("Введите адрес мультимедиа-объекта");

            if (string.IsNullOrWhiteSpace(uri))
            {
                return;
            }

            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 = uri
                });
                QDocument.ActivatedObject = atom;
                Insert(index + 1, atom);
                OwnerDocument.ActiveItem = null;

                OwnerDocument.CommitChange();
            }
            catch (Exception exc)
            {
                OwnerDocument.RollbackChange();
                OwnerDocument.OnError(exc);
            }
        }
Exemple #2
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();
            }
        }