Example #1
0
    public bool TryGetInstallationForPath(string editorPath, out ScriptEditor.Installation installation)
    {
        var lowerCasePath = editorPath.ToLower();
        var filename      = Path.GetFileName(lowerCasePath).Replace(" ", "");

        if (filename.StartsWith("code"))
        {
            try
            {
                installation = Installations.First(inst => inst.Path == editorPath);
            }
            catch (InvalidOperationException)
            {
                installation = new ScriptEditor.Installation
                {
                    Name = "Visual Studio Code",
                    Path = editorPath
                };
            }

            return(true);
        }

        installation = default;
        return(false);
    }
Example #2
0
        private void OnAddInstallation()
        {
            try
            {
                var folderBrowser = new FolderBrowserDialog
                {
                    Description         = "Please select the DCS folder you wish to add...",
                    RootFolder          = Environment.SpecialFolder.MyComputer,
                    ShowNewFolderButton = false
                };

                if (folderBrowser.ShowDialog() == DialogResult.OK)
                {
                    var selectedFolder = folderBrowser.SelectedPath;
                    var installation   = new InstallLocation(selectedFolder);

                    Installations.Add(new InstallLocationModel(installation));

                    _settingsService.AddInstalls(installation.Directory);
                }
            }
            catch (Exception e)
            {
                GeneralExceptionHandler.Instance.OnError(e);
            }
        }
Example #3
0
        private void OnDetectInstallations()
        {
            try
            {
                var installations      = InstallationLocator.Locate();
                var addedInstallations = new List <string>();

                foreach (var installation in installations)
                {
                    if (Installations.All(i => i.ToString() != installation.ToString()))
                    {
                        Installations.Add(new InstallLocationModel(installation));
                        addedInstallations.Add(installation.Directory);
                    }
                }

                foreach (var directory in addedInstallations)
                {
                    _settingsService.AddInstalls(directory);
                }
            }
            catch (Exception e)
            {
                GeneralExceptionHandler.Instance.OnError(e);
            }
        }
Example #4
0
        public override Task ActivateAsync()
        {
            try
            {
                Installations.Clear();

                foreach (var install in _settingsService.GetInstallations())
                {
                    Installations.Add(new InstallLocationModel(install));
                }

                if (Installations.Any())
                {
                    Installations[0].IsDefault.Value = true;
                }
            }
            catch (Exception e)
            {
                Tracer.Error(e);
            }
            finally
            {
                IsLoading.Value = false;
            }

            return(base.ActivateAsync());
        }
        private void AssignSummaryValues()
        {
            ClearSummaryValues();
            Installations objInstallationDetails = tvMachineList.SelectedItem as Installations;

            if (objInstallationDetails == null)
            {
                return;
            }

            List <SpotCheck> lstSpotCheck = new List <SpotCheck>();

            lstSpotCheck = lstSpotCheckSummaryDetails.Where(item => item.InstallationNo == objInstallationDetails.Installation_No).ToList();
            if (lstSpotCheck == null || lstSpotCheck.Count <= 0)
            {
                return;
            }

            txtLastMeterUpdate.Text = lstSpotCheck[0].DateTimeStamp.GetUniversalDateTimeFormat();
            if (lstSpotCheck[0].Date == DateTime.MinValue)
            {
                txtLastDropDate.Text = "N/A";
            }
            else
            {
                txtLastDropDate.Text = lstSpotCheck[0].Date.GetUniversalDateTimeFormat();
            }
            txtNetWinLoss.Text       = (lstSpotCheck[0].CashIn - lstSpotCheck[0].CashOut).GetUniversalCurrencyFormatWithSymbol();
            txtHandle.Text           = lstSpotCheck[0].CashIn.GetUniversalCurrencyFormatWithSymbol();
            txtPercentagePayout.Text = lstSpotCheck[0].Payout.ToString() + " %";
            txtDrop.Text             = Convert.ToDecimal(lstSpotCheck[0].CoinsDrop).GetUniversalCurrencyFormatWithSymbol();
            txtHandpay.Text          = lstSpotCheck[0].HandPay.GetUniversalCurrencyFormatWithSymbol();
        }
Example #6
0
        public override bool Commit()
        {
            var defaultInstallation = Installations.First(i => i.IsDefault.Value);

            _settingsService.AddInstalls(Installations.Select(i => i.ConcreteInstall.Directory).ToArray());
            _settingsService.SelectedInstall = defaultInstallation.ConcreteInstall;

            return(base.Commit());
        }
Example #7
0
        public Game Generate(GameGeneratorSettings settings)
        {
            // Generate galaxy
            var generator = new GalaxyGenerator(rnd);
            var galaxy    = generator.Generate(settings.GalaxySettings);

            // Populate galaxy
            var players = settings.PlayerNames
                          .Select((name, index) => new Player
            {
                Id   = index + 1,
                Name = name,
            })
                          .ToList();

            foreach (var player in players)
            {
                var uninhabitedPlanets = galaxy.Planets
                                         .Where(p => p.Settlement == null)
                                         .ToArray();

                var homeworld = rnd.PickOne(uninhabitedPlanets);

                homeworld.Details.Environment = player.Race.EnvironmentPreferences;

                homeworld.Settlement = new Settlement()
                {
                    OwnerId       = player.Id,
                    Population    = new Population(10_000),
                    Installations = new Installations
                    {
                        Scanner = 100,
                    },
                };

                var fleet = new Fleet()
                {
                    OwnerId      = player.Id,
                    Position     = homeworld.Position,
                    ScannerRange = 50,
                };
                galaxy.Fleets.Add(fleet);
                fleet.Name = $"Scout #{fleet.Id}";
            }

            var gameSettings = new GameRules();

            var game = new Game(gameSettings, galaxy)
            {
                Name    = settings.GameName,
                Players = new EntityStore <Player>(players),
            };

            return(game);
        }
Example #8
0
        internal void RemoveNotInstalledCheckedInstallations()
        {
            foreach (var i in Installations.ToList())
            {
                if (i.NotInstalled && i.CheckForUpdatesFlag)
                {
                    Installations.Remove(i);
                }
            }

            OnPropertyChanged("Installations");
        }
Example #9
0
        private void MantainNoConflictState()
        {
            // TODO: do not allow duplicates in custom part - postponed ATM, the user is warned when adding new installation
            // can be done with Installations.ItemPropertyChanged

            if (!auto_discovery_activated)
            {
                return;
            }

            // disable auto-discovered installations that have the same path as one of custom-set installations
            foreach (var i in Installations)
            {
                if (i.IsAutodiscoveredInstance)
                {
                    var same_pathed = Installations.Where(x => x.Path.TrimEnd('\\') == i.Path.TrimEnd('\\') && x.IsAutodiscoveredInstance == false);
                    if (same_pathed.Count() > 0)
                    {
                        if (i.CheckForUpdatesFlag != false)
                        {
                            i.CheckForUpdatesFlag = false;
                        }
                    }
                    else
                    {
                        if (i.CheckForUpdatesFlag != true)
                        {
                            i.CheckForUpdatesFlag = true;
                        }
                    }
                }
                else
                {
                    var same_pathed_autos = Installations.Where(x => x.Path.TrimEnd('\\') == i.Path.TrimEnd('\\') && x.IsAutodiscoveredInstance == true);
                    if (same_pathed_autos.Count() > 0)
                    {
                        if (i.OverridesAutodiscovered == false)
                        {
                            i.OverridesAutodiscovered = true;
                        }
                    }
                    else
                    {
                        if (i.OverridesAutodiscovered == true)
                        {
                            i.OverridesAutodiscovered = false;
                        }
                    }
                }
            }

            OnPropertyChanged("Installations");
        }
        private void btnPerformSpotCheck_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!CheckMachineSelected())
                {
                    return;
                }
                this.IsEnabled = false;

                Installations objInstallationDetails = tvMachineList.SelectedItem as Installations;
                if (objInstallationDetails == null)
                {
                    return;
                }

                int iLstIndx = -1;
                iLstIndx = (from SpotCheck objSpotCheck in lstSpotCheckSummaryDetails
                            where objSpotCheck.InstallationNo == objInstallationDetails.Installation_No
                            select lstSpotCheckSummaryDetails.LastIndexOf(objSpotCheck)).DefaultIfEmpty(-1).FirstOrDefault();

                Action doAnalysis = () =>
                {
                    if (iLstIndx >= 0)
                    {
                        lstSpotCheckSummaryDetails.RemoveAt(iLstIndx);
                    }
                    lstSpotCheckSummaryDetails.Add(oSpotCheckConfiguration.GetSpotCheckSummaryDetails(objInstallationDetails.Installation_No, objInstallationDetails.POP)[0]);
                };

                List <int> lstInatallation = new List <int>();
                lstInatallation.Add(objInstallationDetails.Installation_No);
                LoadingWindow ld_analysis = new LoadingWindow(this, ModuleName.SpotCheck, lstInatallation, doAnalysis);
                ld_analysis.ShowDialog();

                AfterProcessCompleted();
                //txtblkMessage.Text = (Application.Current.FindResource("MessageID504") as string).Replace("@@@@@@", objInstallationDetails.Bar_Position_Name);
            }

            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
                //txtblkMessage.Text = Application.Current.FindResource("MessageID505") as string;
            }

            finally
            {
                this.IsEnabled = true;
            }
        }
Example #11
0
        // TODO: This service should create the Installation itself
        /// <summary>
        /// Adds the installation if an installation with the same path doesn't already exist.
        /// </summary>
        /// <param name="install">The install.</param>
        /// <returns>If the install was added sucessfully</returns>
        public bool TryAddInstallation(IInstallation install)
        {
            if (install == null)
            {
                return(false);
            }

            if (Installations.Any(testInstall => install.Path.NormalizePath() == testInstall.Path.NormalizePath()))
            {
                return(false);
            }

            Installations.Add(install);
            return(true);
        }
        public override Task ActivateAsync()
        {
            Installations.Clear();

            foreach (var install in _settingsService.GetInstallations())
            {
                Installations.Add(install);
            }

            SelectedInstall.Value = _settingsService.SelectedInstall;

            CheckDcsStatus();

            return(base.ActivateAsync());
        }
        private void AssignInstallationValues()
        {
            Installations objInstallationDetails = tvMachineList.SelectedItem as Installations;

            if (objInstallationDetails == null)
            {
                return;
            }

            txtDate.Text      = DateTime.Now.GetUniversalDateFormat();
            txtTime.Text      = DateTime.Now.GetUniversalTimeFormat();
            txtZone.Text      = objInstallationDetails.Zone_Name;
            txtPos.Text       = objInstallationDetails.Bar_Position_Name;
            txtUser.Text      = SecurityHelper.CurrentUser.UserName;
            txtGameTitle.Text = objInstallationDetails.GameTitle;
        }
Example #14
0
        public override bool Validate()
        {
            if (Installations.Any() && Installations.Count(i => i.IsDefault.Value) == 0)
            {
                var window = WindowAssist.GetWindow(Controller);
                MessageBoxEx.Show("You must set a default installation to continue.", "Default Installations", MessageBoxButton.OK, parent: window);
                return(false);
            }

            if (Installations.Count(i => i.ConcreteInstall.IsValidInstall) == 0)
            {
                var window = WindowAssist.GetWindow(Controller);
                return(MessageBoxEx.Show("No valid DCS World installations were found.   Are you sure you want to continue?", "Installations", MessageBoxButton.YesNo, parent: window) == MessageBoxResult.Yes);
            }

            return(base.Validate());
        }
Example #15
0
        public override Task ActivateAsync()
        {
            try
            {
                Installations.Clear();

                foreach (var install in SettingsController.GetInstallations())
                {
                    Installations.Add(new InstallLocationModel(install));
                }
            }
            catch (Exception e)
            {
                Tracer.Error(e);
            }

            return(base.ActivateAsync());
        }
Example #16
0
        private void UpdateInstallations()
        {
            Installations.Clear();

            var selectedInstall = SelectedInstall.Value;

            if (selectedInstall == null)
            {
                selectedInstall = SettingsController.GetCurrentInstall();
            }

            foreach (var install in SettingsController.GetInstallations())
            {
                Installations.Add(install);
            }

            SelectedInstall.Value = selectedInstall;
        }
Example #17
0
        // TODO: the app shouldn't rely on if an MCFireWorld is found in WorldExporerService, it should:
        // TODO: 1) discover worlds found in an installation folder for use by the rest of the app
        // TODO: 2) save MCFireWorlds on shutdown
        // TODO: 3) MCFireWorlds should operate without being added to the service (operate after being removed too)
        // TODO: 4) MCFireWorlds should have clear guarantees when 2 operate on the same world (or when Minecraft open)
        // TODO: 5) Move IWorldExplorerService to MCFire.Common

        public WorldWorldExplorerService()
        {
            // TODO: FIRSTRUN after new assemblies
#if DEBUG && !FIRSTRUN
            // if debug, add game installation automatically
            if (Installations.Count != 0)
            {
                return;
            }
            var path =
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".minecraft")
                .ToLower();
            var gameInstall = Installation.New(path);
            if (gameInstall != null)
            {
                Installations.Add(gameInstall);
            }
#endif
        }
        private static Game CreateGame()
        {
            var game = new Game()
            {
                Rules = new GameRules(),

                Players = new EntityStore <Player>
                {
                    new Player()
                    {
                        Id   = 1,
                        Name = "Player One",
                    },
                },

                Galaxy = new Galaxy()
                {
                    Bounds = new GalaxyBounds(800),

                    Planets = new EntityStore <Planet>
                    {
                        new Planet()
                        {
                            Id       = 1,
                            Name     = "Planet One",
                            Position = new Position(100, 100),
                            Details  = new PlanetDetails()
                            {
                                Environment = new Environment(10, 50, 20),
                                Minerals    = new Minerals(20, 30, 50),
                            },
                            Settlement = new Settlement()
                            {
                                OwnerId       = 1,
                                Population    = new Population(10_000),
                                Installations = new Installations
                                {
                                    Scanner = 100,
                                },
                            },
                        },
                    },
                },
Example #19
0
        private void OnRemoveInstallation()
        {
            try
            {
                var installation = SelectedInstall.Value;

                if (installation == null)
                {
                    return;
                }

                Installations.Remove(installation);
                _settingsService.RemoveInstalls(installation.ConcreteInstall.Directory);
            }
            catch (Exception e)
            {
                GeneralExceptionHandler.Instance.OnError(e);
            }
        }
Example #20
0
        public bool TryGetInstallationForPath(string editorPath, out CodeEditor.Installation installation)
        {
            if (IsRiderInstallation(editorPath))
            {
                try
                {
                    installation = Installations.First(inst => inst.Path == editorPath);
                }
                catch (InvalidOperationException)
                {
                    installation = new CodeEditor.Installation {
                        Name = editorPath, Path = editorPath
                    };
                }
                return(true);
            }

            installation = default;
            return(false);
        }
Example #21
0
        private void OnRemoveInstallation()
        {
            try
            {
                var installation = SelectedInstall.Value;

                if (installation == null)
                {
                    return;
                }

                if (MessageBoxEx.Show($"Are you sure you want to remove the {installation.ConcreteInstall.Name} install", "Remove Install", System.Windows.MessageBoxButton.YesNo) == System.Windows.MessageBoxResult.Yes)
                {
                    Installations.Remove(installation);
                    SettingsController.RemoveInstalls(installation.ConcreteInstall.Directory);
                }
            }
            catch (Exception e)
            {
                GeneralExceptionHandler.Instance.OnError(e);
            }
        }
Example #22
0
        private void DiscoverAndAddInstallationsFromRegistry(bool user_scope)
        {
            RemoveRegistryAutoDiscoveredInstallations(user_scope);

            var _installs = user_scope ? AdoptiumInstallationsDiscoverer.DiscoverInstallationsByRegistryHKCU() :
                            AdoptiumInstallationsDiscoverer.DiscoverInstallationsByRegistryHKLM();

            HoldAutoReCheckForUpdateSuggested = true;
            for (int k = 0; k < _installs.Count; k++)
            {
                DiscoveredInstallation i = _installs[k];

                // we want to reset HoldAutoReCheckForUpdateSuggested at the last element
                if (k == _installs.Count - 1)
                {
                    HoldAutoReCheckForUpdateSuggested = false;
                }

                Installation inst = new Installation(i, true, user_scope);
                Installations.Add(inst);
            }
        }
        private void PrintSpotCheckReport()
        {
            Installations objInstallationDetails = tvMachineList.SelectedItem as Installations;

            if (objInstallationDetails == null)
            {
                return;
            }

            List <SpotCheck> lstSpotCheck = new List <SpotCheck>();

            lstSpotCheck = lstSpotCheckSummaryDetails.Where(item => item.InstallationNo == objInstallationDetails.Installation_No).ToList();
            if (lstSpotCheck == null || lstSpotCheck.Count <= 0)
            {
                return;
            }

            using (CReportViewer cReportViewer = new CReportViewer())
            {
                cReportViewer.ShowSpotCheckReport(
                    objInstallationDetails.Bar_Position_Name,
                    objInstallationDetails.Zone_Name.IsNullOrEmpty() ? string.Empty : objInstallationDetails.Zone_Name,
                    objInstallationDetails.GameTitle,                                //(Convert.ToDecimal(objInstallationDetails.POP) / 100).ToString(),
                    (Convert.ToDecimal(objInstallationDetails.POP)).ToString(),
                    lstSpotCheck[0].DateTimeStamp,
                    (lstSpotCheck[0].CashIn - lstSpotCheck[0].CashOut),
                    lstSpotCheck[0].CashIn,
                    Convert.ToDecimal(lstSpotCheck[0].Payout),
                    Convert.ToDecimal(lstSpotCheck[0].CoinsDrop.ToString("#,##0.00")),
                    lstSpotCheck[0].HandPay,
                    lstSpotCheck[0].Date,
                    Settings.SiteCode
                    );
                cReportViewer.ShowDialog();
            }
        }
Example #24
0
        private async Task NewInstallHandler()
        {
            var specDialog = new InstallationSpecBuilderDialog();

            if (specDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            using (_lock.Lock())
            {
                try
                {
                    await Task.Run(() => _factorio.GetStandaloneInstallation(specDialog.SpecResult));

                    Installations.Clear();
                    Installations.AddRange(_factorio.EnumerateInstallations());
                }
                catch (UnauthorizedAccessException)
                {
                    Error = "Could not access the directory.";
                }
                catch (DirectoryNotFoundException)
                {
                    Error = "Invalid directory.";
                }
                catch (IOException)
                {
                    Error = "The path exists as a file, or is on an unmapped drive.";
                }
                catch (SecurityException)
                {
                    Error = "Not authorized to access the directory.";
                }
            }
        }
Example #25
0
 private void AddInst(Installations inst)
 {
     currRoom.ListOfInstallations.Add(inst);
 }
Example #26
0
 private void SaveImp_Click(object sender, EventArgs e)
 {
     if (!isNewImp) SaveLoad.UpdateEl_2(tempImp, ImpedanceDate.Value, objId, db);
     else
     {
         if (currObj.El_2.Any<El_2>(p => p.ControlDate == IsolationDate.Value))
         {
             MessageBox.Show("Вече съществува актуализация със същата дата!");
             return;
         }
         SaveLoad.SaveEl_2(tempImp, objId, db);
         //currObj.El_1.Add(tempIsol);
     }
     foreach (Control con in Impedance.Controls)
     {
         if (con == NewActImp || con == EditActImp || con == SaveImp || con == BackImp || con == EngineerNameImp || con == ImpedanceDate)
             con.Enabled = true;
         else con.Enabled = false;
     }
     //db.SaveChanges();
     SwitchVisImp();
     El_2 t = tempImp;
     tempImp = new El_2();
     foreach (Sectors sec in t.ListOfSectors)
     {
         Sectors tempS = new Sectors();
         tempS.SectorName = sec.SectorName;
         foreach (Floors f in sec.ListOfFloors)
         {
             Floors tempF = new Floors();
             tempF.NameFloor = f.NameFloor;
             foreach (Rooms r in f.ListOfRooms)
             {
                 Rooms tempR = new Rooms();
                 tempR.RoomName = r.RoomName;
                 foreach (Installations inst in r.ListOfInstallations)
                 {
                     Installations tempI = new Installations();
                     tempI.Amperage = inst.Amperage;
                     tempI.Coefficient = inst.Coefficient;
                     tempI.FollowsRequirements = inst.FollowsRequirements;
                     tempI.Impedance = inst.Impedance;
                     tempI.InstallationName = inst.InstallationName;
                     tempI.isAutomaticProtector = inst.isAutomaticProtector;
                     tempI.Item = inst.Item;
                     tempI.Max = inst.Max;
                     tempI.NumberOfInstallation = inst.NumberOfInstallation;
                     tempI.Ofazen = inst.Ofazen;
                     tempI.Reset = inst.Reset;
                     tempR.ListOfInstallations.Add(tempI);
                 }
                 tempF.ListOfRooms.Add(tempR);
             }
             tempS.ListOfFloors.Add(tempF);
         }
         tempImp.ListOfSectors.Add(tempS);
     }
     tempImp.Coefficent = t.Coefficent;
     tempImp.ControlDate = t.ControlDate;
     tempImp.isAuto = t.isAuto;
     tempImp.MaxMeasured = t.MaxMeasured;
     tempImp.MinMeasured = t.MinMeasured;
     tempImp.NameOfEngineer = t.NameOfEngineer;
     tempImp.ObjectName = t.ObjectName;
 }
Example #27
0
        private void rows_TextChanged(object sender, EventArgs e)
        {
            TextBox temp = sender as TextBox;
            if (temp.Text.IndexOf("\r\n") == -1 || temp.Text == "") return;
            temp.Text = temp.Text.Replace("\r\n", "");
            temp.Text = temp.Text.Replace(" ", "");
            int type = Rows.Controls.IndexOf(temp);
            string[] sp = temp.Text.Split(',');
            Installations lum = new Installations();
            Random r = new Random();
            //try
            //{
                foreach (Installations inst in currRoom.ListOfInstallations)
                {
                    if (inst.Item.Id > 4000) currRoom.ListOfInstallations.Remove(inst);
                }
                foreach (string s in sp)
                {
                    currRoom.ListOfInstallations.Add(new Installations());
                    for (int i = 0; i < System.Convert.ToInt32(s); i++ )
                    {
                        lum.isAutomaticProtector = ((LumIsAuto.Controls[type] as GroupBox).Controls[1] as RadioButton).Checked;
                        lum.Impedance = r.NextDouble() * (EL2Ref.MaxMeasured - EL2Ref.MaxMeasured) + EL2Ref.MaxMeasured;
                        lum.Amperage = System.Convert.ToDouble((LumAmp.Controls[type] as NumericUpDown).Value);
                        lum.Coefficient = EL2Ref.Coefficent;
                        lum.Ofazen = false;
                        lum.Reset = true;
                        lum.Max = (Main.Stats.lambda * lum.Coefficient) / lum.Amperage;
                        lum.FollowsRequirements = (lum.Impedance < lum.Max) && lum.Reset && !lum.Ofazen;
                        lum.NumberOfInstallation = i;
                        lum.NumberOfProtector = -1;
                        lum.Id = currRoom.ListOfInstallations.Count;
                        lum.InstallationName = Main.Stats.Items[type + ContCount.Controls.Count + LightCount.Controls.Count + PowAmpCollection.Controls.Count].Name + " №" + lum.NumberOfInstallation.ToString();
                        lum.Item = Main.Stats.Items[type + ContCount.Controls.Count + LightCount.Controls.Count + PowAmpCollection.Controls.Count];
                        currRoom.ListOfInstallations.Add(lum);
                    }

                }
            //}
            //catch
            //{
            //    MessageBox.Show("Грешно въведени данни за редовете. Използвайте числа, разделени със запетаи!");
            //    temp.Text = "";
            //}
        }
Example #28
0
 private void Count_ValueChanged(object sender, EventArgs e)
 {
     NumericUpDown temp = sender as NumericUpDown;
     int value = System.Convert.ToInt32(temp.Value);
     Panel container = counts.First<Panel>(p => p.Controls.IndexOf(temp) > -1);
     int prim = counts.ToList<Panel>().IndexOf(container);
     int sec = container.Controls.IndexOf(temp);
     string name = names[prim].Items[sec * 2].ToString();
     InstallationItem item = Main.Stats.Items.First<InstallationItem>(i => i.Name == name);
     int type = Main.Stats.Items.IndexOf(item);
     //if (Main.Stats.Items[type].Id >= 4000) prim = 3;
     //Panel[]
     Installations firstInst = currRoom.ListOfInstallations.FirstOrDefault(i => i.Item == item);
     int first = currRoom.FirstIndex(type);
     if(firstInst == null) first = -1;
     int count = currRoom.ListOfInstallations.Count(i => i.Item == item);
     int last = first + count - 1;
     List<Installations> ofType = (from p in currRoom.ListOfInstallations
                                       where p.Item == item
                                       select p).ToList<Installations>();
     Random r = new Random();
     if (value < count)
     {
         DialogResult dialogResult;
         if (showMsg) dialogResult = MessageBox.Show("По този начин ще изтриете вече въведени съоръжения. Сигурни ли сте, че искате да продължите?", "Изтриване на съоръжения", MessageBoxButtons.YesNo);
         else dialogResult = System.Windows.Forms.DialogResult.Yes;
         if (dialogResult == DialogResult.Yes)
         {
             for (int i = value; i < count; i++)
             {
                 Installations instToDel = ofType.ElementAt(value);
                 currRoom.ListOfInstallations.Remove(instToDel);
                 //ImpBindingSource.RemoveAt(first + value);
                 CurrProg.DataSource = ImpBindingSource;
             }
             ImpBindingSource.Clear();
             foreach (Installations inst in currRoom.ListOfInstallations) ImpBindingSource.Add(inst);
             CurrProg.DataSource = ImpBindingSource;
             CurrProg.Columns[0].DataPropertyName = "InstallationName";
             CurrProg.Columns[1].DataPropertyName = "Amperage";
             CurrProg.Columns[2].DataPropertyName = "Coefficient";
             CurrProg.Columns[3].DataPropertyName = "Impedance";
             CurrProg.Columns[4].DataPropertyName = "Max";
             CurrProg.Update();
             CurrProg.Refresh();
         }
     }
     else
     {
         Installations tempInst = new Installations();
         Control ContainerCount = new Control(), ContainerType = new Control(), ContainerAmp = new Control();
         if (prim == 0) { ContainerCount = ContCount; ContainerType = TypePro; ContainerAmp = ContAmp; }
         if (prim == 1) { ContainerCount = LightCount; ContainerType = LightTypePro; ContainerAmp = LightAmp; }
         if (prim == 2) { ContainerCount = PowAmp; ContainerType = PowIsAuto; ContainerAmp = PowAmperage; }
         if (prim == 3) { ContainerCount = Rows; ContainerType = LumIsAuto; ContainerAmp = LumAmp; }
         int typeThis = ContainerCount.Controls.IndexOf(temp);
         if (count == 0)
         {
             for (int i = 0; i < value; i++)
             {
                 tempInst = new Installations();
                 tempInst.Item = Main.Stats.Items[type];
                 tempInst.isAutomaticProtector = ((ContainerType.Controls[typeThis] as GroupBox).Controls[1] as RadioButton).Checked;
                 tempInst.Impedance = r.NextDouble() * (EL2Ref.MaxMeasured - EL2Ref.MinMeasured) + EL2Ref.MinMeasured;
                 tempInst.Amperage = System.Convert.ToDouble((ContainerAmp.Controls[typeThis] as NumericUpDown).Value);
                 tempInst.Coefficient = EL2Ref.Coefficent;
                 tempInst.Ofazen = false;
                 tempInst.Reset = true;
                 tempInst.Max = Main.Stats.lambda / (tempInst.Amperage * tempInst.Coefficient);
                 tempInst.FollowsRequirements = (tempInst.Impedance < tempInst.Max) && tempInst.Reset && !tempInst.Ofazen;
                 tempInst.NumberOfInstallation = i + 1;
                 tempInst.NumberOfProtector = -1;
                 //tempInst.Id = currRoom.ListOfInstallations.Count;
                 if (value > 1) tempInst.InstallationName = Main.Stats.Items[type].Name + " №" + (tempInst.NumberOfInstallation).ToString();
                 else tempInst.InstallationName = Main.Stats.Items[type].Name;
                 AddInst(tempInst);
                 ImpBindingSource.Add(tempInst);
                 CurrProg.DataSource = ImpBindingSource;
                 CurrProg.Columns[0].DataPropertyName = "InstallationName";
                 CurrProg.Columns[1].DataPropertyName = "Amperage";
                 CurrProg.Columns[2].DataPropertyName = "Coefficient";
                 CurrProg.Columns[3].DataPropertyName = "Impedance";
                 CurrProg.Columns[4].DataPropertyName = "Max";
             }
         }
         else
         {
             for (int i = last; i < last + value - count; i++)
             {
                 tempInst = new Installations();
                 tempInst.Item = Main.Stats.Items[type];
                 tempInst.isAutomaticProtector = ((ContainerType.Controls[typeThis] as GroupBox).Controls[1] as RadioButton).Checked;
                 tempInst.Impedance = r.NextDouble() * (EL2Ref.MaxMeasured - EL2Ref.MinMeasured) + EL2Ref.MinMeasured;
                 tempInst.Amperage = System.Convert.ToDouble((ContainerAmp.Controls[typeThis] as NumericUpDown).Value);
                 tempInst.Coefficient = EL2Ref.Coefficent;
                 tempInst.Ofazen = false;
                 tempInst.Reset = true;
                 tempInst.Max = Main.Stats.lambda / (tempInst.Amperage * tempInst.Coefficient);
                 tempInst.FollowsRequirements = (tempInst.Impedance < tempInst.Max) && tempInst.Reset && !tempInst.Ofazen;
                 tempInst.NumberOfInstallation = i + 1 - first;
                 tempInst.NumberOfProtector = -1;
                 //tempInst.Id = currRoom.ListOfInstallations.Count;
                 if (value > 1) tempInst.InstallationName = Main.Stats.Items[type].Name + " №" + (tempInst.NumberOfInstallation).ToString();
                 else tempInst.InstallationName = Main.Stats.Items[type].Name;
                 currRoom.Insert(i + 1, tempInst);
                 ImpBindingSource.Insert(i + 1, tempInst);
                 CurrProg.DataSource = ImpBindingSource;
                 CurrProg.Columns[0].DataPropertyName = "InstallationName";
                 CurrProg.Columns[1].DataPropertyName = "Amperage";
                 CurrProg.Columns[2].DataPropertyName = "Coefficient";
                 CurrProg.Columns[3].DataPropertyName = "Impedance";
                 CurrProg.Columns[4].DataPropertyName = "Max";
             }
         }
     }
     CurrProg.Update();
     CurrProg.Refresh();
 }
Example #29
0
 public static void InitializeInstallations()
 {
     Assert.IsTrue(Installations.FindRDirectory());
     Assert.IsTrue(Installations.FindSkyline());
 }
Example #30
0
 private void RemoveRegistryAutoDiscoveredInstallations(bool user_scope)
 {
     Installations.Remove(x => (x.IsRegistryAutodiscoveredInstance && x.RegistryUserScope == user_scope));
 }