public OSInstallation(GameEnvironment gameEnvironment) { InitializeComponent(); GameEnvironment = gameEnvironment; Collection <OpticalDisc> opticalDiscs = new Collection <OpticalDisc>(); foreach (OpticalDrive opticalDrive in GameEnvironment.Computers.CurrentPlayerComputer.OpticalDrives) { if (opticalDrive.Properties.OpticalDisc != null) { opticalDiscs.Add(opticalDrive.Properties.OpticalDisc); } } foreach (Game.Objects.OperatingSystem os in GameEnvironment.Items.AllOperatingSystems) { foreach (OpticalDisc opticalDisc in opticalDiscs) { if (opticalDisc.Properties.OperatingSystem == os.Uid) { LabelInstall.Content = "Установка " + os.Name; StartInstallButton.IsEnabled = true; OpticalDisc = opticalDisc; OperatingSystem = os; return; } } } LabelInstall.Content = "Файлы операционной системы не найдены!"; }
private void BuyButton_Click(object sender, RoutedEventArgs e) { if (GameEnvironment.Player.House == null) { GameMessageBox.Show("Покупка", "Вам негде это хранить, для начала обзаведитесь жильем.", GameMessageBox.MessageBoxType.Information); return; } Button button = sender as Button; if (button.Tag is BaseItem) { double price = (button.Tag as BaseItem).Price * GameEnvironment.Money.PlayerCurrency[0].Course; price += price / 100 * StorePercentage; if (price <= GameEnvironment.Money.PlayerCurrency[0].Count) { GameEnvironment.Money.PlayerCurrency[0].Withdraw("Оплата покупки: " + (button.Tag as BaseItem).Name, "Киоск с дисками", GameEnvironment.GameEvents.GameTimer.DateAndTime, price); CoinCount.Content = GameEnvironment.Money.PlayerCurrency[0].Count.ToString("N3") + " " + GameEnvironment.Money.PlayerCurrency[0].Abbreviation; if (button.Tag is OpticalDisc) { OpticalDisc opticalDisc = (button.Tag as OpticalDisc); GameEnvironment.Items.OpticalDiscs.Add(new OpticalDisc(opticalDisc.Uid, opticalDisc.Name, opticalDisc.GetTypeValue(), opticalDisc.Price, opticalDisc.ManufacturingDate, opticalDisc.Properties)); } SellerText.Text = "Спасибо за покупку " + (button.Tag as BaseItem).Name + ", держите свой компакт-диск!"; } else { SellerText.Text = "Извини, без денег я тебе его не отдам."; } } }
private void OpenDisc_Click(object sender, RoutedEventArgs e) { Button button = (sender as Button); var parent = FindParent <DockPanel>(button); if (parent == null) { return; } var child = GetChildOfType <ComboBox>(parent); if (child == null) { return; } if (child.Tag is OpticalDrive) { OpticalDisc opticalDisc = (child.Tag as OpticalDrive).Properties.OpticalDisc; if (opticalDisc == null) { return; } if (opticalDisc.Properties.Programs != null) { InstallSoft.Children.Clear(); InstallSoft.Children.Add(new MCInstallSoft(GameEnvironment, opticalDisc.Properties.Programs)); DevicesAndDrives.Visibility = Visibility.Collapsed; InstallSoft.Visibility = Visibility.Visible; } else { GameMessageBox.Show("Запуск с диска", "На этом диске нет программ!", GameMessageBox.MessageBoxType.Information); } } }
private void OpticalDisc_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (initialize) { return; } ComboBox comboBox = (sender as ComboBox); if (comboBox.SelectedItem != null) { OpticalDisc opticalDisc = ((comboBox.SelectedItem as ComboBoxItem).Tag as OpticalDisc); (comboBox.Tag as OpticalDrive).Properties.OpticalDisc = opticalDisc; Drawing(); } }
private void LoadFromCD(GameEvent @event) { if (DiscInDrive.SelectedItem != null) { OpticalDisc opticalDisc = DiscInDrive.SelectedItem as OpticalDisc; foreach (Objects.OperatingSystem operatingSystem in GameEnvironment.Items.AllOperatingSystems) { if (opticalDisc.Properties.OperatingSystem == operatingSystem.Uid) { OutputFromComputer.Visibility = Visibility.Collapsed; DiscPanel.Visibility = Visibility.Visible; ComputersList.IsEnabled = true; break; } } ComputersList.IsEnabled = true; } else { OutputFromComputer.Text = "Reboot and Select proper Boot device \r or Insert Boot Media in selected Boot device"; ComputersList.IsEnabled = true; } }
public ReturnResult <OpticalDisc> GetById(int id) { DbProvider dbProvider = new DbProvider(); string outCode = String.Empty; string outMessage = String.Empty; OpticalDisc opticalDisc = null; StoredProcedureConfigs <OpticalDisc> storedProcedureConfigs = new StoredProcedureConfigs <OpticalDisc>(); dbProvider.SetQuery(storedProcedureConfigs._GET_SINGLE_STORED_PROCEDURE, CommandType.StoredProcedure) .SetParameter("Id", SqlDbType.Int, id, ParameterDirection.Input) .SetParameter("ERROR_CODE", SqlDbType.NVarChar, DBNull.Value, 100, ParameterDirection.Output) .SetParameter("ERROR_MESSAGE", SqlDbType.NVarChar, DBNull.Value, 400, ParameterDirection.Output) .GetSingle <OpticalDisc>(out opticalDisc) .Complete(); dbProvider.GetOutValue("ERROR_CODE", out outCode) .GetOutValue("ERROR_MESSAGE", out outMessage); return(new ReturnResult <OpticalDisc>() { Item = opticalDisc, ErrorCode = outCode, ErrorMessage = outMessage, }); }