Esempio n. 1
0
 public void LoadQueue()
 {
     if (ini.Read("QueueCount", "File") != "")
     {
         bool cannadd;
         for (int i = 0; i < Int64.Parse(ini.Read("QueueCount", "File")); i++)
         {
             cannadd = true;
             try
             {
                 System.IO.StreamReader sr = new System.IO.StreamReader(ini.Read("Queue." + i.ToString(), "File"));
             }
             catch (FileNotFoundException)
             {
                 cannadd = false;
             }
             if (cannadd)
             {
                 recentFilepath.Enqueue(ini.Read("Queue." + i.ToString(), "File"));
                 if (ini.Read("Queue." + i.ToString(), "File") == null)
                 {
                     return;
                 }
             }
         }
     }
     BTFTranslator.DisplayQue(this.displayMenu);
 }
Esempio n. 2
0
        public async void SaveFile(string text, bool useDialog, string fileName = "untitled", string defaultExt = ".btf", string filter = "BTF Files(*.btf)|*.btf")
        {
            if (useDialog)
            {
                SaveFileDialog Savecode = new SaveFileDialog();
                string         dir      = "";
                Savecode.FileName   = fileName;
                Savecode.DefaultExt = defaultExt;
                Savecode.Filter     = filter;
                bool?result = Savecode.ShowDialog();
                if (result == true)
                {
                    dir = Savecode.FileName;
                    FileStream   fs = new FileStream(dir, FileMode.Create, FileAccess.Write);
                    StreamWriter sw = new StreamWriter(fs);
                    await sw.WriteLineAsync(text); // 파일 저장

                    filePath = Savecode.FileName;
                    if (!recentFilepath.Contains(Savecode.FileName))
                    {
                        if (recentFilepath.Count == Qlimit)
                        {
                            recentFilepath.Dequeue();
                            recentFilepath.Enqueue(filePath);
                        }
                        else if (recentFilepath.Count < Qlimit)
                        {
                            recentFilepath.Enqueue(filePath);
                        }
                        BTFTranslator.DisplayQue(this.displayMenu);
                    }
                    sw.Flush();
                    sw.Close();
                    fs.Close();
                }
            }
            else if (!useDialog)
            {
                StreamWriter sw = new StreamWriter(filePath, false);
                await sw.WriteAsync(text); // 파일 저장

                sw.Flush();
                sw.Close();
            }
        }
Esempio n. 3
0
        public async void LoadFile(string filter = "BTF Files (*.btf)|*.btf")//파일불러오기
        {
            loaderr = false;
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = filter;
            bool?result = dlg.ShowDialog();

            if (result == true)
            {
                using (System.IO.StreamReader sr = new System.IO.StreamReader(dlg.FileName))
                {
                    await Task.Run(() =>
                    {
                        this.reading  = sr.ReadToEnd();
                        this.filePath = dlg.FileName;
                    });

                    if (!recentFilepath.Contains(dlg.FileName))
                    {
                        if (recentFilepath.Count == Qlimit)
                        {
                            recentFilepath.Dequeue();
                            recentFilepath.Enqueue(filePath);
                        }
                        else if (recentFilepath.Count < Qlimit)
                        {
                            recentFilepath.Enqueue(filePath);
                        }
                        BTFTranslator.DisplayQue(this.displayMenu);
                    }
                }
            }
            else
            {
                loaderr = true;
            }
        }