public void AddEmptyMetadata()
        {
            Presentation presentation = m_UrakawaSession.DocumentProject.Presentations.Get(0);

            Metadata metadata = presentation.MetadataFactory.CreateMetadata();

            metadata.NameContentAttribute = new MetadataAttribute
            {
                Name         = SupportedMetadata_Z39862005.MagicStringEmpty, //"",
                NamespaceUri = "",
                Value        = SupportedMetadata_Z39862005.MagicStringEmpty
            };
            MetadataAddCommand cmd = presentation.CommandFactory.CreateMetadataAddCommand
                                         (metadata);

            presentation.UndoRedoManager.Execute(cmd);
        }
        public void ImportMetadata()
        {
            //m_ShellView.ExecuteShellProcess(MetadataPaneViewModel.METADATA_IMPORT_DIRECTORY);

            string text;
            List <Tuple <string, string> > metadatas = readMetadataImport(out text);

            var editBox = new TextBoxReadOnlyCaretVisible
            {
                Text          = text,
                AcceptsReturn = true,
                TextWrapping  = TextWrapping.WrapWithOverflow
            };

            var windowPopup = new PopupModalWindow(m_ShellView,
                                                   UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_MetadataPane_Lang.Import),
                                                   new ScrollViewer {
                Content = editBox
            },
                                                   PopupModalWindow.DialogButtonsSet.OkCancel,
                                                   PopupModalWindow.DialogButton.Ok,
                                                   true, 500, 600, null, 40, null);

            windowPopup.EnableEnterKeyDefault = false;

            editBox.Loaded += new RoutedEventHandler((sender, ev) =>
            {
                //editBox.SelectAll();
                FocusHelper.FocusBeginInvoke(editBox);
            });

            windowPopup.ShowModal();


            if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton))
            {
                if (!string.IsNullOrEmpty(editBox.Text))
                {
                    StreamWriter streamWriter = new StreamWriter(METADATA_IMPORT_FILE, false, Encoding.UTF8);
                    try
                    {
                        streamWriter.Write(editBox.Text);
                    }
                    finally
                    {
                        streamWriter.Close();
                    }

                    string newText;
                    metadatas = readMetadataImport(out newText);
                    //DebugFix.assert(newText.Equals(editBox.Text, StringComparison.Ordinal));

                    Presentation presentation = m_UrakawaSession.DocumentProject.Presentations.Get(0);

                    foreach (Tuple <string, string> md in metadatas)
                    {
                        List <NotifyingMetadataItem> toRemove = new List <NotifyingMetadataItem>();
                        foreach (NotifyingMetadataItem m in this.MetadataCollection.Metadatas)
                        {
                            if (m.Name.Equals(md.Item1, StringComparison.Ordinal))
                            {
                                if (!m.Definition.IsRepeatable)
                                {
                                    if (!toRemove.Contains(m))
                                    {
                                        toRemove.Add(m);
                                    }
                                }
                            }
                        }
                        foreach (var m in toRemove)
                        {
                            RemoveMetadata(m);
                        }

                        Metadata metadata = presentation.MetadataFactory.CreateMetadata();
                        metadata.NameContentAttribute = new MetadataAttribute
                        {
                            Name         = md.Item1,
                            NamespaceUri = "",
                            Value        = md.Item2
                        };
                        MetadataAddCommand cmd = presentation.CommandFactory.CreateMetadataAddCommand
                                                     (metadata);
                        presentation.UndoRedoManager.Execute(cmd);
                    }
                }
            }
        }