Exemplo n.º 1
0
        private void FocusWindowShow(object sender, RoutedEventArgs e)
        {
            FocusKeyWindow fkw;

            using (key = Registry.CurrentUser.OpenSubKey(@"Software\FocusScoring"))
                fkw = new FocusKeyWindow(
                    Coder.Decode(key.GetValue("fkey").ToString()),
                    FocusManager.IsBaseMode());
            fkw.Owner = this;
            fkw.Show();

            fkw.KeyAccepted += (o, a) =>
            {
                FocusManager = fkw.Manager;

                //MarkersControl.Manager = FocusManager;
                var factory = FocusManager.CreateCompanyFactory();
                CompanyControl.CompanyFactory = factory;
                CompanyControl.Manager        = FocusManager;
                CompanyListsControl.Manager   = FocusManager;
                CompanyListsControl.Excel     = new ExcelExporter(new ListsCache <string>("SettingsLists"), new ListsCache <CompanyData>("CompanyLists"), factory);
                foreach (var companyData in CompanyControl.CurrentList.Data)
                {
                    companyData.Source?.Reinstance(FocusManager);
                }
                CheckFocusKey(FocusManager);
            };
        }
Exemplo n.º 2
0
        //private ListsCache<CompanyData> CompaniesCache { get; }


        /*public MarkersList Markers { get; set; }
         * public CompanyList Companies { get; set; }*/

        public MainWindow(FocusKeyManager manager)
        {
            FocusManager = manager;
            var CompaniesCache = new ListsCache <CompanyData>("CompanyLists");

            var factory       = FocusManager.CreateCompanyFactory();
            var SettingsCache = new ListsCache <string>("SettingsLists");

            InitializeComponent();
            CheckFocusKey(manager);

            isMonAvailable = FocusManager.GetAvailableMethods().Contains(ApiMethod.mon);

            CheckButton.Content = "Проверить список";//= isMonAvailable ? "Включить автопроверку." : "Проверить список";

            //CheckButton.Visibility = manager.IsBaseMode() ? Visibility.Hidden : Visibility.Visible;

            //MarkersControl.Manager = FocusManager;
            MarkersControl.IsBaseMode = manager.IsBaseMode();

            CompanyControl.CompanyFactory = factory;
            CompanyControl.Manager        = FocusManager;//TODO Attepmpt to remove it
            CompanyControl.markersList    = MarkersControl;
            CompanyControl.FocusKeyUsed  += (o, a) => CheckFocusKey(manager);

            CompanyListsControl.Manager     = FocusManager;
            CompanyListsControl.CompanyList = CompanyControl;
            CompanyListsControl.ListFactory = new ListFactory(CompaniesCache, SettingsCache, new ListsCache <string>("PropertiesCache"));
            CompanyListsControl.Excel       = new ExcelExporter(SettingsCache, CompaniesCache, factory);
            //CompanyListsControl.FocusKeyUsed += (o, a) => CheckFocusKey(manager);
        }
Exemplo n.º 3
0
        private void Ok_Click(object sender, RoutedEventArgs e)
        {
            if (KeyBox.Password.Count() < 40)
            {
                MessageBox.Show("Введен некорректный ключ. Введите ключ длинной 40 знаков", "Конутр.Фокус");
            }
            else
            {
                Manager = FocusKeyManager.StartAccess(KeyBox.Password);
                if (Manager.Usages.StartsWith("Ошибка"))//TODO shitty check
                {
                    MessageBox.Show("Проверьте правильность ключа");
                    return;
                }

                //if (Manager.IsBaseMode() != mode) TODO fix!
                MessageBox.Show("Новый ключ имеет отличный набор методов. Рекомендуется перезапуск приложения.");

                KeyAccepted?.Invoke(this, null);
                Coder.Encode(KeyBox.Password);
                if (this.Owner == null)
                {
                    new MainWindow(Manager).Show();
                }
                this.Close();
            }
        }
        public MarkerListWindow(FocusKeyManager manager)
        {
            this.manager = manager;
            InitializeComponent();

            markersList = manager.GetAllMarkers.Select(MarkerSubData.Create).ToList();

            MarkersList.ItemsSource = markersList;
        }
Exemplo n.º 5
0
        private void CheckFocusKey(FocusKeyManager manager)
        {
            KeyCounter.Text = "Ключ: использовано " + manager.Usages;
            var worker = new BackgroundWorker();

            worker.DoWork             += (o, e) => Thread.Sleep(10000);
            worker.RunWorkerCompleted += (o, e) =>
                                         KeyCounter.Text = "Ключ: использовано " + manager.Usages;
            worker.RunWorkerAsync(20000);
        }
Exemplo n.º 6
0
 public FocusKeyWindow()
 {
     InitializeComponent();
     using (key = Registry.CurrentUser.CreateSubKey(@"Software\FocusScoring"))
     {
         if (key != null)
         {
             if (key.GetValue("fkey") != null)
             {
                 this.Hide();
                 Manager = FocusKeyManager.StartAccess(Coder.Decode(key.GetValue("fkey").ToString()));
                 KeyAccepted?.Invoke(this, null);
                 var mW = new MainWindow(Manager);
                 mW.Owner = null;
                 mW.Show();
                 this.Close();
             }
         }
     }
 }