/// <summary>
 /// Loads an argument in any of the known formats.
 /// </summary>
 /// <param name="filename"></param>
 public void loadAXLorRE3(string filename)
 {
     if (filename.ToLower().EndsWith(".axl"))
     {
         loadArg(filename);
     }
     else if (filename.ToLower().EndsWith(".re3"))
     {
         this.loadRE3Map(filename);
     }
     else if (filename.ToLower().EndsWith(".rtnl"))
     {
         Rationale rat  = new Rationale();
         Argument  arat = rat.importFromRationale(filename);
         currentArg = arat;
     }
     else
     {
         return;
     }
     loadTree();
     verifyTree(false);
 }
        /// <summary>
        /// Open an argument file with a standard open file dialog box.
        /// </summary>
        /// <returns></returns>
        public ArgMapInterface openArgument()
        {
            System.Windows.Forms.OpenFileDialog openFileDialog1;
            ArgMapInterface ai;              // if this object needs to be re-created
            DialogResult    r;
            string          fn;

            openFileDialog1        = new System.Windows.Forms.OpenFileDialog();
            openFileDialog1.Filter = "Argumentative files (*.axl)|*.axl|Reasonable files (*.re3)|*.re3" +
                                     "|Araucaria (*.aml;*.scm)|*.aml;*.scm|All Argument files (.axl;.re3;.rtnl)|*.axl;*.re3;*.rtnl";
            openFileDialog1.FilterIndex = 4;

            try
            {
                r = openFileDialog1.ShowDialog();
            }
            catch
            {
                r = DialogResult.Cancel;
            }
            if (r == DialogResult.OK)
            {
                fn = openFileDialog1.FileName;

                if (fn.ToLower().EndsWith(".axl") || fn.ToLower().EndsWith(".re3"))
                {
                    ai = new ArgMapInterface(false, theTV, editArea);
                    ai.loadAXLorRE3(fn);
                    currentfilename = fn;
                    return(ai);
                }
                else if (fn.ToLower().EndsWith(".aml"))                 // Araucaria file
                {
                    Araucaria ara = new Araucaria();
                    ara.load(fn);
                    CurrentArg.setArg(ara.A.findHead());
                    loadTree();
                    currentfilename = fn;
                    return(this);
                }
                else if (fn.ToLower().EndsWith(".scm"))                 // Read scheme set
                {
                    Araucaria ara = new Araucaria();
                    MessageBox.Show("Araucaria Scheme Sets are read but are not yet supported.");
                    ara.load(fn);
                    // TODO What to do with the scheme set
                }
                else if (fn.ToLower().EndsWith(".rtnl"))                 // Read scheme set
                {
                    Rationale rat  = new Rationale();
                    Argument  arat = rat.importFromRationale(fn);
                    if (arat == null)
                    {
                        return(null);
                    }
                    CurrentArg.setArg(arat.findHead());
                    loadTree();
                    currentfilename = fn;
                    return(this);
                }
                else
                {
                    MessageBox.Show(String.Format("Do not know how to open file type {0}", System.IO.Path.GetExtension(fn)));
                }
            }
            return(null);
        }
Exemple #3
0
        /// <summary>Save argument in format depanding on file extension or id number</summary>
        /// <param name="fileName">File name with extension</param>
        /// <param name="FilterIndex"></param>
        public void saveAs(string fileName, int FilterIndex)
        {
            Node   n;
            string ending;

            n      = this.findHead();
            ending = System.IO.Path.GetExtension(fileName).ToLower();
            if (ending.Equals(".bmp") || FilterIndex == (int)fileIndex.bmp)
            {
                DrawTree d = new DrawTree(0, 0, 1);
                d.drawTree(System.IO.Path.GetFileNameWithoutExtension(fileName) + ".bmp", n, ImageFormat.Bmp);
            }
            else if (ending.ToLower().Equals(".png") || FilterIndex == (int)fileIndex.png)
            {
                DrawTree d = new DrawTree(0, 0, 1);
                d.drawTree(System.IO.Path.GetFileNameWithoutExtension(fileName) + ".png", n, ImageFormat.Png);
            }
            else if (ending.ToLower().Equals(".jpg") || FilterIndex == (int)fileIndex.jpg)
            {
                DrawTree d = new DrawTree(0, 0, 1);
                d.drawTree(fileName, n, ImageFormat.Jpeg);
            }
            else if (ending.ToLower().Equals(".gif") || FilterIndex == (int)fileIndex.gif)
            {
                DrawTree d = new DrawTree(0, 0, 1);
                d.drawTree(fileName, n, ImageFormat.Gif);
            }
            else if (ending.ToLower().Equals(".rtnl") || FilterIndex == (int)fileIndex.rtn)                    // Rationale export
            {
                Rationale rx = new Rationale();
                rx.exportToRationale(fileName, findHead(), false);                       // expanded = false.  Option should set to true zz
            }
            else if (ending.Equals(".axl") || FilterIndex == (int)fileIndex.axl)         // already has the correct extension
            {
                saveArg(fileName, null, false);
                // addFileToRecent(fileName);
            }
            else if (ending.ToLower().Equals(""))
            {
                if (fileName != fileName + ".axl")
                {
                    if (System.IO.File.Exists(fileName + ".axl"))
                    {
                        DialogResult result;
                        string       message = String.Format("{0} exists. Do you wish to overwrite?", fileName);

                        result = System.Windows.Forms.MessageBox.Show
                                     (message, "Overwrite?", System.Windows.Forms.MessageBoxButtons.YesNo);
                        if (result != DialogResult.Yes)
                        {
                            return;
                        }
                    }
                }
                fileName = fileName + ".axl";
                saveArg(fileName, null, false);
            }
            else
            {
                fileName = fileName + ".axl";
                saveArg(fileName, null, false);
                // addFileToRecent(fileName);
            }
        }