コード例 #1
0
        private void Config_Ready(object sender, CustomEventArgs.ConfigReadyEventArgs e)
        {
            var sitesList = e.Sites;

            var prepTabs = new List <TabItemViewModel>();

            foreach (var site in sitesList)
            {
                Credntials.CredentialsManager.DefaultInstance.Username = site.Username;
                Credntials.CredentialsManager.DefaultInstance.Password = site.Password;

                var prepTab = new TabItemViewModel();
                prepTab.Title               = site.Name;
                prepTab.Watched             = site.Watched;
                prepTab.Url                 = site.Mirrors[0];
                prepTab.Mirrors             = site.Mirrors;
                prepTab.Closeable           = !site.Watched;
                prepTab.ErrorMessage        = site.Message;
                prepTab.WarningSoundPath    = site.WarningSoundPath;
                prepTab.ErrorSoundPath      = site.ErrorSoundPath;
                prepTab.HeartbeatTimeout    = site.HeartbeatTimeout;
                prepTab.PageLoadTimeout     = site.LoadPageTimeout;
                prepTab.SwitchMirrorTimeout = site.SwitchMirrorTimeout;
                prepTab.AlertDelayTime      = site.AlertDelayTime;
                prepTab.Close              += TabClosed;
                prepTab.NewTabRequest      += Tab_NewTabRequest;
                prepTab.UrlChanged         += PrepTab_MirrorChanged;
                lock (locker) {
                    Tabs.Add(prepTab);
                }
            }
            RaisePropertyChanged(nameof(Tabs));
            SelectedTab = Tabs[0];
        }
コード例 #2
0
 private void TabClosed(object sender, StringMessageEventArgs e)
 {
     //find tab
     if (e.Message != string.Empty)
     {
         TabItemViewModel tab = null;
         lock (locker) {
             foreach (var t in Tabs)
             {
                 if (t.Url.Contains(e.Message))
                 {
                     tab = t;
                     break;
                 }
             }
         }
         if (tab != null)
         {
             CloseTab(tab);
         }
     }
     else
     {
         var prey = (TabItemViewModel)sender;
         CloseTab(prey);
     }
 }
コード例 #3
0
 /// <summary>
 /// ћетод закрыти¤ указаной вкладки
 /// </summary>
 /// <param name="prey">ћодель вкладки под закрытие</param>
 private void CloseTab(TabItemViewModel prey)
 {
     if (Tabs.Count == 1)
     {
         App.Current.Shutdown();
     }
     else
     {
         lock (locker) {
             Tabs.Remove(prey);
         }
         RaisePropertyChanged(nameof(Tabs));
         prey?.DisposeTab();
     }
 }
コード例 #4
0
 private void Tab_NewTabRequest(object sender, CustomEventArgs.TabRequestEventArgs e)
 {
     Application.Current.Dispatcher.Invoke(() => {
         var tab = new TabItemViewModel {
             Title     = "",
             Watched   = false,
             Url       = e.URL,
             Closeable = true
         };
         tab.Close         += TabClosed;
         tab.NewTabRequest += Tab_NewTabRequest;
         lock (locker) {
             Tabs.Add(tab);
         }
         RaisePropertyChanged(nameof(Tabs));
         SelectedTab = tab;
     });
 }