PageRenderTime 85ms CodeModel.GetById 78ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Main/src/DynamicDataDisplay.Maps/Charts/Map.DebugMenu.cs

#
C# | 74 lines | 70 code | 4 blank | 0 comment | 11 complexity | b19588a9f03a469ede0bde6ff91c09e4 MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Text;
 5using System.Windows;
 6using System.Diagnostics;
 7using System.IO;
 8using Microsoft.Research.DynamicDataDisplay.Maps.Servers;
 9
10namespace Microsoft.Research.DynamicDataDisplay.Charts.Maps
11{
12	public partial class Map
13	{
14		private void OnOpenCache(object sender, RoutedEventArgs e)
15		{
16			var fileTileServer = FileTileServer as FileSystemTileServer;
17			if (fileTileServer != null)
18			{
19				var cachePath = fileTileServer.CachePath;
20				while (!Directory.Exists(cachePath))
21				{
22					var lastDirIndex = cachePath.LastIndexOf(Path.DirectorySeparatorChar);
23					if (lastDirIndex > -1)
24						cachePath = cachePath.Substring(0, lastDirIndex);
25				}
26				Process.Start(cachePath);
27			}
28		}
29
30		private void OnClearCache(object sender, RoutedEventArgs e)
31		{
32			var fileTileServer = FileTileServer as FileSystemTileServer;
33			if (fileTileServer != null)
34			{
35				try
36				{
37					DirectoryInfo cacheDirectory = new DirectoryInfo(fileTileServer.CachePath);
38					if (cacheDirectory.Exists)
39						cacheDirectory.Delete(true);
40				}
41				catch (Exception exc)
42				{
43					Debug.WriteLine("Exception while deleting of file cache directory: " + exc.Message);
44				}
45			}
46		}
47
48		private void OnDeleteCaches(object sender, RoutedEventArgs e)
49		{
50			var fileTileServer = FileTileServer as FileSystemTileServer;
51			if (fileTileServer != null)
52			{
53				try
54				{
55					DirectoryInfo cacheDirectory = new DirectoryInfo(fileTileServer.CachePath);
56					cacheDirectory.Parent.Delete(true);
57				}
58				catch (Exception exc)
59				{
60					Debug.WriteLine("Exception while deleting of all file cache directories: " + exc.Message);
61				}
62			}
63		}
64
65		private void OnClearMemoryCache(object sender, RoutedEventArgs e)
66		{
67			var memoryTileServer = TileSystem.MemoryServer as LRUMemoryCache;
68			if (memoryTileServer != null)
69			{
70				memoryTileServer.Clear();
71			}
72		}
73	}
74}