Exemple #1
0
        private void StartStopSearchButton_Click(object sender, EventArgs e)
        {
            PushToSettings();

            if (SearchSettings.BadSettings())
            {
                MessageBox.Show("Ошибка! \nНужно задать корневую директорию и хотя бы один фильтр, и их длина должна быть не больше 50 символов.");
                return;
            }

            SearchStarted = !SearchStarted;

            if (SearchStarted)
            {
                DisableConfig();
                PauseResumeSearchButton.Enabled = true;
                StartStopSearchButton.Text      = "Stop";
                BackgroundSearcher.RunWorkerAsync();
                SearchTimer.Start();
            }
            else
            {
                BackgroundSearcher.CancelAsync();
                SearchPaused = false;
                EnableConfig();
                PauseResumeSearchButton.Text    = "Pause";
                PauseResumeSearchButton.Enabled = false;
                SearchTimer.Stop();
            }
        }
 /// <summary>
 /// Input on the search box changed,
 /// start searchTimer to validate and search.
 /// </summary>
 private void searchBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     // No need to search if there is no data
     if (ViewModel.Collections.Count > 0)
     {
         SearchTimer.Stop();
         SearchTimer.Start();
     }
 }
        public void Stop()
        {
            SearchTimer.Stop();
            SliderTimer.Stop();

            ViewModel.Status = SongStatus.Stopped;

            sliderControl.Value = 0;

            ViewModel.Player.Stop();
        }
 /// <summary>
 /// Checks searchBox for valid input,
 /// in that case filters treeView content.
 /// </summary>
 private void SearchTimer_Tick(object sender, EventArgs e)
 {
     if (ViewModel.SearchField["Input"] == null) // If validation passed
     {
         if (ViewModel.SearchField.Input != MusicSearchField.InitialInputValue)
         {
             ViewModel.FilterSearch();
         }
     }
     else
     {
         ViewModel.RefreshBands();
     }
     SearchTimer.Stop();
 }
Exemple #5
0
        /// <summary>
        /// Called whenever (and ONLY whenever) the user has either
        /// 1. selected an item from the result set
        /// 2. decided not to select an item from the result set
        /// 3. cleared the currently selected item
        /// </summary>
        private void OnUserEndedSearchEvent()
        {
            if (SearchTimer != null)
            {
                SearchTimer.Stop();
                //setting to null so that when a new search starts, we grab fresh values for the time interval
                SearchTimer = null;
            }

            if (SearchProvider != null)
            {
                SearchProvider.CancelAllSearches();
            }

            ShowResults           = false;
            noResultsPopup.IsOpen = false;
        }
Exemple #6
0
        private void BackgroundSearcher_DoWork(object sender, DoWorkEventArgs e)
        {
            ProcessCurrentDirectory(SearchSettings.RootDirPath);
            SearchPaused  = false;
            SearchStarted = false;
            this.Invoke(
                new MethodInvoker(delegate
            {
                EnableConfig();
                PauseResumeSearchButton.Text    = "Pause";
                PauseResumeSearchButton.Enabled = false;
                SearchTimer.Stop();
                StartStopSearchButton.Text = "Start";
            })
                );

            BackgroundSearcher.CancelAsync();
        }
Exemple #7
0
        private void PauseResumeSearchButton_Click(object sender, EventArgs e)
        {
            SearchPaused = !SearchPaused;

            if (SearchPaused)
            {
                _busy.Reset();
                PauseResumeSearchButton.Text = "Resume";
                SearchTimer.Stop();
            }
            else
            {
                PauseResumeSearchButton.Text = "Pause";
                _busy.Set();
                SearchTimer.Start();
            }

            SearchSettings.SaveSettingsToConfig();
        }
 private void SearchTimer_Tick(object sender, EventArgs e)
 {
     if (hidden2)
     {
         pnlSearch.Width = pnlSearch.Width + 10;
         if (pnlSearch.Width >= panelWidth)
         {
             SearchTimer.Stop();
             hidden2 = false;
             this.Refresh();
             this.pnlSearch.BringToFront();
         }
     }
     else
     {
         pnlSearch.Width = pnlSearch.Width - 10;
         if (pnlSearch.Width <= 0)
         {
             SearchTimer.Stop();
             hidden2 = true;
             this.Refresh();
         }
     }
 }
Exemple #9
0
        /// <summary>
        /// Метод обработки нажатия левой кнопкой по закрепленному Customer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Pinned_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (this.ListViewPinned.SelectedItem != null)
            {
                Customer selected = this.FindTTbyCode((this.ListViewPinned.SelectedItem as PinnedTT).Code, AllTT);
                if ((this.ListViewPinned.SelectedIndex != -1) && (selected != null))
                {
                    selected.Comment = (this.ListViewPinned.SelectedItem as PinnedTT).Comment;
                    try
                    {
                        // Проверка существования данного customer в ранее открытых
                        Customer getCustomer = FindTTbyCode(selected.NumberCVZ.ToString(), OpenedTT);
                        if (getCustomer != null)
                        {
                            foreach (var item in Tabs.Items)
                            {
                                if (item == getCustomer)
                                {
                                    Tabs.SelectedItem = item;
                                }
                            }
                            ;
                        }
                        else
                        {
                            Customer curCustomer;
                            //if (selected.Content == null)
                            //{
                            curCustomer = CreateCustomerForType(CustomerTypes.TTCVZ, selected);
                            //}
                            //else
                            curCustomer = selected;
                            OpenTTinTab(curCustomer, true);
                            Log($"Открыта {curCustomer.ToStringDisplay}");
                            //curCustomer.Focus();
                        }
                    }
                    catch (Exception ex)
                    {
                        Log("Ошибка при выводе закрепленной ЦВЗ. " + ex.Message, true, true, ex.StackTrace);
                    }
                }
                else
                {
                    SearchTimer.Stop();



                    // Проверка существования данного customer в ранее открытых
                    var getTab = (from i in OpenedTT where i.Lan_Ip == (ListViewPinned.SelectedItem as PinnedTT).IPAddress select i).FirstOrDefault();
                    if (getTab != null)
                    {
                        /*getTab.Focus()*/;
                    }
                    else
                    {
                        //IPAddress address;
                        //this.TextBoxSearch.Text = (this.ListViewPinned.SelectedItem as PinnedTT).Code;
                        //this.TextBoxSearch.Focus();
                        //if (IPAddress.TryParse(this.TextBoxSearch.Text, out address))
                        //{
                        //    this.OpenCustomTT();
                        //}
                        Customer curCustomer = CreateCustomerForType(CustomerTypes.SingleIP, new Customer(this) /*{ Owner = this }*/, (this.ListViewPinned.SelectedItem as PinnedTT).IPAddress);
                        OpenTTinTab(curCustomer);
                        //OpenedTT.Add(curCustomer);
                        Log($"Открыт {curCustomer.Lan_Ip}");
                        //curCustomer.Focus();
                    }


                    //IPAddress address;
                    //this.TextBoxSearch.Text = (this.ListViewPinned.SelectedItem as PinnedTT).Code;
                    //this.TextBoxSearch.Focus();
                    //if (IPAddress.TryParse(this.TextBoxSearch.Text, out address))
                    //{
                    //    this.OpenCustomTT();
                    //}
                }
            }
        }
Exemple #10
0
 private void PinnedWatchTimer_Tick(object sender, EventArgs e)
 {
     foreach (PinnedTT dtt in PinnedTTs)
     {
         if ((dtt.NotifyAt != DateTime.MinValue) && (DateTime.Now >= dtt.NotifyAt))
         {
             this.ActivateMainWindow();
             dtt.NotifyAt = DateTime.MinValue;
             ShowBalloonWarning(dtt.Comment, $"{dtt.Code} - {dtt.Name}");
             TaskDialogOptions options = new TaskDialogOptions
             {
                 Owner           = this,
                 Title           = "DSList",
                 Content         = dtt.Comment,
                 MainInstruction = $"{dtt.Code} - {dtt.Name}",
                 MainIcon        = VistaTaskDialogIcon.Warning
             };
             options.CustomButtons           = new string[] { "ОК", "Открепить ТТ", "Открыть ТТ", "Отложить" };
             options.DefaultButtonIndex      = 0;
             options.AllowDialogCancellation = true;
             TaskDialogResult result = TaskDialog.Show(options);
             int?customButtonResult  = result.CustomButtonResult;
             int num = 1;
             if ((customButtonResult.GetValueOrDefault() == num) ? customButtonResult.HasValue : false)
             {
                 Customer tt = this.FindTTbyCode(dtt.Code, this.AllTT);
                 if (tt == null)
                 {
                     tt = new Customer(this)
                     {
                         NumberCVZ = int.Parse(dtt.Code),
                         //Owner = this
                     };
                 }
                 this.UnpinTT(tt, true);
                 this.PinnedWatchTimer_Tick(sender, e);
                 break;
             }
             customButtonResult = result.CustomButtonResult;
             num = 2;
             if ((customButtonResult.GetValueOrDefault() == num) ? customButtonResult.HasValue : false)
             {
                 if (dtt.Code == "0" && dtt.IPAddress != null)
                 {
                     SearchTimer.Stop();
                     // Проверка существования данного customer в ранее открытых
                     var getTab = (from i in OpenedTT where i.Lan_Ip == dtt.IPAddress select i).FirstOrDefault();
                     if (getTab != null)
                     {
                         /*getTab.Focus()*/;
                     }
                     else
                     {
                         //this.TextBoxSearch.Text = (this.ListViewPinned.SelectedItem as PinnedTT).Code;
                         //this.TextBoxSearch.Focus();
                         Customer curCustomer = CreateCustomerForType(CustomerTypes.SingleIP, new Customer(this) /*{ Owner = this }*/, dtt.IPAddress);
                         OpenTTinTab(curCustomer);
                         //OpenedTT.Add(curCustomer);
                         Log($"Открыт {curCustomer.Lan_Ip}");
                         /*curCustomer.Focus()*/;
                     }
                 }
                 Customer selected = this.FindTTbyCode(dtt.Code, this.AllTT);
                 if (selected != null)
                 {
                     selected.Comment = dtt.Comment;
                     Customer curCustomer = CreateCustomerForType(CustomerTypes.TTCVZ, selected);
                     OpenTTinTab(selected, true);
                     //if (selected.NumberCVZ.ToString()!="0")
                     //{
                     //    Customer curCustomer = CreateCustomerForType(CustomerTypes.TTCVZ, selected);
                     //    this.OpenTTinTab(selected, true);
                     //}
                     //else
                     //{
                     //    Customer curCustomer = CreateCustomerForType(CustomerTypes.SingleIP, selected);
                     //    this.OpenTTinTab(selected, true);
                     //}
                 }
             }
             customButtonResult = result.CustomButtonResult;
             num = 3;
             if ((customButtonResult.GetValueOrDefault() == num) ? customButtonResult.HasValue : false)
             {
                 options = new TaskDialogOptions
                 {
                     Owner           = this,
                     Title           = "DSList",
                     Content         = dtt.Comment,
                     MainInstruction = $"Отложить {dtt.Code} - {dtt.Name}"
                 };
                 options.CustomButtons           = new string[] { "Отмена" };
                 options.DefaultButtonIndex      = 0;
                 options.AllowDialogCancellation = true;
                 List <string> list = new List <string>();
                 for (int i = 1; i < this.NotifyMinutesComboBox.Items.Count; i++)
                 {
                     list.Add((this.NotifyMinutesComboBox.Items[i] as ComboBoxItem).Content.ToString());
                 }
                 options.CommandButtons = list.ToArray();
                 TaskDialogResult result2 = TaskDialog.Show(options);
                 if (!result2.CommandButtonResult.HasValue)
                 {
                     break;
                 }
                 int      num2 = int.Parse((this.NotifyMinutesComboBox.Items[result2.CommandButtonResult.Value + 1] as ComboBoxItem).Tag.ToString());
                 DateTime time = DateTime.Now.AddMinutes((double)num2);
                 dtt.NotifyAt = time;
             }
         }
     }
 }
Exemple #11
0
        protected List <Move>?startSearch(Position?position, SearchMode mode)
        {
            try {
                if (position is null)
                {
                    throw new PositionException("Null Position");
                }
                else if (SearchTimer is null)
                {
                    throw new PositionException("Null SearchTimer Stopwatch");
                }
                else
                {
                    SearchTimer.Reset();
                    IntervalNodes      =
                        HeartbeatNodes = (UInt64)NodeTotal;
                    LastBeatMS         = SearchTimer.ElapsedMilliseconds;
                }

                if (position.IsLegal())
                {
                    StartDepth = 0;     //[Init]
                    ClearSearchCounts();

                    if (UCI.IsDebug)
                    {
                        var dtStarted = DateTime.Now;
#if Herald
                        herald(dtStarted, position.Name);
#endif
#if NoteStartAndFinish
                        LogInfo(Level.note, $"Started at {dtStarted:yyyy-MM-dd HH:mm:ss.ff}");
#endif
                    }

                    SearchTimer.Start();

                    switch (mode)
                    {
                    case SearchMode.BestMove:
                        var mValue = position.IteratePlies(Bound);
                        break;

                    case SearchMode.Perft:
                        position.IterateCases();
                        break;
                    }
                }
                else
                {
                    throw new PositionException("Illegal Setup");
                }
            }
            catch (OperationCanceledException) {
                //
                // OperationCanceledException is thrown in MonitorBound() via ThrowIfCancellationRequested(),
                // when Cancel() has been called on the source of this Task's CancellationToken.  Catching
                // it here allows stack frames for an active search to return Position objects to the pool.
                //
            }
            catch (FinalPositionException ex) {
                LogInfo(Level.note, ex.Message);
            }
            catch (ApplicationException ex) {
#if StackTrace
                LogInfo(Level.error, ex.ToString());
#else
                LogInfo(Level.error, ex.Message);
#endif
            }
            catch (Exception ex) {
                LogInfo(Level.error, ex.ToString());
            }
            finally {
                if (SearchTimer.IsRunning)
                {
                    SearchTimer.Stop();
                }

                if (UCI.IsDebug)
                {
                    LogInfoNewLine(Level.note);
#if NoteStartAndFinish
                    LogInfo(Level.note, $"Finished at {DateTime.Now:yyyy-MM-dd HH:mm:ss.ff}");
#endif
                    var dElapsedMS = (Double)SearchTimer.ElapsedMilliseconds;
                    displayCounts(mode, dElapsedMS);
                }
            }

            //
            //[Optional]Repeat final bestmove report:
            //
            if (BestMoves is not null)
            {
                var sb = new StringBuilder();
                //[Note]refreshPV() has been called
                sb.BestMove(BestMoves, Rule);
                if (sb.Length > 0)
                {
                    LogLine(sb.ToString());
                }
            }

            return(BestMoves);
        }