/// <summary> /// Default ctor sets default values, called when there are no serialized settings /// </summary> private UserSettings() { SettingsDirPath = FilesLocation.GetSaveDirPath(); SettingsFilePath = FilesLocation.GetSavePath(); ShortDisplayTime = TimeSpan.FromSeconds((double)CycleTimesEnum.ShortDisplayTime); ShortIntervalTime = TimeSpan.FromSeconds((double)CycleTimesEnum.ShortIntervalTime); LongDisplayTime = TimeSpan.FromSeconds((double)CycleTimesEnum.LongDisplayTime); LongIntervalTime = TimeSpan.FromSeconds((double)CycleTimesEnum.LongIntervalTime); LockLengthTimeExtent = TimeSpan.FromMinutes(5); NotificationLength = TimeSpan.FromSeconds(6); PostponeLength = TimeSpan.FromMinutes(2); PostponeAmount = 2; IsShortSkippable = false; IsLongSkippable = true; ShouldBreakWhenFullScreen = true; IndefPauseEnabled = false; IsFullscreenBreak = true; IsLongBreakLocksScreen = false; IsPermissiveNotification = false; IsNotificationEnabled = false; Scaling = 1; AddDefaultQuotes(); CreateSettingsDto(); SetUpQuoteRandomizer(); logger.Info("New settings created with defaults"); }
public async Task <ActionResult> LabZoom(int CourseTopicFileId) { CourseTopicFile courseTopicFile = await db.GetCourseTopicFileByIdAsync(CourseTopicFileId); File file = await db.GetFileByCourseTopicFileIdAsync(User.Identity.Name, CourseTopicFileId); if (courseTopicFile == null || !file.FileType.Name.ToLower().Contains("zoom") || !await db.HaveUserAccessToCourseTopicFile(User.Identity.Name, CourseTopicFileId)) { return(RedirectToAction("error", "pages")); } bool IsTeacher = await db.IsTeacherByEmailAsync(User.Identity.Name); bool IsHaveAccess = false; if (IsTeacher) { IsHaveAccess = await db.HaveTeacherAccessToCourseByEmailAsync(User.Identity.Name, courseTopicFile.CourseId); Session["FileTypes"] = Session["FileTypes"] == null?db.GetFileTypesLab() : Session["FileTypes"]; } else { IsHaveAccess = await db.HaveUserAccessToCourseAsync(User.Identity.Name, courseTopicFile.CourseId); } if (!IsHaveAccess) { return(RedirectToAction("index", "pages")); } FilesLocation location = db.GetFileLocationByFileId(file.FileId); bool IsImageCompressed = !String.IsNullOrWhiteSpace(location.AttachedFileLocation); String attachedFile = IsImageCompressed ? location.AttachedFileLocation : location.FileLocation; String[] FileName = attachedFile.Split('\\'); if (IsImageCompressed) { int OriginalImageWidth = Image.FromStream(new FileStream(location.FileLocation, FileMode.Open, FileAccess.Read)).Width; int CompressedImageWidth = Image.FromStream(new FileStream(location.AttachedFileLocation, FileMode.Open, FileAccess.Read)).Width; int CompressionRatio = (int)Math.Ceiling(double.Parse(((double)OriginalImageWidth / CompressedImageWidth).ToString())); Session["ImageCompressSize_" + User.Identity.Name + file.FileId] = CompressionRatio; } else { Session["ImageCompressSize_" + User.Identity.Name + file.FileId] = 1; } ViewData["FileName"] = FileName[FileName.Length - 1]; ViewData["CourseTopicFile"] = courseTopicFile; ViewData["file"] = file; ViewBag.ShowNavigation = false; ViewBag.HideSiteLogo = true; return(View(file)); }
public async Task <ActionResult> LabTools(int CourseTopicFileId) { CourseTopicFile courseTopicFile = await db.GetCourseTopicFileByIdAsync(CourseTopicFileId); File file = await db.GetFileByCourseTopicFileIdAsync(User.Identity.Name, CourseTopicFileId); if (courseTopicFile == null || !file.FileType.Name.ToLower().Contains("tools") || !await db.HaveUserAccessToCourseTopicFile(User.Identity.Name, CourseTopicFileId)) { return(RedirectToAction("error", "pages")); } bool IsTeacher = await db.IsTeacherByEmailAsync(User.Identity.Name); bool IsHaveAccess = false; if (IsTeacher) { IsHaveAccess = await db.HaveTeacherAccessToCourseByEmailAsync(User.Identity.Name, courseTopicFile.CourseId); Session["FileTypes"] = Session["FileTypes"] == null?db.GetFileTypesLab() : Session["FileTypes"]; } else { IsHaveAccess = await db.HaveUserAccessToCourseAsync(User.Identity.Name, courseTopicFile.CourseId); } if (!IsHaveAccess) { return(RedirectToAction("Course", "pages", new { id = courseTopicFile.CourseId })); } FilesLocation location = db.GetFileLocationByFileId(file.FileId); string[] FileName = location.FileLocation.Split('\\'); ViewData["CourseTopicFile"] = courseTopicFile; ViewData["FileName"] = FileName[FileName.Length - 1]; ViewBag.ShowNavigation = false; ViewBag.HideSiteLogo = true; try { excel = new Application(); books = excel.Workbooks; book = books.Open(location.AttachedFileLocation); sheet = book.Sheets[1]; xlRange = sheet.UsedRange; int x = GetColumn(); int y = GetRow(); List <LabPixelModel> labPixels = new List <LabPixelModel>(); String[,] sh = new String[y - 1, x]; for (int i = 2; i <= y; i++) { labPixels.Add(new LabPixelModel() { x1 = (int)xlRange.Cells[i, 1].Value2, y1 = (int)xlRange.Cells[i, 2].Value2, x2 = (int)xlRange.Cells[i, 3].Value2, y2 = (int)xlRange.Cells[i, 4].Value2, L = (double)xlRange.Cells[i, 5].Value2, A = (double)xlRange.Cells[i, 6].Value2, B = (double)xlRange.Cells[i, 7].Value2, V = (double)xlRange.Cells[i, 8].Value2, C = (double)xlRange.Cells[i, 9].Value2, M = (double)xlRange.Cells[i, 10].Value2, Y = (double)xlRange.Cells[i, 11].Value2, Comment = xlRange.Cells[i, 12].Value2.ToString() //Color = xlRange.Cells[i, 13].Value2.ToString() }); } Session["PixelsInfo_" + User.Identity.Name + $"_file{file.FileId}"] = labPixels; } catch { Session["PixelsInfo_" + User.Identity.Name + $"_file{file.FileId}"] = null; } //Excel close books.Close(); excel.Application.Quit(); excel.Quit(); int hWnd = excel.Application.Hwnd; GetWindowThreadProcessId((IntPtr)hWnd, out uint processID); Process.GetProcessById((int)processID).Kill(); book = null; excel = null; sheet = null; return(View(file)); }