public AdvancedAuthorWindow(Setting setting, Logger logger)
 {
     InitializeComponent();
     authorPanel.SetSetting(setting, logger);
     authorPanel.SplitterChanged += AuthorPanelSplitterChanged;
     _setting = setting;
 }
Пример #2
0
 public SettingWindow(Setting setting)
     : this()
 {
     Original = setting;
     Result = new Setting();
     Result.PartialCopy(Original);
     DataContext = Result;
 }
Пример #3
0
        public Updater(Setting setting, Logger service)
        {
            _syncContext = SynchronizationContext.Current;
            _logger = service;
            _setting = setting;

            _worker = new BackgroundWorker {WorkerSupportsCancellation = true};
            _worker.DoWork += WorkerDoWork;
            _worker.RunWorkerCompleted += WorkerRunWorkerCompleted;
        }
Пример #4
0
        public AuthorUpdates(Author author, Setting setting, Logger logger)
        {
            InitializeComponent();

            _author = author;
            _setting = setting;

            AuthorWindowSetting authorWindowSetting = _setting.GetAuthorWindowSetting(author);
            Width = authorWindowSetting.Size.Width;
            Height = authorWindowSetting.Size.Height;
            Left = authorWindowSetting.Location.X;
            Top = authorWindowSetting.Location.Y;

            SizeChanged += AuthorUpdatesSizeChanged;
            LocationChanged += AuthorUpdatesLocationChanged;

            authorPanel.SetSetting(setting, logger);
            authorPanel.Build(author, authorWindowSetting.HeightComment);
            authorPanel.SplitterChanged += AuthorPanelSplitterChanged;

            Title = author.Name;
            AuthorUpdateDate.Content = "Состояние текстов автора на дату: " + author.UpdateDate.ToShortDateString();
        }
Пример #5
0
        public static void Init(Setting setting, Logger logger)
        {
            _setting = setting;
            _logger = logger;
            // в зависимости от того, используем БД или нет, грузим данные из разных мест
            if (setting.UseDatabase)
            {
                MainWindow.MainForm.InitializeDatabase(false);
                LoadDataFromDatabase();
            }
            else
            {
                LoadDataFromXml();
            }
            ClearAuthorsChengedStatus();
            Authors.ListChanged += ((o, e) => Refresh());
            OutputCollection = new ObservableCollection<object>();
            Refresh();

            _updater = new Updater(_setting, _logger);
            _updater.UpdaterComplete += UpdaterComplete;
            #if !DEBUG
            //if (!_setting.UseGoogle) // если указано синхронизироваться с гуглом, не запускаем сразу обновление, чтобы синхронизации успела отработать и скачать возможные изменени
                UpdateAuthors();
            #endif

            #if !DEBUG
               // if (!_setting.UseGoogle)
                _updateTimer = new Timer {Interval = 3600000, AutoReset = false};
            //else // если используем гугл, то запускаем проверку обновления через 10 минут
               //     _updateTimer = new Timer {Interval = 60000 * 10, AutoReset = false};
            #else
            _updateTimer = new Timer { Interval = 60000, AutoReset = false};
            #endif
            _updateTimer.Elapsed += (o, e) => UpdateAuthors();

            _setting.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == "IntervalOfUpdate")
                {
                    UpdateIntervalAndStart();
                    _logger.Add("Периодичность обновления: " + IntervalOfUpdateConverter.Parse(_setting.IntervalOfUpdate));
                }
                //else if (e.PropertyName=="UseGoogle")
                {
                    //if (_setting.UseGoogle)
                    //    StartGoogleSync();
                    //else
                    //    StopGoogleSync();
                }
            };

            TimerBasedAuthorsSaver.StartMonitoring(false);
            // если указано синхронизироваться с Google
            //if (_setting.UseGoogle)
            //{
            //    StartGoogleSync();
            //    _updateTimer.Start(); // ручками толкаем таймер, так как мы пропустили этап обновлений, где он запускается
            //}
        }
Пример #6
0
 private static void StartReader(Setting setting, DownloadTextItem sender)
 {
     Thread thread = new Thread(StartReaderPP) { IsBackground = true };
     thread.Start(new StartReaderThreadParam
                      {Context = SynchronizationContext.Current, Setting = setting, DownloadTextItem = sender});
 }
Пример #7
0
 public void SetSetting(Setting value, Logger logger)
 {
     _logger = logger;
     MainWindow.GetSettings().PropertyChanged += SettingPropertyChanged; // отписываемся в Unloaded
     //if (MainWindow.GetSettings() == null)
     //{
     //    MainWindow.GetSettings() = value;
     //    MainWindow.GetSettings().PropertyChanged += SettingPropertyChanged; // отписываемся в Unloaded
     //}
     //else
     //{
     //    throw new Exception("Повторное присвоение setting для AuthorPanel");
     //}
 }
Пример #8
0
 /// <summary>
 /// Копирует некоторые поля объекта
 /// </summary>
 public void PartialCopy(Setting original)
 {
     DesiredPositionAdvancedWindow = original.DesiredPositionAdvancedWindow;
     AdvancedWindowVisibleStyle = original.AdvancedWindowVisibleStyle;
     CloseHowToMinimize = original.CloseHowToMinimize;
     DefaultActionAsAuthorPage = original.DefaultActionAsAuthorPage;
     ProxySetting.UseProxy = original.ProxySetting.UseProxy;
     ProxySetting.Address = original.ProxySetting.Address;
     ProxySetting.Port = original.ProxySetting.Port;
     ProxySetting.UseAuthentification = original.ProxySetting.UseAuthentification;
     ProxySetting.UserName = original.ProxySetting.UserName;
     ProxySetting.Password = original.ProxySetting.Password;
     UseRSS = original.UseRSS;
     RSSFileName = original.RSSFileName;
     RSSCount = original.RSSCount;
     AfterUpdater = original.AfterUpdater;
     BeforeUpdater = original.BeforeUpdater;
     AfterUpdaterParam = original.AfterUpdaterParam;
     BeforeUpdaterParam = original.BeforeUpdaterParam;
     MarkAuthorIsReadWithAuthorPage = original.MarkAuthorIsReadWithAuthorPage;
     OpenAuthorPageSortingDate = original.OpenAuthorPageSortingDate;
     DefaultReader = original.DefaultReader;
     AlternativeReader = original.AlternativeReader;
     AlternativeReaderParam = original.AlternativeReaderParam;
     BookConverter = original.BookConverter;
     BookConverterParam = original.BookConverterParam;
     MaxCacheSize = original.MaxCacheSize;
     Cached = original.Cached;
     IntervalOfUpdate = original.IntervalOfUpdate;
     UseDatabase = original.UseDatabase;
     UseGoogle = original.UseGoogle;
     GoogleLogin = original.GoogleLogin;
     GooglePassword = original.GooglePassword;
 }
Пример #9
0
 public static Setting CopyFrom(Setting setting)
 {
     var xs = new XmlSerializer(typeof (Setting));
     var sb = new StringBuilder();
     var w = new StringWriter(sb, CultureInfo.InvariantCulture);
     xs.Serialize(w, setting,
                  new XmlSerializerNamespaces(new[] {new XmlQualifiedName(string.Empty)}));
     var reader = new StringReader(sb.ToString());
     var sr = new XmlSerializer(typeof (Setting));
     return (Setting) sr.Deserialize(reader);
 }
Пример #10
0
 public static void Init(ListBox mainListBox, Logger logger, Setting setting)
 {
     _mainListBox = mainListBox;
     _logger = logger;
     if (Directory.Exists(BooksPath()))
     {
         Thread thread = new Thread(ClearCache) { IsBackground = true };
         thread.Start(setting.MaxCacheSize*1024*1024);
     }
 }
Пример #11
0
        private void MainWindowLoaded(object sender, RoutedEventArgs e)
        {
            // создаем основную логику программы
            _setting = Setting.LoadFromXml();
            _setting.PropertyChanged += SettingPropertyChanged;

            // проконтролируем, показывать или нет панель произведений на главной странице в зависимости от настроек
            CheckForAuthorPanelAlwaysVisivility();

            _logger = new Logger();
            WEB.Init(_setting.ProxySetting, _logger);
            InfoUpdater.Init(_setting, _logger);
            InfoUpdater.InfoUpdaterRefresh += SetFocusToSelectedItem;
            InfoUpdater.Authors.ListChanged += ((o, le) =>
                                                    {
                                                        if ((le.PropertyDescriptor != null) &&
                                                            (le.PropertyDescriptor.Name == "IsNew"))
                                                        {
                                                            AuthorsListBox_SelectionChanged(o, null);
                                                            bool summaryIsNew = false;
                                                            foreach (Author author in InfoUpdater.Authors)
                                                            {
                                                                if (author.IsNew)
                                                                {
                                                                    summaryIsNew = true;
                                                                    break;
                                                                }
                                                            }
                                                            if (!summaryIsNew)
                                                                _mNotifyIcon.Icon = Properties.Resources.books;
                                                        }
                                                    });

            // инициализируем трей и сворачиваем окно
            InitTray();
            #if !DEBUG
            HideWindow();
            #endif

            // Создаются дополнительные кнопки в заголовке
            CreateTopButton();

            // Привязки
            DataContext = _setting;
            AuthorsListBox.ItemsSource = InfoUpdater.OutputCollection;
            StatusLabel.DataContext = _logger;
            PlayPauseButton.DataContext = _logger;
            LogListBox.DataContext = _logger;
            DownloadTextHelper.Init(downloadHelper, _logger, _setting);
            downloadHelper.ItemsSource = DownloadTextHelper.DownloadTextItems;

            AuthorsListBox.SelectedItem =
                InfoUpdater.Authors.FindAuthor(_setting.LastAuthorUrl.Replace("zhurnal.lib.ru", "samlib.ru"));
            AuthorsListBox.Focus();
            SetFocusToSelectedItem();

            // Обновляем интерфейс (иконки на кнопках сортировки)
            SettingPropertyChanged(null, new PropertyChangedEventArgs("Init"));

            LoadedFlag = true;
        }
Пример #12
0
 /// <summary>
 /// вызов окна настроек
 /// </summary>
 public void ShowSettingsWindow()
 {
     currentUseDatabase = _setting.UseDatabase;
     SettingWindow settingWindow = new SettingWindow(_setting) { Owner = this };
     _setting = settingWindow.ShowDialog();
 }
Пример #13
0
 public SIXamlReader(Setting setting)
 {
     InitializeComponent();
     DataContext = setting;
 }