SEBWIN-106: Implemented URL randomization for browser window.
This commit is contained in:
		
							parent
							
								
									ccfba9fdce
								
							
						
					
					
						commit
						137b463044
					
				
					 37 changed files with 259 additions and 189 deletions
				
			
		|  | @ -58,7 +58,6 @@ | ||||||
|   --> |   --> | ||||||
| 
 | 
 | ||||||
|   <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) --> |   <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) --> | ||||||
|    |  | ||||||
|   <dependency> |   <dependency> | ||||||
|     <dependentAssembly> |     <dependentAssembly> | ||||||
|       <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" /> |       <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" /> | ||||||
|  |  | ||||||
|  | @ -17,14 +17,18 @@ namespace SafeExamBrowser.Configuration.ConfigurationData | ||||||
| 		{ | 		{ | ||||||
| 			foreach (var item in rawData) | 			foreach (var item in rawData) | ||||||
| 			{ | 			{ | ||||||
| 				Map(item.Key, item.Value, settings); | 				MapBrowserSettings(item.Key, item.Value, settings); | ||||||
|  | 				MapConfigurationFileSettings(item.Key, item.Value, settings); | ||||||
|  | 				MapGeneralSettings(item.Key, item.Value, settings); | ||||||
|  | 				MapInputSettings(item.Key, item.Value, settings); | ||||||
|  | 				MapUserInterfaceSettings(item.Key, item.Value, settings); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			MapKioskMode(rawData, settings); | 			MapKioskMode(rawData, settings); | ||||||
| 			MapUserAgentMode(rawData, settings); | 			MapUserAgentMode(rawData, settings); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		private void Map(string key, object value, Settings settings) | 		private void MapBrowserSettings(string key, object value, Settings settings) | ||||||
| 		{ | 		{ | ||||||
| 			switch (key) | 			switch (key) | ||||||
| 			{ | 			{ | ||||||
|  | @ -61,9 +65,23 @@ namespace SafeExamBrowser.Configuration.ConfigurationData | ||||||
| 				case Keys.Browser.ShowReloadWarningAdditionalWindow: | 				case Keys.Browser.ShowReloadWarningAdditionalWindow: | ||||||
| 					MapShowReloadWarningAdditionalWindow(settings, value); | 					MapShowReloadWarningAdditionalWindow(settings, value); | ||||||
| 					break; | 					break; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		private void MapConfigurationFileSettings(string key, object value, Settings settings) | ||||||
|  | 		{ | ||||||
|  | 			switch (key) | ||||||
|  | 			{ | ||||||
| 				case Keys.ConfigurationFile.ConfigurationPurpose: | 				case Keys.ConfigurationFile.ConfigurationPurpose: | ||||||
| 					MapConfigurationMode(settings, value); | 					MapConfigurationMode(settings, value); | ||||||
| 					break; | 					break; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		private void MapGeneralSettings(string key, object value, Settings settings) | ||||||
|  | 		{ | ||||||
|  | 			switch (key) | ||||||
|  | 			{ | ||||||
| 				case Keys.General.AdminPasswordHash: | 				case Keys.General.AdminPasswordHash: | ||||||
| 					MapAdminPasswordHash(settings, value); | 					MapAdminPasswordHash(settings, value); | ||||||
| 					break; | 					break; | ||||||
|  | @ -76,6 +94,13 @@ namespace SafeExamBrowser.Configuration.ConfigurationData | ||||||
| 				case Keys.General.StartUrl: | 				case Keys.General.StartUrl: | ||||||
| 					MapStartUrl(settings, value); | 					MapStartUrl(settings, value); | ||||||
| 					break; | 					break; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		private void MapInputSettings(string key, object value, Settings settings) | ||||||
|  | 		{ | ||||||
|  | 			switch (key) | ||||||
|  | 			{ | ||||||
| 				case Keys.Input.Keyboard.EnableAltEsc: | 				case Keys.Input.Keyboard.EnableAltEsc: | ||||||
| 					MapEnableAltEsc(settings, value); | 					MapEnableAltEsc(settings, value); | ||||||
| 					break; | 					break; | ||||||
|  | @ -136,6 +161,13 @@ namespace SafeExamBrowser.Configuration.ConfigurationData | ||||||
| 				case Keys.Input.Mouse.EnableRightMouse: | 				case Keys.Input.Mouse.EnableRightMouse: | ||||||
| 					MapEnableRightMouse(settings, value); | 					MapEnableRightMouse(settings, value); | ||||||
| 					break; | 					break; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		private void MapUserInterfaceSettings(string key, object value, Settings settings) | ||||||
|  | 		{ | ||||||
|  | 			switch (key) | ||||||
|  | 			{ | ||||||
| 				case Keys.UserInterface.AllowKeyboardLayout: | 				case Keys.UserInterface.AllowKeyboardLayout: | ||||||
| 					MapKeyboardLayout(settings, value); | 					MapKeyboardLayout(settings, value); | ||||||
| 					break; | 					break; | ||||||
|  |  | ||||||
|  | @ -150,11 +150,9 @@ namespace SafeExamBrowser.Configuration.ConfigurationData | ||||||
| 
 | 
 | ||||||
| 			settings.UserInterfaceMode = UserInterfaceMode.Desktop; | 			settings.UserInterfaceMode = UserInterfaceMode.Desktop; | ||||||
| 			 | 			 | ||||||
| 			// TODO: Default values for testing of alpha version only, remove for final release! | 			// TODO: Default value overrides for alpha version, remove for final release! | ||||||
| 			settings.ActionCenter.ShowApplicationLog = true; | 			settings.ActionCenter.ShowApplicationLog = true; | ||||||
| 			settings.Browser.AllowDeveloperConsole = true; | 			settings.Browser.AllowDeveloperConsole = true; | ||||||
| 			settings.Browser.MainWindowSettings.AllowAddressBar = true; |  | ||||||
| 			settings.Taskbar.ShowApplicationLog = true; |  | ||||||
| 
 | 
 | ||||||
| 			return settings; | 			return settings; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -22,7 +22,7 @@ using SafeExamBrowser.Contracts.UserInterface.Browser; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Browser.Events; | using SafeExamBrowser.Contracts.UserInterface.Browser.Events; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Windows; | using SafeExamBrowser.Contracts.UserInterface.Windows; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Windows.Events; | using SafeExamBrowser.Contracts.UserInterface.Windows.Events; | ||||||
| using SafeExamBrowser.UserInterface.Desktop.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Desktop | namespace SafeExamBrowser.UserInterface.Desktop | ||||||
| { | { | ||||||
|  | @ -100,7 +100,7 @@ namespace SafeExamBrowser.UserInterface.Desktop | ||||||
| 
 | 
 | ||||||
| 		public void UpdateAddress(string url) | 		public void UpdateAddress(string url) | ||||||
| 		{ | 		{ | ||||||
| 			Dispatcher.Invoke(() => UrlTextBox.Text = url); | 			Dispatcher.Invoke(() => UrlTextBox.Text = WindowSettings.AllowAddressBar ? url : UrlRandomizer.Randomize(url)); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		public void UpdateIcon(IIconResource icon) | 		public void UpdateIcon(IIconResource icon) | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ using System.Windows.Controls; | ||||||
| using SafeExamBrowser.Contracts.Applications; | using SafeExamBrowser.Contracts.Applications; | ||||||
| using SafeExamBrowser.Contracts.Core; | using SafeExamBrowser.Contracts.Core; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Desktop.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Desktop.Controls | namespace SafeExamBrowser.UserInterface.Desktop.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ using System.Windows.Controls; | ||||||
| using SafeExamBrowser.Contracts.Client; | using SafeExamBrowser.Contracts.Client; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell; | using SafeExamBrowser.Contracts.UserInterface.Shell; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Desktop.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Desktop.Controls | namespace SafeExamBrowser.UserInterface.Desktop.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -10,7 +10,7 @@ using System; | ||||||
| using System.ComponentModel; | using System.ComponentModel; | ||||||
| using System.Windows.Controls; | using System.Windows.Controls; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Desktop.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Desktop.Controls | namespace SafeExamBrowser.UserInterface.Desktop.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -16,7 +16,7 @@ using FontAwesome.WPF; | ||||||
| using SafeExamBrowser.Contracts.SystemComponents; | using SafeExamBrowser.Contracts.SystemComponents; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell; | using SafeExamBrowser.Contracts.UserInterface.Shell; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Desktop.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Desktop.Controls | namespace SafeExamBrowser.UserInterface.Desktop.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -16,7 +16,7 @@ using System.Windows.Threading; | ||||||
| using SafeExamBrowser.Contracts.Applications; | using SafeExamBrowser.Contracts.Applications; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell; | using SafeExamBrowser.Contracts.UserInterface.Shell; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Desktop.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Desktop.Controls | namespace SafeExamBrowser.UserInterface.Desktop.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ using System.Windows.Controls; | ||||||
| using SafeExamBrowser.Contracts.Applications; | using SafeExamBrowser.Contracts.Applications; | ||||||
| using SafeExamBrowser.Contracts.Core; | using SafeExamBrowser.Contracts.Core; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Desktop.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Desktop.Controls | namespace SafeExamBrowser.UserInterface.Desktop.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ using System.Windows.Controls; | ||||||
| using SafeExamBrowser.Contracts.Client; | using SafeExamBrowser.Contracts.Client; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell; | using SafeExamBrowser.Contracts.UserInterface.Shell; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Desktop.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Desktop.Controls | namespace SafeExamBrowser.UserInterface.Desktop.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ using System.ComponentModel; | ||||||
| using System.Windows; | using System.Windows; | ||||||
| using System.Windows.Controls; | using System.Windows.Controls; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Desktop.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Desktop.Controls | namespace SafeExamBrowser.UserInterface.Desktop.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -16,7 +16,7 @@ using FontAwesome.WPF; | ||||||
| using SafeExamBrowser.Contracts.SystemComponents; | using SafeExamBrowser.Contracts.SystemComponents; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell; | using SafeExamBrowser.Contracts.UserInterface.Shell; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Desktop.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Desktop.Controls | namespace SafeExamBrowser.UserInterface.Desktop.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -148,9 +148,6 @@ | ||||||
|       <DependentUpon>SplashScreen.xaml</DependentUpon> |       <DependentUpon>SplashScreen.xaml</DependentUpon> | ||||||
|     </Compile> |     </Compile> | ||||||
|     <Compile Include="UserInterfaceFactory.cs" /> |     <Compile Include="UserInterfaceFactory.cs" /> | ||||||
|     <Compile Include="Utilities\IconResourceLoader.cs" /> |  | ||||||
|     <Compile Include="Utilities\VisualExtensions.cs" /> |  | ||||||
|     <Compile Include="Utilities\XamlIconResource.cs" /> |  | ||||||
|     <Compile Include="ViewModels\DateTimeViewModel.cs" /> |     <Compile Include="ViewModels\DateTimeViewModel.cs" /> | ||||||
|     <Compile Include="ViewModels\LogViewModel.cs" /> |     <Compile Include="ViewModels\LogViewModel.cs" /> | ||||||
|     <Compile Include="ViewModels\ProgressIndicatorViewModel.cs" /> |     <Compile Include="ViewModels\ProgressIndicatorViewModel.cs" /> | ||||||
|  | @ -373,6 +370,10 @@ | ||||||
|       <Project>{47DA5933-BEF8-4729-94E6-ABDE2DB12262}</Project> |       <Project>{47DA5933-BEF8-4729-94E6-ABDE2DB12262}</Project> | ||||||
|       <Name>SafeExamBrowser.Contracts</Name> |       <Name>SafeExamBrowser.Contracts</Name> | ||||||
|     </ProjectReference> |     </ProjectReference> | ||||||
|  |     <ProjectReference Include="..\SafeExamBrowser.UserInterface.Shared\SafeExamBrowser.UserInterface.Shared.csproj"> | ||||||
|  |       <Project>{38525928-87ba-4f8c-8010-4eb97bfaae13}</Project> | ||||||
|  |       <Name>SafeExamBrowser.UserInterface.Shared</Name> | ||||||
|  |     </ProjectReference> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <Resource Include="Images\LogNotification.ico" /> |     <Resource Include="Images\LogNotification.ico" /> | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ using SafeExamBrowser.Contracts.I18n; | ||||||
| using SafeExamBrowser.Contracts.Logging; | using SafeExamBrowser.Contracts.Logging; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell; | using SafeExamBrowser.Contracts.UserInterface.Shell; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Desktop.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Desktop | namespace SafeExamBrowser.UserInterface.Desktop | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -22,7 +22,7 @@ using SafeExamBrowser.Contracts.UserInterface.Browser; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Browser.Events; | using SafeExamBrowser.Contracts.UserInterface.Browser.Events; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Windows; | using SafeExamBrowser.Contracts.UserInterface.Windows; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Windows.Events; | using SafeExamBrowser.Contracts.UserInterface.Windows.Events; | ||||||
| using SafeExamBrowser.UserInterface.Mobile.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Mobile | namespace SafeExamBrowser.UserInterface.Mobile | ||||||
| { | { | ||||||
|  | @ -100,7 +100,7 @@ namespace SafeExamBrowser.UserInterface.Mobile | ||||||
| 
 | 
 | ||||||
| 		public void UpdateAddress(string url) | 		public void UpdateAddress(string url) | ||||||
| 		{ | 		{ | ||||||
| 			Dispatcher.Invoke(() => UrlTextBox.Text = url); | 			Dispatcher.Invoke(() => UrlTextBox.Text = WindowSettings.AllowAddressBar ? url : UrlRandomizer.Randomize(url)); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		public void UpdateIcon(IIconResource icon) | 		public void UpdateIcon(IIconResource icon) | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ using System.Windows.Controls; | ||||||
| using SafeExamBrowser.Contracts.Applications; | using SafeExamBrowser.Contracts.Applications; | ||||||
| using SafeExamBrowser.Contracts.Core; | using SafeExamBrowser.Contracts.Core; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Mobile.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Mobile.Controls | namespace SafeExamBrowser.UserInterface.Mobile.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ using System.Windows.Controls; | ||||||
| using SafeExamBrowser.Contracts.Client; | using SafeExamBrowser.Contracts.Client; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell; | using SafeExamBrowser.Contracts.UserInterface.Shell; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Mobile.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Mobile.Controls | namespace SafeExamBrowser.UserInterface.Mobile.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -10,7 +10,7 @@ using System; | ||||||
| using System.ComponentModel; | using System.ComponentModel; | ||||||
| using System.Windows.Controls; | using System.Windows.Controls; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Mobile.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Mobile.Controls | namespace SafeExamBrowser.UserInterface.Mobile.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -16,7 +16,7 @@ using FontAwesome.WPF; | ||||||
| using SafeExamBrowser.Contracts.SystemComponents; | using SafeExamBrowser.Contracts.SystemComponents; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell; | using SafeExamBrowser.Contracts.UserInterface.Shell; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Mobile.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Mobile.Controls | namespace SafeExamBrowser.UserInterface.Mobile.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -16,7 +16,7 @@ using System.Windows.Threading; | ||||||
| using SafeExamBrowser.Contracts.Applications; | using SafeExamBrowser.Contracts.Applications; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell; | using SafeExamBrowser.Contracts.UserInterface.Shell; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Mobile.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Mobile.Controls | namespace SafeExamBrowser.UserInterface.Mobile.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ using System.Windows.Controls; | ||||||
| using SafeExamBrowser.Contracts.Applications; | using SafeExamBrowser.Contracts.Applications; | ||||||
| using SafeExamBrowser.Contracts.Core; | using SafeExamBrowser.Contracts.Core; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Mobile.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Mobile.Controls | namespace SafeExamBrowser.UserInterface.Mobile.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ using System.Windows.Controls; | ||||||
| using SafeExamBrowser.Contracts.Client; | using SafeExamBrowser.Contracts.Client; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell; | using SafeExamBrowser.Contracts.UserInterface.Shell; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Mobile.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Mobile.Controls | namespace SafeExamBrowser.UserInterface.Mobile.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ using System.ComponentModel; | ||||||
| using System.Windows; | using System.Windows; | ||||||
| using System.Windows.Controls; | using System.Windows.Controls; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Mobile.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Mobile.Controls | namespace SafeExamBrowser.UserInterface.Mobile.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -16,7 +16,7 @@ using FontAwesome.WPF; | ||||||
| using SafeExamBrowser.Contracts.SystemComponents; | using SafeExamBrowser.Contracts.SystemComponents; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell; | using SafeExamBrowser.Contracts.UserInterface.Shell; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Mobile.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Mobile.Controls | namespace SafeExamBrowser.UserInterface.Mobile.Controls | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -159,9 +159,6 @@ | ||||||
|       <DependentUpon>Taskbar.xaml</DependentUpon> |       <DependentUpon>Taskbar.xaml</DependentUpon> | ||||||
|     </Compile> |     </Compile> | ||||||
|     <Compile Include="UserInterfaceFactory.cs" /> |     <Compile Include="UserInterfaceFactory.cs" /> | ||||||
|     <Compile Include="Utilities\IconResourceLoader.cs" /> |  | ||||||
|     <Compile Include="Utilities\VisualExtensions.cs" /> |  | ||||||
|     <Compile Include="Utilities\XamlIconResource.cs" /> |  | ||||||
|     <Compile Include="ViewModels\DateTimeViewModel.cs" /> |     <Compile Include="ViewModels\DateTimeViewModel.cs" /> | ||||||
|     <Compile Include="ViewModels\LogViewModel.cs" /> |     <Compile Include="ViewModels\LogViewModel.cs" /> | ||||||
|     <Compile Include="ViewModels\ProgressIndicatorViewModel.cs" /> |     <Compile Include="ViewModels\ProgressIndicatorViewModel.cs" /> | ||||||
|  | @ -172,6 +169,10 @@ | ||||||
|       <Project>{47da5933-bef8-4729-94e6-abde2db12262}</Project> |       <Project>{47da5933-bef8-4729-94e6-abde2db12262}</Project> | ||||||
|       <Name>SafeExamBrowser.Contracts</Name> |       <Name>SafeExamBrowser.Contracts</Name> | ||||||
|     </ProjectReference> |     </ProjectReference> | ||||||
|  |     <ProjectReference Include="..\SafeExamBrowser.UserInterface.Shared\SafeExamBrowser.UserInterface.Shared.csproj"> | ||||||
|  |       <Project>{38525928-87ba-4f8c-8010-4eb97bfaae13}</Project> | ||||||
|  |       <Name>SafeExamBrowser.UserInterface.Shared</Name> | ||||||
|  |     </ProjectReference> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <Page Include="AboutWindow.xaml"> |     <Page Include="AboutWindow.xaml"> | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ using SafeExamBrowser.Contracts.I18n; | ||||||
| using SafeExamBrowser.Contracts.Logging; | using SafeExamBrowser.Contracts.Logging; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell; | using SafeExamBrowser.Contracts.UserInterface.Shell; | ||||||
| using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | using SafeExamBrowser.Contracts.UserInterface.Shell.Events; | ||||||
| using SafeExamBrowser.UserInterface.Mobile.Utilities; | using SafeExamBrowser.UserInterface.Shared.Utilities; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Mobile | namespace SafeExamBrowser.UserInterface.Mobile | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -1,71 +0,0 @@ | ||||||
| /* |  | ||||||
|  * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET) |  | ||||||
|  *  |  | ||||||
|  * This Source Code Form is subject to the terms of the Mozilla Public |  | ||||||
|  * License, v. 2.0. If a copy of the MPL was not distributed with this |  | ||||||
|  * file, You can obtain one at http://mozilla.org/MPL/2.0/. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| using System; |  | ||||||
| using System.Windows; |  | ||||||
| using System.Windows.Controls; |  | ||||||
| using System.Windows.Documents; |  | ||||||
| using System.Windows.Markup; |  | ||||||
| using System.Windows.Media; |  | ||||||
| using System.Windows.Media.Imaging; |  | ||||||
| using SafeExamBrowser.Contracts.Core; |  | ||||||
| 
 |  | ||||||
| namespace SafeExamBrowser.UserInterface.Mobile.Utilities |  | ||||||
| { |  | ||||||
| 	/// <summary> |  | ||||||
| 	/// TODO: Move to shared library? |  | ||||||
| 	/// </summary> |  | ||||||
| 	internal static class IconResourceLoader |  | ||||||
| 	{ |  | ||||||
| 		internal static UIElement Load(IIconResource resource) |  | ||||||
| 		{ |  | ||||||
| 			try |  | ||||||
| 			{ |  | ||||||
| 				if (resource.IsBitmapResource) |  | ||||||
| 				{ |  | ||||||
| 					return LoadBitmapResource(resource); |  | ||||||
| 				} |  | ||||||
| 				else if (resource.IsXamlResource) |  | ||||||
| 				{ |  | ||||||
| 					return LoadXamlResource(resource); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			catch (Exception) |  | ||||||
| 			{ |  | ||||||
| 				return NotFoundSymbol(); |  | ||||||
| 			} |  | ||||||
| 
 |  | ||||||
| 			throw new NotSupportedException($"Application icon resource of type '{resource.GetType()}' is not supported!"); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		private static UIElement LoadBitmapResource(IIconResource resource) |  | ||||||
| 		{ |  | ||||||
| 			return new Image |  | ||||||
| 			{ |  | ||||||
| 				Source = new BitmapImage(resource.Uri) |  | ||||||
| 			}; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		private static UIElement LoadXamlResource(IIconResource resource) |  | ||||||
| 		{ |  | ||||||
| 			using (var stream = Application.GetResourceStream(resource.Uri)?.Stream) |  | ||||||
| 			{ |  | ||||||
| 				return XamlReader.Load(stream) as UIElement; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		private static UIElement NotFoundSymbol() |  | ||||||
| 		{ |  | ||||||
| 			return new TextBlock(new Run("X") { Foreground = Brushes.Red, FontWeight = FontWeights.Bold }) |  | ||||||
| 			{ |  | ||||||
| 				HorizontalAlignment = HorizontalAlignment.Center, |  | ||||||
| 				VerticalAlignment = VerticalAlignment.Center |  | ||||||
| 			}; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  | @ -1,45 +0,0 @@ | ||||||
| /* |  | ||||||
|  * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET) |  | ||||||
|  *  |  | ||||||
|  * This Source Code Form is subject to the terms of the Mozilla Public |  | ||||||
|  * License, v. 2.0. If a copy of the MPL was not distributed with this |  | ||||||
|  * file, You can obtain one at http://mozilla.org/MPL/2.0/. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| using System.Windows; |  | ||||||
| using System.Windows.Interop; |  | ||||||
| using System.Windows.Media; |  | ||||||
| 
 |  | ||||||
| namespace SafeExamBrowser.UserInterface.Mobile.Utilities |  | ||||||
| { |  | ||||||
| 	/// <summary> |  | ||||||
| 	/// TODO: Move to shared library? |  | ||||||
| 	/// </summary> |  | ||||||
| 	internal static class VisualExtensions |  | ||||||
| 	{ |  | ||||||
| 		/// <summary> |  | ||||||
| 		/// WPF works with device-independent pixels. This method is required to |  | ||||||
| 		/// transform such values to their absolute, device-specific pixel value. |  | ||||||
| 		/// Source: https://stackoverflow.com/questions/3286175/how-do-i-convert-a-wpf-size-to-physical-pixels |  | ||||||
| 		/// </summary> |  | ||||||
| 		internal static Vector TransformToPhysical(this Visual visual, double x, double y) |  | ||||||
| 		{ |  | ||||||
| 			Matrix transformToDevice; |  | ||||||
| 			var source = PresentationSource.FromVisual(visual); |  | ||||||
| 
 |  | ||||||
| 			if (source != null) |  | ||||||
| 			{ |  | ||||||
| 				transformToDevice = source.CompositionTarget.TransformToDevice; |  | ||||||
| 			} |  | ||||||
| 			else |  | ||||||
| 			{ |  | ||||||
| 				using (var newSource = new HwndSource(new HwndSourceParameters())) |  | ||||||
| 				{ |  | ||||||
| 					transformToDevice = newSource.CompositionTarget.TransformToDevice; |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 
 |  | ||||||
| 			return transformToDevice.Transform(new Vector(x, y)); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  | @ -1,28 +0,0 @@ | ||||||
| /* |  | ||||||
|  * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET) |  | ||||||
|  *  |  | ||||||
|  * This Source Code Form is subject to the terms of the Mozilla Public |  | ||||||
|  * License, v. 2.0. If a copy of the MPL was not distributed with this |  | ||||||
|  * file, You can obtain one at http://mozilla.org/MPL/2.0/. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| using System; |  | ||||||
| using SafeExamBrowser.Contracts.Core; |  | ||||||
| 
 |  | ||||||
| namespace SafeExamBrowser.UserInterface.Mobile.Utilities |  | ||||||
| { |  | ||||||
| 	/// <summary> |  | ||||||
| 	/// TODO: Move to shared library? |  | ||||||
| 	/// </summary> |  | ||||||
| 	internal class XamlIconResource : IIconResource |  | ||||||
| 	{ |  | ||||||
| 		public Uri Uri { get; private set; } |  | ||||||
| 		public bool IsBitmapResource => false; |  | ||||||
| 		public bool IsXamlResource => true; |  | ||||||
| 
 |  | ||||||
| 		public XamlIconResource(Uri uri) |  | ||||||
| 		{ |  | ||||||
| 			Uri = uri; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  | @ -0,0 +1,51 @@ | ||||||
|  | using System.Reflection; | ||||||
|  | using System.Runtime.InteropServices; | ||||||
|  | using System.Windows; | ||||||
|  | 
 | ||||||
|  | // General Information about an assembly is controlled through the following | ||||||
|  | // set of attributes. Change these attribute values to modify the information | ||||||
|  | // associated with an assembly. | ||||||
|  | [assembly: AssemblyTitle("SafeExamBrowser.UserInterface.Shared")] | ||||||
|  | [assembly: AssemblyDescription("Safe Exam Browser")] | ||||||
|  | [assembly: AssemblyCompany("ETH Zürich")] | ||||||
|  | [assembly: AssemblyProduct("SafeExamBrowser.UserInterface.Shared")] | ||||||
|  | [assembly: AssemblyCopyright("Copyright © 2019 ETH Zürich, Educational Development and Technology (LET)")] | ||||||
|  | 
 | ||||||
|  | // Setting ComVisible to false makes the types in this assembly not visible | ||||||
|  | // to COM components.  If you need to access a type in this assembly from | ||||||
|  | // COM, set the ComVisible attribute to true on that type. | ||||||
|  | [assembly: ComVisible(false)] | ||||||
|  | 
 | ||||||
|  | //In order to begin building localizable applications, set | ||||||
|  | //<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file | ||||||
|  | //inside a <PropertyGroup>.  For example, if you are using US english | ||||||
|  | //in your source files, set the <UICulture> to en-US.  Then uncomment | ||||||
|  | //the NeutralResourceLanguage attribute below.  Update the "en-US" in | ||||||
|  | //the line below to match the UICulture setting in the project file. | ||||||
|  | 
 | ||||||
|  | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | [assembly: ThemeInfo( | ||||||
|  | 	ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||||||
|  | 									 //(used if a resource is not found in the page, | ||||||
|  | 									 // or application resource dictionaries) | ||||||
|  | 	ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||||||
|  | 											  //(used if a resource is not found in the page, | ||||||
|  | 											  // app, or any theme specific resource dictionaries) | ||||||
|  | )] | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | // Version information for an assembly consists of the following four values: | ||||||
|  | // | ||||||
|  | //      Major Version | ||||||
|  | //      Minor Version | ||||||
|  | //      Build Number | ||||||
|  | //      Revision | ||||||
|  | // | ||||||
|  | // You can specify all the values or you can default the Build and Revision Numbers | ||||||
|  | // by using the '*' as shown below: | ||||||
|  | // [assembly: AssemblyVersion("1.0.*")] | ||||||
|  | [assembly: AssemblyVersion("1.0.0.0")] | ||||||
|  | [assembly: AssemblyFileVersion("1.0.0.0")] | ||||||
|  | [assembly: AssemblyInformationalVersion("1.0.0.0")] | ||||||
|  | @ -0,0 +1,79 @@ | ||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||||
|  |   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||||||
|  |   <PropertyGroup> | ||||||
|  |     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||||||
|  |     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||||||
|  |     <ProjectGuid>{38525928-87BA-4F8C-8010-4EB97BFAAE13}</ProjectGuid> | ||||||
|  |     <OutputType>library</OutputType> | ||||||
|  |     <RootNamespace>SafeExamBrowser.UserInterface.Shared</RootNamespace> | ||||||
|  |     <AssemblyName>SafeExamBrowser.UserInterface.Shared</AssemblyName> | ||||||
|  |     <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||||||
|  |     <FileAlignment>512</FileAlignment> | ||||||
|  |     <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||||||
|  |     <WarningLevel>4</WarningLevel> | ||||||
|  |     <Deterministic>true</Deterministic> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||||||
|  |     <DebugSymbols>true</DebugSymbols> | ||||||
|  |     <DebugType>full</DebugType> | ||||||
|  |     <Optimize>false</Optimize> | ||||||
|  |     <OutputPath>bin\Debug\</OutputPath> | ||||||
|  |     <DefineConstants>DEBUG;TRACE</DefineConstants> | ||||||
|  |     <ErrorReport>prompt</ErrorReport> | ||||||
|  |     <WarningLevel>4</WarningLevel> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||||||
|  |     <DebugType>pdbonly</DebugType> | ||||||
|  |     <Optimize>true</Optimize> | ||||||
|  |     <OutputPath>bin\Release\</OutputPath> | ||||||
|  |     <DefineConstants>TRACE</DefineConstants> | ||||||
|  |     <ErrorReport>prompt</ErrorReport> | ||||||
|  |     <WarningLevel>4</WarningLevel> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> | ||||||
|  |     <DebugSymbols>true</DebugSymbols> | ||||||
|  |     <OutputPath>bin\x86\Debug\</OutputPath> | ||||||
|  |     <DefineConstants>DEBUG;TRACE</DefineConstants> | ||||||
|  |     <DebugType>full</DebugType> | ||||||
|  |     <PlatformTarget>x86</PlatformTarget> | ||||||
|  |     <ErrorReport>prompt</ErrorReport> | ||||||
|  |     <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> | ||||||
|  |     <OutputPath>bin\x86\Release\</OutputPath> | ||||||
|  |     <DefineConstants>TRACE</DefineConstants> | ||||||
|  |     <Optimize>true</Optimize> | ||||||
|  |     <DebugType>pdbonly</DebugType> | ||||||
|  |     <PlatformTarget>x86</PlatformTarget> | ||||||
|  |     <ErrorReport>prompt</ErrorReport> | ||||||
|  |     <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||||||
|  |   </PropertyGroup> | ||||||
|  |   <ItemGroup> | ||||||
|  |     <Reference Include="System" /> | ||||||
|  |     <Reference Include="System.Xml" /> | ||||||
|  |     <Reference Include="Microsoft.CSharp" /> | ||||||
|  |     <Reference Include="System.Xaml"> | ||||||
|  |       <RequiredTargetFramework>4.0</RequiredTargetFramework> | ||||||
|  |     </Reference> | ||||||
|  |     <Reference Include="WindowsBase" /> | ||||||
|  |     <Reference Include="PresentationCore" /> | ||||||
|  |     <Reference Include="PresentationFramework" /> | ||||||
|  |   </ItemGroup> | ||||||
|  |   <ItemGroup> | ||||||
|  |     <Compile Include="Properties\AssemblyInfo.cs"> | ||||||
|  |       <SubType>Code</SubType> | ||||||
|  |     </Compile> | ||||||
|  |     <Compile Include="Utilities\IconResourceLoader.cs" /> | ||||||
|  |     <Compile Include="Utilities\UrlRandomizer.cs" /> | ||||||
|  |     <Compile Include="Utilities\VisualExtensions.cs" /> | ||||||
|  |     <Compile Include="Utilities\XamlIconResource.cs" /> | ||||||
|  |   </ItemGroup> | ||||||
|  |   <ItemGroup> | ||||||
|  |     <ProjectReference Include="..\SafeExamBrowser.Contracts\SafeExamBrowser.Contracts.csproj"> | ||||||
|  |       <Project>{47da5933-bef8-4729-94e6-abde2db12262}</Project> | ||||||
|  |       <Name>SafeExamBrowser.Contracts</Name> | ||||||
|  |     </ProjectReference> | ||||||
|  |   </ItemGroup> | ||||||
|  |   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||||||
|  | </Project> | ||||||
|  | @ -15,11 +15,11 @@ using System.Windows.Media; | ||||||
| using System.Windows.Media.Imaging; | using System.Windows.Media.Imaging; | ||||||
| using SafeExamBrowser.Contracts.Core; | using SafeExamBrowser.Contracts.Core; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Desktop.Utilities | namespace SafeExamBrowser.UserInterface.Shared.Utilities | ||||||
| { | { | ||||||
| 	internal static class IconResourceLoader | 	public static class IconResourceLoader | ||||||
| 	{ | 	{ | ||||||
| 		internal static UIElement Load(IIconResource resource) | 		public static UIElement Load(IIconResource resource) | ||||||
| 		{ | 		{ | ||||||
| 			try | 			try | ||||||
| 			{ | 			{ | ||||||
|  | @ -0,0 +1,43 @@ | ||||||
|  | /* | ||||||
|  |  * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET) | ||||||
|  |  *  | ||||||
|  |  * This Source Code Form is subject to the terms of the Mozilla Public | ||||||
|  |  * License, v. 2.0. If a copy of the MPL was not distributed with this | ||||||
|  |  * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | using System; | ||||||
|  | using System.Text; | ||||||
|  | 
 | ||||||
|  | namespace SafeExamBrowser.UserInterface.Shared.Utilities | ||||||
|  | { | ||||||
|  | 	public static class UrlRandomizer | ||||||
|  | 	{ | ||||||
|  | 		private const string DIGITS = "0123456789"; | ||||||
|  | 		private const string LETTERS = "abcdefghijklmnopqrstuvwxyz"; | ||||||
|  | 
 | ||||||
|  | 		public static string Randomize(string url) | ||||||
|  | 		{ | ||||||
|  | 			var generator = new Random(); | ||||||
|  | 			var result = new StringBuilder(); | ||||||
|  | 
 | ||||||
|  | 			foreach (var character in url) | ||||||
|  | 			{ | ||||||
|  | 				if (Char.IsDigit(character)) | ||||||
|  | 				{ | ||||||
|  | 					result.Append(DIGITS[generator.Next(DIGITS.Length)]); | ||||||
|  | 				} | ||||||
|  | 				else if (Char.IsLetter(character)) | ||||||
|  | 				{ | ||||||
|  | 					result.Append(LETTERS[generator.Next(LETTERS.Length)]); | ||||||
|  | 				} | ||||||
|  | 				else | ||||||
|  | 				{ | ||||||
|  | 					result.Append(character); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			return result.ToString(); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | @ -10,16 +10,16 @@ using System.Windows; | ||||||
| using System.Windows.Interop; | using System.Windows.Interop; | ||||||
| using System.Windows.Media; | using System.Windows.Media; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Desktop.Utilities | namespace SafeExamBrowser.UserInterface.Shared.Utilities | ||||||
| { | { | ||||||
| 	internal static class VisualExtensions | 	public static class VisualExtensions | ||||||
| 	{ | 	{ | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| 		/// WPF works with device-independent pixels. This method is required to | 		/// WPF works with device-independent pixels. This method is required to | ||||||
| 		/// transform such values to their absolute, device-specific pixel value. | 		/// transform such values to their absolute, device-specific pixel value. | ||||||
| 		/// Source: https://stackoverflow.com/questions/3286175/how-do-i-convert-a-wpf-size-to-physical-pixels | 		/// Source: https://stackoverflow.com/questions/3286175/how-do-i-convert-a-wpf-size-to-physical-pixels | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		internal static Vector TransformToPhysical(this Visual visual, double x, double y) | 		public static Vector TransformToPhysical(this Visual visual, double x, double y) | ||||||
| 		{ | 		{ | ||||||
| 			Matrix transformToDevice; | 			Matrix transformToDevice; | ||||||
| 			var source = PresentationSource.FromVisual(visual); | 			var source = PresentationSource.FromVisual(visual); | ||||||
|  | @ -9,9 +9,9 @@ | ||||||
| using System; | using System; | ||||||
| using SafeExamBrowser.Contracts.Core; | using SafeExamBrowser.Contracts.Core; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.UserInterface.Desktop.Utilities | namespace SafeExamBrowser.UserInterface.Shared.Utilities | ||||||
| { | { | ||||||
| 	internal class XamlIconResource : IIconResource | 	public class XamlIconResource : IIconResource | ||||||
| 	{ | 	{ | ||||||
| 		public Uri Uri { get; private set; } | 		public Uri Uri { get; private set; } | ||||||
| 		public bool IsBitmapResource => false; | 		public bool IsBitmapResource => false; | ||||||
|  | @ -56,6 +56,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.Configurati | ||||||
| EndProject | EndProject | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.UserInterface.Mobile", "SafeExamBrowser.UserInterface.Mobile\SafeExamBrowser.UserInterface.Mobile.csproj", "{89BC24DD-FF31-496E-9816-A160B686A3D4}" | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.UserInterface.Mobile", "SafeExamBrowser.UserInterface.Mobile\SafeExamBrowser.UserInterface.Mobile.csproj", "{89BC24DD-FF31-496E-9816-A160B686A3D4}" | ||||||
| EndProject | EndProject | ||||||
|  | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.UserInterface.Shared", "SafeExamBrowser.UserInterface.Shared\SafeExamBrowser.UserInterface.Shared.csproj", "{38525928-87BA-4F8C-8010-4EB97BFAAE13}" | ||||||
|  | EndProject | ||||||
| Global | Global | ||||||
| 	GlobalSection(SolutionConfigurationPlatforms) = preSolution | 	GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||||
| 		Debug|Any CPU = Debug|Any CPU | 		Debug|Any CPU = Debug|Any CPU | ||||||
|  | @ -232,6 +234,14 @@ Global | ||||||
| 		{89BC24DD-FF31-496E-9816-A160B686A3D4}.Release|Any CPU.Build.0 = Release|Any CPU | 		{89BC24DD-FF31-496E-9816-A160B686A3D4}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
| 		{89BC24DD-FF31-496E-9816-A160B686A3D4}.Release|x86.ActiveCfg = Release|Any CPU | 		{89BC24DD-FF31-496E-9816-A160B686A3D4}.Release|x86.ActiveCfg = Release|Any CPU | ||||||
| 		{89BC24DD-FF31-496E-9816-A160B686A3D4}.Release|x86.Build.0 = Release|Any CPU | 		{89BC24DD-FF31-496E-9816-A160B686A3D4}.Release|x86.Build.0 = Release|Any CPU | ||||||
|  | 		{38525928-87BA-4F8C-8010-4EB97BFAAE13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{38525928-87BA-4F8C-8010-4EB97BFAAE13}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{38525928-87BA-4F8C-8010-4EB97BFAAE13}.Debug|x86.ActiveCfg = Debug|x86 | ||||||
|  | 		{38525928-87BA-4F8C-8010-4EB97BFAAE13}.Debug|x86.Build.0 = Debug|x86 | ||||||
|  | 		{38525928-87BA-4F8C-8010-4EB97BFAAE13}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{38525928-87BA-4F8C-8010-4EB97BFAAE13}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{38525928-87BA-4F8C-8010-4EB97BFAAE13}.Release|x86.ActiveCfg = Release|Any CPU | ||||||
|  | 		{38525928-87BA-4F8C-8010-4EB97BFAAE13}.Release|x86.Build.0 = Release|Any CPU | ||||||
| 	EndGlobalSection | 	EndGlobalSection | ||||||
| 	GlobalSection(SolutionProperties) = preSolution | 	GlobalSection(SolutionProperties) = preSolution | ||||||
| 		HideSolutionNode = FALSE | 		HideSolutionNode = FALSE | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 dbuechel
						dbuechel