ExplorerForm.cs
Description du code
ExplorerForm.cs est un fichier du projet BrolExplorer.Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/brolexplorer/.
Projet BrolExplorer :
Explorateur de media en CSharp.
Code source ou contenu du fichier
Code c# (ExplorerForm.cs) (478 lignes)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using be.gaudry.explorer.view.controls; using be.gaudry.view; using be.gaudry.photobrol.view.controls; using be.gaudry.events; using System.IO; using be.gaudry.explorer.renamer.view; using be.gaudry.explorer.brolzip; using be.gaudry.explorer.filestats.view; using be.gaudry.explorer.filestats.view.controls; using be.gaudry.model.config; using be.gaudry.model.file; using be.gaudry.model.drawing; using be.gaudry.explorer.metadata.model.tags; using be.gaudry.explorer.brolzip.view; using be.gaudry.model.enums; using be.gaudry.explorer.metadata.view; namespace be.gaudry.explorer.view { public partial class ExplorerForm : MDIChildForm, IMDIChild { #region constructor and declarations private List<UserControl> toolPanels; private BrolExplorerAboutBox aboutBox; private SearchMediaUserControl searchUC; private ExplorerUserControl explorerUC; private ImageEditorUserControl imageEditor; public enum DISPLAY { none, mediaBrowser, explorer, imageEditor }; private DISPLAY display; private String currentFilePath, currentDirPath, version; private const string exportDisplaySettingString = "display/explorerType"; public ExplorerForm() { InitializeComponent(); setVersion(); addToolStrip(explorerTS); initSearchUC(); initExplorerUC(); display = DISPLAY.none; currentFilePath = ""; currentDirPath = ""; } private void setVersion() { Plugin p = PluginsManager.getPlugin(PLUGIN.explorer); if (p != null) { //p.MainForm = this; this.version = string.Format( "{0} {1}", p.Name, p.Version ); } } public ExplorerForm(DISPLAY display):this() { this.display = display; } #endregion #region initializations private void initExplorerUC() { explorerUC.Display = ExplorerUserControl.FILES_DISPLAY.explorer; explorerUC.Dock = DockStyle.Fill; explorerUC.ShowDesktop = true; explorerUC.ShowMyDocuments = true; explorerUC.ShowMyFavorites = true; explorerUC.ShowMyNetwork = true; explorerUC.ShowMyPictures = true; explorerUC.View = System.Windows.Forms.View.LargeIcon; toolPanels.Add(explorerUC); } private void initSearchUC() { searchUC.Dock = DockStyle.Fill; toolPanels.Add(searchUC); } private void initImageEditor() { imageEditor.AutoScroll = true; imageEditor.Dock = System.Windows.Forms.DockStyle.Fill; toolPanels.Add(imageEditor); } #endregion #region public methods public void setMenuStripDock(DockStyle dockStyle) { this.mainMenuStrip.Dock = dockStyle; } public void openMediaBrowser() { cleanToolPannels(); if(currentDirPath!="")searchUC.setPath(currentDirPath); contentPanel.Controls.Add(searchUC); } public void openExplorer() { cleanToolPannels(); contentPanel.Controls.Add(explorerUC); } public void openImageEditor(String fileFullName) { if (imageEditor == null) initImageEditor(); imageEditor.ImageLocation = fileFullName; cleanToolPannels(); contentPanel.Controls.Add(imageEditor); } #endregion #region menu display private void smallIconsTSMenuItem_Click(object sender, EventArgs e) { explorerUC.Display = ExplorerUserControl.FILES_DISPLAY.explorer; explorerUC.View = System.Windows.Forms.View.SmallIcon; } private void tileTSMenuItem_Click(object sender, EventArgs e) { explorerUC.Display = ExplorerUserControl.FILES_DISPLAY.explorer; explorerUC.View = System.Windows.Forms.View.Tile; } private void largeIconsTSMenuItem_Click(object sender, EventArgs e) { explorerUC.Display = ExplorerUserControl.FILES_DISPLAY.explorer; explorerUC.View = System.Windows.Forms.View.LargeIcon; } private void listTSMenuItem_Click(object sender, EventArgs e) { explorerUC.Display = ExplorerUserControl.FILES_DISPLAY.explorer; explorerUC.View = System.Windows.Forms.View.List; } private void detailsTSMenuItem_Click(object sender, EventArgs e) { explorerUC.Display = ExplorerUserControl.FILES_DISPLAY.explorer; explorerUC.View = System.Windows.Forms.View.Details; } private void stripTSMenuItem_Click(object sender, EventArgs e) { explorerUC.Display = ExplorerUserControl.FILES_DISPLAY.images; } private void openStatsAction(object sender, EventArgs e) { /*BrolFileStatsForm form = new BrolFileStatsForm(); form.setStartPath(currentDirPath); form.ShowDialog(this);*/ explorerUC.Display = ExplorerUserControl.FILES_DISPLAY.stats; } #endregion #region menu tools private void openIconsFormTsMi_Click(object sender, EventArgs e) { form.Show(); } private void showMusicTagEditorTsMi_Click(object sender, EventArgs e) { form.Show(this); } private void openMetaDataFormTsMi_Click(object sender, EventArgs e) { form.Show(); } #endregion #region menu file private void openPropertyFileTsMi_Click(object sender, EventArgs e) { if (!string.Empty.Equals(currentFilePath)) { FileHelper.openFileProperties(currentFilePath); } } private void openPropertiesMessageTsMi_Click(object sender, EventArgs e) { if (!string.Empty.Equals(currentFilePath)) { FileTagHelper.showProperties(currentFilePath, this); } } private void openBrolZipTSB_Click(object sender, EventArgs e) { form.setStartPath(currentDirPath); form.ShowDialog(this); } private void openRenamerAction(object sender, EventArgs e) { form.setStartPath(currentDirPath); form.ShowDialog(this); } private void openSearchPanelAction(object sender, EventArgs e) { openMediaBrowser(); } private void openBrowsePanelAction(object sender, EventArgs e) { openExplorer(); } private void openImageEditorTSMenuItem_Click(object sender, EventArgs e) { if (PluginsManager.PhotoBrolPlugAvailable) { openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); openFileDialog.Filter = "Fichiers bitmap (*.bmp)|*.bmp|Fichiers Jpeg (*.jpg)|*.jpg|Toutes les images valides (*.bmp/*.jpg)|*.bmp/*.jpg"; openFileDialog.FilterIndex = 2; //openFileDialog.RestoreDirectory = true; if (DialogResult.OK == openFileDialog.ShowDialog()) { openImageEditor(openFileDialog.FileName); } } else { MessageBox.Show( this, "Le plugin PhotoBrol n'est pas installé. Vous pouvez le télécharger sur l'infobrol.", "Plugin non installé", MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); } } private void quitterToolStripMenuItem_Click(object sender, EventArgs e) { this.Close(); } private void openDefaultTSMenuItem_Click(object sender, EventArgs e) { FileHelper.open( currentFilePath, "BrolExplorer" ); } private void openWithTSMenuItem_Click(object sender, EventArgs e) { FileHelper.openWith( currentFilePath, "BrolExplorer" ); } private void openInEditorTSMenuItem_Click(object sender, EventArgs e) { if (ImageHelper.isImg(currentFilePath)) { openImageEditor(currentFilePath); } else MessageBox.Show( this, "Aucun éditeur n'est disponible pour l'instant pour ce type de fichier...", "Editeur de brols", MessageBoxButtons.OK, MessageBoxIcon.Stop ); } #endregion #region menu edit private void annulerToolStripMenuItem_Click(object sender, EventArgs e) { if (contentPanel.Controls.Contains(imageEditor)) { imageEditor.undo(); } } private void rétablirToolStripMenuItem_Click(object sender, EventArgs e) { if (contentPanel.Controls.Contains(imageEditor)) { imageEditor.redo(); } } #endregion #region misc private methods private void explorerCMS_Opening(object sender, CancelEventArgs e) { bool fileExists = File.Exists(currentFilePath); //Console.WriteLine("test : " + currentFilePath); if (searchUC.Visible) { bool enable = searchUC.getResultsCount() > 0; saveDGVTsMi.Enabled = enable; printDgvTsMi.Enabled = enable; openDefaultTSMenuItem.Enabled = fileExists && enable; openInEditorTSMenuItem.Enabled = openDefaultTSMenuItem.Enabled; openWithTSMenuItem.Enabled = openDefaultTSMenuItem.Enabled; fileNameTsMiTB.Visible = openDefaultTSMenuItem.Enabled; fileNameTSS.Visible = openDefaultTSMenuItem.Enabled; openPropertyFileCTsMi.Enabled = openDefaultTSMenuItem.Enabled; openPropertiesMessageCTsMi.Enabled = openDefaultTSMenuItem.Enabled; } else { openDefaultTSMenuItem.Enabled = fileExists; openInEditorTSMenuItem.Enabled = fileExists; openWithTSMenuItem.Enabled = fileExists; fileNameTsMiTB.Visible = fileExists; fileNameTSS.Visible = fileExists; openPropertiesMessageCTsMi.Enabled = fileExists; openPropertyFileCTsMi.Enabled = fileExists; } dgvTSS.Visible = searchUC.Visible; saveDGVTsMi.Visible = searchUC.Visible; printDgvTsMi.Visible = searchUC.Visible; //Console.WriteLine("test2 : " + currentFilePath); fileNameTsMiTB.Text = "Fichier sélectionné : " + currentFilePath;// Path.GetFileName(currentFilePath); /*if (!File.Exists(currentFilePath)) { e.Cancel = true; }*/ //else //{ //testTSMenuItem.DropDownItems.Clear(); /* String mediaTypeStr = Path.GetExtension(currentFilePath).ToUpper(); String info; switch (mediaTypeStr) { case "DVD": case ".AVI": case ".MPG": case ".MPEG": case ".WMV": info="Type vidéo"; break; case ".MP3": case ".WAV": info = "Type audio"; break; case ".JPEG": case ".JPG": case ".GIF": case ".PNG": case ".BMP": info = "Type image"; break; case ".PDF": case ".DOC": case ".TXT": case ".PPS": case ".PPT": info = "Type \"livre\""; break; default: info= mediaTypeStr.Replace(".", "Fichier "); break; } //testTSMenuItem.DropDownItems.Add(info); fileInfoTSMenuItem.Text = info;*/ //} } private void ExplorerForm_Activated(object sender, EventArgs e) { setStatusMessage( "Copyright 2006 BrolDev", version, "" ); } private void cleanToolPannels() { foreach (UserControl ctl in toolPanels) { if (contentPanel.Controls.Contains(ctl)) contentPanel.Controls.Remove(ctl); } } private void fileSelected(object sender, String filePath) { if(!string.Empty.Equals(filePath)) currentFilePath = filePath; } private void dirSelected(object sender, String dirPath) { if (!string.Empty.Equals(dirPath)) currentDirPath = dirPath; } private void onAbout_Click(object sender, EventArgs e) { aboutBox.ShowDialog(this); } /*private void ExplorerForm_Load(object sender, EventArgs e) { switch (display) { case DISPLAY.none: break; case DISPLAY.explorer: contentPanel.Controls.Add(explorerUC); break; case DISPLAY.imageEditor: contentPanel.Controls.Add(this.imageEditor); break; case DISPLAY.mediaBrowser: contentPanel.Controls.Add(this.searchUC); break; } }*/ #endregion #region dgv methods private void saveDGVTsMi_Click(object sender, EventArgs e) { searchUC.saveBtn_Click(sender, e); } private void printDGVTsMi_Click(object sender, EventArgs e) { searchUC.printBtn_Click(sender, e); } #endregion #region IMDIChild Members public MenuStrip getMainMenuStrip() { return mainMenuStrip; } #endregion } }
Structure et Fichiers du projet
Afficher/masquer...Icône | Nom | Taille | Modification |
Icône | Nom | Taille | Modification |
| _ | Répertoire parent | 0 octets | 1732372345 23/11/2024 15:32:25 |
| _ | controls | 0 octets | 1541007170 31/10/2018 18:32:50 |
Utilisation de l'explorateur de code
- Navigation :
- Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
- Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
- La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
- Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
- Affichage :
- Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
- Actions :
- Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 30/10/2009 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/cs-brolexplorer-source-rf-view//ExplorerForm.cs.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.