Exemplo n.º 1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="mappingName">Mapping file name.</param>
        /// <param name="name">File item name.</param>
        /// <param name="type">File item type.</param>
        /// <param name="isChanged">If this file item is changed since last code generation.</param>
        public FileItem(string mappingName, string name, FileItemType type, bool isChanged)
        {
            switch (type)
            {
            case FileItemType.DataAccess:
            {
                this.fileName         = string.Format("{0}.DataAccess.{1}.cs", mappingName, name, CultureInfo.InvariantCulture);
                this.templateFilePath = GetTemplateFilePath(@"Templates\DbSharper.DataAccess.xslt");
                break;
            }

            case FileItemType.Models:
            {
                this.fileName         = string.Format("{0}.Models.{1}.cs", mappingName, name, CultureInfo.InvariantCulture);
                this.templateFilePath = GetTemplateFilePath(@"Templates\DbSharper.Models.xslt");
                break;
            }

            default:
                throw new ArgumentOutOfRangeException("type");
            }

            this.isChanged = isChanged;
            this.name      = name;
            this.type      = type;
        }
Exemplo n.º 2
0
 public FileItem(string name, decimal size, string date = "", FileItemType type = FileItemType.DIR)
 {
     Name = name;
     Size = size;
     Date = date;
     Type = type;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a concrete type based on an enum.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static FileItem Create(FileItemType type)
        {
            switch (type)
            {
            case FileItemType.JPEG:
                return(new ImageJpeg());

                break;

            case FileItemType.GIF:
                return(new ImageGif());

                break;

            case FileItemType.PNG:
                return(new ImagePng());

                break;

            case FileItemType.XHTML:
                return(new Chapter());

                break;

            default:
                throw new NotImplementedException();
                break;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 基于路径或则URL的定义方式,必须是全路径。

        /// </summary>
        /// <param name="filePath">本地文件全路径</param>
        public FileItem(FileItemType fileItemType, string filePath, string fileAlias)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentNullException("filePath is null or empty!");
            }

            switch (fileItemType)
            {
            case FileItemType.FileInfo:
                InitFileInfo(new FileInfo(filePath));
                break;

            case FileItemType.HttpUrl:
                InitUrl(filePath);
                break;

            default:
                throw new ArgumentException("unsupport FileItemType!");
            }

            if (!string.IsNullOrEmpty(fileAlias))
            {
                _fileName = fileAlias;
            }
        }
Exemplo n.º 5
0
        public FileItem(DeviceObject deviceObject, ICameraDevice device)
        {
            Device       = device;
            DeviceObject = deviceObject;
            ItemType     = FileItemType.CameraObject;
            FileName     = deviceObject.FileName;
            FileDate     = deviceObject.FileDate;
            IsChecked    = true;
            if (deviceObject.ThumbData != null && deviceObject.ThumbData.Length > 4)
            {
                try
                {
                    var stream = new MemoryStream(deviceObject.ThumbData, 0, deviceObject.ThumbData.Length);

                    using (var bmp = new Bitmap(stream))
                    {
                        Thumbnail = BitmapSourceConvert.ToBitmapSource(bmp);
                    }
                    stream.Close();
                }
                catch (Exception exception)
                {
                    Log.Debug("Error loading device thumb ", exception);
                }
            }
        }
Exemplo n.º 6
0
        public FileItem(bool customName, string label, bool customIcon, string iconPath, string filePath, string arguments, FileItemType type) : base(customName, label, customIcon, iconPath)
        {
            FilePath  = filePath;
            Arguments = arguments;
            Type      = type;

            //TODO: Handle the file not existing somehow?
        }
Exemplo n.º 7
0
 public FileItem(string file)
 {
     IsLoaded = false;
     FileName = file;
     Name     = Path.GetFileName(file);
     ItemType = FileItemType.File;
     FileInfo = new FileInfo();
 }
Exemplo n.º 8
0
 public FileItem(ICameraDevice device, DateTime time)
 {
     Device    = device;
     ItemType  = FileItemType.CameraObject;
     IsChecked = true;
     ItemType  = FileItemType.Missing;
     FileName  = "Missing";
     FileDate  = time;
 }
Exemplo n.º 9
0
 private void InitFileInfo(FileInfo fileInfo)
 {
     if (fileInfo == null || !fileInfo.Exists)
     {
         throw new ArgumentException("fileInfo is null or not exists!");
     }
     _fileInfo = fileInfo;
     _itemType = FileItemType.FileInfo;
     _fileName = fileInfo.FullName;
 }
Exemplo n.º 10
0
        /// <summary>Constructs the <see cref="FileItemBase"/> with a <see cref="IScanFileInfo"/>.</summary>
        ///
        /// <param name="info">The file information.</param>
        /// <param name="type">The type of the item.</param>
        /// <param name="flags">The flags for the item (except <see cref="FileAttributes"/>).</param>
        private protected FileItemBase(IScanFileInfo info, FileItemType type, FileItemFlags flags)
            : this(info.Name, type, flags)
        {
            LastWriteTimeUtc = info.LastWriteTimeUtc;
            Attributes       = info.Attributes;

            if (!info.IsDirectory && !info.IsSymbolicLink)
            {
                Size = info.Size;
            }
        }
Exemplo n.º 11
0
        private void CreateDefaultIcon(FileItemType type)
        {
            var         iconPath = GetDefaultIconPath(type);
            var         items    = _fileItemsViewModel.DirectoriesAndFiles.Where(item => item.Type == type);
            BitmapFrame bf       = null;
            var         thumb    = CreateThumb(iconPath, bf);

            foreach (var item in items)
            {
                item.Icon = thumb;
            }
        }
Exemplo n.º 12
0
        private void InitUrl(string filePath)
        {
            string s = Path.GetFileName(filePath);

            if (s.IndexOf("?") >= 0)
            {
                s = s.Substring(0, s.IndexOf("?"));
            }
            _fileName = s;
            _url      = filePath;
            _itemType = FileItemType.HttpUrl;
        }
Exemplo n.º 13
0
        public FileListViewItem(string fileName, long size, long usingSize, long freeSize, FileItemType type, DateTime lastAccessTime, int imageIndex)
        {
            FileName       = fileName;
            FileSize       = size;
            UsingSize      = usingSize;
            FreeSize       = freeSize;
            FileType       = type;
            LastAccessTime = lastAccessTime;

            this.Text = fileName;
            this.SubItems.Add(FileHelper.LengthToFileSize((double)size));
            this.SubItems.Add(type.GetDescription());
            this.SubItems.Add(lastAccessTime.ToString());
            this.ImageIndex = imageIndex;
        }
Exemplo n.º 14
0
        /// <summary>
        /// 基于文件名和字节流的构造器。

        /// </summary>
        /// <param name="fileName">文件名称(服务端持久化字节流到磁盘时的文件名)</param>
        /// <param name="content">文件字节流</param>
        public FileItem(string fileName, byte[] content)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }
            if (content == null || content.Length == 0)
            {
                throw new ArgumentNullException("content");
            }

            _fileName = fileName;
            _content  = content;
            _itemType = FileItemType.Content;
        }
Exemplo n.º 15
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FileItemType type = (FileItemType)value;

            switch (type)
            {
            case FileItemType.File: return("../Resources/File.png");

            case FileItemType.Directory: return("../Resources/Folder.png");

            case FileItemType.Drive: return("../Resources/Driver.png");

            default: return(string.Empty);
            }
        }
Exemplo n.º 16
0
        /// <summary>Constructs the <see cref="FileItemBase"/> without any file info.</summary>
        ///
        /// <param name="name">The name of the item.</param>
        /// <param name="type">The type of the item.</param>
        /// <param name="flags">The flags for the item (except <see cref="FileAttributes"/>).</param>
        private protected FileItemBase(string name, FileItemType type, FileItemFlags flags)
        {
            if (flags != FileItemFlags.None)
            {
                this.flags |= (flags & FileItemFlags.TypeFlagsMask);
            }
            if (type == FileItemType.Volume)
            {
                name = PathUtils.AddDirectorySeparator(name);
            }

            Name   = name;
            Type   = type;
            state |= FileItemStates.Exists;
        }
Exemplo n.º 17
0
        private static SqlObjectNode BuildFileItem(SqlFile file, FileItemType type, string scheme, string name)
        {
            switch (type)
            {
            case FileItemType.Table:
            case FileItemType.View:
                return(new TableNode(file, name, scheme));

            case FileItemType.Proc:
            case FileItemType.Func:
                return(new ProcedureNode(file, name, scheme));

            default:
                throw new ArgumentOutOfRangeException(nameof(type), "Unknown node type");
            }
        }
Exemplo n.º 18
0
        protected void BindFileListRepeater(bool updateAjax)
        {
            List <MyFileItem> fileItems = new List <MyFileItem>();

            if (!string.IsNullOrEmpty(this.CurrentPath))
            {
                //ADD IN THE PARENT DIRECTORY
                fileItems.Add(new MyFileItem(ParentFolderText, FileItemType.Directory));
            }
            //GET DIRECTORIES
            string[] directories = System.IO.Directory.GetDirectories(FullCurrentPath);
            foreach (string dir in directories)
            {
                DirectoryInfo dirInfo = new DirectoryInfo(dir);
                if (dirInfo.Name != ".svn")
                {
                    fileItems.Add(new MyFileItem(dirInfo.Name, FileItemType.Directory));
                    _FileNameList.Add(dirInfo.Name);
                }
            }
            //GET FILES
            string[] files = System.IO.Directory.GetFiles(FullCurrentPath);
            foreach (string file in files)
            {
                FileInfo fileInfo = new FileInfo(Path.Combine(FullCurrentPath, file));
                if (fileInfo.Exists)
                {
                    FileItemType thisType = FileHelper.IsImageFile(Path.Combine(FullCurrentPath, file)) ? FileItemType.Image : FileItemType.Other;
                    fileItems.Add(new MyFileItem(fileInfo.Name, thisType));
                    _FileNameList.Add(fileInfo.Name);
                }
            }
            FileListRepeater.DataSource = fileItems;
            FileListRepeater.DataBind();

            // UPDATE ASSOCIATED PATH CONTROLS
            CurrentFolder.Text = string.Format("{0}", CurrentTheme);
            if (CurrentPath.Length > 0)
            {
                CurrentFolder.Text += string.Format("\\{0}", CurrentPath.Replace("\\", "<wbr>\\"));
            }
            if (updateAjax)
            {
                FileListAjax.Update();
            }
        }
Exemplo n.º 19
0
        static void OnFileTypePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FileItem     vf = (FileItem)d;
            FileItemType tp = (FileItemType)e.NewValue;

            if (tp == FileItemType.Image)
            {
                vf.Template = Res.VirImageTemplate;
            }
            else if (tp == FileItemType.Video)
            {
                vf.Template = Res.VirVideoTemplate;
            }
            else
            {
                vf.Template = Res.VirFileTemplate;
            }
        }
Exemplo n.º 20
0
        private static string GetDefaultIconPath(FileItemType type)
        {
            string imagePath = string.Empty;

            switch (type)
            {
            case FileItemType.Drive:
                imagePath = @"E:\GitHub Project\Everything\FileBrowser\Resources\Driver.png";
                break;

            case FileItemType.Directory:
                imagePath = @"E:\GitHub Project\Everything\FileBrowser\Resources\Folder.png";
                break;

            case FileItemType.File:
                imagePath = @"E:\GitHub Project\Everything\FileBrowser\Resources\File.png";
                break;
            }
            return(imagePath);
        }
Exemplo n.º 21
0
        public FileItem(string path)
        {
            ItemType = DetermineItemType(path);

            if (ItemType != FileItemType.MISSING)
            {
                this.path = setPath(Path.GetFullPath(path));

                // initial, make the outlinepath match the
                // file path
                this.outlinePath = this.path;
            }
            else
            {
                // missing only - just save the path for later
                // review
                this.path        = path;
                this.outlinePath = path;
            }
        }
Exemplo n.º 22
0
        /// <summary>Constructs the <see cref="FileItemBase"/> with a <see cref="FileSystemInfo"/>.</summary>
        ///
        /// <param name="info">The file information.</param>
        /// <param name="type">The type of the item.</param>
        /// <param name="flags">The flags for the item (except <see cref="FileAttributes"/>).</param>
        private protected FileItemBase(FileSystemInfo info, FileItemType type, FileItemFlags flags)
            : this(info.Name, type, flags)
        {
            LastWriteTimeUtc = info.LastWriteTimeUtc;
            Attributes       = info.Attributes;

            if (!info.Attributes.HasFlag(FileAttributes.Directory) &&
                !info.Attributes.HasFlag(FileAttributes.ReparsePoint) &&
                info is FileInfo fileInfo)
            {
                Size = fileInfo.Length;
            }

            if (!info.Exists)
            {
                state           &= ~FileItemStates.Exists;
                Attributes       = 0;
                LastWriteTimeUtc = DateTime.MinValue;
            }
        }
Exemplo n.º 23
0
 /// <summary>
 /// Creates a concrete type based on an enum. 
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static FileItem Create(FileItemType type)
 {
     switch (type)
     {
         case FileItemType.JPEG:
             return new ImageJpeg();
             break;
         case FileItemType.GIF:
             return new ImageGif();
             break;
         case FileItemType.PNG:
             return new ImagePng();
             break;
         case FileItemType.XHTML:
             return new Chapter();
             break;
         default:
             throw new NotImplementedException();
             break;
     }
 }
Exemplo n.º 24
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="mappingName">Mapping file name.</param>
        /// <param name="type">File item type.</param>
        /// <param name="isChanged">If this file item is changed since last code generation.</param>
        public FileItem(string mappingName, FileItemType type, bool isChanged)
        {
            switch (type)
            {
            case FileItemType.CacheSettingTemplate:
            {
                name     = "CacheSettingTemplate";
                fileName = string.Format("{0}.{1}.config", mappingName, name, CultureInfo.InvariantCulture);
                break;
            }

            case FileItemType.ConnectionStrings:
            {
                name     = "ConnectionStrings";
                fileName = string.Format("{0}.{1}.cs", mappingName, name, CultureInfo.InvariantCulture);
                break;
            }

            case FileItemType.Document:
            {
                name     = "Document";
                fileName = string.Format("{0}.{1}.html", mappingName, name, CultureInfo.InvariantCulture);
                break;
            }

            case FileItemType.Enums:
            {
                name     = "Enums";
                fileName = string.Format("{0}.{1}.cs", mappingName, name, CultureInfo.InvariantCulture);
                break;
            }

            default:
                throw new ArgumentOutOfRangeException("type");
            }

            this.isChanged        = isChanged;
            this.templateFilePath = GetTemplateFilePath(string.Format(@"Templates\DbSharper.{0}.xslt", name));
            this.type             = type;
        }
Exemplo n.º 25
0
        private FileItem(string file, DirElement parentElement = null, uint count = 0)
        {
            this.parentElement = parentElement;
            name = file;
            type = FileItemType.File;

            if (Directory.Exists(file))
            {
                type = FileItemType.Dir;

                List <string> items = new List <string>();
                items.AddRange(Directory.GetDirectories(file));
                string[] files = Directory.GetFiles(file);
                items.AddRange(files);

                _fileCount = (uint)files.Length;

                foreach (string item in items)
                {
                    children.Add(new FileItem(item, parentElement));
                }
            }
        }
Exemplo n.º 26
0
        public FileListViewItem(string fileName, long size, long usingSize, long freeSize, FileItemType type, DateTime lastAccessTime, int imageIndex)
        {
            FileName       = fileName;
            FileSize       = size;
            UsingSize      = usingSize;
            FreeSize       = freeSize;
            FileType       = type;
            LastAccessTime = lastAccessTime;

            this.Text = fileName;
            this.SubItems.Add(FileHelper.LengthToFileSize((double)size));
            if (type == FileItemType.File)
            {
                var firx = Path.GetExtension(fileName).ToUpper().Replace(".", "");
                this.SubItems.Add(firx + type.GetDescription());
            }
            else
            {
                this.SubItems.Add(type.GetDescription());
            }

            this.SubItems.Add(lastAccessTime.ToString());
            this.ImageIndex = imageIndex;
        }
Exemplo n.º 27
0
 public MyFileItem(string name, FileItemType fileItemType)
 {
     _Name         = name;
     _FileItemType = fileItemType;
 }
Exemplo n.º 28
0
        protected bool ShowFileIcon(object dataItem, FileItemType iconType)
        {
            FileItemType itemType = ((MyFileItem)dataItem).FileItemType;

            return(itemType == iconType);
        }
Exemplo n.º 29
0
 public FileItem(string file)
 {
     IsLoaded = false;
     FileName = file;
     Name = Path.GetFileName(file);
     ItemType = FileItemType.File;
     //FileInfo = new FileInfo();
 }
Exemplo n.º 30
0
        public FileItem(DeviceObject deviceObject, ICameraDevice device)
        {
            Device = device;
            DeviceObject = deviceObject;
            ItemType = FileItemType.CameraObject;
            FileName = deviceObject.FileName;
            FileDate = deviceObject.FileDate;
            IsChecked = true;
            IsLiked = false;
            IsUnLiked = false;
            if (deviceObject.ThumbData != null && deviceObject.ThumbData.Length > 4)
            {
                try
                {
                    var stream = new MemoryStream(deviceObject.ThumbData, 0, deviceObject.ThumbData.Length);

                    using (var bmp = new Bitmap(stream))
                    {
                        Thumbnail = BitmapSourceConvert.ToBitmapSource(bmp);
                    }
                    stream.Close();
                }
                catch (Exception exception)
                {
                    Log.Debug("Error loading device thumb ", exception);
                }
            }
        }
Exemplo n.º 31
0
 public FileSystemItem(string fullName, string name, FileItemType type)
 {
     FullName = fullName;
     Name = name;
     Type = type;
 }
Exemplo n.º 32
0
 public FileItem(ICameraDevice device, DateTime time)
 {
     Device = device;
     ItemType = FileItemType.CameraObject;
     IsChecked = true;
     ItemType = FileItemType.Missing;
     FileName = "Missing";
     FileDate = time;
 }
Exemplo n.º 33
0
 public FileSystemItem(string fullName, string name, FileItemType type)
 {
     FullName = fullName;
     Name     = name;
     Type     = type;
 }
Exemplo n.º 34
0
 public FileItem()
 {
     ItemType = FileItemType.NULL;
 }
Exemplo n.º 35
0
 public FileInfo(string fullName, FileItemType itemType)
 {
     FullName      = fullName;
     this.ItemType = itemType;
 }
Exemplo n.º 36
0
 private static string GetDefaultIconPath(FileItemType type)
 {
     string imagePath = string.Empty;
     switch (type)
     {
         case FileItemType.Drive:
             imagePath = @"E:\GitHub Project\Everything\FileBrowser\Resources\Driver.png";
             break;
         case FileItemType.Directory:
             imagePath = @"E:\GitHub Project\Everything\FileBrowser\Resources\Folder.png";
             break;
         case FileItemType.File:
             imagePath = @"E:\GitHub Project\Everything\FileBrowser\Resources\File.png";
             break;
     }
     return imagePath;
 }
Exemplo n.º 37
0
 private void CreateDefaultIcon(FileItemType type)
 {
     var iconPath = GetDefaultIconPath(type);
     var items = _fileItemsViewModel.DirectoriesAndFiles.Where(item => item.Type == type);
     BitmapFrame bf = null;
     var thumb = CreateThumb(iconPath, bf);
     foreach (var item in items)
     {
         item.Icon = thumb;
     }
 }