Example #1
0
 public TDFile(string fname)
 {
     mName = new wxFileName(fname);
     //content = 0;
     //nextChar = 0;
 }
Example #2
0
        public void OpenFile(String path, bool restore) // RECURSIVE
        {
            string buff;

            // Erik's patch
            path = path.Replace('/', '\\');
            path = path.Replace("%20", " ");

            Globals.gLogger.InstallLog();
            Globals.gnErrors = 0;
            wxFileName fname = new wxFileName(path);

            wxPorting.wxSetWorkingDirectory(fname.GetPath());
            String ext = string.Copy(fname.GetExt()).ToLower();

            switch (ext)
            {
            case "zip":
                Globals.FreeFileList();
                String trkName = string.Copy(fname.GetName());
                trkName += I18N.T(".trk");
                Globals.ReadZipFile(path);
                SimCommand cmd;
                cmd = restore ?
                      (LoadBaseCommand) new LoadCommand(trkName) :
                      (LoadBaseCommand) new OpenCommand(trkName);

                Globals.trainsim_cmd(cmd);
                Globals.current_project = path;
                break;

            case "trk":
                throw new NotImplementedException();
            //  Globals.FreeFileList();
            //  buff = String.Format(I18N.T("%s %s"), restore ? I18N.T("load") : I18N.T("open"), path);
            //  Globals.trainsim_cmd(buff);
            //  Globals.current_project = path;

            case "tdp":
                throw new NotImplementedException();

            //  Globals.FreeFileList();
            //  buff = String.Format(I18N.T("%s %s"), restore ? I18N.T("load") : I18N.T("puzzle"), path);
            //  Globals.trainsim_cmd(buff);
            //  Globals.current_project = path;
            case "sav":
                throw new NotImplementedException();
            //  Globals.FreeFileList();
            //  Globals.savedGame = path;
            //  buff = String.Format(I18N.T("restore %s"), path);
            //  buff = buff.Substring(0, Globals.wxStrlen(buff) - 4);	 // remove extension
            //  Globals.trainsim_cmd(buff);

            default:
                wx.MessageDialog.MessageBox(wxPorting.L("This file type is not recognized."));
                Globals.gLogger.UninstallLog();
                return;
            }

            //int pg = m_frame.m_top.FindPage(wxPorting.L("Layout"));
            //if(pg >= 0)
            //  m_frame.m_top.Selection = (pg);
            //if(m_frame.m_trainInfo != null)
            //  m_frame.m_trainInfo.Update(null);

            //Globals.gLogger.UninstallLog();

            //  Add newly opened file to list of old files

            //int i;

            //for(i = 0; i < m_nOldSimulations; ++i) {
            //  if(path == m_oldSimulations[i]) {
            //    while(i > 0) {
            //      m_oldSimulations[i] = m_oldSimulations[i - 1];
            //      --i;
            //    }
            //    m_oldSimulations[0] = path;
            //    return;
            //  }
            //}
            //for(i = Configuration.MAX_OLD_SIMULATIONS - 1; i > 0; --i)
            //  m_oldSimulations[i] = m_oldSimulations[i - 1];
            //m_oldSimulations[0] = path;
            //if(m_nOldSimulations < Configuration.MAX_OLD_SIMULATIONS)
            //  ++m_nOldSimulations;
        }