Ejemplo n.º 1
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            //デバッガの準備
            Core.Debugger.TextBoxTraceListener tbtl = new Core.Debugger.TextBoxTraceListener(DebugTextBox);
            //Debug.Listeners.Add(tbtl);
            Trace.Listeners.Add(tbtl);
            String TMPDIR = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\tmp\";

            //tmpフォルダの作成
            if (System.IO.Directory.Exists(TMPDIR) == false)
            {
                System.IO.Directory.CreateDirectory(TMPDIR);
            }
            else
            {
                //tmpをクリアする
                foreach (String path in System.IO.Directory.GetFiles(TMPDIR))
                {
                    System.IO.File.Delete(path);
                }
            }

            //設定を読み出す
            Core.ApplicationSetting.SettingClass set;
            if (System.IO.File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\setting.xml"))
            {
                //XmlSerializerオブジェクトを作成
                System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Core.ApplicationSetting.SettingClass));
                //読み込むファイルを開く
                System.IO.FileStream fs = new System.IO.FileStream(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\setting.xml", System.IO.FileMode.Open);
                //XMLファイルから読み込み、逆シリアル化する
                set = (Core.ApplicationSetting.SettingClass)serializer.Deserialize(fs);
                //ファイルを閉じる
                fs.Close();
                //初回起動ではないのでフォーム非表示
                this.WindowState = FormWindowState.Minimized;
            }
            else
            {
                set = new Core.ApplicationSetting.SettingClass();
            }

            //初期化処理
            PutSettingToUI(set);
            initiTunes(set);
            //プラグインシステムの初期化
            plugin = new Plugin.PluginSystem(songmanage);
            plugin.StartThread();
            externalplayer = new Plugin.ExternalPlayerPipe();
            externalplayer.StartThread();
            externalplayer.onSongChangedEvent += externalplayer_onSongChangedEvent;

            this.FormClosing += MainWindow_Closing;
            this.Shown       += MainWindow_Shown;
            CheckForIllegalCrossThreadCalls = false;

            //更新の確認をする
            if (set.CheckUpdate == true)
            {
                updater = new UpdateChecker.Updater();
                updater.CheckUpdateFinished += updater_CheckUpdateFinished;
                Thread UpdaterThread = new Thread(updater.CheckUpdate);
                UpdaterThread.IsBackground = true;
                UpdaterThread.Start();
            }
        }
Ejemplo n.º 2
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            //デバッガの準備
            Core.Debugger.TextBoxTraceListener tbtl = new Core.Debugger.TextBoxTraceListener(DebugTextBox);
            //Debug.Listeners.Add(tbtl);
            Trace.Listeners.Add(tbtl);
            String TMPDIR = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\tmp\";
            //tmpフォルダの作成
            if (System.IO.Directory.Exists(TMPDIR) == false)
            {
                System.IO.Directory.CreateDirectory(TMPDIR);
            }
            else
            {
                //tmpをクリアする
                foreach(String path in System.IO.Directory.GetFiles(TMPDIR)){
                    System.IO.File.Delete(path);
                }
            }

            //設定を読み出す
            Core.ApplicationSetting.SettingClass set;
            if(System.IO.File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\setting.xml"))
            {
                //XmlSerializerオブジェクトを作成
                System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Core.ApplicationSetting.SettingClass));
                //読み込むファイルを開く
                System.IO.FileStream fs = new System.IO.FileStream(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\setting.xml", System.IO.FileMode.Open);
                //XMLファイルから読み込み、逆シリアル化する
                set = (Core.ApplicationSetting.SettingClass) serializer.Deserialize(fs);
                //ファイルを閉じる
                fs.Close();
                //初回起動ではないのでフォーム非表示
                this.WindowState = FormWindowState.Minimized;
            }
            else
            {
                set = new Core.ApplicationSetting.SettingClass();
            }

            //初期化処理
            PutSettingToUI(set);
            initiTunes(set);
            //プラグインシステムの初期化
            plugin = new Plugin.PluginSystem(songmanage);
            plugin.StartThread();
            externalplayer = new Plugin.ExternalPlayerPipe();
            externalplayer.StartThread();
            externalplayer.onSongChangedEvent += externalplayer_onSongChangedEvent;

            this.FormClosing += MainWindow_Closing;
            this.Shown += MainWindow_Shown;
            CheckForIllegalCrossThreadCalls = false;

            //更新の確認をする
            if (set.CheckUpdate == true)
            {
                updater = new UpdateChecker.Updater();
                updater.CheckUpdateFinished += updater_CheckUpdateFinished;
                Thread UpdaterThread = new Thread(updater.CheckUpdate);
                UpdaterThread.IsBackground = true;
                UpdaterThread.Start();
            }
        }