Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //args = new[] { @"C:\Users\Yoshi\Desktop\Private.ytel" };
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            using (var main = new MainConfig())
            {
                if (args.Length < 1 || string.IsNullOrEmpty(args[0]))
                {
                    using (var initForm = new InitForm())
                    {
                        var result = initForm.ShowDialog();
                        if (result == DialogResult.OK)
                        {
                            main.CreateNewConf(
                                initForm.ConfName,
                                initForm.ConfDir,
                                initForm.Password,
                                initForm.DataDir);
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                else
                {
                    if (File.Exists(args[0]))
                    {
                        main.ReadFromFile(args[0]);
                    }
                    else
                    {
                        MessageBox.Show("引数は任意。(指定する場合はマスタパスの設定ファイル");
                        return;
                    }
                }
                Application.Run(main);
            }
        }
Ejemplo n.º 2
0
 internal static void ChangePassword(IMainConfig config)
 {
     if (!config.IsPasswordConfirmed)
     {
         using (var signIn = new SignIn())
         {
             signIn.Config = config;
             signIn.ShowDialog();
             if (signIn.DialogResult != DialogResult.OK)
             {
                 // 認証不通過。
                 return;
             }
         }
     }
     using (var changePassword = new InitForm()
     {
         IsAsAddNew = false,
         ConfName = config.ConfName,
     })
     {
         changePassword.ShowDialog();
         if (changePassword.DialogResult == DialogResult.OK)
         {
             string newPassword = changePassword.Password;
             string oldPassword = config.Password;
             foreach (ItemPolicy item in config.Items)
             {
                 item.ResavePassword(oldPassword, newPassword, config.DatFolder);
             }
             config.Password = newPassword;
             config.DatFolder = config.DatFolder;
             config.SaveToFile();
         }
     }
 }