Ejemplo n.º 1
0
        /// <summary>
        /// Login Thread
        /// </summary>
        public void ThreadFuncSearch(object[] data)
        {
            string sID     = SearchStr;
            string sType   = null;
            object oRecord = null;

            oRecord = Tool.TryGet(sID, out sType);
            if (Application.Current != null)
            {
                Application.Current.Dispatcher.BeginInvoke((Action) delegate()
                {
                    if (sType.IsNotBlank())
                    {
                        Config.AddHistorySearch(SearchStr);
                        SearchList = Config.HistorySearchs();
                        if (sType == "Search")
                        {
                            VMSearch.Load((SearchResult)oRecord);
                            Manager.ShowDialog(VMSearch);
                            if (VMSearch.ResultID.IsNotBlank())
                            {
                                sID     = VMSearch.ResultID;
                                oRecord = Tool.TryGet(sID, out sType);
                            }
                        }

                        if (sType.IsNotBlank() && sType != "Search")
                        {
                            oRecord = VMInfo.Load(oRecord);
                            Manager.ShowDialog(VMInfo);
                            if (VMInfo.Result)
                            {
                                MainListItemViewModel newNode = new MainListItemViewModel(oRecord, VMInfo.OutputDir, VMInfo.QualityList[VMInfo.SelectQualityIndex], Config.Resolution());
                                ItemList.Add(newNode);
                                newNode.StartWork();
                            }
                        }
                    }
                    else
                    {
                        Errlabel     = "Search Err!";
                        ShowErrlabel = true;
                    }
                    CloseWaitView();
                });
            }
        }
        public async void Search()
        {
            if (InSearch)
            {
                return;
            }
            if (SearchStr.IsBlank())
            {
                Errlabel = "Search String is Empty!";
                return;
            }

            //Search
            InSearch = true;
            eObjectType SearchType = eObjectType.None;
            object      SearchObj  = await Task.Run(() => { return(TidalTool.tryGet(SearchStr, out SearchType)); });

            InSearch = false;

            if (SearchType == eObjectType.None)
            {
                Errlabel = "Search Err!";
                return;
            }
            if (SearchType == Tidal.eObjectType.SEARCH)
            {
                VMSearch.Load((Tidal.SearchResult)SearchObj);
                Manager.ShowDialog(VMSearch);
                SearchType = VMSearch.ResultType;
                SearchObj  = VMSearch.ResultObject;
                if (SearchType == eObjectType.None)
                {
                    return;
                }
            }

            SearchObj = VMInfo.Load(SearchObj);
            Manager.ShowDialog(VMInfo);
            if (VMInfo.Result)
            {
                MainListItemViewModel newNode = new MainListItemViewModel(SearchObj, ItemList);
                ItemList.Add(newNode);
                newNode.StartWork();
            }
        }