public SoundEventsSynchronizer(ISynchronizeInvoke synchronizeObject,
                                IFolderObject <SoundEvent> foldersToSync,
                                IFoldersFinder <SoundEvent, Sound> finder,
                                IFileSystem fileSystem,
                                string rootPath = null,
                                string filters  = null)
     : base(synchronizeObject, foldersToSync, finder, rootPath, filters) => FileSystem = fileSystem;
        public virtual int CompareTo(Column column, IFolderObject obj)
        {
            // get the values for this item and the other item in the
            // specified column

            object value1 = GetColumnValue(column);
            object value2 = obj.GetColumnValue(column);

            if (column != null && column.Comparer != null)
            {
                // the column provides a comparer
                return(column.Comparer.Compare(value1, value2));
            }
            else if (value1 == null && value2 != null)
            {
                return(1);                      // sort empty column values to the bottom
            }
            else if (value2 == null && value1 != null)
            {
                return(-1);                     // sort empty column values to the bottom
            }
            else if (value1 == null && value2 == null ||
                     !(value1 is IComparable && value2 is IComparable))
            {
                // compare the display names as a last resort
                return(GetDisplayName(NameOptions.Normal).CompareTo(obj.GetDisplayName(NameOptions.Normal)));
            }
            else
            {
                // the values implement IComparable, so work with that;
                // hopefully the values are compatible
                return(((IComparable)value1).CompareTo(value2));
            }
        }
Example #3
0
        public Item(byte[][] pathData, string root, string path, string name, IFileObject fo, IFolderObject parrent, IShellView sv)
        {
            base.ShellView = sv;
            this.parrent   = parrent;
            columns        = new ColumnCollection();
            columns.Add(ColName);
            columns.Add(ColAttr);
            columns.Add(ColPerm1);
            columns.Add(ColPerm2);
            columns.Add(ColFileSize);
            columns.Add(ColDate);
            columns.Add(ColTime);
            columns.Add(ColLinkTo);

            this.root = root;
            this.path = path;
            this.name = name;
            this.fo   = fo;
            base.SetPath(pathData);
            if (string.IsNullOrEmpty(root))
            {
                if (string.IsNullOrEmpty(path))
                {
                    base.SetPath(string.Format("{0}", name));
                }
                else
                {
                    base.SetPath(string.Format("{0}{1}{2}", path, FD, name));
                }
            }
            else
            {
                base.SetPath(string.Format("{0}{1}{2}{3}{4}", root, FD, path, FD, name));
            }
        }
Example #4
0
        public Folder(byte[][] pathData, IdList idlist, string root, string path, FolderAttributes attrs, IFileObject fo, IShellView sv, IFolderObject parrent)
        {
            this.parrent = parrent;
            columns      = new ColumnCollection();
            columns.Add(ColName);
            columns.Add(ColAttr);
            columns.Add(ColPerm1);
            columns.Add(ColPerm2);
            columns.Add(ColFileSize);
            columns.Add(ColDate);
            columns.Add(ColTime);
            columns.Add(ColLinkTo);

            base.ShellView = sv;
            this.attrs     = attrs;
            this.root      = root;
            this.path      = path;
            this.fo        = fo;

            if (string.IsNullOrEmpty(root))
            {
                base.SetPath(string.Format("{0}", path));
            }
            else
            {
                base.SetPath(string.Format("{0}{1}{2}", root, FD, path));
            }

            base.SetPath(pathData);
            base.SetIdList(idlist);
        }
Example #5
0
 public FolderSynchronizer(ISynchronizeInvoke synchronizingObject, IFolderObject <TFolder> foldersToSync, IFoldersFinder <TFolder, TFile> finder, string rootPath = null, string filters = null)
 {
     Finder         = finder;
     SyncedFolders  = foldersToSync;
     Finder.Filters = filters;
     if (string.IsNullOrEmpty(rootPath))
     {
         FileWatcher = new FileSystemWatcherExtended()
         {
             Filters = filters
         };
     }
     else
     {
         FileWatcher = new FileSystemWatcherExtended(RootPath, Filters);
     }
     FileWatcher.IncludeSubdirectories         = true;
     FileWatcher.AlwaysMonitorDirectoryChanges = true;
     FileWatcher.SynchronizingObject           = synchronizingObject;
     SyncFilter = NotifyFilter.Directory | NotifyFilter.File;
     FileWatcher.FileCreated        += OnFileWatcherCreated;
     FileWatcher.FileDeleted        += OnFileWatcherDeleted;
     FileWatcher.FileRenamed        += OnFileWatcherRenamed;
     FileWatcher.FileSubPathRenamed += OnFileWatcherSubPathRenamed;
 }
Example #6
0
 public static string GetDisplayFolder(this IFolderObject folderObject, Culture culture)
 {
     if (culture == null)
     {
         return(folderObject.DisplayFolder.TrimFolder());
     }
     return(folderObject.TranslatedDisplayFolders[culture]?.TrimFolder() ?? "");
 }
Example #7
0
        public virtual void SetFolderName(IFolderObject folderObj, string sName)
        {
            string sOldFile = folderObj.PathString;
            string sOld     = string.Format("{0}/{1}", GetBaseFolder(), sOldFile);
            string sNew     = string.Format("{0}/{1}", GetBaseFolder(), sName);

            ADBCommand    command = new ADBCommand();
            CommandResult rez     = command.Rename(sOld, sNew);
        }
Example #8
0
        /*
         * public  IImageList list_SHIL_SMALL;
         * public  IImageList list_SHIL_LARGE;
         * public  IImageList list_SHIL_EXTRALARGE;
         * public  IImageList list_SHIL_JUMBO;
         *
         * public System.Drawing.Icon icon_s;
         * public System.Drawing.Icon icon_l;
         * public System.Drawing.Icon icon_e;
         * public System.Drawing.Icon icon_j;
         */
        internal ExtractIconImpl(IFolderObject folderObj)
        {
            if (folderObj == null)
            {
                throw new ArgumentNullException("folderObj");
            }

            this.folderObj = folderObj;
        }
Example #9
0
        private void BuildFolderForObject(IFolderObject obj)
        {
            var folderStrings = obj.GetDisplayFolder(Culture).Split(';').Distinct(StringComparer.InvariantCultureIgnoreCase);

            foreach (var folderString in folderStrings)
            {
                var folder = Folder.CreateFolder(obj.Table, folderString);
                folder.Children.Add(obj);
            }
        }
Example #10
0
        public static IEnumerable <Folder> GetFolderStack(this IFolderObject folderObject, Culture culture)
        {
            var folder = folderObject.GetFolder(culture);

            while (folder != null && folder.Name != "")
            {
                yield return(folder);

                folder = folder.GetFolder(culture);
            }
        }
Example #11
0
        public static Folder GetFolder(this IFolderObject folderObject, Culture culture)
        {
            var df = folderObject.GetDisplayFolder(culture);

            if (df == null)
            {
                return(null);
            }
            Folder folder;

            return(folderObject.Table.FolderCache.TryGetValue(df, out folder) ? folder : null);
        }
Example #12
0
        public ExploreMenuItem(IFolderObject folderObj, byte[][] fqPidl, string text, string helpText, string verb, IFolderObject[] items = null)
            : base(null, false, false, true, helpText, false, false, text, verb)
        {
            _items     = items;
            _folderObj = folderObj;
            if (fqPidl == null)
            {
                throw new ArgumentNullException("fqPidl");
            }

            this.fqPidl = fqPidl;
            Click      += new EventHandler(ExploreMenuItem_Click);
        }
 /// <summary> Enumerates files that matches given file path </summary>
 public static IEnumerable <TFile> EnumerateFolderFiles <TFolder, TFile>(this IFolderObject <TFolder> folderCollection, string path)
     where TFolder : class, IFolderObject <TFile>
     where TFile : class, IFileObject
 {
     foreach (TFolder soundEvent in folderCollection.Files)
     {
         TFile sound = soundEvent.Files.Find(x => x.Info.FullName.ComparePath(path));
         if (sound != null)
         {
             yield return(sound);
         }
     }
 }
Example #14
0
        public static string GetDisplayFolder(this IFolderObject folderObject, Culture culture)
        {
            if (culture == null)
            {
                return(folderObject.DisplayFolder.TrimFolder());
            }
            if (folderObject is Folder f)
            {
                return(f.DisplayFolder);
            }
            var folder = folderObject.TranslatedDisplayFolders[culture];

            return(folder == null ? "" : folder.TrimFolder());
        }
Example #15
0
        internal void AddError(IFolderObject folderObject)
        {
            if (ErrorMessage == null)
            {
                ErrorMessage = "Child objects with errors:";
            }
            if (folderObject is Folder f)
            {
                ErrorMessage += "\r\nObjects inside the '" + f.Name + "' folder.";
            }

            else
            {
                ErrorMessage += "\r\n" + folderObject.GetTypeName() + " " + folderObject.GetName();
            }
        }
Example #16
0
        private void GetAttributeOwnerGroup(IFolderObject item, ref string sAttr, ref string sOwner, ref string sGroup)
        {
            Column columnAttr  = null;
            Column columnOwner = null;
            Column columnGroup = null;

            foreach (Column column in Items[0].Columns)
            {
                if (column.Name.ToLower().Equals("attributes"))
                {
                    columnAttr = column;
                }
                if (column.Name.ToLower().Equals("owner"))
                {
                    columnOwner = column;
                }
                if (column.Name.ToLower().Equals("group"))
                {
                    columnGroup = column;
                }
            }
            if (columnAttr != null)
            {
                object obj = Items[0].GetColumnValue(columnAttr);
                if (obj != null)
                {
                    sAttr = obj.ToString();
                }
            }
            if (columnOwner != null)
            {
                object obj = Items[0].GetColumnValue(columnOwner);
                if (obj != null)
                {
                    sOwner = obj.ToString();
                }
            }
            if (columnGroup != null)
            {
                object obj = Items[0].GetColumnValue(columnGroup);
                if (obj != null)
                {
                    sGroup = obj.ToString();
                }
            }
        }
Example #17
0
 public static void SetDisplayFolder(this IFolderObject folderObject, string newFolderName, Culture culture)
 {
     if (folderObject is Folder)
     {
         var folder = folderObject as Folder;
         folder.DisplayFolder = newFolderName;
     }
     else
     {
         if (culture == null)
         {
             folderObject.DisplayFolder = newFolderName;
         }
         else
         {
             folderObject.TranslatedDisplayFolders[culture] = newFolderName;
         }
     }
 }
Example #18
0
        public override void CopyItems(IFolderObject fo, List <string> lItems)
        {
            List <string> folders = new List <string>();
            List <string> files   = new List <string>();
            CommandResult cr      = Copy(fo.PathString, lItems, ref folders, ref files);

            if (!cr.IsSuccess)
            {
                cr.ShowMessage();
                return;
            }

            IntPtr pCurrObj = ItemIdList.Create(null, fo.PathData).Ptr;

            Shell32.SHChangeNotify(ShellChangeEvents.UpdateDir,
                                   ShellChangeFlags.IdList | ShellChangeFlags.Flush,
                                   pCurrObj,
                                   IntPtr.Zero);
            Marshal.FreeCoTaskMem(pCurrObj);
        }
 public static bool TryGetFolderFile <TFolder, TFile>(this IFolderObject <TFolder> folderCollection, string path, out TFile file, out TFolder folder)
     where TFolder : class, IFolderObject <TFile>
     where TFile : class, IFileObject
 {
     foreach (TFolder folderItem in folderCollection.Files)
     {
         foreach (TFile folderFile in folderItem.Files)
         {
             if (folderFile.Info.FullName.ComparePath(path))
             {
                 file   = folderFile;
                 folder = folderItem;
                 return(true);
             }
         }
     }
     folder = null;
     file   = null;
     return(false);
 }
 public void MoveObject(IFolderObject sourceObject, Table newDestinationTable, bool allowOverwrite)
 {
     if (sourceObject is Measure m)
     {
         var kpi = m.KPI;
         m.Delete();
         m.RenewMetadataObject();
         if (kpi != null)
         {
             kpi.RenewMetadataObject(); m.Reinit();
         }
         newDestinationTable.Measures.Add(m);
     }
     if (sourceObject is CalculatedColumn c)
     {
         var name = c.Name;
         c.Delete();
         c.RenewMetadataObject();
         c.MetadataObject.Name = newDestinationTable.Columns.GetNewName(name);
         newDestinationTable.Columns.Add(c);
     }
 }
        public virtual void CopyItems(IFolderObject fo, List <string> lItems)
        {
            if (fo == null)
            {
                List <string> folders = new List <string>();
                List <string> files   = new List <string>();

                string sRealDestination = lItems[lItems.Count - 1];
                lItems.RemoveAt(lItems.Count - 1);

                if (lItems.Count > 0)
                {
                    foreach (string item in lItems)
                    {
                        string   sObject = item;
                        byte[][] btp     = CodePath.Decode(CodePath.GetPathFromString(sObject));

                        LinkMayker lb        = new LinkMayker();
                        IntPtr     path      = ItemIdList.Create(null, btp).Ptr;
                        string     sFullName = sObject.Substring(sObject.IndexOf('\\') + 1);
                        lb.MakeLink("Virtual Link", path, sRealDestination + "\\" + sFullName.Substring(sFullName.LastIndexOf(FD[0]) + 1) + ".lnk");
                        Marshal.FreeCoTaskMem(path);

                        //Copy(sRealDestination, lItems, ref folders, ref files);
                    }
                }
            }
            else
            {
                List <string> folders = new List <string>();
                List <string> files   = new List <string>();

                CommandResult cr = Copy(fo.PathString, lItems, ref folders, ref files);
                if (!cr.IsSuccess)
                {
                    cr.ShowMessage();
                }
            }
        }
Example #22
0
        private bool Matches(IFolderObject folderObj)
        {
            FolderAttributes attrs = folderObj.Attributes;

            bool hidden        = (attrs & FolderAttributes.Hidden) != FolderAttributes.None;
            bool includeHidden = (opts & EnumOptions.IncludeHidden) == EnumOptions.IncludeHidden;

            bool folder            = (attrs & FolderAttributes.Folder) != FolderAttributes.None;
            bool includeFolders    = (opts & EnumOptions.Folders) == EnumOptions.Folders;
            bool includeNonFolders = (opts & EnumOptions.NonFolders) == EnumOptions.NonFolders;

            bool storage        = (attrs & (FolderAttributes.StorageAncestor | FolderAttributes.StorageAncestor)) != FolderAttributes.None;
            bool includeStorage = (opts & EnumOptions.Storage) == EnumOptions.Storage;

            bool share         = (attrs & FolderAttributes.Share) != FolderAttributes.None;
            bool includeShares = (opts & EnumOptions.Shareable) == EnumOptions.Shareable;

            return
                ((hidden ? includeHidden : true) &&
                 (folder ? includeFolders : includeNonFolders) &&
                 (storage ? includeStorage : true) &&
                 (share ? includeShares : true));
        }
Example #23
0
        internal ContextMenuImpl(IFolderObject root, params IFolderObject[] fos)
        {
            if (root != null)
            {
                root.ContextMenu = this;
            }

            if (fos == null)
            {
                throw new ArgumentNullException("fos");
            }
            else if (fos.Length == 0)
            {
                throw new ArgumentOutOfRangeException("fos.Length", fos.Length, "must be >= 1");
            }
            else if (root == null && fos.Length > 1)
            {
                throw new InvalidOperationException();
            }

            ShellMenuItem[] mis;

            if (fos.Length == 1)
            {
                mis = fos[0].MenuItems;
                fos[0].ContextMenu = this;
            }
            else
            {
                mis = root.GetMenuItems(fos);
            }

            menuItems = (mis == null)
                                ? new ShellMenuItem[] {}
                                : mis;
        }
Example #24
0
 internal void AddError(IFolderObject folderObject)
 {
     if (ErrorMessage == null)
     {
         ErrorMessage = "Child objects with errors:";
         var parentFolder = this.GetFolder(Tree.Culture);
         if (parentFolder != null && parentFolder.Name != "")
         {
             parentFolder.AddError(this);
         }
         else
         {
             Table.AddError(this);
         }
     }
     if (folderObject is Folder f)
     {
         ErrorMessage += "\r\nObjects inside the '" + f.Name + "' folder.";
     }
     else
     {
         ErrorMessage += "\r\n" + folderObject.GetTypeName() + " " + folderObject.GetName();
     }
 }
Example #25
0
        public void SetData(IFolderObject[] items, IFolderObject folderObj)
        {
            _folderObj = folderObj;
            Items      = items;

            if (Items.Count() == 1)
            {
                string sAttr  = null;
                string sOwner = null;
                string sGroup = null;
                GetAttributeOwnerGroup(Items[0], ref sAttr, ref sOwner, ref sGroup);

                if (!cbOwner.Items.Contains(sOwner))
                {
                    cbOwner.Items.Add(sOwner);
                }
                cbOwner.Text = sOwner;

                if (!cbGroup.Items.Contains(sGroup))
                {
                    cbGroup.Items.Add(sGroup);
                }
                cbGroup.Text = sGroup;

                if (!string.IsNullOrEmpty(sAttr))
                {
                    this.Text = string.Format("P[{0}] O[{1}] G[{2}] {3}", sAttr, sOwner, sGroup,
                                              string.Format("/{0}", Items[0].PathString));
                    ParseAttribute(sAttr);
                }
                else
                {
                    //clear all data
                }
            }
        }
 /// <summary> Enumerates files that are sub paths of given folder path</summary>
 public static IEnumerable <TFile> EnumerateSubPathFiles <TFile>(this IFolderObject <TFile> folders, string path) where TFile : IFileSystemObject =>
 folders.Files.Where(file => IOHelper.IsSubPathOf(file.Info.FullName, path));
 /// <summary> Enumerates files that matches given file path </summary>
 public static IEnumerable <TFile> EnumerateFiles <TFile>(this IFolderObject <TFile> folders, string path) where TFile : IFileSystemObject =>
 folders.Files.Where(file => file.Info.FullName.ComparePath(path));
 public IFolderSynchronizer <SoundEvent, Sound> Create(IFolderObject <SoundEvent> foldersToSync, string rootPath = null, string filters = null) =>
 new SoundEventsSynchronizer(synchonizingObject, foldersToSync, finder, fileSystem, rootPath, filters);
 public static bool TryGetFolderFile <TFolder, TFile>(this IFolderObject <TFolder> folderCollection, string path, out TFile file)
     where TFolder : class, IFolderObject <TFile>
     where TFile : class, IFileObject => TryGetFolderFile(folderCollection, path, out file, out TFolder folder);
 /// <summary> Enumerates files that matches given file path </summary>
 public static IEnumerable <(TFolder folder, TFile file)> EnumerateFolderFilesExtended <TFolder, TFile>(this IFolderObject <TFolder> folderCollection, string path)