Exemple #1
0
 internal DocumentScope(IDocumentItem document, bool isFormattingScope)
 {
     Document          = document;
     IsFormattingScope = isFormattingScope;
     HasAlias          = false;
     AliasName         = null;
 }
 /// <summary>
 ///		Loops through all the document items children
 /// </summary>
 /// <param name="documentItem"></param>
 public void VisitChildren(IDocumentItem documentItem)
 {
     foreach (var documentItemChild in documentItem.Children)
     {
         documentItemChild.Accept(this);
     }
 }
Exemple #3
0
        public void RefreshChildren(IDocumentItem item, bool selectNewlyCreatedItems)
        {
            if (item == null)
            {
                return;
            }
            if (item == this)
            {
                (
                    from i in base.Items
                    where i.Parent == null
                    select i).ToList <IProjectItem>().ForEach(new Action <IProjectItem>(this.ProcessItem));
                this.RefreshDirectory(base.ProjectRoot.Path, selectNewlyCreatedItems);
                return;
            }
            IProjectItem projectItem = item as IProjectItem;

            if (projectItem == null || projectItem.Project != this)
            {
                return;
            }
            this.ProcessItem(projectItem);
            if (projectItem.CanAddChildren)
            {
                this.RefreshDirectory(projectItem.DocumentReference.Path, selectNewlyCreatedItems);
            }
        }
Exemple #4
0
        protected override void InternalExectute()
        {
            List <IDocumentItem> documentItems;
            IDocumentItem        documentItem = this.Selection().SingleOrNull <IDocumentItem>();

            if (documentItem != null)
            {
                documentItems = (!this.recursive ? new List <IDocumentItem>()
                {
                    documentItem
                } : (
                                     from item in base.GetFileItemAndDescendants(documentItem)
                                     where SourceControlStatusCache.GetCachedStatus(item) == SourceControlStatus.CheckedIn
                                     select item).ToList <IDocumentItem>());
                string[] array = (
                    from item in documentItems
                    select item.DocumentReference.Path).ToArray <string>();
                if (base.SourceControlProvider.Checkout(array) == SourceControlSuccess.Success)
                {
                    SourceControlStatusCache.SetCachedStatus(documentItems, SourceControlStatus.CheckedOut);
                    return;
                }
                SourceControlStatusCache.UpdateStatus(documentItems, base.SourceControlProvider);
            }
        }
Exemple #5
0
 public DocumentScope(IDocumentItem document, string aliasName)
 {
     Document          = document;
     IsFormattingScope = false;
     HasAlias          = true;
     AliasName         = aliasName;
 }
Exemple #6
0
 public DocumentScope(IDocumentItem document)
 {
     Document          = document;
     IsFormattingScope = false;
     HasAlias          = false;
     AliasName         = null;
 }
        /// <summary>
        ///		Creates nods that relates to children and render order
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="document"></param>
        /// <returns></returns>
        public static MorestachioNode CreateNodes(MorestachioNode parent, IDocumentItem document, out List <MorestachioNode> nodes)
        {
            nodes = new List <MorestachioNode>();
            var stack = new Stack <Tuple <IDocumentItem, IDocumentItem> >();

            stack.Push(new Tuple <IDocumentItem, IDocumentItem>(parent?.Item, document));
            var rootNode = new MorestachioNode(parent, document);

            nodes.Add(rootNode);
            while (stack.Any())
            {
                var item       = stack.Pop();
                var parentNode = nodes.Find(f => f.Item == item.Item2) ?? rootNode;
                foreach (var documentItem in item.Item2.Children)
                {
                    stack.Push(new Tuple <IDocumentItem, IDocumentItem>(item.Item2, documentItem));
                    var morestachioNode = new MorestachioNode(parentNode, documentItem);

                    nodes.Add(morestachioNode);
                    parentNode.Leafs.Add(morestachioNode);
                }
            }

            var prevNode = rootNode;

            foreach (var morestachioNode in nodes.Skip(1))
            {
                prevNode.Next            = morestachioNode;
                morestachioNode.Previous = prevNode;
                prevNode = morestachioNode;
            }

            return(rootNode);
        }
Exemple #8
0
 protected void Dispatch(IDocumentItem documentItem, PdfDocumentWriter writer, Context context)
 {
     if (!documentItem.Hidden)
     {
         this.GetType().GetMethod("Handle" + documentItem.GetType().Name, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(this, new object[] { documentItem, writer, context });
     }
 }
 /// <summary>
 ///   Attempts to cast the <see cref="IDocumentItem.Tag"/> to type <typeparamref name="T"/>, throwing an exception
 ///   if <see cref="IDocumentItem.Tag"/> is null or the tag is not compatible with T.
 /// </summary>
 public static T GetView <T>(this IDocumentItem documentItem)
     where T : class, IDocumentItemView
 {
     return(documentItem.GetViewOrNull <T>()
            ?? throw new InvalidOperationException(
                $"block {documentItem} does not have a view of type {typeof(T)} attached to it" +
                (documentItem.Tag == null ? " (it has no attached view)" : "")));
 }
Exemple #10
0
 public string SerializeToText(IDocumentItem obj)
 {
     using (var ms = new MemoryStream())
     {
         BinarySerializer.WriteObject(ms, obj);
         return(Encoding.UTF8.GetString(ms.ToArray()));
     }
 }
Exemple #11
0
        public static void AssertDocumentItemIsSameAsTemplate(ITemplateContainer textContainer,
                                                              IDocumentItem documentItem,
                                                              ParserOptions options)
        {
            var text = ((textContainer as StringTemplateContainer).Template as StringTemplateResource).ToString();

            AssertDocumentItemIsSameAsTemplate(text, documentItem, options);
        }
 public IDocument CreateDocument(IDocumentItem item)
 {
     if (item is IDiagram)
         return new DiagramDocument((IDiagram)item, DockForm);            
     else if (item is TemplateFile)
         return new TemplateDocument((TemplateFile)item, DockForm);
     throw new NotSupportedException(item.GetType().Name);
 }
Exemple #13
0
 public override void SetProperty(string propertyName, object propertyValue)
 {
     if (propertyName == "TargetDocument")
     {
         this.targetItem = propertyValue as IDocumentItem;
         return;
     }
     base.SetProperty(propertyName, propertyValue);
 }
        public static void SetSelection(this IServiceProvider source, IDocumentItem item)
        {
            ItemSelectionSet itemSelectionSets = source.SelectionSet();

            if (itemSelectionSets != null)
            {
                itemSelectionSets.SetSelection(item);
            }
        }
Exemple #15
0
 internal HierarchicalNode(IDocumentItem documentItem, Microsoft.Expression.Project.UserInterface.ProjectPane projectPane)
 {
     this.ProjectPane     = projectPane;
     this.documentItem    = documentItem;
     this.serviceProvider = projectPane.Services;
     if (documentItem != null)
     {
         base.IsSelected = this.Services.ProjectManager().ItemSelectionSet.IsSelected(this.documentItem);
     }
 }
        private bool IsValidStatusForHistory(IDocumentItem documentItem)
        {
            SourceControlStatus cachedStatus = SourceControlStatusCache.GetCachedStatus(documentItem);

            if (cachedStatus == SourceControlStatus.None)
            {
                return(false);
            }
            return(cachedStatus != SourceControlStatus.Add);
        }
Exemple #17
0
        public string SerializeToText(IDocumentItem obj)
        {
            var BinarySerializer = new DataContractSerializer(obj.GetType());

            using (var ms = new MemoryStream())
            {
                BinarySerializer.WriteObject(ms, obj);
                return(Encoding.UTF8.GetString(ms.ToArray()));
            }
        }
Exemple #18
0
        protected bool FileHasPendingChange(IDocumentItem item)
        {
            SourceControlStatus cachedStatus = SourceControlStatusCache.GetCachedStatus(item);

            if (cachedStatus == SourceControlStatus.CheckedIn)
            {
                return(false);
            }
            return(cachedStatus != SourceControlStatus.None);
        }
Exemple #19
0
 /// <summary>
 ///		Checks for embedded LineBreak operations
 /// </summary>
 /// <param name="documentItem"></param>
 public void CheckForInlineTagLineBreakAtEnd(IDocumentItem documentItem)
 {
     if (documentItem.TagCreationOptions?.FirstOrDefault(e => e.Name == "Embedded.TrimTailing")?.Value is bool valSingle && valSingle)
     {
         StringBuilder.Append(" |-");
     }
     if (documentItem.TagCreationOptions?.FirstOrDefault(e => e.Name == "Embedded.TrimAllTailing")?.Value is bool valAll && valAll)
     {
         StringBuilder.Append(" |--");
     }
 }
 private void InternalExecute(IDocumentItem item)
 {
     try
     {
         this.EditItemExternally(item);
     }
     catch (Win32Exception win32Exception)
     {
         this.DisplayCommandFailedExceptionMessage(win32Exception);
     }
 }
        protected override void InternalExectute()
        {
            IDocumentItem documentItem = this.Selection().SingleOrNull <IDocumentItem>();

            if (documentItem != null)
            {
                ISourceControlProvider sourceControlProvider = base.SourceControlProvider;
                string[] path = new string[] { documentItem.DocumentReference.Path };
                sourceControlProvider.History(path);
            }
        }
Exemple #22
0
 public override void Execute()
 {
     this.HandleBasicExceptions(() => {
         IWebsiteProject websiteProject = this.SelectedProjectOrNull() as IWebsiteProject;
         if (websiteProject != null)
         {
             IDocumentItem documentItem = this.Selection().First <IDocumentItem>();
             websiteProject.RefreshChildren(documentItem, true);
             SourceControlStatusCache.UpdateStatus(documentItem.Descendants.AppendItem <IDocumentItem>(documentItem), base.Services.SourceControlProvider());
         }
     });
 }
Exemple #23
0
        public string SerializeToText(IDocumentItem obj)
        {
            var devidedTypes = typeof(MorestachioDocument).Assembly.GetTypes().Where(e => e.IsClass)
                               .Where(e => typeof(IDocumentItem).IsAssignableFrom(e)).ToArray();
            var XmlSerializer = new XmlSerializer(obj.GetType(), devidedTypes);

            using (var ms = new MemoryStream())
            {
                XmlSerializer.Serialize(ms, obj);
                return(Encoding.UTF8.GetString(ms.ToArray()));
            }
        }
        protected override bool ShouldAddItem(IDocumentItem item)
        {
            bool  flag = false;
            IView view = base.Services.ActiveView();

            if (view != null)
            {
                IProjectItem projectItem = item as IProjectItem;
                flag = (projectItem == null ? false : projectItem.DocumentType.CanInsertTo(projectItem, view));
            }
            return(flag);
        }
Exemple #25
0
        /// <summary>
        ///		Loops through all the document items children
        /// </summary>
        /// <param name="documentItem"></param>
        public void VisitChildren(IDocumentItem documentItem)
        {
            if (!(documentItem is IBlockDocumentItem blockItem))
            {
                return;
            }

            foreach (var documentItemChild in blockItem.Children)
            {
                documentItemChild.Accept(this);
            }
        }
Exemple #26
0
 public override void Execute()
 {
     if (this.targetItem != null)
     {
         this.Execute(this.targetItem);
         this.targetItem = null;
         return;
     }
     foreach (IDocumentItem item in this.GetItems())
     {
         this.Execute(item);
     }
 }
        protected override bool ShouldAddItem(IDocumentItem item)
        {
            IProjectItem projectItem = item as IProjectItem;

            if (!PathHelper.FileExists(item.DocumentReference.Path))
            {
                return(false);
            }
            if (projectItem == null)
            {
                return(true);
            }
            return(projectItem.DocumentType.PreferredExternalEditCommand != PreferredExternalEditCommand.None);
        }
Exemple #28
0
        protected override void InternalExectute()
        {
            Dictionary <string, string> strs;
            IDocumentItem documentItem = this.Selection().SingleOrNull <IDocumentItem>();

            if (documentItem != null)
            {
                if (!this.SaveSolution(true))
                {
                    return;
                }
                using (IDisposable disposable = this.SuspendWatchers())
                {
                    List <IDocumentItem> list  = base.GetFileItemAndDescendants(documentItem).Where <IDocumentItem>(new Func <IDocumentItem, bool>(this.FileHasPendingChange)).ToList <IDocumentItem>();
                    string[]             array = (
                        from item in list
                        select item.DocumentReference.Path).ToArray <string>();
                    base.SourceControlProvider.RevertChange(array, out strs);
                    foreach (string key in strs.Keys)
                    {
                        DocumentReference documentReference = DocumentReference.Create(key);
                        if (!documentReference.IsValidPathFormat)
                        {
                            continue;
                        }
                        string directoryNameOrRoot = Microsoft.Expression.Framework.Documents.PathHelper.GetDirectoryNameOrRoot(documentReference);
                        if (directoryNameOrRoot == null || !Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(directoryNameOrRoot))
                        {
                            continue;
                        }
                        try
                        {
                            if (!Directory.EnumerateFiles(directoryNameOrRoot, "*.*", SearchOption.AllDirectories).Any <string>())
                            {
                                Directory.Delete(directoryNameOrRoot);
                            }
                        }
                        catch (IOException oException)
                        {
                        }
                        catch (SecurityException securityException)
                        {
                        }
                    }
                }
                SourceControlStatusCache.UpdateStatus(this.Solution().Descendants.AppendItem <IDocumentItem>(this.Solution()), base.SourceControlProvider);
            }
        }
Exemple #29
0
        protected IEnumerable <IDocumentItem> GetFileItemAndDescendants(IDocumentItem item)
        {
            IEnumerable <IDocumentItem> documentItems = item.Descendants.Where <IDocumentItem>((IDocumentItem descendant) => {
                if (descendant.IsDirectory || descendant.IsReference || descendant.IsVirtual)
                {
                    return(false);
                }
                return(Microsoft.Expression.Framework.Documents.PathHelper.IsValidPath(descendant.DocumentReference.Path));
            });

            if (!item.IsDirectory && !item.IsReference && !item.IsVirtual && Microsoft.Expression.Framework.Documents.PathHelper.IsValidPath(item.DocumentReference.Path))
            {
                documentItems = documentItems.AppendItem <IDocumentItem>(item);
            }
            return(documentItems);
        }
Exemple #30
0
        private void SerilalizeAndDeserialize(IDocumentItem document)
        {
            var text             = DocumentSerializerStrategy.SerializeToText(document);
            var deserialized     = DocumentSerializerStrategy.DeSerializeToText(text, document.GetType());
            var deserializedText = DocumentSerializerStrategy.SerializeToText(deserialized);

            Assert.That(document, Is.EqualTo(deserialized), () =>
            {
                return($"Object left is: " +
                       $"\"{text}\" " +
                       $"and right ist " +
                       $"\"{deserializedText}\"" +
                       $"");
            });

            Assert.That(deserializedText, Is.EqualTo(text));
        }
Exemple #31
0
        protected bool IsDirectoryBasedProjectOrFolder(IDocumentItem target)
        {
            IProject project = target as IProject;

            if (project == null)
            {
                IProjectItem projectItem = target as IProjectItem;
                if (projectItem != null && projectItem.IsDirectory)
                {
                    project = projectItem.Project;
                }
            }
            if (project == null)
            {
                return(false);
            }
            return(project.IsDirectory);
        }
 public void OpenDocument(IDocumentItem item)
 {
     if (item is TypeBase)
     {
         using (TypeBaseDialog dialog = new TypeBaseDialog())
         {
             dialog.ShowDialog((TypeBase)item);
         }
     }
     else
     {
         IDocument doc = Documents.FirstOrDefault(p => p.DocumentItem == item);
         if (doc != null)
             Show(doc);
         else
             Open(CreateDocument(item));
     }
 }
Exemple #33
0
 public void AddChild(IDocumentItem child)
 {
     child.Parent?.RemoveChild(child);
     child.Parent = this;
     Items.Add(child);
 }
Exemple #34
0
 public void RemoveChild(IDocumentItem child)
 {
     child.Parent = null;
     Items.Remove(child);
 }
 private void OnDeleteDocumentItem(IDocumentItem item)
 {
     if (!ShowDeleteDialog(item)) return;
     if (item.Parent != null)
     {
         item.Parent.RemoveChild(item);
     }
     else
     {
         TreeViewModel.Categories.Remove((Category) item);
     }
 }
Exemple #36
0
 private static string GetChildItemXmlName(IDocumentItem childItem)
 {
     if (childItem is Category) return CategoryElementName;
     return LinkElementName;
 }
        private void OnEditDocumentItem(IDocumentItem item)
        {
            var link = item as Link;
            if (link != null)
            {
                _container.Resolve<IDialogManager<Link>>().ShowEditDialog(link);
                return;
            }

            var category = (Category) item;
            _container.Resolve<IDialogManager<Category>>().ShowEditDialog(category);
        }
Exemple #38
0
 public void OpenDocument(IDocumentItem item)
 {
     docManager.OpenDocument(item);
 }
Exemple #39
0
 public static void SetDocument(IDocumentItem doc)
 {
     if (instance == null) return;
     instance.document = doc;
     instance.InitListView();
 }
Exemple #40
0
 private static XElement WriteItem(IDocumentItem item)
 {
     var link = item as Link;
     return link != null ? WriteLink(link) : WriteCategory((Category) item);
 }
 private bool ShowDeleteDialog(IDocumentItem item)
 {
     var link = item as Link;
     if (link != null)
     {
         return _container.Resolve<IDialogManager<Link>>().ShowDeleteDialog(link) == true;
     }
     var category = (Category) item;
     return _container.Resolve<IDialogManager<Category>>().ShowDeleteDialog(category) == true;
 }