public bool BeginIncorporaMetadata(FileSystemNodePlus<MyAddittionalData> nodo, MyFileSystemPlus mfsp) { if(GetIncorporaMetadataStatus()==MetadataIncluderAsyncStatus.nul) { Worker = new Thread(() => { IncorporaMetadataRicorsivo(nodo, mfsp); OnEnd?.Invoke(); }); Worker.Start(); return true; } else { return false; } }
private void LoadNode(FileSystemNodePlus<MyAddittionalData> Node) { if (Node != null) { CurrentNode = Node; Controls.Clear(); if (Node.Parent != null) { AddComponent(Node.Parent, false, ".."); } foreach (FileSystemNodePlus<MyAddittionalData> nd in Node.GetAllNode(FileSystemNodePlusType.Directory).OrderBy(x => x.Name)) { AddComponent(nd); } foreach (FileSystemNodePlus<MyAddittionalData> nf in Node.GetAllNode(FileSystemNodePlusType.File).OrderBy(x => x.Name)) { AddComponent(nf); } this.Focus(); } }
/// <summary> /// DEPRECATA! NON FUNZIONANTE /// </summary> /// <param name="nodo"></param> /// <param name="mfsp"></param> /// <param name="EndFormat"></param> /// <returns></returns> private long CalcoloSpazio(FileSystemNodePlus<MyAddittionalData> nodo, MyFileSystemPlus mfsp, FFMpegMediaMetadata EndFormat) { if (EndFormat is FFMpegMediaMetadataMp3 ) { long t = 0; foreach (FileSystemNodePlus<MyAddittionalData> n in nodo.GetAllNode()) { while (Pause) Thread.Sleep(100); if (n.Type == FileSystemNodePlusType.Directory) t += CalcoloSpazio(n, mfsp, EndFormat); else if (n.Type == FileSystemNodePlusType.File) { String p = mfsp.GetFullPath(n); if (SystemService.FileExist(p)) { textBox_source.SetTextInvoke(p); if(FFmpeg.GetMetadata(p).MediaMetadata!=null) { String temp = FFmpeg.GetMetadata(p).MediaMetadata.Duration; string[] st = temp.Split(':'); long tt = 0; if (st.Length == 3) { try { tt = st[0].ParseInt() * 144000; //trovo i secondi e moltiplico x 320/8 -> 3600*40 tt += st[1].ParseInt() * 2400; //trovo i secondi e moltiplico x 320/8 -> 60*40 tt += st[2].Split('.')[0].ParseInt() * 40; //trovo i secondi e moltiplico x 320/8 -> 60*40 } catch (Exception e) { } t += tt; } } } progressBar_total.SetValueInvoke(progressBar_total.Value + 1); } } return t; } return 0; }
private void IncorporaMetadataRicorsivo(FileSystemNodePlus<MyAddittionalData> nodo, MyFileSystemPlus mfsp) { foreach (FileSystemNodePlus<MyAddittionalData> n in nodo.GetAllNode()) { while (_Pause) Thread.Sleep(100); if (n.Type == FileSystemNodePlusType.Directory) IncorporaMetadataRicorsivo(n, mfsp); else if (n.Type == FileSystemNodePlusType.File) { IncorporaMetadataNodo(n, mfsp.GetFullPath(n)); } } }
public SelectControl(FileSystemNodePlus<MyAddittionalData> Node, CheckBox c) { this.Node = Node; this.c = c; c.MouseClick += C_MouseClick; CurrentSelect = NodeSelect; }
public bool EqualNodo(FileSystemNodePlus<MyAddittionalData> n) { return n == _Nodo; }
private void SetSelectParentNodeRecursive(FileSystemNodePlus<MyAddittionalData> Nodo, bool Value) { if (Value) { Nodo.AddittionalData.Selezionato = true; } else { foreach (FileSystemNodePlus<MyAddittionalData> n in Nodo.GetAllNode()) if (n.AddittionalData.Selezionato) return; Nodo.AddittionalData.Selezionato = false; } if (Nodo.Parent != null) SetSelectParentNodeRecursive(Nodo.Parent, Value); }
private void SetSelectChildNodeRecursive(FileSystemNodePlus<MyAddittionalData> Node, bool Value) { Node.AddittionalData.Selezionato = Value; foreach(FileSystemNodePlus<MyAddittionalData> n in Node.GetAllNode()) SetSelectChildNodeRecursive(n, Value); }
public SingleFile GetSingleFileFromNode(FileSystemNodePlus<MyAddittionalData> Node) { foreach(SingleFile s in Controls) { if (s.Nodo == Node) return s; } return null; }
public SingleFile(FileSystemNodePlus<MyAddittionalData> Nodo) { InitializeComponent(); this._Nodo = Nodo; if (Nodo.Type == FileSystemNodePlusType.Directory) this.Icon.BackgroundImage = global::MusicLibraryManager.Properties.Resources.Folder; else if (Nodo.Type == FileSystemNodePlusType.File) { Icon icon = RegisteredFileType.GetIconFromExtension(Path.GetExtension(Nodo.Name).ToLower()); if (icon != null) this.Icon.BackgroundImage = icon.ToBitmap(); } label1.Text = Nodo.ToString(); Control[] c = { this, label1, Icon, textBox1 }; foreach(Control cc in c) { cc.MouseClick += SingleFile_MouseClick; cc.MouseClick += SingleFile_RightClickCheck; cc.MouseDoubleClick += SingleFile_MouseDoubleClick; cc.MouseDown += SingleFile_MouseDown; cc.MouseUp += SingleFile_MouseUp; cc.MouseMove += SingleFile_MouseMove; cc.KeyDown += SingleFile_KeyDown; } checkBox1.MouseClick += SingleFile_RightClickCheck; sc = new SelectControl(Nodo, checkBox1); sc.OnShowCheckBoxChanged += () => { Invalidate(); }; sc.OnCurrentSelectChanged += () => { Invalidate(); }; sc.OnNodeSelectChanged += () => { SetSelectParentNode(sc.NodeSelect); SetSelectChildNode(sc.NodeSelect); }; sc.OnCheckBoxClick += (Keys Modificatore) => { if (OnSingleFileSelectChange != null) OnSingleFileSelectChange(Nodo, Modificatore); Invalidate(); }; Status = SingleFileStatus.Normal; }
private void S_OnSingleFileSelectChange(FileSystemNodePlus<MyAddittionalData> Nodo, Keys Modificatore) { if(Modificatore!=Keys.Shift) LastClicked = Controls.IndexOf(Controls.OfType<SingleFile>().Where(sf => sf.EqualNodo(Nodo)).First()); else { int NowClicked= Controls.IndexOf(Controls.OfType<SingleFile>().Where(sf => sf.EqualNodo(Nodo)).First()); int max = LastClicked > NowClicked ? LastClicked : NowClicked; for (int i=LastClicked<NowClicked?LastClicked:NowClicked;i<max;i++) { if (Controls[i] is SingleFile) Controls[i]._Cast<SingleFile>().sc.Select = true; } LastClicked = NowClicked; } }
public void IncorporaMetadataNodo(FileSystemNodePlus<MyAddittionalData> nodo,String PathSource) { if (SystemService.FileExist(PathSource)) { OnNodeStartProcessing?.Invoke(nodo, PathSource); if (nodo.AddittionalData == null) nodo.AddittionalData = new MyAddittionalData(); if (nodo.AddittionalData.Metadata == null) nodo.AddittionalData.Metadata = new FFmpegMetadata(); nodo.AddittionalData.Metadata = FFmpeg.GetMetadata(PathSource); nodo.AddittionalData.Size = SystemService.FileSize(PathSource); SystemService.GetMD5(PathSource, (double percent) => { OnProgressChangedSingleMD5?.Invoke(percent); }, (byte[] Hash) => { if (Hash != null) { nodo.AddittionalData.MD5 = Hash.ToHexString(true); OnNodeProcessed?.Invoke(nodo, PathSource, MetadataIncluderError.nul); } else OnNodeProcessed?.Invoke(nodo, PathSource, MetadataIncluderError.MD5Err); }); } else OnNodeProcessed?.Invoke(nodo, PathSource, MetadataIncluderError.FileNonTrovato); }
private void S_OnSingleFileRightClick(FileSystemNodePlus<MyAddittionalData> Nodo) { ApricontextMenuStrip(Cursor.Position); }
private void S_OnSingleFileDoubleClick(SingleFile Sender,FileSystemNodePlus<MyAddittionalData> Nodo) { if (Nodo.Type == FileSystemNodePlusType.Directory) { if (Sender.ShowedName == "..") { String s = CurrentNode.Name; LoadNode(Nodo); ScrollTo("^" + s); } else { LoadNode(Nodo); } } }
private void S_OnSingleFileMouseUp(SingleFile SF) { if (Type == FileBrowserType.Playlist) { Cursor.Current = Cursors.Default; if (DownNode != SF.Nodo) { if (SF.Nodo.Type == FileSystemNodePlusType.Directory) { String path = CurrentNode.GetFullPath(); MyFileSystemPlus Clo = currentFileSystem.Clone(); FileSystemNodePlus<MyAddittionalData> nn = Clo.GetNodeFromPath(path); MyFileSystemPlus temp = new MyFileSystemPlus(); temp.Root = nn; temp = temp.FindPreserveTree((x) => { return x.AddittionalData.Selezionato; }, FileSystemNodePlusControlType.Pre); CurrentNode.Remove((t) => { return t.Type == FileSystemNodePlusType.File && t.AddittionalData.Selezionato; }, FileSystemNodePlusLevelType.AllNode, FileSystemNodePlusControlType.Pre); CurrentNode.Remove((t) => { return t.Type == FileSystemNodePlusType.Directory && t.ChildCount == 0 && t.AddittionalData.Selezionato; }, FileSystemNodePlusLevelType.AllNode, FileSystemNodePlusControlType.Post); temp.DeselectAll(); SF.Nodo.Merge(temp.Root); SF.Selected = false; ReloadNode(); if (PlaylistChanged != null) PlaylistChanged(currentFileSystem); } } DownNode = null; } }
private void S_OnSingleFileMouseDown(SingleFile SF) { if (Type == FileBrowserType.Playlist) { DownSingleFile = SF; DownNode = SF.Nodo; Cursor.Current = Cursors.Cross; } }
private void S_OnSingleFileNodoChangeName(SingleFile Sender, FileSystemNodePlus<MyAddittionalData> Nodo, string NewName) { if (Nodo.Parent == null) Sender.Status = SingleFileStatus.Normal; else { FileSystemNodePlus<MyAddittionalData> parent = Nodo.Parent; FileSystemNodePlus<MyAddittionalData> nt = Nodo.Clone(NewName); parent.Remove((x) => { return x == Nodo; }, FileSystemNodePlusLevelType.FirstLevel, FileSystemNodePlusControlType.Pre); parent.Add(nt); ReloadNode(); if (PlaylistChanged != null) PlaylistChanged(currentFileSystem); } }
public void AddComponent(FileSystemNodePlus<MyAddittionalData> Component,bool Selectionable=true,String OverrideName=null) { SingleFile s = new SingleFile(Component); s.Location = new Point(0, s.Height * Controls.Count); s.Width = Width; s.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; s.OnSingleFileDoubleClick += S_OnSingleFileDoubleClick; s.OnSingleFileRightClick += S_OnSingleFileRightClick; s.OnSingleFileSelectChange += S_OnSingleFileSelectChange; s.OnSingleFileMouseDown += S_OnSingleFileMouseDown; s.OnSingleFileMouseUp += S_OnSingleFileMouseUp; s.OnSingleFileMouseMove += S_OnSingleFileMouseMove; s.OnSingleFileNodoChangeName += S_OnSingleFileNodoChangeName; s.OnSingleFileKeyDown += S_OnSingleFileKeyDown; if(OverrideName!=null) s.ShowedName = OverrideName; if (_Status == FileBrowserStatus.browsing) s.sc.ShowCheckBox = false; else if (_Status == FileBrowserStatus.Select) s.sc.ShowCheckBox = true; s.sc.Selectionable = Selectionable; Controls.Add(s); }
/// <summary> /// Scorre tutte le cartelle presenti nella cartella Reale e controlla i file: /// se un file viente trovato nella cartella e nel FileSystem allora viene impostato il flag Selezionato a true /// se un file non viene trovato nel FileSystem, viene aggiunto al FileSystem Temp /// /// </summary> /// <param name="FileSystem"></param> /// <param name="CurrentPath">Path da controllare</param> /// <param name="Temp"></param> private void UpdateRecursiveRealToList(MyFileSystemPlus FileSystem, String CurrentPath, FileSystemNodePlus<MyAddittionalData> Temp) { //scorro tutte le cartelle //imposto selezionato a tutti i file che trovo //alla fine rimuovo i file non selezionati String[] tfolder = SystemService.GetDirectories(CurrentPath); foreach (String s in tfolder) { UpdateRecursiveRealToList(FileSystem, s, Temp.CreateNode(s.TrimEnd('\\', '/').SplitAndGetLast("\\", "/"), FileSystemNodePlusType.Directory)); } String[] tfile = SystemService.GetFiles(CurrentPath); foreach (String s in tfile) { if (LoadOption == null || (LoadOption != null && (!LoadOption.RestrictExtensionEnable || LoadOption.RestrictExtension.Contains(System.IO.Path.GetExtension(s).TrimStart('.').ToLower())))) { FileSystemNodePlus<MyAddittionalData> n = FileSystem.GetNodeFromPath(s); if (n == null) { //se il file non viene trovato vuol dire che è nuovo e lo aggiungo al temp Temp.CreateNode(s.TrimEnd('\\', '/').SplitAndGetLast("\\", "/"), FileSystemNodePlusType.File); } else if (n.AddittionalData.Size == SystemService.FileSize(s) && n.AddittionalData.MD5!=null && n.Type == (SystemService.FileExist(s)?FileSystemNodePlusType.File:FileSystemNodePlusType.Directory)) { // il file non è stato modificato ( dimensine ) // ha l'md5 // che il tipo corrisponda ( per errori di vecchi Index // lo seleziono ( vuol dire che lo tengo ) . n.AddittionalData.Selezionato = true; } else // nel caso in cui il file è stato modificato { //reinserisco il file all'interno di temp in modo che venga rianalizzato Temp.CreateNode(s.TrimEnd('\\', '/').SplitAndGetLast("\\", "/"), FileSystemNodePlusType.File); } } } }