Ejemplo n.º 1
0
 /// <summary>
 /// Adds the tab from file. Use this method only if you want to save a file to a new filename.
 /// </summary>
 /// <param name='_nb'>
 /// The notebook.
 /// </param>
 /// <param name='_fileNameNew'>
 /// The new Filename
 /// </param>
 /// <param name='_pageindex'>
 /// The index of the page.
 /// </param>
 public static void AddTabFromFile(Notebook _nb, string _fileNameNew, int _pageindex)
 {
     try {
         if (System.IO.File.Exists(_fileNameNew))
         {
             //FileName = FileNameNew;	//Fixme: If nothing happens, change this comment.
             libTerminus.cRegex newregex;
             if (g_tmp != null)
             {
                 newregex = g_tmp;
                 g_tmp    = null;
             }
             else
             {
                 newregex = new cRegex(_fileNameNew);
             }
             _nb.InsertPage(newregex, new Label(new FileInfo(_fileNameNew).Name, ref _nb, newregex), _pageindex);
             _nb.ShowAll();
             g_files.Add(_fileNameNew);
         }
         else
         {
             libTerminus.cRegex newregex = new cRegex(_fileNameNew);
             _nb.InsertPage(newregex, new Label(Catalog.GetString("New Phrase"), ref _nb, newregex), _pageindex);
             _nb.ShowAll();
             g_files.Add(_fileNameNew);
         }
     } catch (Exception ex) {
         MessageBox.Show("error: " + ex.Message, cTerminus.g_programName, ButtonsType.Close, MessageType.Error);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Save the specified nb, Index and Filename.
 /// </summary>
 /// <param name='_nb'>
 /// Nb.
 /// </param>
 /// <param name='_Index'>
 /// Index.
 /// </param>
 /// <param name='_Filename'>
 /// Filename.
 /// </param>
 public static void Save(Notebook _nb, int _Index, string _Filename)
 {
     try {
         if (_Filename != "" && disable != true)
         {
             ((libTerminus.cRegex)_nb.GetNthPage(_nb.Page)).Save(_Filename);
             int    current = _nb.Page;
             string data    = ((libTerminus.cRegex)_nb.GetNthPage(_nb.Page)).GetDataSourceBuffer();
             ((libTerminus.cRegex)_nb.GetNthPage(_nb.Page)).Saved = true;
             ((libTerminus.cRegex)_nb.GetNthPage(_nb.Page)).setDataBuffer(data);
             g_tmp = ((libTerminus.cRegex)_nb.GetNthPage(_nb.Page));
             _nb.Remove(_nb.GetNthPage(_nb.Page));
             AddTabFromFile(_nb, _Filename, current);
             _nb.Page = current;
         }
     } catch (Exception ex) {
         MessageBox.Show(ex.Message, cTerminus.g_programName, ButtonsType.Close, MessageType.Error);
     }
 }
Ejemplo n.º 3
0
        //public static bool enableDataBase;
        /// <summary>
        /// Adds a new tab to the given notebook
        /// </summary>
        /// <param name='_nb'>
        /// The notebook.
        /// </param>
        /// <param name='_filename'>
        /// The filename. If you have a filename, use it. If you don't have a filename, use "" instead.
        /// </param>
        public static void AddTab(Notebook _nb, string _filename)
        {
            try {
                string FileName;
                if (System.IO.File.Exists(_filename))
                {
                    FileName = new System.IO.FileInfo(_filename).Name;
                }
                else
                {
                    FileName = "";
                }

                libTerminus.cRegex newregex = new cRegex(_filename);
                newregex.Saved = true;
                _nb.AppendPage(newregex, new Label(Catalog.GetString("New Phrase"), ref _nb, newregex));
                _nb.ShowAll();
                _nb.Page = _nb.NPages - 1;
                g_files.Add(_filename);
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, cTerminus.g_programName, ButtonsType.Close, MessageType.Error);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets the title.
 /// </summary>
 /// <returns>
 /// The title.
 /// </returns>
 /// <param name='_nb'>
 /// Notebook
 /// </param>
 /// <param name='_Index'>
 /// Index of the current page.
 /// </param>
 public static string getTitle(Notebook _nb, int _Index)
 {
     try {
         cRegex p_current = ((libTerminus.cRegex)_nb.GetNthPage(_nb.Page));
         if (p_current.g_filename == "")
         {
             return(g_programName);
         }
         else
         {
             if (p_current.Saved)
             {
                 return(p_current.g_filename + " - " + g_programName);
             }
             else
             {
                 return(p_current.g_filename + "* - " + g_programName);
             }
         }
     } catch (Exception ex) {
         //MessageBox.Show (ex.Message, cTerminus.g_programName, ButtonsType.Close, MessageType.Error);
         return(g_programName + " ");
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds the tab from file.
 /// </summary>
 /// <param name='_nb'>
 /// The notebook.
 /// </param>
 public static void AddTabFromFile(Notebook _nb)
 {
     try {
         string FileNameNew;
         FileNameNew = ShowOpenDialog();
         if (g_files.Contains(FileNameNew) == false)
         {
             if (System.IO.File.Exists(FileNameNew))
             {
                 libTerminus.cRegex newregex = new cRegex(FileNameNew);
                 _nb.AppendPage(newregex, new Label(new FileInfo(FileNameNew).Name, ref _nb, newregex));
                 _nb.ShowAll();
                 _nb.Page = _nb.NPages - 1;
                 g_files.Add(FileNameNew);
             }
         }
         else
         {
             _nb.Page = g_files.IndexOf(FileNameNew);
         }
     } catch (Exception ex) {
         MessageBox.Show(ex.Message, cTerminus.g_programName, ButtonsType.Close, MessageType.Error);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Save the specified nb, Index and Filename.
        /// </summary>
        /// <param name='_nb'>
        /// Nb.
        /// </param>
        /// <param name='_Index'>
        /// Index.
        /// </param>
        /// <param name='_Filename'>
        /// Filename.
        /// </param>
        public static void Save(Notebook _nb, int _Index, string _Filename)
        {
            try {
                if (_Filename != "" && disable != true) {

                    ((libTerminus.cRegex)_nb.GetNthPage (_nb.Page)).Save (_Filename);
                    int current = _nb.Page;
                    string data = ((libTerminus.cRegex)_nb.GetNthPage (_nb.Page)).GetDataSourceBuffer ();
                    ((libTerminus.cRegex)_nb.GetNthPage (_nb.Page)).Saved = true;
                    ((libTerminus.cRegex)_nb.GetNthPage (_nb.Page)).setDataBuffer (data);
                    g_tmp = ((libTerminus.cRegex)_nb.GetNthPage (_nb.Page));
                    _nb.Remove (_nb.GetNthPage (_nb.Page));
                    AddTabFromFile (_nb, _Filename, current);
                    _nb.Page = current;

                }
            } catch (Exception ex) {
                MessageBox.Show (ex.Message, cTerminus.g_programName, ButtonsType.Close, MessageType.Error);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Adds the tab from file. Use this method only if you want to save a file to a new filename.
 /// </summary>
 /// <param name='_nb'>
 /// The notebook.
 /// </param>
 /// <param name='_fileNameNew'>
 /// The new Filename
 /// </param>
 /// <param name='_pageindex'>
 /// The index of the page.
 /// </param>
 public static void AddTabFromFile(Notebook _nb, string _fileNameNew, int _pageindex)
 {
     try {
         if (System.IO.File.Exists (_fileNameNew)) {
             //FileName = FileNameNew;	//Fixme: If nothing happens, change this comment.
             libTerminus.cRegex newregex;
             if (g_tmp != null) {
                 newregex = g_tmp;
                 g_tmp = null;
             } else {
                 newregex = new cRegex (_fileNameNew);
             }
             _nb.InsertPage (newregex, new Label (new FileInfo (_fileNameNew).Name, ref _nb, newregex), _pageindex);
             _nb.ShowAll ();
             g_files.Add (_fileNameNew);
         } else {
             libTerminus.cRegex newregex = new cRegex (_fileNameNew);
             _nb.InsertPage (newregex, new Label (Catalog.GetString ("New Phrase"), ref _nb, newregex), _pageindex);
             _nb.ShowAll ();
             g_files.Add (_fileNameNew);
         }
     } catch (Exception ex) {
         MessageBox.Show ("error: " + ex.Message, cTerminus.g_programName, ButtonsType.Close, MessageType.Error);
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Adds the tab from file.
        /// </summary>
        /// <param name='_nb'>
        /// The notebook.
        /// </param>
        public static void AddTabFromFile(Notebook _nb)
        {
            try {
                string FileNameNew;
                FileNameNew = ShowOpenDialog ();
                if (g_files.Contains (FileNameNew) == false) {
                    if (System.IO.File.Exists (FileNameNew)) {
                        libTerminus.cRegex newregex = new cRegex (FileNameNew);
                        _nb.AppendPage (newregex, new Label (new FileInfo (FileNameNew).Name, ref _nb, newregex));
                        _nb.ShowAll ();
                        _nb.Page = _nb.NPages - 1;
                        g_files.Add (FileNameNew);
                    }
                } else {
                    _nb.Page = g_files.IndexOf (FileNameNew);
                }

            } catch (Exception ex) {
                MessageBox.Show (ex.Message, cTerminus.g_programName, ButtonsType.Close, MessageType.Error);
            }
        }
Ejemplo n.º 9
0
        //public static bool enableDataBase;
        /// <summary>
        /// Adds a new tab to the given notebook
        /// </summary>
        /// <param name='_nb'>
        /// The notebook.
        /// </param>
        /// <param name='_filename'>
        /// The filename. If you have a filename, use it. If you don't have a filename, use "" instead.
        /// </param>
        public static void AddTab(Notebook _nb, string _filename)
        {
            try {
                string FileName;
                if (System.IO.File.Exists (_filename))
                    FileName = new System.IO.FileInfo (_filename).Name;
                else
                    FileName = "";

                libTerminus.cRegex newregex = new cRegex (_filename);
                newregex.Saved = true;
                _nb.AppendPage (newregex, new Label (Catalog.GetString ("New Phrase"), ref _nb, newregex));
                _nb.ShowAll ();
                _nb.Page = _nb.NPages - 1;
                g_files.Add (_filename);
            } catch (Exception ex) {
                MessageBox.Show (ex.Message, cTerminus.g_programName, ButtonsType.Close, MessageType.Error);
            }
        }