예제 #1
0
        //Обрабатываем нажатеие сверху
        private async void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            var o = sender as CheckBox;

            if (o == null)
            {
                return;
            }
            var x = (SportType)o.Content;

            lock (_bkChangedLock)
            {
                foreach (var book in _mainSetting.bookmakers)
                {
                    foreach (var sport in book.Sports)
                    {
                        if (sport.SportType != x)
                        {
                            continue;
                        }
                        if (o.IsChecked != null)
                        {
                            sport.IsFilter = o.IsChecked.Value;
                        }
                    }
                }
            }

            SettingsManger.SaveSettings(_mainSetting);
        }
예제 #2
0
        private void MainView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            _mainSetting.WinSet.BrZoom1       = BrowserTab1.zoomLvl;
            _mainSetting.WinSet.BrZoom2       = BrowserTab2.zoomLvl;
            _mainSetting.WinSet.MaxPercent    = _maxPercent;
            _mainSetting.WinSet.MinPercent    = _minPercent;
            _mainSetting.WinSet.WindowsHeight = ActualHeight;
            _mainSetting.WinSet.WindowsWidth  = ActualWidth;
            _mainSetting.WinSet.SpliterOne    = SpliterOne.ActualHeight;
            _mainSetting.WinSet.SpliterTwo    = SpliterTwo.ActualWidth;

            _mainSetting.WinSet.ColumnsWidth = new List <double>();

            var gridview = Forks.View as GridView;

            if (gridview == null)
            {
                return;
            }
            foreach (var column in gridview.Columns)
            {
                var t = column.ActualWidth;
                _mainSetting.WinSet.ColumnsWidth.Add(t);
            }

            SettingsManger.SaveSettings(_mainSetting);
        }
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     SettingsManger.SaveSettings(settings);
     if (UpdateSetting != null)
     {
         UpdateSetting(settings);
     }
     this.Close();
 }
예제 #4
0
        public LoginView()
        {
            _settings = SettingsManger.LoadSettingTry();

            InitializeComponent();
            txtLogin.Text        = _settings.Login;
            txtPassword.Password = _settings.Password;
            Task.Factory.StartNew(LoadBaners);
            lblVersion.Content = ABShared.ProjectVersion.Version.ToString();
        }
예제 #5
0
        private void LoadData()
        {
            var td = SettingsManger.LoadSettingTry().bookmakers;

            _bookmakers = new List <Bookmaker>();
            foreach (var key in td)
            {
                _bookmakers.Add(key);
            }
        }
예제 #6
0
        private void ShowSettingView(int?l = null)
        {
            //Синхронизируем настройки
            lock (_bkChangedLock)
                _mainSetting.bookmakers = _bookmakers.ToList();
            SettingsManger.SaveSettings(_mainSetting);

            //Показываем окно настроек
            SettingsView sv = new SettingsView(_mainSetting, _client, l);

            sv.UpdateSetting += delegate(Settings dt)
            {
                lock (_bkChangedLock)
                    _mainSetting = dt;

                if (dt.IsDoubleButton)
                {
                    BtnDouble.Visibility = Visibility.Visible;
                }
                else
                {
                    BtnDouble.Visibility = Visibility.Hidden;
                }

                //Показываем список активных БК
                Test.ItemsSource = _bookmakers.Where(x => x.IsShow).ToList();

                lock (_bkChangedLock)
                {
                    foreach (var manag in _managers)
                    {
                        foreach (var key in _mainSetting.bookmakers)
                        {
                            if (manag.Key == key.BkType)
                            {
                                manag.Value.SetUrl(key.Url);
                            }
                        }
                    }

                    LbFilters.ItemsSource = _mainSetting.Sports;
                }
            };
            sv.ShowDialog();


            SetBtnLigntStyle(BtnSetting);
        }
예제 #7
0
        private void btnLogin(object sender, RoutedEventArgs e)
        {
            try
            {
                var btn   = sender as Button;
                int index = (int)btn.Tag;

                var bookmaker = _bookmakers[index];

                var manag = _managers[bookmaker.BkType];

                manag.SetUrl(bookmaker.Url);
                manag.SignIn(bookmaker.Login, bookmaker.Password);

                _mainSetting.bookmakers = _bookmakers.ToList();
                SettingsManger.SaveSettings(_mainSetting);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Не удалось войти: " + ex.Message);
            }
        }
예제 #8
0
        /*
        -host [VALUE]
        -user [VALUE]
        -password [VALUE]

        -hash [VALUE] (Can be used multiple times when using the same command on several hashes)
        
        -noTokenAuth
        -debug (appends tracing to debug.log)
        -ui (shows UI, will attach to parent if already in a console)
        -list
        -listprivate
        -listpublic


        -start[_ifprivate|_ifpublic]
        -stop[_ifprivate|_ifpublic]
        -forcestart[_ifprivate|_ifpublic]
        -unpause[_ifprivate|_ifpublic]
        -pause[_ifprivate|_ifpublic]
        -recheck[_ifprivate|_ifpublic]
        -remove[_ifprivate|_ifpublic]
        -removeData[_ifprivate|_ifpublic]
        -label[_ifprivate|_ifpublic] [VALUE]
        -removeLabel[_ifprivate|_ifpublic]
        -setPrio[_ifprivate|_ifpublic] [VALUE]
        -setProperty[_ifprivate|_ifpublic] [NAME] [VALUE]

        -save [NAME] [VALUE] [NAME2] [VALUE2] .... [NAME_N] [VALUE_N] (currently used: user, password and host)

        -add [HASH](uses magnet)
        -addResolved [HASH] (uses torcache)
        */
        public Governor(string[] args)
        {
            bool useToken = true;
            Uri host = null;
            string user = null;
            SecureString password = null;
            var actions = new List<Command>();
            var hashes = new List<string>();

            var serverCommands = new List<IServerCommand>();

            for (int i = 0; i < args.Length; i++)
            {
                var name = args[i];

                if (!name.StartsWith("-", StringComparison.Ordinal)) continue; //not considered a command

                name = name.Substring(1).Trim().ToUpperInvariant();
                
                switch (name)
                {
                    case "HOST":
                        host = new Uri(args[++i]);
                        break;
                    case "USER":
                        user = args[++i];
                        break;

                    case "PASSWORD":
                        password = args[++i].ToSecureString();
                        break;

                    case "HASH":
                        hashes.Add(args[++i]);
                        break;

                    case "NOTOKENAUTH":
                        useToken = false;
                        break;

                    case "ADD":
                        serverCommands.Add(new AddCommand(args[++i], true));
                        break;

                    case "ADDRESOLVED":
                        serverCommands.Add(new AddCommand(args[++i], false));
                        break;

                    case "DEBUG":
                        var writerListener = new TextWriterTraceListener(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "debug.log"));
                        writerListener.TraceOutputOptions |= TraceOptions.DateTime;
                        Trace.AutoFlush = true; //Otherwise nothing will be written to the file.
                        Trace.Listeners.Add(writerListener);
                        break;

                    case "LIST":
                        serverCommands.Add(new ListCommand(Execution.Always));
                        break;

                    case "LISTPRIVATE":
                        serverCommands.Add(new ListCommand(Execution.Private));
                        break;

                    case "LISTPUBLIC":
                        serverCommands.Add(new ListCommand(Execution.Public));
                        break;

                    case "UI":
                        //Ignore
                        break;


                    default:
                        actions.Add(Command.Build(name, ref i, args));
                        break;
                }
            }
            
            if (user == null || password == null || host == null)
            {
                var settings = new SettingsManger();

                if (user == null) user = settings.Get("USER");
                if (password == null) password = settings.GetSecure("PASSWORD");
                if (host == null) host = settings.GetUri("HOST");
            }

            Server = new TorrentServer(host, user, password, useToken);
            ServerCommands = serverCommands;
            Actions = actions;
            Hashes = hashes;
        }
예제 #9
0
        private async void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            var data = txtServer.Text.Split(':');

            if (data.Length != 2)
            {
                MessageBox.Show("Адрес сервера не верен. Перезапустите программу!");
                return;
            }

            string host     = data[0];
            int    port     = Convert.ToInt32(data[1]);
            string login    = txtLogin.Text;
            string password = txtPassword.Password;


            var task = Task <DClient> .Factory.StartNew(delegate()
            {
                return(Conection(host, port, login, password));
            });

            var cl = await task;

            this.Dispatcher.Invoke(delegate() {
                btnLogin.IsEnabled   = true;
                prgStatus.Visibility = Visibility.Collapsed;
            });

            if (cl == null)
            {
                return;
            }

            if (cl.NeedUpdate)
            {
                var rez = MessageBox.Show("Необходимо обновить клиент! Сделать это сейчас?", "Запрос", MessageBoxButton.YesNo);
                if (rez == MessageBoxResult.Yes)
                {
                    try
                    {
                        Process.Start("Updater.exe");
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Не удалось запустить Updater. Сделайте это вручную. " + ex.Message);
                    }
                    return;
                }

                else
                {
                    MessageBox.Show("Дальнейшая работа невозможна! Программа будет закрыта!");
                    this.Close();
                }
            }
            if (!cl.IsLogin)
            {
                return;
            }

            try
            {
                _settings.Login    = txtLogin.Text;
                _settings.Password = txtPassword.Password;
                SettingsManger.SaveSettings(_settings);
                var mn = new MainView(cl, _settings);
                mn.Show();
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show(ex.StackTrace);
            }
        }
예제 #10
0
        public static void Main(string[] args)
        {
            ProfileOptimization.SetProfileRoot(AppDomain.CurrentDomain.BaseDirectory);
            ProfileOptimization.StartProfile("uGovernor.jit");
            
            if (args == null || args.Length == 0)
            {
                Trace.TraceError("No startup arguments supplied.", args);
                Environment.Exit(1);
                return;
            }

            Trace.TraceInformation(string.Join("~", args));

            _enableUI = args.Contains("-ui", StringComparer.OrdinalIgnoreCase);
            _attached = false;


            if (_enableUI && EnsureShell())
            {
                var consoleListener = new ConsoleTraceListener();
                consoleListener.TraceOutputOptions |= TraceOptions.DateTime | TraceOptions.Timestamp;

                Trace.Listeners.Add(consoleListener);
            }
            
            try
            {
                if (args.Contains("-SAVE", StringComparer.OrdinalIgnoreCase))
                {
                    var settings = new SettingsManger();

                    var commands = args.Where(x => !StringComparer.OrdinalIgnoreCase.Equals(x, "-SAVE"))
                                       .Select((x, i) => i % 2 == 0 ? x.TrimStart('-').ToUpperInvariant() : x)
                                       .ToArray();

                    for (int i = 0; i < commands.Length; i++)
                        settings.Set(commands[i], commands[++i]);

                    Trace.TraceInformation("Saving settings...");
                    settings.Save();
                }
#if DEBUG
                else if (args.Contains("-PRINTCFG", StringComparer.OrdinalIgnoreCase))
                {
                    EnsureShell();

                    var settings = new SettingsManger();
                    foreach (var setting in settings)
                    {
                        Console.WriteLine($"{setting} - {settings.Get(setting)}");
                    }                    
                }
#endif
                else
                {
                    var governor = new Governor(args);
                    governor.Run();
                }
            }
            catch (Exception e)
            {
                Trace.TraceError(string.Format("{0}{0}{1}{0}", Environment.NewLine, e.Message));

                if (_attached)
                    ReadKey();
            }
            finally
            {
                if (_enableUI)
                {
                    Write("Press any key to continue...");

                    if (!_attached)
                        ReadKey(true);

                    NativeMethods.FreeConsole();
                }
            }
        }