/// <summary> /// Used to set the options in Quick Views /// </summary> /// <param name="options">The options object</param> /// <param name="join">Join</param> /// <param name="arrow">Arrow</param> /// <param name="notation">Box or R notation</param> /// <param name="orientation">Orientation</param> /// <param name="shading">Shading and drop shadow</param> /// <param name="distributed">Distributed line drawing</param> /// <param name="blackAndWhite">Set colours to black and white</param> public void setStandardOptions(Options.OptionsData options, DrawTree.joinType join, DrawTree.arrowType arrow, DrawTree.notationType notation, DrawTree.treeOrientationType orientation, bool shading, bool distributed, bool blackAndWhite) { options.Justification = DrawTree.justificationType.jCentre; options.Join = join; options.Arrow = arrow; options.BoxShading = shading; options.DropShadow = shading; // Part of shading as standard options.ShowLegend = true; // Default options.Notation = notation; options.TreeOrientation = orientation; options.Distributed = distributed; if (!blackAndWhite) { options.premise = new Options.ElementOptions("Arial", 16, Color.Black, Color.LightGray, 3, 400, DashStyle.Solid); options.reason = new Options.ElementOptions("Arial", 10, Color.Black, Color.FromArgb(142, 243, 141), 2, 200, DashStyle.Solid); options.objection = new Options.ElementOptions("Arial", 10, Color.Black, Color.FromArgb(238, 136, 134), 2, 200, DashStyle.Solid); options.helper = new Options.ElementOptions("Arial", 10, Color.Black, Color.FromArgb(133, 132, 225), 1, 200, DashStyle.Solid); } else { options.premise = new Options.ElementOptions("Arial", 16, Color.Black, Color.Black, 3, 400, DashStyle.Solid); options.reason = new Options.ElementOptions("Arial", 10, Color.Black, Color.Black, 2, 200, DashStyle.Solid); options.objection = new Options.ElementOptions("Arial", 10, Color.Black, Color.Black, 2, 200, DashStyle.Dash); options.helper = new Options.ElementOptions("Arial", 10, Color.Black, Color.Black, 1, 200, DashStyle.Dot); } }
/// <summary> /// save as bmp file /// </summary> /// <param name="n"></param> /// <returns>Bitmap of current Node and children</returns> public Bitmap drawTree(Node n) { Bitmap b; Graphics g; Options.OptionsData d = Options.OptionsData.Instance; // set drawing options justification = d.Justification; join = d.Join; treeOrientation = d.TreeOrientation; useRnotation = d.Notation; dropShadow = d.DropShadow; boxShading = d.BoxShading; showLegend = d.ShowLegend; arrows = d.Arrow; marker = d.Marker; helpersAsCoPremises = d.HelpersAsCoPremises; // Width and height calculation should only be a cross check maxWidth = 0; maxHeight = 0; recalc(n); b = new Bitmap((int)maxWidth + 20, (int)maxHeight + 20); // 20 pixel border g = Graphics.FromImage(b); // gets the graphics drawing object g.Clear(Color.White); // clears the background drawTree(g, n); return(b); }
/// <summary> /// Draws the tree from the specified node /// </summary> /// <param name="g">The Drawing GDI object</param> /// <param name="n">Root Node</param> public void drawTree(Graphics g, Node n) { graphics = g; Options.OptionsData d = Options.OptionsData.Instance; // set drawing options justification = d.Justification; join = d.Join; treeOrientation = d.TreeOrientation; useRnotation = d.Notation; dropShadow = d.DropShadow; boxShading = d.BoxShading; showLegend = d.ShowLegend; arrows = d.Arrow; marker = d.Marker; helpersAsCoPremises = d.HelpersAsCoPremises; // Width and height calculation should only be a cross check maxWidth = 0; maxHeight = 0; g.PageScale = zoom; // if(needsRecalc) recalc(n); // calcStartXY(n,ref x,ref y); // for debug // g.DrawRectangle(new Pen(Color.Bisque),0,0,maxWidth,maxHeight); // g.DrawString("maxHeight & maxWidth:"+maxWidth+" : "+maxHeight,new Font("Courier",8F),new SolidBrush(Color.Black),offsetX,offsetY+maxHeight+margin); drawNode(n.x, n.y, n, 0); legendY = maxHeight - legendHeight; drawLegend(n, true); }
private void buttonOK_Click(object sender, System.EventArgs e) { bool success; // check for files if (!checkBoxCurrentFile.Checked) { if (!System.IO.File.Exists(textBox1.Text)) { MessageBox.Show(String.Format("From path does not exist: {0}", textBox1.Text)); return; } } if (!System.IO.File.Exists(textBoxXslFile.Text)) { MessageBox.Show(String.Format("With path (XSL file) does not exist: {0}", textBoxXslFile.Text)); return; } // maybe test for existing file and ask before overwriting // Execute export Transform t = new Transform(); try { if (this.checkBoxCurrentFile.Checked) { success = t.doTransform("", textBoxXslFile.Text, textBoxXslOut.Text, ami.CurrentArg); } // "" means use current argument in memory else { success = t.doTransform(textBox1.Text, textBoxXslFile.Text, textBoxXslOut.Text, ami.CurrentArg); } if (success) { if (checkBoxOpenWith.Checked) { System.Diagnostics.Process app; app = new System.Diagnostics.Process(); app.StartInfo.FileName = textBoxXslOut.Text; app.Start(); } else { MessageBox.Show(String.Format("{0} successfuly created.", textBoxXslOut.Text), "Success"); } } Options.OptionsData od = Options.OptionsData.Instance; od.setlastXSL(textBoxXslFile.Text); od.setlastXSLoutput(textBoxXslOut.Text); } catch (Exception ex) { MessageBox.Show(String.Format("XSL error. {0}", ex.Message)); } }
/// <summary> /// Transformation (using XSLT) dialog box /// </summary> /// <param name="a"></param> public TransformDlg(ArgMapInterface a) { // // Required for Windows Form Designer support // InitializeComponent(); ami = a; textBox1.Text = a.CurrentFilename; System.IO.Directory.GetCurrentDirectory(); Options.OptionsData od = Options.OptionsData.Instance; this.textBoxXslFile.Text = od.getlastXSL(); this.textBoxXslOut.Text = od.getlastXSLoutput(); correctOutputFile(); }
/// <summary> /// Paints the graphical view on a Windows form /// </summary> /// <param name="e">Standard PaintEventArgs</param> /// <param name="a">Full context of the current argument</param> public void drawTree(System.Windows.Forms.PaintEventArgs e, ArgMapInterface a) { Options.OptionsData d = Options.OptionsData.Instance; if (!d.ShowGraphicalView) { e.Graphics.Clear(Color.White); return; } try { e.Graphics.PageScale = 1.0F; drawTree(e.Graphics, a.CurrentArg.findHead()); } catch (Exception ex) { MessageBox.Show("drawTree error: " + ex.StackTrace); } }
/// <summary> /// Creates a sample argument map with a premise, a reason with helper and a objection with helper. /// </summary> /// <returns>Head Node of new argument</returns> public Node setupSample() { Node p, nr, no, nh; Options.OptionsData d = Options.OptionsData.Instance; // TODO Add to resources for I18N // addPremise p = addNode(Node.ArgumentNodeType.premise, "The Main Premise to the argument", null); // addReadon nr = addNode(Node.ArgumentNodeType.reason, "A reason", p); nh = addNode(Node.ArgumentNodeType.helper, "A helper for the reason", nr); // add Objection no = addNode(Node.ArgumentNodeType.objection, "An objection", p); nh = addNode(Node.ArgumentNodeType.helper, "A helper for the objection", no); head = p; author = d.Author; // load author from options this.fileName = UndefinedFile; modifiedCount = 0; return(p); }
/// <summary> /// Writes the argument to a TextWriter file. /// </summary> /// <param name="file">TextWriter file</param> /// <param name="n">Top Argument Node</param> /// <param name="addTags">Add tags used in XSL Transforms</param> /// <param name="makePremise"></param> private void writeArgumentXML(System.IO.TextWriter file, Node n, bool makePremise, bool addTags) { bool saveSubArgument = false; Node.ArgumentNodeType temp = Node.ArgumentNodeType.unknown; Options.OptionsData d = Options.OptionsData.Instance; if (n == null) { n = findHead(); } if (addTags) { referenceTree(); // Reference tree for <ref> tag } if (makePremise & (n.nodeType != Node.ArgumentNodeType.premise)) { saveSubArgument = true; temp = n.nodeType; n.nodeType = Node.ArgumentNodeType.premise; } file.WriteLine("<argument>"); if (!(author.Equals("") & d.Author.Equals(""))) // Add author if defined { file.Write("<author>"); if (author.Equals("")) // does the argument not have an author { file.Write(d.Author); } else { file.Write(author); } file.WriteLine("</author>"); } if (creationDateDefined) { file.Write("<created>"); file.Write(DateTimetoString(creationDate)); file.WriteLine("</created>"); } file.Write("<modified>"); file.Write(DateTimetoString(this.modifiedDate)); file.WriteLine("</modified>"); if (addTags) // add tags used for XSLT { // Title file.Write("<title>"); file.Write(Title); file.WriteLine("</title>"); // Todays date - difficult to format with XSLT file.Write("<day>"); file.Write(DateTime.Today.DayOfWeek.ToString()); file.Write("</day>"); file.Write("<dayNum>"); file.Write(DateTime.Today.Day.ToString()); file.Write("</dayNum>"); file.Write("<month>"); file.Write(DateTime.Today.Month.ToString()); file.Write("</month>"); file.Write("<year>"); file.Write(DateTime.Today.Year.ToString()); file.Write("</year>"); file.Write("<shortDate>"); file.Write(DateTime.Today.ToShortDateString()); file.Write("</shortDate>"); file.Write("<shortTime>"); file.Write(DateTime.Now.ToShortTimeString()); file.Write("</shortTime>"); file.Write("<longDate>"); file.Write(DateTime.Today.ToLongDateString()); file.Write("</longDate>"); file.Write("<longTime>"); file.Write(DateTime.Now.ToLongTimeString()); file.Write("</longTime>"); } writeNode(file, n, addTags); file.WriteLine("</argument>"); file.Close(); if (saveSubArgument) { n.nodeType = temp; } }