/// <summary> /// Handles the Click event of the lbSaveFiles control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void lbSaveFiles_Click(object sender, EventArgs e) { FileStreamInfo[] fsi = FileUpCtrl.Files; if (fsi != null && fsi.Length > 0) { try { StringBuilder filePath = new StringBuilder(Server.MapPath(ManagementHelper.GetImportExportFolderPath(_MetaDataImportFolder))); filePath.Append(fsi[0].FileName); if (File.Exists(filePath.ToString())) { File.Delete(filePath.ToString()); } FileUpCtrl.SaveAs(fsi[0], filePath.ToString()); FileUpCtrl.ReleaseAll(); // update upload status lblUploadResult.Text = String.Empty; //"File saved successfully."; UploadResultPanel.Update(); } catch (Exception ex) { lblUploadResult.Text = ex.Message; UploadResultPanel.Update(); } finally { FilesControl.DataBind(); FilesPanel.Update(); } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack || String.Compare(Request.Form["__EVENTTARGET"], CommandManager.GetCurrent(this.Page).ID, false) == 0) { BindData(); } string btnId = btnImport.UniqueID; if (Page.IsPostBack && !String.IsNullOrEmpty(btnId) && Request.Form[btnId] != null) { string filePath = FilesControl.GetSelectedFilePath(); if (String.IsNullOrEmpty(filePath)) { DisplayErrorMessage("No selected file."); return; } else { SelectedFilePath = filePath; } } CommandManager cm = CommandManager.GetCurrent(this.Page); cm.AddCommand("", "Content", "SiteImport", "cmdShowDialogSiteImportConfirm"); }
public FilesControl CreateFileControl(FileModel fModel) { FilesControl fc = new FilesControl(fModel); SetupFileControlCallbacks(fc); return(fc); }
public void TryNavigateToPath(string path) { // is a drive if (path == string.Empty) { ClearFiles(); foreach (FileModel drive in Fetcher.GetDrives()) { FilesControl fc = CreateFileControl(drive); AddFile(fc); } } else if (path.IsFile()) { // Open the file // MessageBox.Show($"Opening {path}"); Process.Start(path); } else if (path.IsDirectory()) { Process.Start(path); } else { // something bad has happened... } }
/// <summary> /// Handles the Click event of the lbSaveFiles control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void lbSaveFiles_Click(object sender, EventArgs e) { FileStreamInfo[] fsi = FileUpCtrl.Files; if (fsi != null && fsi.Length > 0) { try { string filePath = Path.Combine(HttpContext.Current.Server.MapPath(ManagementHelper.GetImportExportFolderPath("catalog")), fsi[0].FileName); if (File.Exists(filePath)) { File.Delete(filePath); } FileUpCtrl.SaveAs(fsi[0], filePath); FileUpCtrl.ReleaseAll(); // update upload status lblUploadResult.Text = String.Empty; //"File saved successfully."; UploadResultPanel.Update(); } catch (Exception ex) { lblUploadResult.Text = ex.Message; UploadResultPanel.Update(); } finally { FilesControl.DataBind(); FilesPanel.Update(); } } }
/// <summary> /// Handles the Click event of the btnImport control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void btnImport_Click(object sender, EventArgs e) { string filePath = FilesControl.GetSelectedFilePath(); string mappingFilePath = MappingFilesControl.GetSelectedFilePath(); if (String.IsNullOrEmpty(filePath)) { DisplayErrorMessage("No data file selected."); return; } else { SelectedFilePath = filePath; } if (String.IsNullOrEmpty(mappingFilePath)) { DisplayErrorMessage("No mapping file selected."); return; } else { SelectedMappingFilePath = mappingFilePath; } if (!String.IsNullOrEmpty(ListCatalogs.SelectedValue)) { Guid appId = GetCurrentApplicationId(); // start import in a new thread ProgressControl1.StartOperation(new System.Threading.ThreadStart(delegate { DoImport(appId); })); } }
private async void Window_Loaded(object sender, RoutedEventArgs e) { StartupWindow startupWindow = new StartupWindow(); startupWindow.Show(); FilesControlObject = new FilesControl(); SettingsControlObject = new SettingsControl(); PlayerControlObject = new PlayerControl(); UserRatingControlObject = new UserRatingControl(); SV_MainDisplay.Content = FilesControlObject; MakeButtonPressedOnLeft(Button_FileControl); await WarmupMediaInfoEngine(); await SearchForVLCDLL(); await LoadUserSettings(); startupWindow.Close(); if (WindowState == WindowState.Minimized) { WindowState = WindowState.Normal; } Activate(); }
void ProgressControl1_ProgressCompleted(object data) { if (data != null) { int result = 0; Int32.TryParse(data.ToString(), out result); if (result == 100) { FilesControl.DataBind(); FilesPanel.Update(); } } }
public BotDataManager() { _filesControl = new FilesControl(); _logger = Logging.GetLogger <BotDataManager>(); _allSettings = _filesControl.LoadAllSettings(); _logger.LogInformation("Bot settings loaded successfully."); this.LoadLoginCredentials(); this.LoadBotSettings(); this.LoadBotIntervals(); this.BotDictionary = _filesControl.LoadBotDictionary(); UseColoredMessages = BotSettings.UseColoredMessages; }
public void NavigateOnStartup(string path) { ClearFiles(); List <FileModel> filesAndFolders = Fetcher.GetDirectories(path); filesAndFolders.AddRange(Fetcher.GetFiles(path)); filesAndFolders.Sort((x, y) => DateTime.Compare(x.DateModified, y.DateModified)); filesAndFolders.Reverse(); foreach (FileModel file in filesAndFolders) { FilesControl fc = CreateFileControl(file); AddFile(fc); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { BindData(); } string btnId = btnImport.UniqueID; if (Page.IsPostBack && !String.IsNullOrEmpty(btnId) && Request.Form[btnId] != null) { string filePath = FilesControl.GetSelectedFilePath(); if (String.IsNullOrEmpty(filePath)) { DisplayErrorMessage("No selected file."); return; } else { SelectedFilePath = filePath; } } }
public async void TryNavigateToPath(string path) { if (path == string.Empty) { ClearFiles(); foreach (FileModel drive in Fetcher.GetDrives()) { FilesControl fc = CreateFileControl(drive); AddFile(fc); } } else if (path.IsFile()) { MessageBox.Show($"Opening {path}"); } else if (path.IsDirectory()) { ClearFiles(); string backPath = path.Substring(0, path.LastIndexOf('\\')); if (!backPath.Contains('\\')) { backPath += "\\"; DriveInfo dInfo = new DriveInfo(backPath); FileModel dModel = new FileModel() { Icon = IconHelpers.GetIconOfFile(backPath, true, true), Name = dInfo.Name, Path = dInfo.Name, DateModified = DateTime.Now, Type = FileType.Drive, SizeBytes = dInfo.TotalSize }; FilesControl back = CreateFileControl(dModel); AddFile(back); } else { DirectoryInfo dInfo = new DirectoryInfo(backPath); FileModel dModel = new FileModel() { Icon = IconHelpers.GetIconOfFile(backPath, true, true), Name = dInfo.Name, Path = dInfo.FullName, DateCreated = dInfo.CreationTime, DateModified = dInfo.LastWriteTime, Type = FileType.Folder, SizeBytes = Fetcher.DirSize(new DirectoryInfo(backPath), 1) }; FilesControl back = CreateFileControl(dModel); AddFile(back); } List <FileModel> directories = new List <FileModel>(); await Fetcher.GetDirectories(path, directories); foreach (FileModel dir in directories) { FilesControl fc = CreateFileControl(dir); AddFile(fc); } foreach (FileModel file in Fetcher.GetFiles(path)) { FilesControl fc = CreateFileControl(file); AddFile(fc); } } else { MessageBox.Show("Something get wrong"); } }
public void SetupFileControlCallbacks(FilesControl fc) { fc.NavigateToPathCallback = NavigateFromModel; }
public void RemoveFile(FilesControl file) { FileItems.Remove(file); }
public void AddFile(FilesControl file) { FileItems.Add(file); }