示例#1
0
        private static void OnItemStatusChanged(SmartItem item)
        {
            string status = item.Status.ToString();

            if (status.Ends("Error"))
            {
                item.OptColor = SolidColors.DarkRed;
            }
            else if (status.Equal("Ignored"))
            {
                item.OptColor = SolidColors.DarkOrange;
            }
            else if (status.Ends("ed"))
            {
                item.OptColor = SolidColors.SolidBlue;
            }
            else
            {
                item.OptColor = SolidColors.DarkGreen;
            }
            item.Operation = AppLanguage.Get("LangOperation" + status);

            switch (item.Status)
            {
            case ItemStatus.Uploading: Counts.Files++; Counts.Update(); break;

            case ItemStatus.Created: Counts.Folders++; Counts.Update(); break;
            }
        }
示例#2
0
        internal HistoryItem(string server, string name, string path, string oldValue, string newValue, string status, DateTime date)
        {
            Server   = server;
            ItemName = name;
            ItemPath = path;
            OldValue = oldValue;
            NewValue = newValue;
            Status   = status;

            if (status.Ends("Error"))
            {
                StatusColor = SolidColors.DarkRed;
            }
            else if (status.Equal("Ignored"))
            {
                StatusColor = SolidColors.DarkOrange;
            }
            else
            {
                StatusColor = SolidColors.DarkGreen;
            }
            Item_Status = AppLanguage.Get("LangOperation" + status);

            Ticks = date.Ticks;
        }
示例#3
0
        private static void _set()
        {
            Home   = DirectoryHelper.DesktopDirectory;
            ThisPC = AppLanguage.Get("LangThisPC");

            fsw              = new FileSystemWatcher();
            fsw.Filter       = "*.*";
            fsw.NotifyFilter = NotifyFilters.Size | NotifyFilters.FileName | NotifyFilters.DirectoryName;
            fsw.Changed     += new FileSystemEventHandler(ListChanged);
            fsw.Created     += new FileSystemEventHandler(ListChanged);
            fsw.Deleted     += new FileSystemEventHandler(ListChanged);
            fsw.Renamed     += new RenamedEventHandler(ListChanged);
        }
示例#4
0
        internal void Update()
        {
            string count = string.Empty;

            if ((files != 0) || (folders != 0))
            {
                if (folders != 0)
                {
                    count = AppLanguage.Get("LangTextFoldersX").FormatC(folders);
                    if (files != 0)
                    {
                        count += AppLanguage.Get("LangTextSpaceComma") + " ";
                    }
                }
                if (files != 0)
                {
                    count += AppLanguage.Get("LangTextFilesX").FormatC(files);
                }
            }
            Items = count;
        }
示例#5
0
        internal static async Task <bool> SetItemsAsync(string path)
        {
            if (path.NullEmpty())
            {
                return(false);
            }
            if ((path != LocalHelper.ThisPC) && !DirectoryHelper.Exists(path))
            {
                return(false);
            }

            fsw.EnableRaisingEvents = false;
            List <SmartItem> items  = new List <SmartItem>();
            bool             listed = false;
            await Task.Run(() =>
            {
                if (path == Home)
                {
                    SmartItem item = new SmartItem();
                    item.FullName  = item.ItemName = LocalHelper.ThisPC;
                    item.ItemIcon  = IconHelper.Get((int)ImageList.SpecialFolderCSIDL.DRIVES);

                    items.Add(item);
                    //items.Add(documentsPath);
                    listed = true;
                }

                if (path == LocalHelper.ThisPC)
                {
                    DriveInfo[] localDrives = DirectoryHelper.GetDrives();
                    try
                    {
                        for (int i = 0; i < localDrives.Length; i++)
                        {
                            SmartItem Ditem = new SmartItem(new DirectoryInfo(localDrives[i].Name));
                            Ditem.ItemName  = (localDrives[i].IsReady ? localDrives[i].VolumeLabel : string.Empty) + " (" + localDrives[i].Name.TrimEnd('\\') + ')' + (localDrives[i].IsReady ?
                                                                                                                                                                       " " + AppLanguage.Get("LangFreeSpaceX").FormatC(SizeUnit.Parse(localDrives[i].AvailableFreeSpace)) : string.Empty);
                            items.Add(Ditem);
                        }
                        listed = true;
                    }
                    catch (Exception exp) { ExceptionHelper.Log(exp); }
                    localDrives = null;
                }
                else
                {
                    DirectoryInfo Localdir = null;
                    try { Localdir = new DirectoryInfo(path); }
                    catch (Exception exp) { ExceptionHelper.Log(exp); }

                    if (Localdir != null)
                    {
                        listed = true;
                        DirectoryInfo[] dirs = null;
                        try
                        {
                            dirs = Localdir.GetDirectories();
                            for (int i = 0; i < dirs.Length; i++)
                            {
                                if ((dirs[i].Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                                {
                                    items.Add(new SmartItem(dirs[i]));
                                }
                            }
                        }
                        catch (Exception exp) { ExceptionHelper.Log(exp); }
                        dirs = null;

                        FileInfo[] files = null;
                        try
                        {
                            files = Localdir.GetFiles();
                            for (int i = 0; i < files.Length; i++)
                            {
                                if ((files[i].Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                                {
                                    items.Add(new SmartItem(files[i]));
                                }
                            }
                        }
                        catch (Exception exp) { ExceptionHelper.Log(exp); }
                        files = null;
                    }
                    Localdir = null;
                }
            });

            if (listed)
            {
                if (DirectoryHelper.Exists(path))
                {
                    if (fsw.Path != path)
                    {
                        fsw.Path = path;
                    }
                    fsw.EnableRaisingEvents = true;
                }

                LastPath    = CurrentPath;
                CurrentPath = path;

                if (path == LocalHelper.ThisPC)
                {
                    ParentPath = Home;
                }
                else
                {
                    ParentPath = DirectoryHelper.GetParentPath(path);
                }

                Items = new ObservableCollection <SmartItem>(items);
                return(true);
            }
            else
            {
                return(false);
            }
        }