Exemplo n.º 1
0
        /// <summary>
        ///     添加字符串变量
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StrToolStripMenuItemClick(object sender, EventArgs e)
        {
            var stringVariable =
                new TextVariable(_iVariableDesignRepository.FindGroupByPath(GetVariableGroupPath(_currentNode.FullPath)));

            _iVariableDesignRepository.AddVariable(stringVariable);
            AddVarToListview(stringVariable, dataGridView_Avaiable);
        }
Exemplo n.º 2
0
        public ActionResult MonkeyStoryText(string verb1, string noun1, string adverb1, string adjective1)
        {
            TextVariable monkeyTextVariable = new TextVariable();

            monkeyTextVariable.Verb1      = verb1;
            monkeyTextVariable.Noun1      = noun1;
            monkeyTextVariable.Adverb1    = adverb1;
            monkeyTextVariable.Adjective1 = adjective1;
            return(View(monkeyTextVariable));
        }
Exemplo n.º 3
0
        public ActionResult InTheJungleStoryText(string verb1, string verb2, string verb3, string verb4, string noun1, string noun2, string noun3, string noun4, string adjective1, string adjective2, string adjective3, string adjective4, string adjective5, string adjective6, string adjective7)
        {
            TextVariable inTheJungleTextVariable = new TextVariable();

            inTheJungleTextVariable.Verb1      = verb1;
            inTheJungleTextVariable.Verb1      = verb2;
            inTheJungleTextVariable.Verb1      = verb3;
            inTheJungleTextVariable.Verb1      = verb4;
            inTheJungleTextVariable.Noun1      = noun1;
            inTheJungleTextVariable.Noun1      = noun2;
            inTheJungleTextVariable.Noun1      = noun3;
            inTheJungleTextVariable.Noun1      = noun4;
            inTheJungleTextVariable.Adjective1 = adjective1;
            inTheJungleTextVariable.Adjective1 = adjective2;
            inTheJungleTextVariable.Adjective1 = adjective3;
            inTheJungleTextVariable.Adjective1 = adjective4;
            inTheJungleTextVariable.Adjective1 = adjective5;
            inTheJungleTextVariable.Adjective1 = adjective6;
            inTheJungleTextVariable.Adjective1 = adjective7;
            return(View(inTheJungleTextVariable));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Registers a variable <paramref name="handler"/> with the specified <paramref name="name"/>.
        /// </summary>
        /// <param name="name">Name of the variable.</param>
        /// <param name="handler">The function that provides the variable value.</param>
        public static void RegisterVariable(string name, TextVariable handler)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(name));
            Contract.Requires<ArgumentNullException>(handler != null);

            string variableName = name.ToLower();
            if (variables.ContainsKey(variableName))
            {
                if (variables[variableName] == handler)
                    return;

                log.WarnFormat("Replacing existing handler '{0}' for variable '{1}' with new handler '{2}'",
                    Util.GetMethodSignature(variables[variableName].Method),
                    variableName,
                    Util.GetMethodSignature(handler.Method));
            }

            variables[variableName] = handler;
        }
 public Dictionary<string, Component> GetComponents()
 {
     Dictionary<string, Component> compDict = new Dictionary<string, Component>();Stack<List<IDialogItem>> stack = new Stack<List<IDialogItem>>();IDialogItem item;Preference pref;Format fmt;pref = new Preference("(TEMPLATE_ID)",null,"694f9b08-bc19-4db9-9773-cb03aa8f10c9");compDict.Add(pref.Name, pref);pref = new Preference("(MARK_ANSWER_FIELDS)",null,"True");compDict.Add(pref.Name, pref);{stack.Push(new List<IDialogItem>(2));item = new TextVariable("Employee Name",null,null,null,null,FieldWidth.Full,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,1,0,"",false);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new MultipleChoiceVariable("Employee Gender",null,null,null,null,FieldWidth.Default,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,new OptionList(new List<Option>(2){new Option("Male",null,null),new Option("Female",null,null)}),MultipleChoiceStyle.RadioButtons,false,"",null);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new Dialog("Employee Information",null,null,null,null,FieldWidth.Default,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,new DialogItemList(stack.Peek()),null,RepeatType.None,false,true,false,null,null,10,TrueFalseGroupType.None,false,PromptPosition.Top,true,12,true,false,false,true,new VariablePlacement[]{VariablePlacement.Default, VariablePlacement.Default},null,null);compDict.Add(item.Name, item as Component);stack.Pop();}{stack.Push(new List<IDialogItem>(3));item = new DateVariable("Agreement Date",null,null,null,null,FieldWidth.Full,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","____________",' ',0,MergeAlignment.Left);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new MultipleChoiceVariable("Company Representative",null,null,null,new Resource(ResourceType.Text, ResourceLocation.ResourcePane, new StaticTextEvaluator("Stephanie Hanson signs for editorial employees, Ed Walters for marketing, and Kim Schuster for production"), null),FieldWidth.Default,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,new OptionList(new List<Option>(3){new Option("Stephanie Hanson",null,null),new Option("Ed Walters",null,null),new Option("Kim Schuster",null,null)}),MultipleChoiceStyle.RadioButtons,false,"",null);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new DateVariable("Signature Date",null,null,new StaticTextEvaluator("Signature Date (Leave blank if unknown)"),null,FieldWidth.Calculated,-1,ColumnWidth.Calculated,0,true,true,false,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new Dialog("Agreement Information",null,null,null,null,FieldWidth.Default,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,new DialogItemList(stack.Peek()),null,RepeatType.None,false,true,false,null,null,10,TrueFalseGroupType.None,false,PromptPosition.Top,true,12,true,false,false,true,new VariablePlacement[]{VariablePlacement.Default, VariablePlacement.Default, VariablePlacement.Default},null,null);compDict.Add(item.Name, item as Component);stack.Pop();}{stack.Push(new List<IDialogItem>(7));item = new TextVariable("Job Title",null,null,null,null,FieldWidth.Full,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,1,0,"",false);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new TextVariable("Job Description",null,null,new StaticTextEvaluator("Complete the following sentence: Job duties shall include _______"),null,FieldWidth.Full,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,4,0,"",false);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new DateVariable("Start Date",null,null,null,null,FieldWidth.Full,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new TrueFalseVariable("Employee to Complete Trial Period",null,null,null,null,FieldWidth.Full,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,false);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new VerticalSpacingDialogElement("White Space",null,100);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new TrueFalseVariable("Employee to Receive Paid Seminar Days",null,null,null,null,FieldWidth.Full,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,false);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new NumberVariable("Number of Seminar Days",null,null,null,null,FieldWidth.Calculated,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,0,"",0.000000,5.000000);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new Dialog("Job Information",null,null,null,null,FieldWidth.Default,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,new DialogItemList(stack.Peek()),new DialogScriptEvaluator(Job_0020Information_Script),RepeatType.None,false,true,false,null,null,10,TrueFalseGroupType.MultipleSelect,false,PromptPosition.Top,true,12,true,false,false,true,new VariablePlacement[]{VariablePlacement.Default, VariablePlacement.Default, VariablePlacement.Default, VariablePlacement.Default, VariablePlacement.Default, VariablePlacement.Default, VariablePlacement.Default},null,null);compDict.Add(item.Name, item as Component);stack.Pop();}item = new ComputedVariable("Probation End Date",null,null,null,null,FieldWidth.Default,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,new ComputationScriptEvaluator<DateValue>(Probation_0020End_0020Date_Script),null);compDict.Add(item.Name, item as Component);{stack.Push(new List<IDialogItem>(5));item = new MultipleChoiceVariable("Employment Status",null,null,null,null,FieldWidth.Default,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,new OptionList(new List<Option>(3){new Option("Exempt",null,null),new Option("Non-exempt",null,null),new Option("Part-time",null,null)}),MultipleChoiceStyle.RadioButtonGrid,false,"",null);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new NumberVariable("Annual Salary",null,null,null,null,FieldWidth.Calculated,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,2,"$",0.000000,0.000000);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new NumberVariable("Hourly Salary",null,null,null,null,FieldWidth.Calculated,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,2,"$",0.000000,0.000000);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = compDict["White Space"] as IDialogItem;stack.Peek().Add(item);item = new NumberVariable("Number of Vacation Days",null,null,null,null,FieldWidth.Calculated,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,0,"",0.000000,0.000000);compDict.Add(item.Name, item as Component);stack.Peek().Add(item);item = new Dialog("Salary and Benefits",null,null,null,null,FieldWidth.Default,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,new DialogItemList(stack.Peek()),new DialogScriptEvaluator(Salary_0020and_0020Benefits_Script),RepeatType.None,false,true,false,null,null,10,TrueFalseGroupType.None,false,PromptPosition.Top,true,12,true,false,false,true,new VariablePlacement[]{VariablePlacement.Default, VariablePlacement.Default, VariablePlacement.Default, VariablePlacement.Default, VariablePlacement.Default},null,null);compDict.Add(item.Name, item as Component);stack.Pop();}item = new ComputedVariable("Full-time Annual Salary",null,null,null,null,FieldWidth.Default,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,new ComputationScriptEvaluator<NumberValue>(Full_002Dtime_0020Annual_0020Salary_Script),Full_002Dtime_0020Annual_0020Salary_Sum);compDict.Add(item.Name, item as Component);item = new ComputedVariable("Part-time Annual Salary",null,null,null,null,FieldWidth.Default,0,ColumnWidth.Calculated,0,true,true,true,AutoInterviewAction.Gray,"","",' ',0,MergeAlignment.Left,new ComputationScriptEvaluator<NumberValue>(Part_002Dtime_0020Annual_0020Salary_Script),Part_002Dtime_0020Annual_0020Salary_Sum);compDict.Add(item.Name, item as Component);return compDict;
 }
Exemplo n.º 6
0
        static void Main()
        {
            var style     = File.Load <StyleFile>("ieee.csl");
            var processor = new Processor(style, LocaleFile.Defaults);

            var bibEntries = BibParser.Parse(System.IO.File.ReadAllText("lib.bib"), out var _);

            var citations = bibEntries.Select(e => e.ToCitation()).ToArray();

            for (int i = 0; i < citations.Length; i++)
            {
                citations[i]["citation-number"] = new TextVariable(i.ToString());
            }

            var runs = processor.Bibliography(new Localization.Culture("de-DE"), citations);


            Stopwatch watch = Stopwatch.StartNew();

            var context = new Context();

            context.Logger.Level = LogLevel.Debug;
            new ReflectionLoader().Discover(context, typeof(TestPackage).Assembly);

            StringBuilder sb = new StringBuilder();

            //sb.AppendLine("\\setlength[baselinestretch]{2}");
            //sb.AppendLine("\\cfooter{Page \\thepage}");

            //sb.AppendLine("\\section{This is a section}");

            //sb.AppendLine("\\begin{figure}");
            //sb.AppendLine("\\centering");
            //sb.AppendLine("\\includegraphics{test-image.png}");
            //sb.AppendLine("\\caption{First Test Image}");
            //sb.AppendLine("\\end{figure}");

            sb.AppendLine("// Das ist ein Test");
            sb.AppendLine("/*");
            sb.AppendLine("Das hier ist ein zweiter Test");
            sb.AppendLine("*/");
            sb.AppendLine("But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure? On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that ");
            sb.AppendLine("Das ist ein toller @b()");
            sb.AppendLine("{");
            sb.AppendLine("Hier! das ist echt @bold() {test}");
            sb.AppendLine("}");

            sb.AppendLine("@test({a: d, key: value, enum: One}, {a: xD, key: value, enum: One})");

            sb.AppendLine("@BibliographyStyle(ieee.csl)");
            sb.AppendLine("@Bibliography(lib.bib)");

            sb.AppendLine();
            sb.AppendLine();
            sb.AppendLine();
            sb.AppendLine("@Section(This is a section)");
            sb.AppendLine();
            sb.AppendLine("Aft\\-er the @Color(blue, first) section [follows]@Footnote(Some Paragraph Content, \"1\") a @Bold(pagebreak).@Cite(Zanoni.2015)");
            sb.AppendLine("The following is a citation: @Cite(\"Zanoni.2015\")");
            sb.AppendLine();
            sb.AppendLine();
            sb.AppendLine();
            sb.AppendLine("But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure? On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that ");
            //sb.AppendLine();
            //sb.AppendLine();
            //sb.AppendLine();
            //sb.AppendLine();
            //sb.AppendLine();
            //sb.AppendLine();
            //sb.AppendLine();
            //sb.AppendLine();
            //sb.AppendLine("\\begin{figure}");
            //sb.AppendLine();
            //sb.AppendLine();
            //sb.AppendLine("\\centering");
            //sb.AppendLine();
            //sb.AppendLine();
            //sb.AppendLine("\\includegraphics{test-image.png}");
            //sb.AppendLine();
            //sb.AppendLine();
            //sb.AppendLine("\\caption{Test Image}");
            //sb.AppendLine();
            //sb.AppendLine();
            //sb.AppendLine("\\end{figure}");

            //sb.AppendLine("\\begin{figure}");
            //sb.AppendLine("\\centering");
            //sb.AppendLine("\\includegraphics{test-image.png}");
            //sb.AppendLine("\\caption{Second Test Image}");
            //sb.AppendLine("\\end{figure}");

            //sb.AppendLine("\\begin{figure}");
            //sb.AppendLine("\\centering");
            //sb.AppendLine("\\includegraphics{test-image.png}");
            //sb.AppendLine("\\caption{Second Test Image}");
            //sb.AppendLine("\\end{figure}");

            sb.AppendLine("@Figure() {");
            sb.AppendLine("@Centering()");
            sb.AppendLine("@IncludeGraphics(test-image.png, { Draft: true })");
            sb.AppendLine("@Caption(Second Test Image)");
            sb.AppendLine("}");

            sb.AppendLine();
            sb.AppendLine("@PrintBibliography()");

            //sb.AppendLine();
            //sb.AppendLine("1 1 1 1 1 1 1 1 1 1");

            //sb.AppendLine();
            //sb.AppendLine();

            //for (int i = 0; i < 100; i++)
            //{
            //    sb.Append("1 ");
            //}
            //sb.AppendLine("\\begin{figure}");
            //sb.AppendLine("\\centering");
            //sb.AppendLine("\\includegraphics{test-image.png}");
            //sb.AppendLine("\\caption{Third Test Image}");
            //sb.AppendLine("\\end{figure}");

            //sb.AppendLine();
            ////sb.AppendLine("\\pagebreak");

            //for (int i = 0; i < 98; i++)
            //{
            //    sb.AppendLine("\\section{This is a section}");
            //    sb.AppendLine();
            //}

            sb.AppendLine("@figure()\n{ }");
            sb.AppendLine("@test(null)");
            sb.Append("@Figure() { }");
            sb.AppendLine("@includegraphics({Some, Text @Command()})");

            ScriberLexer   lexer   = new ScriberLexer(CharStreams.fromstring(sb.ToString()));
            ScriberParser  parser  = new ScriberParser(new CommonTokenStream(lexer));
            var            root    = parser.root();
            ScriberVisitor visitor = new ScriberVisitor();

            visitor.Visit(root);
            var result = Compiler.Compile(context, visitor.Elements);

            var document = result.Document;

            document.Run(context.Logger);

            var bytes = document.ToPdf();


            System.IO.File.WriteAllBytes("test.pdf", bytes);

            watch.Stop();
            Debug.WriteLine($"Created document in {watch.ElapsedMilliseconds}ms");
        }