Esempio n. 1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            bool   isNew;
            String strMuteId = "KomicAheGao_{57B300B2-DAF1-4C18-8A9C-30CC689DD6D0}";

            if (e.Args.Length > 0)
            {
                foreach (String arg in e.Args)
                {
                    if (arg == AppEnums.APP_ARG_AUTOSTART)
                    {
                        App.Current.Properties[AppEnums.APP_PROP_KEY_ISAUTOSTART] = true;
                    }
                }
            }

            // Create mutex
            _mutex = new Mutex(true, strMuteId, out isNew);

            if (!isNew)
            {
                Debug.WriteLine("KomicAheGao has opened");
                App.Current.Properties[AppEnums.APP_PROP_KEY_ISOPENED] = true;

                RegMethod.SetMessage(RegMethod.REG_Value_Open_Manage, true);
                Shutdown();
            }
            else
            {
                Debug.WriteLine("KomicAheGao Startup!");
                base.OnStartup(e);
            }
        }
Esempio n. 2
0
 public bool DetachExt(string extName)
 {
     if (RegMethod.DetachMpcBeExt(extName))
     {
         _extColle.Remove(extName);
         MainVM.SaveToFile(this);
         return(true);
     }
     return(false);
 }
Esempio n. 3
0
        public bool ReattachExt(string extName)
        {
            if (RegMethod.DetachMpcBeExt(extName))
            {
                if (RegMethod.AttachMpcBeExt(extName))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
 public bool AttachExt(string extName)
 {
     if (RegMethod.AttachMpcBeExt(extName))
     {
         //Save ext.
         _extColle.Add(extName);
         MainVM.SaveToFile(this);
     }
     else
     {
         return(false);
     }
     return(true);
 }
Esempio n. 5
0
        public bool AttachExt(List <string> extList)
        {
            foreach (string extName in extList)
            {
                if (RegMethod.AttachMpcBeExt(extName))
                {
                    //Save ext.
                    _extColle.Add(extName);
                }
            }

            MainVM.SaveToFile(this);

            return(true);
        }
Esempio n. 6
0
        /// <summary>
        /// MPC-BE關閉後,讀取Registry資訊並儲存置資料庫
        /// </summary>
        private static void SaveMpcBeFileHistoryToDB(string savePath)
        {
            //讀取MPC-BE登錄檔Recent File [x]資料
            Tuple <FilePosData, int> tuple = RegMethod.GetMpcBeRecentFileByPath(savePath);

            if (tuple.Item2 == -1)
            {
                return;
            }

            FilePosData saveData = tuple.Item1;
            FileInfo    fileInfo = new FileInfo(savePath);

            saveData.FileSize = fileInfo.Length;
            saveData.Name     = fileInfo.Name;

            //寫入資料庫
            _sqlCtrl.InsertData(saveData);
        }
Esempio n. 7
0
        private void BeginRegMessageHandle()
        {
            Task.Factory.StartNew(() =>
            {
                while (!_shutdown)
                {
                    object msg = RegMethod.GetMessage(RegMethod.REG_Value_Open_Manage);
                    if (msg != null)
                    {
                        bool isOpen = Convert.ToBoolean(msg);
                        if (isOpen)
                        {
                            App.Current.Dispatcher.Invoke(() =>
                            {
                                DLG_Manage dlg = new DLG_Manage();
                                dlg.Show();
                            });
                        }
                    }

                    SpinWait.SpinUntil(() => false, 100);
                }
            });
        }
Esempio n. 8
0
        private static void Main(string[] args)
        {
            Console.WriteLine(args[0]);
            Console.WriteLine(args[1]);

            Console.OutputEncoding = System.Text.Encoding.Unicode;

            if (args.Length == 0)
            {
                //無參數 nothing to do.
                return;
            }
            else if (args.Length == 1)
            {
                //只有一個參數,直接執行該參數
                Process.Start(args[0]);
                return;
            }
            else if (args.Length == 2)
            {
                //取出各參數
                String mpcbeExePath = args[0];
                String filePath     = args[1];
                String fileName     = Path.GetFileName(filePath);

                if (mpcbeExePath != null &&
                    mpcbeExePath != "" &&
                    filePath != null &&
                    filePath != "")
                {
                    //初始化資料庫
                    string launcherPath = Assembly.GetEntryAssembly().Location;
                    _sqlCtrl = new SqliteCtrl(Path.GetDirectoryName(launcherPath));
                    _sqlCtrl.Init();

                    _regWatcher = new RegWatcher();
                    _regWatcher.RegRecentFileChanged += On_MpcBe_RegChanged;

                    //讀取資料庫是否存在該檔案紀錄
                    FilePosData curData = _sqlCtrl.GetDataByFullPath(filePath);
                    if (curData != null)
                    {
                        //資料庫存在該檔案紀錄
                        //插入MPC-BE登錄檔歷史資料
                        RegMethod.SetMpcBeRecentFile(curData.FullPath, curData.Position, curData.AudioTrack, curData.Subtitle);
                    }
                    else
                    {
                        //讀取資料庫是否存在同檔名紀錄
                        List <FilePosData> nameList = _sqlCtrl.GetDataByName(fileName);

                        if (nameList != null &&
                            nameList.Count > 0)
                        {
                            //比對檔案大小
                            long fileSize = (new FileInfo(filePath).Length);
                            foreach (FilePosData data in nameList)
                            {
                                if (data.FileSize == fileSize)
                                {
                                    //替換資料庫該檔案紀錄
                                    _sqlCtrl.RemoveDataByFullPath(data.FullPath);
                                    data.FullPath = filePath;
                                    _sqlCtrl.InsertData(data);

                                    //相同檔名、相同檔案大小
                                    //插入MPC-BE登陸檔歷史資料
                                    RegMethod.SetMpcBeRecentFile(data.FullPath, data.Position, data.AudioTrack, data.Subtitle);

                                    break;
                                }
                            }
                        }
                        else
                        {
                            //無歷史資料 直接啟動MPC-BE
                            //Nothing to do.
                        }
                    }
                }

                //啟動MPC-BE
                _regWatcher.Start();
                _mpcbeProcess = StartMpcBe(mpcbeExePath, filePath);

                //等待MPC-BE關閉
                _mpcbeProcess.WaitForExit();

                _regWatcher.Stop();
            }
        }