Beispiel #1
0
 public static bool ChangeDirectory(CodeData c,Form1 form)
 {
     if (c.MainArgument == c.CodeName)
     {
         form.MessageAdd(form.OptionValue.NowDirectory);
         return true;
     }
     if(c.MainArgument=="..")
     {
         form.OptionValue.NowDirectory = Directory.GetParent(form.OptionValue.NowDirectory).FullName;
         form.MessageAdd(form.OptionValue.NowDirectory);
         return true;
     }
     else
     {
         var d = Path.Combine(form.OptionValue.NowDirectory, c.MainArgument);
         if (!Directory.Exists(d))
         {
             MessageBox.Show(AddQuote(c.MainArgument) + "は存在しません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
             form.MessageAdd(AddQuote(c.MainArgument) + "は存在しません");
             return true;
         }
         form.OptionValue.NowDirectory = d;
         form.MessageAdd(form.OptionValue.NowDirectory);
     }
     return true;
 }
Beispiel #2
0
 public static bool Directories(CodeData c,Form1 form)
 {
     if (c.MainArgument == c.CodeName)
     {
         var d = Directory.GetDirectories(form.OptionValue.NowDirectory);
         foreach(var str in d)
         {
             form.MessageAdd((new DirectoryInfo(str)).Name);
         }
         return true;
     }
     else
     {
         return ChangeDirectory(c, form);
     }
 }
Beispiel #3
0
        public static bool Run(string code,Form1 form)
        {
            var c = new CodeData(code);
            if (!CodeFunctions.ContainsKey(c.CodeName))
            {
                return false;
            }
            form.MessageAdd(code);
            CodeFunctions[c.CodeName](c, form);

            return true;
        }
Beispiel #4
0
 public static bool Save(CodeData c,Form1 form)
 {
     var conf = c.OptionValue.ContainsKey("conf") ? (bool.Parse(c.OptionValue["conf"])) : form.OptionValue.SaveConf;
     var path =
         c.MainArgument == c.CodeName ?
         form.OptionValue.OpenFilePath:
         Path.Combine(form.OptionValue.NowDirectory, c.MainArgument);
     if(conf)
     {
         if (MessageBox.Show(
             AddQuote(path) + "に保存しますか",
             "確認",
             MessageBoxButtons.YesNo,
             MessageBoxIcon.Exclamation,
             MessageBoxDefaultButton.Button1) !=
                 DialogResult.Yes)
         {
             return true;
         }
     }
     try
     {
         File.WriteAllText(path, form.editSpace.Text);
         form.MessageAdd(AddQuote(path) + "に保存しました");
     }
     catch (Exception)
     {
         MessageBox.Show(AddQuote(path) + "に書き込めません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
         form.MessageAdd(AddQuote(path) + "に書き込めません");
     }
     return true;
 }
Beispiel #5
0
        public static bool Load(CodeData c,Form1 form)
        {
            var path = Path.Combine(form.OptionValue.NowDirectory, c.MainArgument);
            try
            {
                var str = File.ReadAllText(path);
                form.editSpace.Text = str;
                form.Text = "Editor:" + path;
                form.OptionValue.OpenFilePath = path;
                form.MessageAdd(AddQuote(path) + "を開きました");

            }
            catch (Exception)
            {
                MessageBox.Show(AddQuote(path) + "が開けません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                form.MessageAdd(AddQuote(path) + "が開けません");
            }
            return true;
        }