public bool Save() { if (string.IsNullOrEmpty(SavePath)) { return(false); } PList plist = new PList(); plist.Root.Add(TYPE_KEY, TYPE_VALUE); plist.Root.Add(VERSION_KEY, VERSION); plist.Root.Add(BUILD_PLATFORM_KEY, Platform.ToString()); plist.Root.Add(INFO_PLIST_KEY, InfoPlistChanges); plist.Root.Add(APP_CONFIG_KEY, AppConfig); plist.Root.Add(APP_CONFIG_ENABLED_KEY, AppConfigEnabled); plist.Root.Add(MANUAL_ENTITLEMENTS, ManualEntitlements); plist.Root.Add(FRAMEWORKS_KEY, Frameworks.Serialize()); plist.Root.Add(FILES_AND_FOLDERS_KEY, FilesAndFolders.Serialize()); plist.Root.Add(BUILD_SETTINGS_KEY, BuildSettings.Serialize()); plist.Root.Add(SIGNING_KEY, Signing.Serialize()); plist.Root.Add(SCRIPTS_KEY, Scripts.Serialize()); plist.Root.Add(CAPABILITIES_KEY, Capabilities.Serialize()); bool saved = plist.Save(SavePath, true); if (saved) { IsDirty = false; } return(saved); }
public void CreateFile(string filename, string text, string parent) { try { try { string path = @"~\..\..\..\..\Service\bin\Debug\"; factory.CreateFile(path + "encryptedFile_" + filename, text, parent); if (File.Exists(path + "key.txt")) { string key = Key.LoadKey(path + "key.txt"); AES.Decrypt(path + "encryptedFile_" + filename + ".txt", path + filename, key); FilesAndFolders.MoveFile(filename, parent); } } catch (SecurityAccessDeniedException e) { Console.WriteLine("Error 1, security access denied exception: {0}", e.Message); } catch (FaultException e) { Console.WriteLine("Error 2, fault exception: {0}", e.Message); } } catch (SecurityException e) { Console.WriteLine("Error 3 while tryin to CreateFile, security exception: {0}", e.Message); } }
public void CreateFile(string filename, string text, string parent) { CustomPrincipal principal = Thread.CurrentPrincipal as CustomPrincipal; WindowsIdentity winID = principal.Identity as WindowsIdentity; try { using (winID.Impersonate()) { Console.WriteLine("Impersonifikacija klijenta {0}", WindowsIdentity.GetCurrent().Name); if (!Thread.CurrentPrincipal.IsInRole("Change")) { string username = Parser.Parse(Thread.CurrentPrincipal.Identity.Name); try { Audit.AuthorizationFailed(principal.Identity.Name, OperationContext.Current.IncomingMessageHeaders.Action, "Nemam dozvolu za CreateFile."); } catch (ArgumentException e) { Console.WriteLine(e.Message); } throw new FaultException(username + " je pokušao da pozove CreateFile, za šta mu treba dozvola."); } else { string file = filename.Split('\\').ToList().Last(); file = file.Split('_').Last(); if (File.Exists(FilesAndFolders.GetFolderPaths(parent).FirstOrDefault() + "\\" + file + ".txt")) { Console.WriteLine("Vec postoji fajl {0} u folderu {1}.", file, parent); } else { string key = Key.GenerateKey(); Key.StoreKey(key, "key.txt"); AES.Encrypt(ASCIIEncoding.ASCII.GetBytes(text), filename, key); try { Audit.AuthorizationSuccess(principal.Identity.Name, OperationContext.Current.IncomingMessageHeaders.Action); } catch (ArgumentException e) { Console.WriteLine(e.Message); } } } } } catch (Exception e) { Console.WriteLine("Error: {0}", e.Message); } }
bool LoadFile(string pathToFile) { if (!File.Exists(pathToFile)) { Debug.LogError("EgoXproject: Change file does not exist: " + pathToFile); return(false); } SavePath = pathToFile; PList p = new PList(); if (!p.Load(SavePath)) { return(false); } if (!Validate(p)) { return(false); } //set the platform. if non specified will default to ios BuildPlatform platform; if (p.Root.EnumValue(BUILD_PLATFORM_KEY, out platform)) { Platform = platform; } else { Platform = BuildPlatform.iOS; } //reset everything Frameworks.Clear(); FilesAndFolders.Clear(); BuildSettings.Clear(); Scripts.Clear(); Signing.Clear(); Capabilities.Clear(); //load everything InfoPlistChanges = p.Root.DictionaryValue(INFO_PLIST_KEY).Copy() as PListDictionary; AppConfig = p.Root.DictionaryValue(APP_CONFIG_KEY) != null?p.Root.DictionaryValue(APP_CONFIG_KEY).Copy() as PListDictionary : new PListDictionary(); AppConfigEnabled = p.Root.ArrayValue(APP_CONFIG_ENABLED_KEY) != null?p.Root.ArrayValue(APP_CONFIG_ENABLED_KEY).Copy() as PListArray : new PListArray(); ManualEntitlements = p.Root.DictionaryValue(MANUAL_ENTITLEMENTS) != null?p.Root.DictionaryValue(MANUAL_ENTITLEMENTS).Copy() as PListDictionary : new PListDictionary(); LoadFrameworks(p.Root.DictionaryValue(FRAMEWORKS_KEY)); LoadFilesAndFolders(p.Root.DictionaryValue(FILES_AND_FOLDERS_KEY)); LoadScripts(p.Root.ArrayValue(SCRIPTS_KEY)); LoadBuildSettings(p.Root.ArrayValue(BUILD_SETTINGS_KEY)); LoadSigning(p.Root.DictionaryValue(SIGNING_KEY)); LoadCapabilities(p.Root.DictionaryValue(CAPABILITIES_KEY)); IsDirty = false; return(true); }
public async Task StartDirectoryListing() { var client = await ClientService.GetClient(); if (client == null) { return; } _continueListing = true; var path = PathStack.Count > 0 ? PathStack[PathStack.Count - 1].ResourceInfo.Path : "/"; List <ResourceInfo> list = null; try { list = await client.List(path); } catch (ResponseError e) { ResponseErrorHandlerService.HandleException(e); } FilesAndFolders.Clear(); Folders.Clear(); if (list != null) { foreach (var item in list) { FilesAndFolders.Add(new FileOrFolder(item)); if (item.IsDirectory()) { Folders.Add(new FileOrFolder(item)); } } } switch (SettingsService.Instance.LocalSettings.PreviewImageDownloadMode) { case PreviewImageDownloadMode.Always: DownloadPreviewImages(); break; case PreviewImageDownloadMode.WiFiOnly: var connectionProfile = NetworkInformation.GetInternetConnectionProfile(); // connectionProfile can be null (e.g. airplane mode) if (connectionProfile != null && connectionProfile.IsWlanConnectionProfile) { DownloadPreviewImages(); } break; case PreviewImageDownloadMode.Never: break; default: throw new ArgumentOutOfRangeException(); } }
private SecurityAppSettingsHandler() { SecurityAppSettings = FilesAndFolders.GetAppSettingsContent <SecurityAppSettings>(); SecurityAppSettings.SecurityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(SecurityAppSettings.SigningKey)); SecurityAppSettings.SigningCredentials = new SigningCredentials(SecurityAppSettings.SecurityKey, SecurityAlgorithms.HmacSha256); }
public override IFileSettingsBuilder <T> ReadFromFile() { var fileName = this.GetFileName(); var json = FilesAndFolders.GetFileContent(fileName); this.ObjetoSetting = JsonConvert.DeserializeObject <T>(json); return(this); }
public static void Main() { FilesAndFolders ff = new FilesAndFolders("c:\\"); ff.OpenDirectory(); Console.WriteLine(); Console.WriteLine("{0} datoteka u mapi {1}", ff.MaxFiles, ff.HasMostFiles); }
public bool HasChanges() { return(InfoPlistChanges.Count > 0 || Frameworks.HasChanges() || FilesAndFolders.HasChanges() || BuildSettings.HasChanges() || Scripts.HasChanges() || Signing.HasChanges() || Capabilities.HasChanges()); }
public bool HasChanges() { return(AppConfigEnabled.Count > 0 || InfoPlistChanges.Count > 0 || ManualEntitlements.Count > 0 || Frameworks.HasChanges() || FilesAndFolders.HasChanges() || BuildSettings.HasChanges() || Scripts.HasChanges() || Signing.HasChanges() || Capabilities.HasChanges()); }
private async void DownloadPreviewImages() { var client = await ClientService.GetClient(); if (client == null) { return; } foreach (var currentFile in FilesAndFolders.ToArray()) { if (!_continueListing) { break; } try { Stream stream = null; try { stream = await client.GetThumbnail(currentFile, 120, 120); } catch (ResponseError e) { ResponseErrorHandlerService.HandleException(e); } if (stream == null) { continue; } var bitmap = new BitmapImage(); using (var memStream = new MemoryStream()) { await stream.CopyToAsync(memStream); memStream.Position = 0; bitmap.SetSource(memStream.AsRandomAccessStream()); } currentFile.Thumbnail = bitmap; } catch (ResponseError) { currentFile.Thumbnail = new BitmapImage { UriSource = new Uri("ms-appx:///Assets/Images/ThumbnailNotFound.png") }; } } }
public void ReadFile(string filename) { if (FilesAndFolders.GetFilePaths(filename).Count() == 0) { Console.WriteLine("{0} ne postoji.", filename); } else { string filetoread = FilesAndFolders.GetShortestPath(FilesAndFolders.GetFilePaths(filename)); string key = Key.GenerateKey(); Key.StoreKey(key, "key.txt"); AES.Encrypt(ASCIIEncoding.ASCII.GetBytes(File.ReadAllText(filetoread)), filename + "_encryptedToRead", key); } }
public void MoveTo(string fileorfolder, string foldername) { CustomPrincipal principal = Thread.CurrentPrincipal as CustomPrincipal; WindowsIdentity winID = principal.Identity as WindowsIdentity; try { using (winID.Impersonate()) { Console.WriteLine("Impersonifikacija klijenta {0}", WindowsIdentity.GetCurrent().Name); if (!Thread.CurrentPrincipal.IsInRole("Change")) { string username = Parser.Parse(Thread.CurrentPrincipal.Identity.Name); try { Audit.AuthorizationFailed(principal.Identity.Name, OperationContext.Current.IncomingMessageHeaders.Action, "Nemam dozvolu za MoveTo."); } catch (ArgumentException e) { Console.WriteLine(e.Message); } throw new FaultException(username + " je pokušao da pozove MoveTo, za šta mu treba dozvola."); } else { FilesAndFolders.MoveTo(fileorfolder, foldername); try { Audit.AuthorizationSuccess(principal.Identity.Name, OperationContext.Current.IncomingMessageHeaders.Action); } catch (ArgumentException e) { Console.WriteLine(e.Message); } } } } catch (Exception e) { Console.WriteLine("Error: {0}", e.Message); } }
public void Merge(XcodeChangeFile other) { if (Platform != other.Platform) { Debug.LogError("Cannot merge change files. Platforms do not match"); return; } MergePListEntries(InfoPlistChanges, other.InfoPlistChanges); Frameworks.Merge(other.Frameworks); FilesAndFolders.Merge(other.FilesAndFolders); BuildSettings.Merge(other.BuildSettings); Scripts.Merge(other.Scripts); Signing.Merge(other.Signing); Capabilities.Merge(other.Capabilities); }
public ItemViewModel(string viewPath, Page p) { pageName = p.Name; // Personalize retrieved items for view they are displayed in if (p.Name == "GenericItemView" || p.Name == "ClassicModePage") { isPhotoAlbumMode = false; } else if (p.Name == "PhotoAlbumViewer") { isPhotoAlbumMode = true; } if (pageName != "ClassicModePage") { GenericFileBrowser.P.path = viewPath; FilesAndFolders.Clear(); } tokenSource = new CancellationTokenSource(); token = tokenSource.Token; MemoryFriendlyGetItemsAsync(viewPath, token); if (pageName != "ClassicModePage") { History.AddToHistory(viewPath); if (History.HistoryList.Count == 1) { BS.isEnabled = false; //Debug.WriteLine("Disabled Property"); } else if (History.HistoryList.Count > 1) { BS.isEnabled = true; //Debug.WriteLine("Enabled Property"); } } }
static void Main(string[] args) { FilesAndFolders.TestCopyFiles(); Console.ReadKey(); }
public async Task StartDirectoryListing(ResourceInfo resourceInfoToExclude, String viewName = null) { var client = await ClientService.GetClient(); if (client == null || IsSelecting) { return; } _continueListing = true; if (PathStack.Count == 0) { PathStack.Add(new PathInfo { ResourceInfo = new ResourceInfo() { Name = "Nextcloud", Path = "/" }, IsRoot = true }); } var path = PathStack.Count > 0 ? PathStack[PathStack.Count - 1].ResourceInfo.Path : "/"; List <ResourceInfo> list = null; try { if (viewName == "sharesIn" | viewName == "sharesOut" | viewName == "sharesLink") { PathStack.Clear(); list = await client.GetSharesView(viewName); } else if (viewName == "favorites") { PathStack.Clear(); list = await client.GetFavorites(); } else { list = await client.List(path); } } catch (ResponseError e) { ResponseErrorHandlerService.HandleException(e); } FilesAndFolders.Clear(); Folders.Clear(); if (list != null) { foreach (var item in list) { if (resourceInfoToExclude != null && item == resourceInfoToExclude) { continue; } FilesAndFolders.Add(new FileOrFolder(item)); if (!item.IsDirectory) { continue; } if (RemoveResourceInfos != null) { var index = RemoveResourceInfos.FindIndex(res => res.Path.Equals(item.Path, StringComparison.Ordinal)); if (index == -1) { Folders.Add(new FileOrFolder(item)); } } else { Folders.Add(new FileOrFolder(item)); } } } switch (SettingsService.Instance.LocalSettings.PreviewImageDownloadMode) { case PreviewImageDownloadMode.Always: DownloadPreviewImages(); break; case PreviewImageDownloadMode.WiFiOnly: var connectionProfile = NetworkInformation.GetInternetConnectionProfile(); // connectionProfile can be null (e.g. airplane mode) if (connectionProfile != null && connectionProfile.IsWlanConnectionProfile) { DownloadPreviewImages(); } break; case PreviewImageDownloadMode.Never: break; default: throw new ArgumentOutOfRangeException(); } SortList(); }
public async void MemoryFriendlyGetItemsAsync(string path, Page passedPage) { TextState.isVisible = Visibility.Collapsed; tokenSource = new CancellationTokenSource(); CancellationToken token = App.ViewModel.tokenSource.Token; pageName = passedPage.Name; Universal.path = path; // Personalize retrieved items for view they are displayed in switch (pageName) { case "GenericItemView": isPhotoAlbumMode = false; break; case "PhotoAlbumViewer": isPhotoAlbumMode = true; break; case "ClassicModePage": isPhotoAlbumMode = false; break; } if (pageName != "ClassicModePage") { FilesAndFolders.Clear(); } Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); Universal.path = path; // Set visible path to reflect new navigation try { PVIS.isVisible = Visibility.Visible; TextState.isVisible = Visibility.Collapsed; switch (Universal.path) { case "Desktop": Universal.path = MainPage.DesktopPath; break; case "Downloads": Universal.path = MainPage.DownloadsPath; break; case "Documents": Universal.path = MainPage.DocumentsPath; break; case "Pictures": Universal.path = MainPage.PicturesPath; break; case "Music": Universal.path = MainPage.MusicPath; break; case "Videos": Universal.path = MainPage.VideosPath; break; case "OneDrive": Universal.path = MainPage.OneDrivePath; break; } folder = await StorageFolder.GetFolderFromPathAsync(Universal.path); History.AddToHistory(Universal.path); if (History.HistoryList.Count == 1) { BS.isEnabled = false; } else if (History.HistoryList.Count > 1) { BS.isEnabled = true; } QueryOptions options = new QueryOptions() { FolderDepth = FolderDepth.Shallow, IndexerOption = IndexerOption.UseIndexerWhenAvailable }; string sort = "By_Name"; if (sort == "By_Name") { SortEntry entry = new SortEntry() { AscendingOrder = true, PropertyName = "System.FileName" }; options.SortOrder.Add(entry); } uint index = 0; const uint step = 250; if (!folder.AreQueryOptionsSupported(options)) { options.SortOrder.Clear(); } folderQueryResult = folder.CreateFolderQueryWithOptions(options); IReadOnlyList <StorageFolder> folders = await folderQueryResult.GetFoldersAsync(index, step); int foldersCountSnapshot = folders.Count; while (folders.Count != 0) { foreach (StorageFolder folder in folders) { if (token.IsCancellationRequested) { return; } gotFolName = folder.Name.ToString(); gotFolDate = folder.DateCreated.ToString(); gotFolPath = folder.Path.ToString(); gotFolType = "Folder"; gotFolImg = Visibility.Visible; gotFileImgVis = Visibility.Collapsed; gotEmptyImgVis = Visibility.Collapsed; if (pageName == "ClassicModePage") { ClassicFolderList.Add(new Classic_ListedFolderItem() { FileName = gotFolName, FileDate = gotFolDate, FileExtension = gotFolType, FilePath = gotFolPath }); } else { FilesAndFolders.Add(new ListedItem() { EmptyImgVis = gotEmptyImgVis, ItemIndex = FilesAndFolders.Count, FileImg = null, FileIconVis = gotFileImgVis, FolderImg = gotFolImg, FileName = gotFolName, FileDate = gotFolDate, FileExtension = gotFolType, FilePath = gotFolPath }); } } index += step; folders = await folderQueryResult.GetFoldersAsync(index, step); } index = 0; fileQueryResult = folder.CreateFileQueryWithOptions(options); IReadOnlyList <StorageFile> files = await fileQueryResult.GetFilesAsync(index, step); int filesCountSnapshot = files.Count; while (files.Count != 0) { foreach (StorageFile file in files) { if (token.IsCancellationRequested) { return; } gotName = file.DisplayName.ToString(); gotDate = file.DateCreated.ToString(); // In the future, parse date to human readable format if (file.FileType.ToString() == ".exe") { gotType = "Executable"; } else { gotType = file.DisplayType; } gotPath = file.Path.ToString(); gotFolImg = Visibility.Collapsed; gotDotFileExtension = file.FileType; if (isPhotoAlbumMode == false) { const uint requestedSize = 20; const ThumbnailMode thumbnailMode = ThumbnailMode.ListView; const ThumbnailOptions thumbnailOptions = ThumbnailOptions.UseCurrentScale; try { gotFileImg = await file.GetThumbnailAsync(thumbnailMode, requestedSize, thumbnailOptions); BitmapImage icon = new BitmapImage(); if (gotFileImg != null) { gotEmptyImgVis = Visibility.Collapsed; icon.SetSource(gotFileImg.CloneStream()); } else { gotEmptyImgVis = Visibility.Visible; } gotFileImgVis = Visibility.Visible; if (pageName == "ClassicModePage") { ClassicFileList.Add(new ListedItem() { FileImg = icon, FileIconVis = gotFileImgVis, FolderImg = gotFolImg, FileName = gotName, FileDate = gotDate, FileExtension = gotType, FilePath = gotPath }); } else { FilesAndFolders.Add(new ListedItem() { DotFileExtension = gotDotFileExtension, EmptyImgVis = gotEmptyImgVis, FileImg = icon, FileIconVis = gotFileImgVis, FolderImg = gotFolImg, FileName = gotName, FileDate = gotDate, FileExtension = gotType, FilePath = gotPath }); } } catch { // Silent catch here to avoid crash // TODO maybe some logging could be added in the future... } } else { const uint requestedSize = 275; const ThumbnailMode thumbnailMode = ThumbnailMode.PicturesView; const ThumbnailOptions thumbnailOptions = ThumbnailOptions.ResizeThumbnail; try { gotFileImg = await file.GetThumbnailAsync(thumbnailMode, requestedSize, thumbnailOptions); BitmapImage icon = new BitmapImage(); if (gotFileImg != null) { gotEmptyImgVis = Visibility.Collapsed; icon.SetSource(gotFileImg.CloneStream()); } else { gotEmptyImgVis = Visibility.Visible; } gotFileImgVis = Visibility.Visible; if (pageName == "ClassicModePage") { ClassicFileList.Add(new ListedItem() { FileImg = icon, FileIconVis = gotFileImgVis, FolderImg = gotFolImg, FileName = gotName, FileDate = gotDate, FileExtension = gotType, FilePath = gotPath }); } else { FilesAndFolders.Add(new ListedItem() { DotFileExtension = gotDotFileExtension, EmptyImgVis = gotEmptyImgVis, FileImg = icon, FileIconVis = gotFileImgVis, FolderImg = gotFolImg, FileName = gotName, FileDate = gotDate, FileExtension = gotType, FilePath = gotPath }); } } catch { // Silent catch here to avoid crash // TODO maybe some logging could be added in the future... } } } index += step; files = await fileQueryResult.GetFilesAsync(index, step); } if (foldersCountSnapshot + filesCountSnapshot == 0) { TextState.isVisible = Visibility.Visible; } if (pageName != "ClassicModePage") { PVIS.isVisible = Visibility.Collapsed; } PVIS.isVisible = Visibility.Collapsed; stopwatch.Stop(); Debug.WriteLine("Loading of: " + path + " completed in " + stopwatch.ElapsedMilliseconds + " Milliseconds."); } catch (UnauthorizedAccessException e) { if (path.Contains(@"C:\")) { DisplayConsentDialog(); } else { MessageDialog unsupportedDevice = new MessageDialog("This device may be unsupported. Please file an issue report in Settings - About containing what device we couldn't access. Technical information: " + e, "Unsupported Device"); await unsupportedDevice.ShowAsync(); } stopwatch.Stop(); Debug.WriteLine("Loading of: " + Universal.path + " failed in " + stopwatch.ElapsedMilliseconds + " Milliseconds."); } catch (COMException e) { stopwatch.Stop(); Debug.WriteLine("Loading of: " + Universal.path + " failed in " + stopwatch.ElapsedMilliseconds + " Milliseconds."); Frame rootFrame = Window.Current.Content as Frame; MessageDialog driveGone = new MessageDialog(e.Message, "Drive Unplugged"); await driveGone.ShowAsync(); rootFrame.Navigate(typeof(MainPage), new SuppressNavigationTransitionInfo()); } tokenSource = null; }
public async void GetItemsAsync(string path) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); IsTerminated = false; PUIP.Path = path; try { folder = await StorageFolder.GetFolderFromPathAsync(path); // Set location to the current directory specified in path folderList = await folder.GetFoldersAsync(); // Create a read-only list of all folders in location fileList = await folder.GetFilesAsync(); // Create a read-only list of all files in location NumOfFolders = folderList.Count; // How many folders are in the list NumOfFiles = fileList.Count; // How many files are in the list NumOfItems = NumOfFiles + NumOfFolders; NumItemsRead = 0; if (NumOfItems == 0) { TextState.isVisible = Visibility.Visible; } PUIH.Header = "Loading " + NumOfItems + " items"; ButtonText.buttonText = "Hide"; if (NumOfItems >= 250) { PVIS.isVisible = Visibility.Visible; } if (NumOfFolders > 0) { foreach (StorageFolder fol in folderList) { if (IsStopRequested) { IsStopRequested = false; IsTerminated = true; return; } int ProgressReported = (NumItemsRead * 100 / NumOfItems); UpdateProgUI(ProgressReported); gotFolName = fol.Name.ToString(); gotFolDate = fol.DateCreated.ToString(); gotFolPath = fol.Path.ToString(); gotFolType = "Folder"; gotFolImg = Visibility.Visible; gotFileImgVis = Visibility.Collapsed; if (pageName == "ClassicModePage") { ClassicFolderList.Add(new Classic_ListedFolderItem() { FileName = gotFolName, FileDate = gotFolDate, FileExtension = gotFolType, FilePath = gotFolPath }); } else { FilesAndFolders.Add(new ListedItem() { ItemIndex = FilesAndFolders.Count, FileImg = null, FileIconVis = gotFileImgVis, FolderImg = gotFolImg, FileName = gotFolName, FileDate = gotFolDate, FileExtension = gotFolType, FilePath = gotFolPath }); } NumItemsRead++; } } if (NumOfFiles > 0) { foreach (StorageFile f in fileList) { if (IsStopRequested) { IsStopRequested = false; IsTerminated = true; return; } int ProgressReported = (NumItemsRead * 100 / NumOfItems); UpdateProgUI(ProgressReported); gotName = f.Name.ToString(); gotDate = f.DateCreated.ToString(); // In the future, parse date to human readable format if (f.FileType.ToString() == ".exe") { gotType = "Executable"; } else { gotType = f.DisplayType; } gotPath = f.Path.ToString(); gotFolImg = Visibility.Collapsed; if (isPhotoAlbumMode == false) { const uint requestedSize = 20; const ThumbnailMode thumbnailMode = ThumbnailMode.ListView; const ThumbnailOptions thumbnailOptions = ThumbnailOptions.UseCurrentScale; gotFileImg = await f.GetThumbnailAsync(thumbnailMode, requestedSize, thumbnailOptions); } else { const uint requestedSize = 275; const ThumbnailMode thumbnailMode = ThumbnailMode.PicturesView; const ThumbnailOptions thumbnailOptions = ThumbnailOptions.ResizeThumbnail; gotFileImg = await f.GetThumbnailAsync(thumbnailMode, requestedSize, thumbnailOptions); } BitmapImage icon = new BitmapImage(); if (gotFileImg != null) { icon.SetSource(gotFileImg.CloneStream()); } gotFileImgVis = Visibility.Visible; if (pageName == "ClassicModePage") { ClassicFileList.Add(new ListedItem() { FileImg = icon, FileIconVis = gotFileImgVis, FolderImg = gotFolImg, FileName = gotName, FileDate = gotDate, FileExtension = gotType, FilePath = gotPath }); } else { FilesAndFolders.Add(new ListedItem() { FileImg = icon, FileIconVis = gotFileImgVis, FolderImg = gotFolImg, FileName = gotName, FileDate = gotDate, FileExtension = gotType, FilePath = gotPath }); } NumItemsRead++; } } if (pageName != "ClassicModePage") { PVIS.isVisible = Visibility.Collapsed; } IsTerminated = true; } catch (UnauthorizedAccessException) { DisplayConsentDialog(); } stopwatch.Stop(); Debug.WriteLine("Loading of: " + path + " completed in " + stopwatch.ElapsedMilliseconds + " Milliseconds."); }
public void ShowFolderContent(string foldername) { FilesAndFolders.ShowFolderContent(foldername); }
public static void ExportLibrary(CSLibrary lib, string folderPath) { //folderPath += @"\ClimateStudioLibrary-" + lib.TimeStamp.Year + "-" + lib.TimeStamp.Month + "-" + lib.TimeStamp.Day + "-" + lib.TimeStamp.Hour + "-" + lib.TimeStamp.Minute; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } //Schedules if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\DaySchedules_Old.csv"))) { writeDayCSV(folderPath + @"\DaySchedules_Old.csv", lib.DaySchedules.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\DaySchedules.csv"))) { writeLibCSV <CSDaySchedule>(folderPath + @"\DaySchedules.csv", lib.DaySchedules.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\YearSchedules.csv"))) { writeYearCSV(folderPath + @"\YearSchedules.csv", lib.YearSchedules.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\ArraySchedules.csv"))) { writeArrayScheduleCSV(folderPath + @"\ArraySchedules.csv", lib.ArraySchedules.ToList()); } //Material Construction if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\OpaqueMaterials.csv"))) { writeLibCSV <CSOpaqueMaterial>(folderPath + @"\OpaqueMaterials.csv", lib.OpaqueMaterials.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\OpaqueConstructions_Old.csv"))) { writeOpaqueConstructionsCSV(folderPath + @"\OpaqueConstructions_Old.csv", lib.OpaqueConstructions.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\OpaqueConstructions.csv"))) { writeLibCSV <CSOpaqueConstruction>(folderPath + @"\OpaqueConstructions.csv", lib.OpaqueConstructions.ToList()); } //Glazing if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\GlazingMaterials.csv"))) { writeLibCSV <CSGlazingMaterial>(folderPath + @"\GlazingMaterials.csv", lib.GlazingMaterials.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\GasMaterials.csv"))) { writeLibCSV <CSGasMaterial>(folderPath + @"\GasMaterials.csv", lib.GasMaterials.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\GlazingConstructions_Old.csv"))) { writeGlazingConstructionsCSV(folderPath + @"\GlazingConstructions_Old.csv", lib.GlazingConstructions.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\GlazingConstructions.csv"))) { writeLibCSV <CSGlazingConstruction>(folderPath + @"\GlazingConstructions.csv", lib.GlazingConstructions.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\GlazingConstructionSimple.csv"))) { writeLibCSV <CSGlazingConstructionSimple>(folderPath + @"\GlazingConstructionSimple.csv", lib.GlazingConstructionsSimple.ToList()); } //Settings if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\WindowSettings.csv"))) { writeLibCSV <CSWindowDefinition>(folderPath + @"\WindowSettings.csv", lib.WindowSettings.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\ZoneVentilations.csv"))) { writeLibCSV <CSZoneVentilation>(folderPath + @"\ZoneVentilations.csv", lib.ZoneVentilations.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\ZoneConditioning.csv"))) { writeLibCSV <CSZoneConditioning>(folderPath + @"\ZoneConditioning.csv", lib.ZoneConditionings.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\ZoneConstruction.csv"))) { writeLibCSV <CSZoneConstruction>(folderPath + @"\ZoneConstruction.csv", lib.ZoneConstructions.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\ZoneLoad.csv"))) { writeLibCSV <CSZoneLoad>(folderPath + @"\ZoneLoad.csv", lib.ZoneLoads.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\DomHotWater.csv"))) { writeLibCSV <CSZoneHotWater>(folderPath + @"\DomHotWater.csv", lib.DomHotWaters.ToList()); } if (!FilesAndFolders.IsFileLocked(new FileInfo(folderPath + @"\ZoneDefinition.csv"))) { // writeLibCSV<ZoneDefinition>(folderPath + @"\ZoneDefinition.csv", lib.ZoneDefinitions.ToList()); writeZoneDefCSV(folderPath + @"\ZoneDefinition.csv", lib.ZoneDefinitions.ToList()); } }
protected void CheckFileExists() => FilesAndFolders.ThrowFileNotFoundException(this._fileName);
public IFileSettingsBuilder <T> SetFileName(string path, string fileName) { this._fileName = FilesAndFolders.SetCurrentFileName(path, fileName); CheckFileExists(); return(this); }
private static ObjectMappingConfigs ReadConfigs() { var configs_string_content = FilesAndFolders.GetFileContent("object_mapping.json"); return(JsonConvert.DeserializeObject <ObjectMappingConfigs>(configs_string_content));; }