void RenderListItem(StringBuilder sb, DocBase member, Func<DocBase, string> memberNameTransform = null)
 {
     sb.Append("\t");
     sb.Append("<li>");
     var memberName = memberNameTransform == null ? member.Name : memberNameTransform(member);
     sb.Append(RenderBold(memberName));
     sb.Append(" - ");
     sb.Append(member.Summary);
     sb.AppendLine("</li>");
 }
Example #2
0
        void RenderListItem(StringBuilder sb, DocBase member, Func <DocBase, string> memberNameTransform = null)
        {
            sb.Append("\t");
            sb.Append("<li>");
            var memberName = memberNameTransform == null ? member.Name : memberNameTransform(member);

            sb.Append(RenderBold(memberName));
            sb.Append(" - ");
            sb.Append(member.Summary);
            sb.AppendLine("</li>");
        }
Example #3
0
 void GetSummaryAndRemarks(DocBase info, IEnumerable <XElement> values, ContentType contentType)
 {
     if (values.Any())
     {
         info.Summary = GetValue(values, SummaryTagName, contentType);
         info.Remarks = GetValue(values, RemarksTagName, contentType);
     }
     else
     {
         info.Summary = "<INVALID DOC MARKUP>";
     }
 }
        private string CreateMarkdown(DocBase model)
        {
            var s = new StringBuilder();

            s.Append($"# {model.Title}\n\n");
            s.Append($"{model.Overview}\n\n");
            s.Append("---\n\n");

            // Table of Contents
            s.Append("## Table of Contents\n\n");
            model.Categories.ForEach(cat => {
                s.Append($"[{cat.Name}](#{cat.Name.Replace(" ", "").ToLower()})\n\n");
            });
            s.Append("---\n\n");

            // Loop Categories
            model.Categories.ForEach(cat => {
                s.Append($"## {cat.Name}\n\n");

                // Loop Actions
                if (cat.Actions.Count > 0)
                {
                    s.Append("### Actions\n\n");
                    s.Append("| Name | Description | Type | Format | Data (Default in bold) |\n");
                    s.Append("| --- | --- | --- | --- | --- |\n");
                    cat.Actions.ForEach(act => {
                        // TODO: Only supports showing a single line of data
                        s.Append($"| {act.Name} | {act.Description} | {act.Type} | {act.Format} | {(act.Data.Count > 0 ? act.Data[0].Values.Replace(act.Data[0].DefaultValue, $"**{act.Data[0].DefaultValue}**") :  "")} |\n");
                    });
                    s.Append("\n\n");
                }

                if (cat.States.Count > 0)
                {
                    // Loop States
                    s.Append("### States\n\n");
                    s.Append("| Id | Type | Description | DefaultValue |\n");
                    s.Append("| --- | --- | --- | --- |\n");
                    cat.States.ForEach(state => {
                        s.Append($"| {state.Id} | {state.Type} | {state.Description} | {state.DefaultValue} |\n");
                    });
                    s.Append("\n\n");
                }

                // Loop Events

                s.Append("---\n\n");
            });

            return(s.ToString());
        }
Example #5
0
        public TagModelItemPicture()
        {
            PictureType = new DocEnum(ID3.FrameContentPicture.PictureTypes);
            Content     = new DocObj <byte[]>();

            Content.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == DocBase.PropertyName(Content, m => m.Value))
                {
                    bitmapFrameCache = null;
                    NotifyPropertyChanged(this, m => m.Image);
                }
            };
        }
Example #6
0
 private void OnListTransactionChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == DocBase.PropertyName(source.Items.Transaction, m => m.Value))
     {
         if (source.Items.Transaction.Value > 0)
         {
             BlockUpdates = true;
         }
         else if (source.Items.Transaction.Value == 0)
         {
             UpdateItems();
             BlockUpdates = false;
         }
     }
 }
 /// <summary>
 /// Process the parameter list.
 /// </summary>
 /// <param name="parameterInfos">The parameter information.</param>
 /// <param name="doc">The parent <see cref="DocBase"/>.</param>
 /// <param name="target">The target list to process to.</param>
 private void ProcessParameters(
     ParameterInfo[] parameterInfos,
     DocBase doc,
     IList <DocParameter> target)
 {
     foreach (var parameter in parameterInfos)
     {
         var param = new DocParameter(doc)
         {
             Name          = parameter.Name,
             ParameterType = new DocBaseType(),
         };
         ProcessType(parameter.ParameterType, param.ParameterType);
         ProcessTypePass2(param.ParameterType);
         target.Add(param);
     }
 }
Example #8
0
        private void OnTreeNodeSelectionChanged(Object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == DocBase.PropertyName(FileTreeModel, m => m.SelectedTreeNode) &&
                !Object.ReferenceEquals(FileTreeModel.SelectedTreeNode, null))
            {
                string newPath = FileTreeModel.SelectedTreeNode.ItemPath;
                string oldPath = Editor.Path.Value;

                if (!FileUtils.ArePathsEqual(newPath, oldPath))
                {
                    History.Instance.ExecuteInTransaction(
                        delegate()
                    {
                        Editor.Path.Value = newPath;
                    },
                        Editor.Transaction.LazyId,
                        new Text("Change Folder to ") + newPath);
                }
            }
        }
        private DocBase CreateModel()
        {
            // Find assembly
            var a = Assembly.GetExecutingAssembly().GetReferencedAssemblies().FirstOrDefault(a => a.Name == _options.Value.PluginName);

            if (a == null)
            {
                throw new FileNotFoundException("Unable to load assembly for reflection.");
            }

            var model = new DocBase {
                Title    = "MSFS 2020 TouchPortal Plugin",
                Overview = "This plugin will provide a two way interface between Touch Portal and Microsoft Flight Simulator 2020 through SimConnect."
            };

            var assembly     = Assembly.Load(a);
            var assemblyList = assembly.GetTypes().ToList();

            // Get all classes with the TouchPortalCategory
            var classList = assemblyList.Where(t => t.CustomAttributes.Any(att => att.AttributeType == typeof(TouchPortalCategoryAttribute))).OrderBy(o => o.Name).ToList();

            // Loop through categories
            classList.ForEach(cat => {
                var catAttr = (TouchPortalCategoryAttribute)Attribute.GetCustomAttribute(cat, typeof(TouchPortalCategoryAttribute));
                var newCat  = new DocCategory {
                    Name = catAttr.Name
                };

                // Loop through Actions
                var actions = cat.GetMembers().Where(t => t.CustomAttributes.Any(att => att.AttributeType == typeof(TouchPortalActionAttribute))).ToList();
                actions.ForEach(act => {
                    var actionAttribute = (TouchPortalActionAttribute)Attribute.GetCustomAttribute(act, typeof(TouchPortalActionAttribute));
                    var newAct          = new DocAction {
                        Name        = actionAttribute.Name,
                        Description = actionAttribute.Description,
                        Type        = actionAttribute.Type,
                        Format      = actionAttribute.Format
                    };

                    // Loop through Action Data
                    var choiceAttributes = act.GetCustomAttributes <TouchPortalActionChoiceAttribute>()?.ToList();

                    if (choiceAttributes?.Count > 0)
                    {
                        for (int i = 0; i < choiceAttributes.Count; i++)
                        {
                            var data = new DocActionData {
                                Type         = "choice",
                                DefaultValue = choiceAttributes[i].DefaultValue,
                                Values       = string.Join(",", choiceAttributes[i].ChoiceValues)
                            };
                            newAct.Data.Add(data);
                        }
                    }

                    newCat.Actions.Add(newAct);
                });

                newCat.Actions = newCat.Actions.OrderBy(c => c.Name).ToList();

                // Loop through States
                var states = cat.GetFields().Where(m => m.CustomAttributes.Any(att => att.AttributeType == typeof(TouchPortalState))).ToList();
                states.ForEach(state => {
                    var stateAttribute = state.GetCustomAttribute <TouchPortalStateAttribute>();

                    if (stateAttribute != null)
                    {
                        var newState = new DocState {
                            Id           = $"{_options.Value.PluginName}.{catAttr.Id}.State.{stateAttribute.Id}",
                            Type         = stateAttribute.Type,
                            Description  = stateAttribute.Description,
                            DefaultValue = stateAttribute.Default
                        };

                        newCat.States.Add(newState);
                    }
                });

                newCat.States = newCat.States.OrderBy(c => c.Description).ToList();

                // Loop through Events

                model.Categories.Add(newCat);
            });

            model.Categories = model.Categories.OrderBy(c => c.Name).ToList();

            return(model);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DocParameter"/> class with the
 /// specified parent.
 /// </summary>
 /// <param name="parent">The parent <see cref="DocBase"/>.</param>
 public DocParameter(DocBase parent)
 {
     Parent = parent;
 }
Example #11
0
 void GetSummaryAndRemarks(DocBase info, IEnumerable<XElement> values, ContentType contentType)
 {
     if(values.Any()) {
         info.Summary = GetValue(values, SummaryTagName, contentType);
         info.Remarks = GetValue(values, RemarksTagName, contentType);
     } else
         info.Summary = "<INVALID DOC MARKUP>";
 }