static InfoboxExtractorTests() { _mockedCommons = Commons.Instance; _mockedTitleParserSingle = new TitleParserSingle(_mockedCommons, new SpecialBuildingNameHelper()); string basePath = AppDomain.CurrentDomain.BaseDirectory; input_Bakery = File.ReadAllText(Path.Combine(basePath, "Testdata", "Extractor", "input_Bakery.txt")); result_Bakery = File.ReadAllText(Path.Combine(basePath, "Testdata", "Extractor", "result_Bakery.infobox")); input_Bank = File.ReadAllText(Path.Combine(basePath, "Testdata", "Extractor", "input_Bank.txt")); result_Bank = File.ReadAllText(Path.Combine(basePath, "Testdata", "Extractor", "result_Bank.infobox")); input_Fishery = File.ReadAllText(Path.Combine(basePath, "Testdata", "Extractor", "input_Fishery.txt")); result_Fishery = File.ReadAllText(Path.Combine(basePath, "Testdata", "Extractor", "result_Fishery.infobox")); input_Hospital = File.ReadAllText(Path.Combine(basePath, "Testdata", "Extractor", "input_Hospital.txt")); result_Hospital = File.ReadAllText(Path.Combine(basePath, "Testdata", "Extractor", "result_Hospital.infobox")); input_Lumberjack = File.ReadAllText(Path.Combine(basePath, "Testdata", "Extractor", "input_Lumberjack's_Hut.txt")); result_Lumberjack = File.ReadAllText(Path.Combine(basePath, "Testdata", "Extractor", "result_Lumberjack's_Hut.infobox")); input_Sawmill = File.ReadAllText(Path.Combine(basePath, "Testdata", "Extractor", "input_Sawmill.txt")); result_Sawmill = File.ReadAllText(Path.Combine(basePath, "Testdata", "Extractor", "result_Sawmill.infobox")); }
public MainViewModelTests() { _mockedFileSystem = new MockFileSystem(); var commonsMock = new Mock <ICommons>(); commonsMock.SetupGet(x => x.CurrentLanguage).Returns(() => "English"); commonsMock.SetupGet(x => x.CurrentLanguageCode).Returns(() => "eng"); commonsMock.SetupGet(x => x.LanguageCodeMap).Returns(() => new Dictionary <string, string>()); _mockedCommons = commonsMock.Object; var mockedLocalizationHelper = new Mock <ILocalizationHelper>(); mockedLocalizationHelper.Setup(x => x.GetLocalization(It.IsAny <string>())).Returns <string>(x => x); mockedLocalizationHelper.Setup(x => x.GetLocalization(It.IsAny <string>(), It.IsAny <string>())).Returns((string value, string langauge) => value); _mockedLocalizationHelper = mockedLocalizationHelper.Object; Localization.Localization.Init(_mockedCommons); _mockedAppSettings = new Mock <IAppSettings>().Object; var annoCanvasMock = new Mock <IAnnoCanvas>(); annoCanvasMock.SetupAllProperties(); //The QuadTree does not have a default constructor, so we need to explicitly set up the property annoCanvasMock.Setup(x => x.PlacedObjects).Returns(new Core.DataStructures.QuadTree <LayoutObject>(new Rect(-100, -100, 200, 200))); _mockedAnnoCanvas = annoCanvasMock.Object; _inMemoryRecentFilesHelper = new RecentFilesHelper(new RecentFilesInMemorySerializer(), new MockFileSystem()); _mockedMessageBoxService = new Mock <IMessageBoxService>().Object; _mockedUpdateHelper = new Mock <IUpdateHelper>().Object; _mockedCellGrouper = Mock.Of <IAdjacentCellGrouper>(); }
public InfoboxParser(ICommons commons) { _commons = commons; parser = new Parser(_commons); parserBothWorlds = new ParserBothWorlds(_commons); }
public WelcomeViewModel(ICommons commonsToUse, IAppSettings appSettingsToUse) { _commons = commonsToUse; _appSettings = appSettingsToUse; Languages = new ObservableCollection <SupportedLanguage>(); Languages.Add(new SupportedLanguage("English") { FlagPath = "Flags/United Kingdom.png" }); Languages.Add(new SupportedLanguage("Deutsch") { FlagPath = "Flags/Germany.png" }); Languages.Add(new SupportedLanguage("Français") { FlagPath = "Flags/France.png" }); Languages.Add(new SupportedLanguage("Polski") { FlagPath = "Flags/Poland.png" }); Languages.Add(new SupportedLanguage("Русский") { FlagPath = "Flags/Russia.png" }); ContinueCommand = new RelayCommand(Continue, CanContinue); }
static InfoboxParserTests() { _mockedCommons = Commons.Instance; _mockedSpecialBuildingNameHelper = new SpecialBuildingNameHelper(); _mockedTitleParserSingle = new TitleParserSingle(_mockedCommons, _mockedSpecialBuildingNameHelper); _mockedRegionHelper = new RegionHelper(); }
public PresetsTreeViewModelTests() { var commonsMock = new Mock <ICommons>(); commonsMock.SetupGet(x => x.SelectedLanguage).Returns(() => "English"); _mockedCommons = commonsMock.Object; }
public StatisticsViewModel(ICommons commonsToUse) { _commons = commonsToUse; TextNothingPlaced = "Nothing Placed"; TextBoundingBox = "Bounding Box"; TextMinimumArea = "Minimum Area"; TextSpaceEfficiency = "Space Efficiency"; TextBuildings = "Buildings"; TextBuildingsSelected = "Buildings Selected"; TextTiles = "Tiles"; TextNameNotFound = "Building name not found"; UsedArea = "12x4"; UsedTiles = 308; MinTiles = 48; Efficiency = "16%"; AreStatisticsAvailable = true; ShowBuildingList = true; Buildings = new ObservableCollection <StatisticsBuilding>(); SelectedBuildings = new ObservableCollection <StatisticsBuilding>(); _statisticsCalculationHelper = new StatisticsCalculationHelper(); _cachedPresetsBuilding = new Dictionary <string, BuildingInfo>(50); }
public InfoboxExtractor(ICommons commonsToUse, ITitleParserSingle titleParserSingleToUse) { _commons = commonsToUse; _titleParserSingle = titleParserSingleToUse; regexMultipleInfoboxes = new Regex(_commons.InfoboxTemplateStart, RegexOptions.Compiled); }
private IParserMultipleRegions GetParser(ICommons commonsToUse = null, ISpecialBuildingNameHelper specialBuildingNameHelperToUse = null, IRegionHelper regionHelperToUse = null) { return(new ParserMultipleRegions(commonsToUse ?? _mockedCommons, specialBuildingNameHelperToUse ?? _mockedSpecialBuildingNameHelper, regionHelperToUse ?? _mockedRegionHelper)); }
public ParserSingleRegion(ICommons commons, ITitleParserSingle titleParserSingleToUse) { _commons = commons; _titleParserSingle = titleParserSingleToUse; //all numbers in the wiki are entered with comma (,) e.g. "42,21", so we need to use a specific culture for parsing (https://anno1800.fandom.com/wiki/Cannery) cultureForParsing = new CultureInfo("de-DE"); }
public ParserBothWorlds(ICommons commons) { _commons = commons; possibleRegions = new List <string> { "OW", "NW" }; }
private MainViewModel GetViewModel(ICommons commonsToUse = null, IAppSettings appSettingsToUse = null, IAnnoCanvas annoCanvasToUse = null) { return(new MainViewModel(commonsToUse ?? _mockedCommons, appSettingsToUse ?? _mockedAppSettings) { AnnoCanvas = annoCanvasToUse ?? _mockedAnnoCanvas }); }
public MainViewModelTests() { var commonsMock = new Mock <ICommons>(); commonsMock.SetupGet(x => x.SelectedLanguage).Returns(() => "English"); _mockedCommons = commonsMock.Object; _mockedAppSettings = new Mock <IAppSettings>().Object; }
private InfoboxParser GetParser(ICommons commonsToUse = null, ITitleParserSingle titleParserSingleToUse = null, ISpecialBuildingNameHelper specialBuildingNameHelperToUse = null, IRegionHelper regionHelperToUse = null) { return(new InfoboxParser(commonsToUse ?? _mockedCommons, titleParserSingleToUse ?? _mockedTitleParserSingle, specialBuildingNameHelperToUse ?? _mockedSpecialBuildingNameHelper, regionHelperToUse ?? _mockedRegionHelper)); }
/// <summary> /// only used for databinding /// </summary> public BuildingSettingsViewModel(ICommons commonsToUse, IAppSettings appSettingsToUse) { _commons = commonsToUse; _appSettings = appSettingsToUse; ApplyColorToSelectionCommand = new RelayCommand(ApplyColorToSelection, CanApplyColorToSelection); ApplyPredefinedColorToSelectionCommand = new RelayCommand(ApplyPredefinedColorToSelection, CanApplyPredefinedColorToSelection); UseColorInLayoutCommand = new RelayCommand(UseColorInLayout, CanUseColorInLayout); //only used for WPF Desinger TextHeader = "Building Settings"; TextSize = "Size"; TextColor = "Color"; TextApplyColorToSelection = "Apply color"; TextApplyColorToSelectionToolTip = "Apply color to all buildings in current selection"; TextApplyPredefinedColorToSelection = "Apply predefined color"; TextApplyPredefinedColorToSelectionToolTip = "Apply predefined color (if found) to all buildings in current selection"; TextAvailableColors = "Available Colors"; TextStandardColors = "Predefined Colors"; TextRecentColors = "Recent Colors"; TextStandard = "Standard"; TextAdvanced = "Advanced"; TextColorsInLayout = "Colors in Layout"; TextColorsInLayoutToolTip = "Double click color to select it"; TextBuildingName = "Label"; TextIcon = "Icon"; TextInfluenceType = "Influence Type"; TextRadius = "Radius"; TextDistance = "Distance"; TextPavedStreet = "Paved Street"; TextPavedStreetWarningTitle = "Paved Street Selection"; TextPavedStreetToolTip = "Checking this option will change the Influence Range for buildings,\nrepresenting the increased range they receive when using paved streets.\nUse the 'Place Building' button to place object."; TextOptions = "Options"; TextEnableLabel = "Enable label"; TextBorderless = "Borderless"; TextRoad = "Road"; TextPlaceBuilding = "Place building"; SelectedColor = Colors.Red; BuildingHeight = 4; BuildingWidth = 4; BuildingTemplate = string.Empty; BuildingName = string.Empty; BuildingIdentifier = string.Empty; BuildingRadius = 0; BuildingInfluenceRange = 0; IsEnableLabelChecked = false; IsBorderlessChecked = false; IsRoadChecked = false; ColorsInLayout = new ObservableCollection <SerializableColor>(); BuildingInfluences = new ObservableCollection <BuildingInfluence>(); InitBuildingInfluences(); SelectedBuildingInfluence = BuildingInfluences.SingleOrDefault(x => x.Type == BuildingInfluenceType.None); }
public AboutViewModel(ICommons commonsToUse) { _commons = commonsToUse; OpenOriginalHomepageCommand = new RelayCommand(OpenOriginalHomepage); OpenProjectHomepageCommand = new RelayCommand(OpenProjectHomepage); OpenWikiHomepageCommand = new RelayCommand(OpenWikiHomepage); CloseWindowCommand = new RelayCommand <ICloseable>(CloseWindow); UpdateLanguage(); }
static ParserTests() { mockedCommons = Commons.Instance; string basePath = AppDomain.CurrentDomain.BaseDirectory; testDataSchnapps_Distillery = File.ReadAllText(Path.Combine(basePath, "Testdata", "Schnapps_Distillery.infobox")); testDataBakery = File.ReadAllText(Path.Combine(basePath, "Testdata", "Bakery.infobox")); testDataCannery = File.ReadAllText(Path.Combine(basePath, "Testdata", "Cannery.infobox")); testDataChapel = File.ReadAllText(Path.Combine(basePath, "Testdata", "Chapel.infobox")); testDataEmpty = File.ReadAllText(Path.Combine(basePath, "Testdata", "empty.infobox")); }
static App() { _commons = Commons.Instance; _appSettings = AppSettings.Instance; _messageBoxService = new MessageBoxService(); Localization.Localization.Init(_commons); _localizationHelper = Localization.Localization.Instance; _updateHelper = new UpdateHelper(ApplicationPath, _appSettings, _messageBoxService, _localizationHelper); _fileSystem = new FileSystem(); }
static ParserBothWorldsTests() { mockedCommons = Commons.Instance; string basePath = AppDomain.CurrentDomain.BaseDirectory; testDataPoliceStation = File.ReadAllText(Path.Combine(basePath, "Testdata", "Police_Station.infobox")); testDataBrickFactory = File.ReadAllText(Path.Combine(basePath, "Testdata", "Brick_Factory.infobox")); testDataHospital = File.ReadAllText(Path.Combine(basePath, "Testdata", "Hospital.infobox")); testDataMarketplace = File.ReadAllText(Path.Combine(basePath, "Testdata", "Marketplace.infobox")); testDataSmallWareHouse = File.ReadAllText(Path.Combine(basePath, "Testdata", "Small_Warehouse.infobox")); testDataEmpty_BothWorlds = File.ReadAllText(Path.Combine(basePath, "Testdata", "empty_BothWorlds.infobox")); }
static ParserMultipleRegionsTests() { _mockedCommons = Commons.Instance; _mockedSpecialBuildingNameHelper = new SpecialBuildingNameHelper(); _mockedRegionHelper = new RegionHelper(); _regionList2Regions = new List <string> { "A", "B" }; _regionList3Regions = new List <string> { "A", "B", "C" }; }
public GeneralSettingsViewModel(IAppSettings appSettingsToUse, ICommons commonsToUse, IRecentFilesHelper recentFilesHelperToUse) { _appSettings = appSettingsToUse; _commons = commonsToUse; _commons.SelectedLanguageChanged += Commons_SelectedLanguageChanged; _recentFilesHelper = recentFilesHelperToUse; UseZoomToPoint = _appSettings.UseZoomToPoint; ZoomSensitivityPercentage = _appSettings.ZoomSensitivityPercentage; HideInfluenceOnSelection = _appSettings.HideInfluenceOnSelection; ShowScrollbars = _appSettings.ShowScrollbars; InvertPanningDirection = _appSettings.InvertPanningDirection; InvertScrollingDirection = _appSettings.InvertScrollingDirection; MaxRecentFiles = _appSettings.MaxRecentFiles; ResetZoomSensitivityCommand = new RelayCommand(ExecuteResetZoomSensitivity, CanExecuteResetZoomSensitivity); ResetMaxRecentFilesCommand = new RelayCommand(ExecuteResetMaxRecentFiles, CanExecuteResetMaxRecentFiles); ClearRecentFilesCommand = new RelayCommand(ExecuteClearRecentFiles, CanExecuteClearRecentFiles); GridLineColors = new ObservableCollection <UserDefinedColor>(); RefreshGridLineColors(); var savedGridLineColor = SerializationHelper.LoadFromJsonString <UserDefinedColor>(_appSettings.ColorGridLines); if (savedGridLineColor is null) { SelectedGridLineColor = GridLineColors.First(); SelectedCustomGridLineColor = SelectedGridLineColor.Color; } else { SelectedGridLineColor = GridLineColors.SingleOrDefault(x => x.Type == savedGridLineColor.Type); SelectedCustomGridLineColor = savedGridLineColor.Color; } ObjectBorderLineColors = new ObservableCollection <UserDefinedColor>(); RefreshObjectBorderLineColors(); var savedObjectBorderLineColor = SerializationHelper.LoadFromJsonString <UserDefinedColor>(_appSettings.ColorObjectBorderLines); if (savedObjectBorderLineColor is null) { SelectedObjectBorderLineColor = ObjectBorderLineColors.First(); SelectedCustomObjectBorderLineColor = SelectedObjectBorderLineColor.Color; } else { SelectedObjectBorderLineColor = ObjectBorderLineColors.SingleOrDefault(x => x.Type == savedObjectBorderLineColor.Type); SelectedCustomObjectBorderLineColor = savedObjectBorderLineColor.Color; } }
public PresetsTreeViewModel(ILocalizationHelper localizationHelperToUse, ICommons commonsToUse) { _localizationHelper = localizationHelperToUse; _commons = commonsToUse; Items = new ObservableCollection <GenericTreeItem>(); FilteredItems = CollectionViewSource.GetDefaultView(Items); DoubleClickCommand = new RelayCommand(DoubleClick, null); //SelectedItemChangedCommand = new RelayCommand(SelectedItemChanged, null); ReturnKeyPressedCommand = new RelayCommand(ReturnKeyPressed, null); BuildingPresetsVersion = string.Empty; FilterGameVersion = CoreConstants.GameVersion.All; FilterText = string.Empty; }
public MainViewModelTests() { var commonsMock = new Mock <ICommons>(); commonsMock.SetupGet(x => x.SelectedLanguage).Returns(() => "English"); _mockedCommons = commonsMock.Object; Localization.Localization.Init(_mockedCommons); _mockedAppSettings = new Mock <IAppSettings>().Object; var annoCanvasMock = new Mock <IAnnoCanvas>(); annoCanvasMock.SetupAllProperties(); _mockedAnnoCanvas = annoCanvasMock.Object; }
public UpdateSettingsViewModel(ICommons commonsToUse, IAppSettings appSettingsToUse, IMessageBoxService messageBoxServiceToUse, IUpdateHelper updateHelperToUse, ILocalizationHelper localizationHelperToUse) { _commons = commonsToUse; _appSettings = appSettingsToUse; _messageBoxService = messageBoxServiceToUse; _updateHelper = updateHelperToUse; _localizationHelper = localizationHelperToUse; CheckForUpdatesCommand = new RelayCommand(ExecuteCheckForUpdates); OpenReleasesCommand = new RelayCommand(ExecuteOpenReleases); DownloadPresetsCommand = new RelayCommand(ExecuteDownloadPresets); }
public ManageKeybindingsViewModel(HotkeyCommandManager hotkeyCommandManager, ICommons commons, IMessageBoxService messageBoxServiceToUse, ILocalizationHelper localizationHelperToUse) { HotkeyCommandManager = hotkeyCommandManager; _messageBoxService = messageBoxServiceToUse; _localizationHelper = localizationHelperToUse; EditCommand = new RelayCommand <Hotkey>(ExecuteRebind); ResetHotkeysCommand = new RelayCommand(ExecuteResetHotkeys); this.commons = commons; this.commons.SelectedLanguageChanged += Instance_SelectedLanguageChanged; UpdateRebindButtonText(); }
public StatisticsViewModel(ILocalizationHelper localizationHelperToUse, ICommons commonsToUse) { _localizationHelper = localizationHelperToUse; _commons = commonsToUse; UsedArea = "12x4"; UsedTiles = 308; MinTiles = 48; Efficiency = "16%"; AreStatisticsAvailable = true; ShowBuildingList = true; Buildings = new ObservableCollection <StatisticsBuilding>(); SelectedBuildings = new ObservableCollection <StatisticsBuilding>(); _statisticsCalculationHelper = new StatisticsCalculationHelper(); _cachedPresetsBuilding = new Dictionary <string, BuildingInfo>(50); }
public InfoboxParser(ICommons commonsToUse, ITitleParserSingle titleParserSingleToUse, ISpecialBuildingNameHelper specialBuildingNameHelperToUse, IRegionHelper regionHelperToUse) { _commons = commonsToUse; _titleParserSingle = titleParserSingleToUse; _specialBuildingNameHelper = specialBuildingNameHelperToUse; _regionHelper = regionHelperToUse; parserSingleRegion = new ParserSingleRegion(_commons, _titleParserSingle); parserOldAndNewWorld = new ParserOldAndNewWorld(_commons, _specialBuildingNameHelper, _regionHelper); parserMultipleRegions = new ParserMultipleRegions(_commons, _specialBuildingNameHelper, _regionHelper); possibleRegions_2Regions = new List <string> { "A", "B" }; possibleRegions_3Regions = new List <string> { "A", "B", "C" }; }
public MainWindow(ICommons commonsToUse) : this() { _commons = commonsToUse; App.DpiScale = VisualTreeHelper.GetDpi(this); _instance = this; // initialize web client _webClient = new WebClient(); _webClient.DownloadStringCompleted += WebClientDownloadStringCompleted; // add event handlers annoCanvas.OnCurrentObjectChanged += UpdateUIFromObject; annoCanvas.OnStatusMessageChanged += StatusMessageChanged; annoCanvas.OnLoadedFileChanged += LoadedFileChanged; annoCanvas.OnClipboardChanged += ClipboardChanged; annoCanvas.StatisticsUpdated += AnnoCanvas_StatisticsUpdated; DpiChanged += MainWindow_DpiChanged; //Get a reference an instance of Localization.MainWindow, so we can call UpdateLanguage() in the SelectedLanguage setter var dependencyObject = LogicalTreeHelper.FindLogicalNode(this, "Menu"); _mainWindowLocalization = (Localization.MainWindow)((Menu)dependencyObject).DataContext; //If language is not recognized, bring up the language selection screen if (!Localization.Localization.LanguageCodeMap.ContainsKey(Settings.Default.SelectedLanguage)) { var w = new Welcome(); w.ShowDialog(); } else { SelectedLanguage = Settings.Default.SelectedLanguage; } foreach (MenuItem item in LanguageMenu.Items) { if (item.Header.ToString() == SelectedLanguage) { item.IsChecked = true; } } LoadSettings(); }
public BuildingSettingsViewModelTests() { var commonsMock = new Mock <ICommons>(); commonsMock.SetupGet(x => x.CurrentLanguage).Returns(() => "English"); commonsMock.SetupGet(x => x.CurrentLanguageCode).Returns(() => "eng"); _mockedCommons = commonsMock.Object; var mockedLocalizationHelper = new Mock <ILocalizationHelper>(); mockedLocalizationHelper.Setup(x => x.GetLocalization(It.IsAny <string>())).Returns <string>(x => x); mockedLocalizationHelper.Setup(x => x.GetLocalization(It.IsAny <string>(), It.IsAny <string>())).Returns((string value, string langauge) => value); _mockedLocalization = mockedLocalizationHelper.Object; Localization.Localization.Init(commonsMock.Object); _mockedAppSettings = new Mock <IAppSettings>().Object; _mockedMessageBoxService = new Mock <IMessageBoxService>().Object; }
private MainViewModel GetViewModel(ICommons commonsToUse = null, IAppSettings appSettingsToUse = null, IRecentFilesHelper recentFilesHelperToUse = null, IMessageBoxService messageBoxServiceToUse = null, IUpdateHelper updateHelperToUse = null, ILocalizationHelper localizationHelperToUse = null, IAnnoCanvas annoCanvasToUse = null, IFileSystem fileSystemToUse = null) { return(new MainViewModel(commonsToUse ?? _mockedCommons, appSettingsToUse ?? _mockedAppSettings, recentFilesHelperToUse ?? _inMemoryRecentFilesHelper, messageBoxServiceToUse ?? _mockedMessageBoxService, updateHelperToUse ?? _mockedUpdateHelper, localizationHelperToUse ?? _mockedLocalizationHelper, fileSystemToUse ?? _mockedFileSystem) { AnnoCanvas = annoCanvasToUse ?? _mockedAnnoCanvas }); }