Пример #1
0
 /// <summary>
 /// IDが現在の一覧内に存在するか確認します。
 /// </summary>
 /// <param name="ID">検索対象のID</param>
 /// <param name="site">検索対象のサイト</param>
 /// <returns>見つかった場合はtrue, 見つからなかった場合はfalseを返します。</returns>
 public bool IsExistAccount(string ID, Accounts.AccountProperties.LoginSite site)
 {
     Accounts.AccountProperties tmp = this.ContainAccount(ID, site);
     if (tmp == null)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Пример #2
0
 /// <summary>
 /// アカウント情報を一覧から削除します。
 /// </summary>
 /// <param name="id">アカウントID</param>
 /// <param name="site">サイトID</param>
 public void DeleteAccount(string id, Accounts.AccountProperties.LoginSite site)
 {
     Accounts.AccountProperties props = this.ContainAccount(id, site);
     if (props.Equals(null))
     {
         SimpleLogger.WriteLine("ID: \"" + id + "\" is already deleted or nothing.");
         MessageBox.Show("ID: \" " + id + " \"は存在しません。", "TricksterTools", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     AccountData.Remove(props);
     SimpleLogger.WriteLine("ID: \"" + id + "\" is deleted.");
 }
Пример #3
0
        /// <summary>
        /// 現在保持しているアカウント情報一覧の中から指定の文字列のIDが含まれているか検索します。
        /// 検索方法については完全一致のみが行われます。
        /// </summary>
        /// <param name="ID">検索するID</param>
        /// <param name="site">サイト</param>
        /// <returns>見つかった場合対象のAccountPropertiesを返します。見つからなかった場合はnullを返します。</returns>
        public Accounts.AccountProperties ContainAccount(string ID, Accounts.AccountProperties.LoginSite site)
        {
            IEnumerator ienum = AccountData.GetEnumerator();

            while (ienum.MoveNext())
            {
                Accounts.AccountProperties acprop = (Accounts.AccountProperties)ienum.Current;
                if (acprop.ID == ID && acprop.Site == site)
                {
                    return(acprop);
                }
            }
            SimpleLogger.WriteLine("\"" + ID + "\" was not found.");
            return(null);
        }
Пример #4
0
 /// <summary>
 /// アカウント情報を追加します。
 /// </summary>
 /// <param name="props">アカウントプロパティ</param>
 public void AddAccount(Accounts.AccountProperties props)
 {
     AccountData.Add(props);
 }
Пример #5
0
                /// <summary>
                /// XMLファイルからIDとパスワードを読み込み、ハッシュテーブル化する
                /// </summary>
                ///
                /// <param name="string">読み込むテキストファイル名</param>
                /// <returns>IDをキー、Passwodを値としたハッシュテーブル</returns>
                public static ArrayList loadAccountKey(string filename)
                {
                    string filepath = "";

                    if (Path.IsPathRooted(filename))
                    {
                        filepath = filename;
                        filename = Path.GetFileName(filename);
                    }
                    else
                    {
                        filepath = Path.GetFullPath(@".\" + filename);
                    }
                    if (File.Exists(filepath))
                    {
                        try
                        {
                            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(XmlAccount));
                            System.IO.FileStream fs        = new System.IO.FileStream(filepath, System.IO.FileMode.Open);
                            XmlMyAccounts        loadDatas = (XmlMyAccounts)serializer.Deserialize(fs);

                            XmlAccount[] dataPack = (XmlAccount[])loadDatas.AccountList;
                            foreach (XmlAccount data in dataPack)
                            {
                                Accounts.AccountProperties props = new Accounts.AccountProperties();
                                props.ID       = data.ID;
                                props.Password = Common.DecryptString(data.Password, AccountController.MasterKey);
                                if (data.Site.Equals(null))
                                {
                                    props.Site = Accounts.AccountProperties.LoginSite.Official;
                                }
                                else
                                {
                                    try
                                    {
                                        props.Site = (Accounts.AccountProperties.LoginSite)data.Site;
                                    }
                                    catch (Exception e)
                                    {
                                        SimpleLogger.WriteLine(e.Message);
                                        props.Site = Accounts.AccountProperties.LoginSite.Official;
                                    }
                                }

                                AccountData.Add(props);
                            }
                            fs.Close();

                            return(AccountData);
                        }
                        catch (FileLoadException ex)
                        {
                            SimpleLogger.WriteLine(ex.Message);
                            MessageBox.Show("例外エラー:\nファイルの読み込み二失敗しました。", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(AccountData);
                        }
                    }
                    else
                    {
                        MessageBox.Show("アカウント情報ファイルを読み込めませんでした。" + Environment.NewLine + "'" + filepath + "'", "Trickster Tools", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(AccountData);
                    }
                }
Пример #6
0
                /// <summary>
                /// XMLファイルからIDとパスワードを読み込み、ハッシュテーブル化する
                /// </summary>
                ///
                /// <param name="filename">読み込むXMLファイル名</param>
                /// <param name="keyword">アカウントデータを読み込むキー</param>
                /// <returns>IDをキー、Passwodを値としたハッシュテーブル</returns>
                public void loadAccounts(string filename, string keyword)
                {
                    string filepath = "";

                    if (Path.IsPathRooted(filename))
                    {
                        filepath = filename;
                        filename = Path.GetFileName(filename);
                    }
                    else
                    {
                        filepath = Path.GetFullPath(Environment.CurrentDirectory + @"\" + filename);
                    }
                    if (File.Exists(filepath))
                    {
                        try
                        {
                            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(XmlTricksterRoot));
                            System.IO.FileStream fs           = new System.IO.FileStream(filepath, System.IO.FileMode.Open);
                            XmlTricksterRoot     XmlRoot      = (XmlTricksterRoot)serializer.Deserialize(fs);
                            XmlMyAccounts        accountDatas = new XmlMyAccounts();
                            accountDatas = XmlRoot.MyAccount;
                            String PasswordDecryptKey;
                            PasswordDecryptKey = getKeyword(accountDatas.EncryptKey);

                            if (AccountController.MasterKey != PasswordDecryptKey)
                            {
                                SimpleLogger.WriteLine("failed to match MasterKey and EncryptedKey in account data.");
                                MessageBox.Show("暗号化キーワードが一致しないためアカウント情報を読み込めませんでした。", "アカウント情報読み込みエラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                            AccountController.isLoadedAccount = true;

                            XmlAccount[] dataPack = (XmlAccount[])accountDatas.AccountList;

                            foreach (XmlAccount data in dataPack)
                            {
                                Accounts.AccountProperties props = new Accounts.AccountProperties();
                                //AccountData[data.ID] = Common.DecryptString(data.Password, AccountController.MasterKey);
                                props.ID       = data.ID;
                                props.Password = Common.DecryptString(data.Password, PasswordDecryptKey);
                                if (data.Site.Equals(null))
                                {
                                    props.Site = Accounts.AccountProperties.LoginSite.Official;
                                }
                                else
                                {
                                    try
                                    {
                                        props.Site = (Accounts.AccountProperties.LoginSite)data.Site;
                                    }catch (Exception e) {
                                        SimpleLogger.WriteLine(e.Message);
                                        props.Site = Accounts.AccountProperties.LoginSite.Official;
                                    }
                                }

                                AccountData.Add(props);
                            }
                            fs.Close();
                        }
                        catch (FileLoadException fle)
                        {
                            SimpleLogger.WriteLine(fle.GetType().ToString() + Environment.NewLine + fle.Message);
                            //MessageBox.Show("例外エラー:\nファイルの読み込みに失敗しました。", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            //return;
                            throw fle;
                        }
                        catch (System.Xml.XmlException xe)
                        {
                            SimpleLogger.WriteLine(xe.GetType().ToString() + Environment.NewLine + xe.Message);
                            //MessageBox.Show("例外エラー:\nデータの処理に失敗しました。", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            //return;
                            throw xe;
                        }
                        catch (System.UnauthorizedAccessException uae)
                        {
                            SimpleLogger.WriteLine(uae.GetType().ToString() + Environment.NewLine + uae.Message);
                            //MessageBox.Show("例外エラー:\nアカウントファイルが読み取り専用か、権限がないため読み込めませんでした。", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            //return;
                            throw uae;
                        }
                        catch (System.InvalidOperationException ioe)
                        {
                            SimpleLogger.WriteLine(ioe.GetType().ToString() + Environment.NewLine + ioe.Message);
                            //MessageBox.Show("例外エラー:\n無効なメソッドの呼び出しが行われました。", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            //return;
                            throw ioe;
                        }
                    }
                    else
                    {
                        SimpleLogger.WriteLine("account file 'accounts.dat' could not read/found.");
                        MessageBox.Show("アカウント情報ファイルを読み込めませんでした。" + Environment.NewLine + "'" + filepath + "'", "Trickster Tools", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        isLoadedAccount = false;
                        return;
                    }
                }
Пример #7
0
                public void saveAccounts(string filename, string keyword)
                {
                    string PasswordEncryptKey;

                    XmlAccount[] config = new XmlAccount[AccountData.Count];

                    PasswordEncryptKey = setKeyword(keyword);
                    IEnumerator ienum = AccountData.GetEnumerator();
                    int         i     = 0;

                    while (ienum.MoveNext())
                    {
                        Accounts.AccountProperties acprop = (Accounts.AccountProperties)ienum.Current;
                        config[i]          = new XmlAccount();
                        config[i].ID       = acprop.ID;
                        config[i].Password = Common.EncryptString(acprop.Password, keyword);
                        config[i].Site     = (int)acprop.Site;
                        i++;
                    }
                    XmlMyAccounts accountdatas = new XmlMyAccounts();

                    accountdatas.AccountList = config;
                    accountdatas.EncryptKey  = PasswordEncryptKey;

                    XmlTricksterRoot XmlRoot = new XmlTricksterRoot();

                    XmlRoot.MyAccount = accountdatas;


                    string filepath = "";

                    if (Path.IsPathRooted(filename))
                    {
                        filepath = filename;
                        filename = Path.GetFileName(filename);
                    }
                    else
                    {
                        filepath = Path.GetFullPath(Environment.CurrentDirectory + @"\" + filename);
                    }

                    if (!File.Exists(filepath))
                    {
                        // ファイルがなければ作成
                        FileStream fs = new FileStream(filepath, FileMode.Create);
                        fs.Close();
                    }

                    FileInfo fi = new FileInfo(filepath);

                    if (fi.IsReadOnly)
                    {
                        SimpleLogger.WriteLine("could not write to file \"" + filepath + "\"");
                        MessageBox.Show("アカウント情報ファイルは読み取り専用のため、保存できません。", "TricksterTools", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (AccountData.Count > 0)
                    {
                        try
                        {
                            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(XmlTricksterRoot));
                            FileStream fs = new FileStream(filepath, FileMode.Create);
                            serializer.Serialize(fs, XmlRoot);
                            fs.Close();
                        }

                        /*
                         * catch (System.Security.SecurityException se)
                         * {
                         *  SimpleLogger.WriteLine(se.GetType().ToString() + Environment.NewLine + se.Message);
                         *  //MessageBox.Show("例外エラー:\nセキュリティエラーです。", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         *  throw se;
                         * }
                         */
                        catch (System.IO.IOException ioe)
                        {
                            SimpleLogger.WriteLine(ioe.GetType().ToString() + Environment.NewLine + ioe.Message);
                            //MessageBox.Show("例外エラー:\n入出力時にエラーが発生しました。", "IOException error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            throw ioe;
                        }
                        catch (System.Xml.XmlException xe)
                        {
                            SimpleLogger.WriteLine(xe.GetType().ToString() + Environment.NewLine + xe.Message);
                            //MessageBox.Show("例外エラー:\nアカウント情報読み込みエラー", "XmlException error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            throw xe;
                        }
                        catch (System.Exception e)
                        {
                            SimpleLogger.WriteLine(e.GetType().ToString() + Environment.NewLine + e.Message);
                            //MessageBox.Show("例外エラー:\n原因の特定ができませんでした。", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            throw e;
                        }
                    }
                }
Пример #8
0
        private void notifyIcon_MouseClick(object sender, MouseEventArgs e)
        {
            TricksterTools.Library.Win32API.SetForegroundWindow(new System.Runtime.InteropServices.HandleRef(this, this.Handle));

            Point mp = Control.MousePosition;

            /** ハッシュテーブルからIDを読み込む **/
            // 保存元のファイル名
            //string fileName = "config.txt";
            //System.Collections.Hashtable accounts = Program.loadConfig(fileName);
            System.Collections.SortedList links = SettingController.Links;

            if (e.Button == MouseButtons.Left)
            {
                #region 左クリック時

                this.contextMenuStrip_Left.Items.Clear();

                if (AccountController.AccountData.Count == 0)
                {
                    this.contextMenuStrip_Left.Items.Add("No Registered ID");
                    this.contextMenuStrip_Left.Enabled = false;
                }
                else
                {
                    this.contextMenuStrip_Left.Enabled = true;
                    IEnumerator ienum = AccountController.AccountData.GetEnumerator();
                    while (ienum.MoveNext())
                    {
                        Accounts.AccountProperties acprop = (Accounts.AccountProperties)ienum.Current;
                        string ID       = acprop.ID;
                        string Password = acprop.Password;

                        ToolStripMenuItem items = new ToolStripMenuItem();
                        items.Text = ID;

                        if (acprop.Site == Accounts.AccountProperties.LoginSite.Official)
                        {
                            items.Image = (Image)Properties.Resources.official.ToBitmap();
                        }
                        else if (acprop.Site == Accounts.AccountProperties.LoginSite.HanGame)
                        {
                            items.Image = (Image)Properties.Resources.hangame.ToBitmap();
                        }
                        else if (acprop.Site == Accounts.AccountProperties.LoginSite.AtGames)
                        {
                            items.Image = (Image)Properties.Resources.atgames.ToBitmap();
                        }
                        else if (acprop.Site == Accounts.AccountProperties.LoginSite.Gamers1)
                        {
                            //items.Image = (Image)Properties.Resources.lievo.ToBitmap();
                            items.Image = (Image)Properties.Resources.gamers1.ToBitmap();
                        }
                        else
                        {
                            items.Image = (Image)Properties.Resources.official.ToBitmap();
                        }


                        items.Click += delegate
                        {
                            if (!Common.isInstalled()) // クライアントがインストールされているか
                            {
                                MessageBox.Show("トリックスター クライアントがインストールされていません。" + Environment.NewLine +
                                                "クライアントプログラムをインストールして再度実行してください。", "TSLoginManager", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                //MessageBox.Show("TRICKSTER client program is not installed in this computer." + Environment.NewLine +
                                //    "Please try to install and run.", "TSLoginManager");
                            }
                            else
                            {
                                SimpleLogger.Write("auto login start...");
                                //LoginController.startGame(ID, Password);
                                if (acprop.Site == Accounts.AccountProperties.LoginSite.Official)
                                {
                                    SimpleLogger.WriteLine("Official");
                                    OfficialLoginController.setPluginHost(this);
                                    OfficialLoginController.startGame(ID, Password);
                                }
                                else if (acprop.Site == Accounts.AccountProperties.LoginSite.HanGame)
                                {
                                    SimpleLogger.WriteLine("HanGame");
                                    HanGameLoginController.setPluginHost(this);
                                    HanGameLoginController.startGame(ID, Password);
                                }
                                else if (acprop.Site == Accounts.AccountProperties.LoginSite.AtGames)
                                {
                                    SimpleLogger.WriteLine("AtGames");
                                    AtGamesLoginController.setPluginHost(this);
                                    AtGamesLoginController.startGame(ID, Password);
                                }
                                else if (acprop.Site == Accounts.AccountProperties.LoginSite.Gamers1)
                                {
                                    SimpleLogger.WriteLine("Lievo");
                                    //LievoLoginController.setPluginHost(this);
                                    //LievoLoginController.startGame(ID, Password);
                                    GamersOneLoginController.setPluginHost(this);
                                    GamersOneLoginController.startGame(ID, Password);
                                }
                                else
                                {
                                    OfficialLoginController.setPluginHost(this);
                                    OfficialLoginController.startGame(ID, Password);
                                }
                            }
                        };
                        this.contextMenuStrip_Left.Items.Add(items);
                    }
                }

                //this.notifyIcon.ContextMenuStrip = this.contextMenuStrip_Left;
                //this.contextMenuStrip_Left.Show(mp.X - contextMenuStrip_Left.Width, mp.Y);
                this.contextMenuStrip_Left.Show(this, PointToClient(Cursor.Position));
                #endregion
            }
            else if (e.Button == MouseButtons.Right)
            {
                #region 右クリック時

                //this.ToolStripMenuItem_Right_Edit.DropDownItems.Clear();
                //this.ToolStripMenuItem_Right_Edit.DisplayStyle = ToolStripItemDisplayStyle.Text;
                this.ToolStripMenuItem_Right_Delete.DropDownItems.Clear();
                this.ToolStripMenuItem_Right_Delete.DisplayStyle = ToolStripItemDisplayStyle.Text;
                this.ToolStripMenuItem_Right_Plugins.DropDownItems.Clear();
                this.ToolStripMenuItem_Right_Plugins.DisplayStyle = ToolStripItemDisplayStyle.Text;
                this.ToolStripMenuItem_Right_Links.DropDownItems.Clear();
                this.ToolStripMenuItem_Right_Links.DisplayStyle = ToolStripItemDisplayStyle.Text;
                this.ToolStripMenuItem_Right_Tool_PluginInfo.DropDownItems.Clear();
                this.ToolStripMenuItem_Right_Tool_PluginInfo.DisplayStyle = ToolStripItemDisplayStyle.Text;

                #region アカウント削除用一覧
                if (AccountController.AccountData.Count == 0)
                {
                    //this.ToolStripMenuItem_Right_Edit.DropDownItems.Add("No Registered ID");
                    //this.ToolStripMenuItem_Right_Edit.Enabled = false;
                    //this.ToolStripMenuItem_Right_Delete.DropDownItems.Add("No Registered ID");
                    this.ToolStripMenuItem_Right_Delete.Enabled = false;
                }
                else
                {
                    //this.ToolStripMenuItem_Right_Edit.Enabled = true;
                    //this.ToolStripMenuItem_Right_Edit.DropDown.Enabled = true;
                    this.ToolStripMenuItem_Right_Delete.Enabled          = true;
                    this.ToolStripMenuItem_Right_Delete.DropDown.Enabled = true;

                    this.contextMenuStrip_Left.Enabled = true;
                    IEnumerator ienum = AccountController.AccountData.GetEnumerator();
                    while (ienum.MoveNext())
                    {
                        //ToolStripMenuItem edit_items = new ToolStripMenuItem();
                        ToolStripMenuItem          del_items = new ToolStripMenuItem();
                        Accounts.AccountProperties acprop    = (Accounts.AccountProperties)ienum.Current;
                        string ID = acprop.ID;
                        //string Password = accounts[ID].ToString();

                        //edit_items.Text = ID;
                        del_items.Text = ID;

                        /*
                         * edit_items.Click += delegate
                         * {
                         *  EditForm edtFrm = new EditForm(ID);
                         *  edtFrm.Show(); // フォームの表示
                         * };
                         * this.ToolStripMenuItem_Right_Edit.DropDownItems.Add(edit_items);
                         */
                        if (acprop.Site == Accounts.AccountProperties.LoginSite.Official)
                        {
                            del_items.Image = (Image)Properties.Resources.official.ToBitmap();
                        }
                        else if (acprop.Site == Accounts.AccountProperties.LoginSite.HanGame)
                        {
                            del_items.Image = (Image)Properties.Resources.hangame.ToBitmap();
                        }
                        else if (acprop.Site == Accounts.AccountProperties.LoginSite.AtGames)
                        {
                            del_items.Image = (Image)Properties.Resources.atgames.ToBitmap();
                        }
                        else if (acprop.Site == Accounts.AccountProperties.LoginSite.Gamers1)
                        {
                            del_items.Image = (Image)Properties.Resources.lievo.ToBitmap();
                        }
                        else
                        {
                            del_items.Image = (Image)Properties.Resources.official.ToBitmap();
                        }

                        del_items.Click += delegate
                        {
                            DialogResult diagres = MessageBox.Show("ID: \" " + ID + " \" を削除しようとしています。" + Environment.NewLine +
                                                                   "よろしいですか?", "TSLoginManager", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
                            if (diagres == DialogResult.No)
                            {
                                return;
                            }
                            ProgramController.AController.delete(ID, acprop.Site);

                            /*
                             * この時点でもアカウント情報をファイルに保存する
                             */
                            string filename = Environment.CurrentDirectory + @"\accounts.dat";
                            if (AccountController.isLoadedAccount && (AccountController.AccountData.Count > 0))
                            {
                                ProgramController.AController.saveAccounts(filename, AccountController.MasterKey);
                            }
                        };
                        this.ToolStripMenuItem_Right_Delete.DropDownItems.Add(del_items);
                    }
                }
                #endregion
                #region プラグイン一覧
                if (Program.plugins.Length == 0)
                {
                    //this.ToolStripMenuItem_Right_Plugins.DropDownItems.Add("No Plugin");
                    this.ToolStripMenuItem_Right_Plugins.Enabled = false;
                }
                else
                {
                    this.ToolStripMenuItem_Right_Plugins.Enabled          = true;
                    this.ToolStripMenuItem_Right_Plugins.DropDown.Enabled = true;

                    foreach (TricksterTools.Plugins.IPlugin plugin in Program.plugins)
                    {
                        ToolStripMenuItem_Plugin PluginItems = new ToolStripMenuItem_Plugin();
                        PluginItems.setPluginName(plugin.GetType().Name, plugin.Name);
                        PluginItems.Click += delegate
                        {
                            PluginController.PluginRun(Program.plugins, PluginItems.ClassName);
                        };
                        this.ToolStripMenuItem_Right_Plugins.DropDownItems.Add(PluginItems);
                    }
                }
                #endregion
                #region プラグイン情報
                if (Program.plugins.Length == 0)
                {
                    //this.ToolStripMenuItem_Right_Tool_PluginInfo.DropDownItems.Add("No Plugin");
                    this.ToolStripMenuItem_Right_Tool_PluginInfo.Enabled = false;
                }
                else
                {
                    this.ToolStripMenuItem_Right_Tool_PluginInfo.Enabled          = true;
                    this.ToolStripMenuItem_Right_Tool_PluginInfo.DropDown.Enabled = true;

                    foreach (TricksterTools.Plugins.IPlugin plugin in Program.plugins)
                    {
                        ToolStripMenuItem_Plugin PluginInfoItems = new ToolStripMenuItem_Plugin();
                        PluginInfoItems.setPluginName(plugin.GetType().Name, plugin.Name);
                        PluginInfoItems.Click += delegate
                        {
                            //PluginInfoForm pluginInfoForm = new PluginInfoForm(plugin);
                            PluginInfoForm pluginInfoForm = new PluginInfoForm(PluginController.getPluginInfo(Program.plugins, PluginInfoItems.ClassName));
                            pluginInfoForm.Show();
                            pluginInfoForm.Owner = this;
                        };
                        this.ToolStripMenuItem_Right_Tool_PluginInfo.DropDownItems.Add(PluginInfoItems);
                    }
                }
                #endregion
                #region リンク一覧

                if (links.ContainsKey("__TSLM_NULL__"))
                {
                    this.ToolStripMenuItem_Right_Links.DropDownItems.Add("No Links");
                    this.ToolStripMenuItem_Right_Links.Enabled = false;
                }
                else
                {
                    this.ToolStripMenuItem_Right_Links.Enabled          = true;
                    this.ToolStripMenuItem_Right_Links.DropDown.Enabled = true;

                    foreach (string key in links.Keys)
                    {
                        ToolStripMenuItem link_items = new ToolStripMenuItem();
                        string            SiteName   = key;
                        link_items.Text   = SiteName;
                        link_items.Click += delegate
                        {
                            System.Diagnostics.Process.Start(links[SiteName].ToString());
                        };
                        this.ToolStripMenuItem_Right_Links.DropDownItems.Add(link_items);
                    }
                }
                #endregion
                #region プラグイン情報
                //this.notifyIcon.ContextMenuStrip = this.contextMenuStrip_Right;
                this.Activate();
                this.contextMenuStrip_Right.Show(mp.X, mp.Y + 275);
                //this.contextMenuStrip_Right.Show(this, Cursor.Position.X - this.Location.X, Cursor.Position.X - this.Location.X);
                //this.contextMenuStrip_Right.Show(PointToScreen(Cursor.Position));

                ToolStripDropDownMenu tsddm_r_del = (ToolStripDropDownMenu)this.ToolStripMenuItem_Right_Delete.DropDown;
                tsddm_r_del.ShowImageMargin = true;
                ToolStripDropDownMenu tsddm_r_link = (ToolStripDropDownMenu)this.ToolStripMenuItem_Right_Links.DropDown;
                tsddm_r_link.ShowImageMargin = false;
                ToolStripDropDownMenu tsddm_r_plugin = (ToolStripDropDownMenu)this.ToolStripMenuItem_Right_Plugins.DropDown;
                tsddm_r_plugin.ShowImageMargin = false;
                ToolStripDropDownMenu tsddm_r_tool = (ToolStripDropDownMenu)this.ToolStripMenuItem_Right_Tool.DropDown;
                tsddm_r_tool.ShowImageMargin = false;
                ToolStripDropDownMenu tsddm_r_tool_setting = (ToolStripDropDownMenu)this.ToolStripMenuItem_Right_Tool_Settings.DropDown;
                tsddm_r_tool_setting.ShowImageMargin = false;
                ToolStripDropDownMenu tsddm_r_tool_plguininfo = (ToolStripDropDownMenu)this.ToolStripMenuItem_Right_Tool_PluginInfo.DropDown;
                tsddm_r_tool_plguininfo.ShowImageMargin = false;
                #endregion
                #endregion
            }
        }
Пример #9
0
                /// <summary>
                /// XML�t�@�C������ID�ƃp�X���[�h��ǂݍ��݁A�n�b�V���e�[�u��������
                /// </summary>
                /// 
                /// <param name="string">�ǂݍ��ރe�L�X�g�t�@�C����</param>
                /// <returns>ID��L�[�APasswod��l�Ƃ����n�b�V���e�[�u��</returns>
                public static ArrayList loadAccountKey(string filename)
                {
                    string filepath = "";
                    if (Path.IsPathRooted(filename))
                    {
                        filepath = filename;
                        filename = Path.GetFileName(filename);
                    }
                    else
                    {
                        filepath = Path.GetFullPath(@".\" + filename);
                    }
                    if (File.Exists(filepath))
                    {
                        try
                        {
                            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(XmlAccount));
                            System.IO.FileStream fs = new System.IO.FileStream(filepath, System.IO.FileMode.Open);
                            XmlMyAccounts loadDatas = (XmlMyAccounts)serializer.Deserialize(fs);

                            XmlAccount[] dataPack = (XmlAccount[])loadDatas.AccountList;
                            foreach (XmlAccount data in dataPack)
                            {
                                Accounts.AccountProperties props = new Accounts.AccountProperties();
                                props.ID = data.ID;
                                props.Password = Common.DecryptString(data.Password, AccountController.MasterKey);
                                if (data.Site.Equals(null))
                                {
                                    props.Site = Accounts.AccountProperties.LoginSite.Official;
                                }
                                else
                                {
                                    try
                                    {
                                        props.Site = (Accounts.AccountProperties.LoginSite)data.Site;
                                    }
                                    catch (Exception e)
                                    {
                                        SimpleLogger.WriteLine(e.Message);
                                        props.Site = Accounts.AccountProperties.LoginSite.Official;
                                    }
                                }

                                AccountData.Add(props);
                            }
                            fs.Close();

                            return AccountData;
                        }
                        catch (FileLoadException ex)
                        {
                            SimpleLogger.WriteLine(ex.Message);
                            MessageBox.Show("��O�G���[:\n�t�@�C���̓ǂݍ��ݓ񎸔s���܂����B", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return AccountData;
                        }
                    }
                    else
                    {
                        MessageBox.Show("�A�J�E���g���t�@�C����ǂݍ��߂܂���ł����B" + Environment.NewLine + "'" + filepath + "'", "Trickster Tools", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return AccountData;
                    }
                }
Пример #10
0
                /// <summary>
                /// XML�t�@�C������ID�ƃp�X���[�h��ǂݍ��݁A�n�b�V���e�[�u��������
                /// </summary>
                /// 
                /// <param name="filename">�ǂݍ���XML�t�@�C����</param>
                /// <param name="keyword">�A�J�E���g�f�[�^��ǂݍ��ރL�[</param>
                /// <returns>ID��L�[�APasswod��l�Ƃ����n�b�V���e�[�u��</returns>
                public void loadAccounts(string filename, string keyword)
                {
                    string filepath = "";
                    if (Path.IsPathRooted(filename))
                    {
                        filepath = filename;
                        filename = Path.GetFileName(filename);
                    }
                    else
                    {
                        filepath = Path.GetFullPath(Environment.CurrentDirectory + @"\" + filename);
                    }
                    if (File.Exists(filepath))
                    {
                        try
                        {
                            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(XmlTricksterRoot));
                            System.IO.FileStream fs = new System.IO.FileStream(filepath, System.IO.FileMode.Open);
                            XmlTricksterRoot XmlRoot = (XmlTricksterRoot)serializer.Deserialize(fs);
                            XmlMyAccounts accountDatas = new XmlMyAccounts();
                            accountDatas = XmlRoot.MyAccount;
                            String PasswordDecryptKey;
                            PasswordDecryptKey = getKeyword(accountDatas.EncryptKey);

                            if (AccountController.MasterKey != PasswordDecryptKey)
                            {
                                SimpleLogger.WriteLine("failed to match MasterKey and EncryptedKey in account data.");
                                MessageBox.Show("�Í����L�[���[�h����v���Ȃ����߃A�J�E���g����ǂݍ��߂܂���ł����B", "�A�J�E���g���ǂݍ��݃G���[", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                            AccountController.isLoadedAccount = true;

                            XmlAccount[] dataPack = (XmlAccount[])accountDatas.AccountList;

                            foreach (XmlAccount data in dataPack)
                            {
                                Accounts.AccountProperties props = new Accounts.AccountProperties();
                                //AccountData[data.ID] = Common.DecryptString(data.Password, AccountController.MasterKey);
                                props.ID = data.ID;
                                props.Password = Common.DecryptString(data.Password, PasswordDecryptKey);
                                if (data.Site.Equals(null))
                                {
                                    props.Site = Accounts.AccountProperties.LoginSite.Official;
                                }
                                else
                                {
                                    try
                                    {
                                        props.Site = (Accounts.AccountProperties.LoginSite)data.Site;
                                    }catch(Exception e){
                                        SimpleLogger.WriteLine(e.Message);
                                        props.Site = Accounts.AccountProperties.LoginSite.Official;
                                    }
                                }

                                AccountData.Add(props);
                            }
                            fs.Close();
                        }
                        catch (FileLoadException fle)
                        {
                            SimpleLogger.WriteLine(fle.GetType().ToString() + Environment.NewLine + fle.Message);
                            //MessageBox.Show("��O�G���[:\n�t�@�C���̓ǂݍ��݂Ɏ��s���܂����B", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            //return;
                            throw fle;
                        }
                        catch (System.Xml.XmlException xe)
                        {
                            SimpleLogger.WriteLine(xe.GetType().ToString() + Environment.NewLine + xe.Message);
                            //MessageBox.Show("��O�G���[:\n�f�[�^�̏����Ɏ��s���܂����B", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            //return;
                            throw xe;
                        }
                        catch (System.UnauthorizedAccessException uae)
                        {
                            SimpleLogger.WriteLine(uae.GetType().ToString() + Environment.NewLine + uae.Message);
                            //MessageBox.Show("��O�G���[:\n�A�J�E���g�t�@�C�����ǂݎ���p���A�������Ȃ����ߓǂݍ��߂܂���ł����B", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            //return;
                            throw uae;
                        }
                        catch (System.InvalidOperationException ioe)
                        {
                            SimpleLogger.WriteLine(ioe.GetType().ToString() + Environment.NewLine + ioe.Message);
                            //MessageBox.Show("��O�G���[:\n�����ȃ��\�b�h�̌Ăяo�����s���܂����B", "Exceptional error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            //return;
                            throw ioe;
                        }
                    }
                    else
                    {
                        SimpleLogger.WriteLine("account file 'accounts.dat' could not read/found.");
                        MessageBox.Show("�A�J�E���g���t�@�C����ǂݍ��߂܂���ł����B" + Environment.NewLine + "'" + filepath + "'", "Trickster Tools", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        isLoadedAccount = false;
                        return;
                    }
                }