private void InitializePoolsCommands()
        {
            AddPool = new RelayCommand(obj =>
            {
                Selection.Add(false);
                PoolsSets.Add(new PoolSet {
                    Name = "New pool"
                });
                _model.cmd_SavePools(PoolsSets.ToList());
            });
            DeletePools = new RelayCommand(obj =>
            {
                for (int i = Selection.Count - 1; i > -1; i--)
                {
                    if (Selection[i])
                    {
                        Selection.RemoveAt(i);
                        PoolsSets[i].Wach = false;
                        PoolsSets.RemoveAt(i);

                        var x = PVMs.Where(pvm => pvm.Index == i).ToList();
                        if (x.Count > 0)
                        {
                            PVs  = PVs.Where(pv => pv.Index != i).ToList();
                            PVMs = PVMs.Where(pvm => pvm.Index != i).ToList();
                        }
                    }
                }
                _model.cmd_SavePools(PoolsSets.ToList());
            });
            UpPools = new RelayCommand(obj =>
            {
                for (int i = 1; i < Selection.Count; i++)
                {
                    if (Selection[i] && !Selection[i - 1])
                    {
                        Selection[i - 1] = true;
                        Selection[i]     = false;

                        PVMs.Where(p => p.Index == i).First().Index     = i - 1;
                        PVMs.Where(p => p.Index == i - 1).First().Index = i;

                        var ps = PoolsSets[i];
                        PoolsSets.Insert(i - 1, ps);
                        PoolsSets.RemoveAt(i);

                        SortPoolsViews();
                    }
                }
            });
            DownPools = new RelayCommand(obj =>
            {
                for (int i = Selection.Count - 2; i > -1; i--)
                {
                    if (Selection[i] && !Selection[i + 1])
                    {
                        Selection[i + 1] = true;
                        Selection[i]     = false;

                        PVMs.Where(p => p.Index == i).First().Index     = i + 1;
                        PVMs.Where(p => p.Index == i + 1).First().Index = i;

                        var ps = PoolsSets[i];
                        PoolsSets.RemoveAt(i);
                        PoolsSets.Insert(i + 1, ps);

                        SortPoolsViews();
                    }
                }
            });
        }
        private void ModelChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case "Rigs": {
                Rigs      = new ObservableCollection <Settings.Rig>(_model.Rigs);
                RigsNames = from r in Rigs orderby r.Index select r.Name;
                for (int i = 0; i < RigsNames.Count(); i++)
                {
                    Indicators.Add(RigStatus.offline);
                    Watch.Add(Rigs[i].Waching);
                    {
                        if (Rigs[i].Waching)
                        {
                            AddRigPanel(i);
                        }
                        else
                        {
                            RemoveRigPanel(i);
                        }
                    }
                }
            } break;

            case "PoolsSets":
            {
                for (int i = 0; i < _model.PoolsSets.Count; i++)
                {
                    Selection.Add(false);
                    PoolsSets.Add(_model.PoolsSets[i]);
                    if (_model.PoolsSets[i].Wach)
                    {
                        WachPoolStart(i);
                    }
                }
            } break;

            case "GenSettings": {
                GenSettings = _model.GenSettings;

                StartOfRange  = GenSettings.TotalMinTemp;
                StartOfRangeD = GenSettings.TotalMinTemp;
                EndOfRange    = GenSettings.TotalMaxTemp;
                EndOfRangeD   = GenSettings.TotalMaxTemp;

                eWeLogin        = GenSettings.eWeLogin;
                eWePasswordSend = GenSettings.eWePassword;
                if (!String.IsNullOrEmpty(eWeLogin) && !String.IsNullOrEmpty(eWePasswordSend))
                {
                    Task.Run(() => eWeConnect());
                }

                Task.Run(() =>
                    {
                        if (!string.IsNullOrEmpty(GenSettings.HiveLogin) && !string.IsNullOrEmpty(GenSettings.HivePassword))
                        {
                            AuthenticationStatus st = HiveClient.HiveAuthentication(
                                GenSettings.HiveLogin, GenSettings.HivePassword);
                            if (st.Status)
                            {
                                HiveLogin           = GenSettings.HiveLogin;
                                HivePasswordSend    = GenSettings.HivePassword;
                                HiveConnection      = true;
                                App.HiveConnection  = true;
                                HiveAccountState    = "Подключение к Hive установлено";
                                HiveConnectionState = "Подключение к Hive установлено";

                                HiveWorkers = HiveClient.GetWorkers();

                                if (HiveWorkers != null)
                                {
                                    List <string> LST = (from w in HiveWorkers select w.name).ToList();
                                    LST.Insert(0, "---");
                                    HiveWorkersNames = LST;
                                }
                            }
                            else
                            {
                                HiveAccountState = st.Message;
                            }
                        }
                        else
                        {
                            HiveAccountState    = "Подключение к Hive отсутствует";
                            HiveConnectionState = "Подключение к Hive отсутствует";
                        }
                    });

                VKuserID = GenSettings.VKuserID;
            } break;
            }
        }