/// <summary> /// Returns the <see cref="KnownTileSource"/> equivalent of <see cref="WellKnownTileSource"/>. /// </summary> /// <param name="wellKnownTileSource">The tile provider to be used.</param> /// <returns>The <see cref="KnownTileSource"/> equivalent of the <paramref name="wellKnownTileSource"/>.</returns> /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="wellKnownTileSource"/> /// is not a valid enum value of <see cref="WellKnownTileSource"/>.</exception> /// <exception cref="NotSupportedException">Thrown when <paramref name="wellKnownTileSource"/> /// is not a supported member.</exception> private static KnownTileSource WellKnownTileSourceToKnownTileSource(WellKnownTileSource wellKnownTileSource) { if (!Enum.IsDefined(typeof(WellKnownTileSource), wellKnownTileSource)) { throw new InvalidEnumArgumentException(nameof(wellKnownTileSource), (int)wellKnownTileSource, typeof(WellKnownTileSource)); } switch (wellKnownTileSource) { case WellKnownTileSource.BingAerial: return(KnownTileSource.BingAerial); case WellKnownTileSource.BingHybrid: return(KnownTileSource.BingHybrid); case WellKnownTileSource.BingRoads: return(KnownTileSource.BingRoads); case WellKnownTileSource.EsriWorldTopo: return(KnownTileSource.EsriWorldTopo); case WellKnownTileSource.EsriWorldShadedRelief: return(KnownTileSource.EsriWorldShadedRelief); case WellKnownTileSource.OpenStreetMap: return(KnownTileSource.OpenStreetMap); default: throw new NotSupportedException(); } }
public void Constructor_ValidValues_ExpectedValues() { // Setup const WellKnownTileSource value = WellKnownTileSource.BingAerial; // Call var mapData = new WellKnownTileSourceMapData(value); // Assert Assert.IsInstanceOf <ImageBasedMapData>(mapData); Assert.AreEqual("Bing Maps - Satelliet", mapData.Name); Assert.IsTrue(mapData.IsVisible); Assert.IsTrue(mapData.IsConfigured); Assert.AreEqual(0, mapData.Transparency.Value); Assert.AreEqual(value, mapData.TileSource); }
public void Clone_FromFullyInitializedConfiguration_ReturnInitializedConfiguration() { // Setup const WellKnownTileSource knownTileSource = WellKnownTileSource.BingAerial; using (new UseCustomSettingsHelper(testSettingsHelper)) using (new UseCustomTileSourceFactoryConfig(new WellKnownTileSourceMapData(knownTileSource))) using (WellKnownTileSourceLayerConfiguration configuration = WellKnownTileSourceLayerConfiguration.CreateInitializedConfiguration(knownTileSource)) { // Call using (var clone = (WellKnownTileSourceLayerConfiguration)configuration.Clone()) { // Assert Assert.IsTrue(clone.Initialized); Assert.AreEqual(configuration.TileSchema, clone.TileSchema); Assert.AreEqual(configuration.TileSchema.Name, clone.TileSchema.Name); Assert.AreEqual(configuration.TileSchema.Format, clone.TileSchema.Format); Assert.IsInstanceOf <AsyncTileFetcher>(clone.TileFetcher); } } }
/// <summary> /// Creates a fully initialized instance of <see cref="WellKnownTileSourceLayerConfiguration"/>. /// </summary> /// <param name="wellKnownTileSource">The tile provider to be used.</param> /// <returns>The new <see cref="WellKnownTileSourceLayerConfiguration"/>.</returns> /// <exception cref="NotSupportedException">Thrown when <paramref name="wellKnownTileSource"/> /// isn't a supported member.</exception> /// <exception cref="CannotCreateTileCacheException">Thrown when creating the file /// cache failed.</exception> public static WellKnownTileSourceLayerConfiguration CreateInitializedConfiguration(WellKnownTileSource wellKnownTileSource) { KnownTileSource knownTileSourceEquivalent = WellKnownTileSourceToKnownTileSource(wellKnownTileSource); ITileSource tileSource = TileSourceFactory.Instance.GetKnownTileSource(knownTileSourceEquivalent); return(new WellKnownTileSourceLayerConfiguration(knownTileSourceEquivalent, tileSource)); }
/// <summary> /// Gets the name of the given tile source. /// </summary> /// <param name="tileSource">The tile source to get the name from.</param> /// <returns>The display name of the enum value.</returns> /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="tileSource"/> /// isn't a member of <see cref="WellKnownTileSource"/>.</exception> private static string GetTileSourceName(WellKnownTileSource tileSource) { return(TypeUtils.GetDisplayName(tileSource)); }
/// <summary> /// Sets the tile source of the map data. /// </summary> /// <param name="tileSource">The <see cref="WellKnownTileSource"/> to set.</param> /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="tileSource"/> /// isn't a member of <see cref="WellKnownTileSource"/>.</exception> public void SetTileSource(WellKnownTileSource tileSource) { Name = GetTileSourceName(tileSource); TileSource = tileSource; }
/// <summary> /// Initializes a new instance of <see cref="WellKnownTileSourceMapData"/>. /// </summary> /// <param name="tileSource">The tile source.</param> /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="tileSource"/> /// isn't a member of <see cref="WellKnownTileSource"/>.</exception> public WellKnownTileSourceMapData(WellKnownTileSource tileSource) : base(GetTileSourceName(tileSource)) { TileSource = tileSource; IsConfigured = true; }
public void GivenMapDataSet_WhenSelectingValidWellKnownMapDataFromContextMenu_ThenBackgroundDataSetAndNotifiesObserver() { // Given var mockRepository = new MockRepository(); var backgroundDataObserver = mockRepository.StrictMock <IObserver>(); backgroundDataObserver.Expect(o => o.UpdateObserver()); WmtsMapData mapData = WmtsMapDataTestHelper.CreateUnconnectedMapData(); var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); var assessmentSectionStateRootContext = new AssessmentSectionStateRootContext(assessmentSection); const WellKnownTileSource wellKnownTileSource = WellKnownTileSource.BingAerial; var newMapData = new WellKnownTileSourceMapData(wellKnownTileSource); BackgroundData newBackgroundData = BackgroundDataConverter.ConvertTo(newMapData); using (new UseCustomSettingsHelper(new TestSettingsHelper { ApplicationLocalUserSettingsDirectory = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.Forms, "EmptyWmtsConnectionInfo") })) using (var treeViewControl = new TreeViewControl()) using (var plugin = new RiskeerPlugin()) { var viewCommands = mockRepository.Stub <IViewCommands>(); var mainWindow = mockRepository.Stub <IMainWindow>(); IGui gui = StubFactory.CreateGuiStub(mockRepository); gui.Stub(g => g.MainWindow).Return(mainWindow); gui.Stub(g => g.ViewCommands).Return(viewCommands); gui.Stub(cmp => cmp.Get(newBackgroundData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); mockRepository.ReplayAll(); assessmentSection.BackgroundData.Attach(backgroundDataObserver); SetBackgroundData(assessmentSection, mapData); DialogBoxHandler = (name, wnd) => { var dialog = (BackgroundMapDataSelectionDialog) new FormTester(name).TheObject; var comboBox = (ComboBox) new ComboBoxTester("mapLayerComboBox", dialog).TheObject; comboBox.SelectedItem = ((BackgroundMapDataSelectionControl[])comboBox.DataSource).OfType <WellKnownMapDataControl>().First(); var dataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject; dataGridViewControl.SetCurrentCell(dataGridViewControl.GetCell(0, 0)); var button = new ButtonTester("selectButton", dialog); button.Click(); dialog.Close(); }; TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(newBackgroundData, assessmentSectionStateRootContext, treeViewControl)) { // When contextMenuStrip.Items[selectContextMenuIndex].PerformClick(); // Then AssertBackgroundData(newMapData, assessmentSection.BackgroundData); } } mockRepository.VerifyAll(); }