Exemplo n.º 1
0
        public void BuildF8(ExtensionItem extension)
        {
            BaseDataField propField = (BaseDataField)ObjectUtils.CreateCopy(modelF8Field);

            propField.DynamicProperty = null;
            propField.ChildrenFields.Clear();
            propField.EntityKey = currEntityKey;
            propField.Entity    = currEntity;
            if (propField.UpdateActions != null)
            {
                propField.UpdateActions.Clear();
            }

            // 必改属性,涉及到数据的加载
            propField.Key                    = extension.Key;
            propField.FieldName              = extension.Key.ToUpperInvariant();
            propField.PropertyName           = extension.Key;
            propField.Name                   = new LocaleValue(extension.Name);
            propField.LookUpObject.FormId    = extension.F8FormId;
            propField.LookUpObject.TableName = extension.F8TableName;

            FormMetadata materialMetada =
                MetaDataServiceHelper.Load(this.Context, extension.F8FormId) as FormMetadata;


            propField.RefFormDynamicObjectType = materialMetada.BusinessInfo.GetDynamicObjectType();
            propField.TableName = extension.F8TableName;
            //  propField.RefFormDynamicObjectType = new DynamicObjectType(extension.F8FormId);

            _currBusinessInfo.Add(propField);
        }
        public TextureExportDialog()
        {
            InitializeComponent();

            splitContainer1.Panel1Collapsed = true;

            foreach (var format in FileManager.GetExportableTextures())
            {
                if (format is IFileFormat)
                {
                    string[] extensions = ((IFileFormat)format).Extension;
                    string[] descs      = ((IFileFormat)format).Description;
                    string   desc       = "";
                    for (int i = 0; i < extensions.Length; i++)
                    {
                        if (descs.Length > i)
                        {
                            desc = descs[i];
                        }

                        ExtensionItem ext = new ExtensionItem();
                        ext.Extension   = extensions[i];
                        ext.Description = desc;
                        Extensions.Add(ext);
                    }
                }
            }
        }
Exemplo n.º 3
0
        internal override void Add(ExtensionItem regAttribute)
        {
            var att             = regAttribute.ExtensionAttribute as RegOsgiEventAttribute;
            var constructorInfo = att?.EventType.GetConstructor(new Type[0]);

            if (constructorInfo != null)
            {
                var handler = constructorInfo.Invoke(new object[0]) as IOsgiEventHandler;
                evts.Add(handler);
            }
        }
Exemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            int index = dataGridExtensions.CurrentCell.RowIndex;

            if (index < 0)
            {
                return;
            }
            ExtensionItem extensionItem = _tableExtensions.Rows[index].Field <ExtensionItem>(0);

            MessageBox.Show(extensionItem.ExtensionDetails(), "Details Extension");
        }
        private void ReadMft(ScanningState state, NtfsReader ntfs, FileNodeIndexes[] fileItemsLookup,
                             List <FileNodeIndexes> fileItems, CancellationToken token)
        {
            foreach (INtfsNode node in ntfs.EnumerateNodes(state.RootPath))
            {
                string fullPath = PathUtils.TrimSeparatorDotEnd(node.FullName);
                bool   isRoot   = (node.NodeIndex == node.ParentNodeIndex);
                if (!isRoot && SkipFile(state, Path.GetFileName(fullPath), fullPath))
                {
                    continue;
                }
                FileItemBase child;
                bool         reparsePoint = node.Attributes.HasFlag(FileAttributes.ReparsePoint);
                if (isRoot)
                {
                    child = state.Root;
                }
                else if (node.Attributes.HasFlag(FileAttributes.Directory))
                {
                    if (!state.IsDrive && state.RootPath == node.FullName.ToUpperInvariant())
                    {
                        child = state.Root;
                    }
                    else
                    {
                        child = new FolderItem(new ScanFileInfo(node));
                    }
                }
                else
                {
                    ExtensionItem extension = Extensions.GetOrAddFromPath(node.Name);
                    FileItem      file      = new FileItem(new ScanFileInfo(node), extension);
                    child = file;
                    if (!reparsePoint)
                    {
                        TotalScannedSize += child.Size;
                    }
                }
                FileNodeIndexes indexes = new FileNodeIndexes(child, node);
                fileItemsLookup[node.NodeIndex] = indexes;

                if (!reparsePoint)
                {
                    fileItems.Add(indexes);
                }

                if (AsyncChecks(token))
                {
                    return;
                }
            }
        }
        /// <summary>Disposes of the <see cref="ExtensionItemViewModel"/>.</summary>

        /*~ExtensionItemViewModel() {
         *      Dispose();
         * }*/

        #endregion

        #region Event Handlers

        private void OnModelChanged(ExtensionItem sender, ExtensionItemEventArgs e)
        {
            switch (e.Action)
            {
            case ExtensionItemAction.ColorChanged:
                Preview = Settings.GetFilePalettePreview(e.Index);
                break;

            case ExtensionItemAction.GetViewModel:
                e.ViewModel = this;
                break;
            }
        }
Exemplo n.º 7
0
 private void DetectExtensionPointAndRegExtensionAttr(Assembly assembly, HashSet <ExtensionItem> extensions)
 {
     try
     {
         var extensionPointAttrs = assembly.GetCustomAttributes <ExtensionPointAttribute>();
         if (extensionPointAttrs != null)
         {
             foreach (ExtensionPointAttribute extensionPointAttr in extensionPointAttrs)
             {
                 _allExtensionPoints[extensionPointAttr.AttributeType] = extensionPointAttr.ExtensionPoint;
             }
         }
         var extensionAttrs = assembly.GetCustomAttributes <ExtensionAttribute>();
         if (extensionAttrs != null)
         {
             foreach (ExtensionAttribute extensionAttr in extensionAttrs)
             {
                 var            item = new ExtensionItem(assembly, extensionAttr);
                 ExtensionPoint point;
                 if (_allExtensionPoints.TryGetValue(extensionAttr.GetType(), out point))
                 {
                     point.Add(item);
                 }
                 else if (extensions != null)
                 {
                     extensions.Add(item);
                 }
                 else
                 {
                     Log.Warn(string.Format("未找到{0}的管理类时,extensions参数不能为null。", extensionAttr.GetType().FullName),
                              new ArgumentNullException("extensions"));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.Error("OSGI 引擎调用RegisterAssembly(Assembly assembly, HashSet<ExtensionAttributeItem> extensions)方法异常", ex);
         if (!DisableExtAttrLoadException)
         {
             throw ex;
         }
     }
 }
 /// <summary>Constructs an <see cref="ExtensionItemViewModel"/>.</summary>
 ///
 /// <param name="extensions">The collection containing this item.</param>
 /// <param name="model">The model that this view model item represents.</param>
 public ExtensionItemViewModel(ExtensionItemViewModelCollection extensions, ExtensionItem model)
 {
     this.extensions = extensions;
     Model           = model;
     icon            = IconCache.FileIcon;
     if (IsEmptyExtension || Extension.Contains(" "))
     {
         // Extensions with spaces have no rights, so says Windows
         typeName   = "File";
         cacheState = IconCacheState.Cached;
     }
     else
     {
         typeName = model.Extension.TrimStart('.').ToUpper() + " File";
         if (CacheMode >= IconCacheMode.FileType)
         {
             LoadIcon();
         }
     }
     HookEvents();
 }
Exemplo n.º 9
0
        public void BuildDecimal(ExtensionItem extension)
        {
            DecimalField propField = (DecimalField)ObjectUtils.CreateCopy(modelDecimalField);

            propField.DynamicProperty = null;
            propField.ChildrenFields.Clear();
            propField.EntityKey = currEntityKey;
            propField.Entity    = currEntity;
            if (propField.UpdateActions != null)
            {
                propField.UpdateActions.Clear();
            }

            // 必改属性,涉及到数据的加载
            propField.Key          = extension.Key;
            propField.FieldName    = extension.Key.ToUpperInvariant();
            propField.PropertyName = extension.Key;
            propField.Name         = new LocaleValue(extension.Name);

            _currBusinessInfo.Add(propField);
        }
        protected void Refresh(RefreshFiles[] refreshFiles, CancellationToken token)
        {
            CanDisplayProgress = rootItem.Type == FileItemType.Volume ||
                                 (rootItem.Type == FileItemType.Computer &&
                                  !rootItem.Children.Any(f => f.Type != FileItemType.Volume &&
                                                         f.Type != FileItemType.FreeSpace && f.Type != FileItemType.Unknown));
            if (CanDisplayProgress)
            {
                if (rootItem.Type == FileItemType.Volume)
                {
                    try {
                        if (rootItem.CheckExists())
                        {
                            DriveInfo driveInfo = new DriveInfo(rootItem.RootPath);
                            TotalSize      = driveInfo.TotalSize;
                            TotalFreeSpace = driveInfo.TotalFreeSpace;
                        }
                        else
                        {
                            CanDisplayProgress = false;
                        }
                    }
                    catch {
                        CanDisplayProgress = false;
                    }
                }
                else if (rootItem.Type == FileItemType.Computer)
                {
                    bool anySuccess = false;
                    foreach (FileItemBase child in rootItem.Children)
                    {
                        if (child is RootItem root)
                        {
                            try {
                                if (root.CheckExists())
                                {
                                    DriveInfo driveInfo = new DriveInfo(root.RootPath);
                                    TotalSize      += driveInfo.TotalSize;
                                    TotalFreeSpace += driveInfo.TotalFreeSpace;
                                    anySuccess      = true;
                                    continue;
                                }
                            }
                            catch { }
                            TotalSize      += root.CachedTotalSize;
                            TotalFreeSpace += root.CachedFreeSpace;
                        }
                    }
                    if (!anySuccess)
                    {
                        CanDisplayProgress = false;
                    }
                }
            }
            // Reset the progress if applicable
            TotalScannedSize = Extensions.TotalSize - refreshFiles.Sum(rf => rf.Files.Sum(f => f.Size));
            ProgressState    = ScanProgressState.Started;

            foreach (RefreshFiles refresh in refreshFiles)
            {
                FolderItem parent         = refresh.Parent;
                FolderItem fileCollection = parent.GetFileCollection();

                Queue <FolderItem> subdirs = new Queue <FolderItem>();

                foreach (FileItemBase refreshChild in refresh.Files)
                {
                    if (!refreshChild.Refresh())
                    {
                        string fullName = refreshChild.FullName;
                        parent.RemoveItem(refreshChild, ref fileCollection);

                        // See if the type changed (file <-> directory)
                        FileItemBase child = null;
                        if (refreshChild.Type == FileItemType.File)
                        {
                            DirectoryInfo info = new DirectoryInfo(fullName);
                            if (info.Exists)
                            {
                                FolderItem folder = new FolderItem(info);
                                child = folder;
                                // Folder exists enqueue it for scanning
                                if (!info.Attributes.HasFlag(FileAttributes.ReparsePoint))
                                {
                                    subdirs.Enqueue(folder);
                                }
                            }
                        }
                        else if (refreshChild.Type == FileItemType.Directory)
                        {
                            FileInfo info = new FileInfo(fullName);
                            if (info.Exists)
                            {
                                ExtensionItem extension = Extensions.GetOrAddFromPath(fullName);
                                FileItem      file      = new FileItem(info, extension);
                                child = file;
                                // File exists, add it to the scanned size
                                if (!info.Attributes.HasFlag(FileAttributes.ReparsePoint))
                                {
                                    TotalScannedSize += child.Size;
                                }
                            }
                        }
                        if (child != null)
                        {
                            FileItem firstFile = parent.GetFirstFile();
                            parent.AddItem(child, ref fileCollection, ref firstFile);
                        }
                    }
                    else if (!refreshChild.IsReparsePointFile)
                    {
                        // Folder exists enqueue it for scanning
                        if (refreshChild is FolderItem folder)
                        {
                            subdirs.Enqueue(folder);
                        }
                        // File exists, add it to the scanned size
                        else
                        {
                            TotalScannedSize += refreshChild.Size;
                        }
                    }

                    if (AsyncChecks(token))
                    {
                        return;
                    }
                }

                if (subdirs.Count > 0)
                {
                    RefreshFolders(subdirs, token);
                }

                if (AsyncChecks(token))
                {
                    return;
                }
            }
        }
Exemplo n.º 11
0
 /// <summary>Constructs the <see cref="FileItem"/> with a <see cref="IScanFileInfo"/>.</summary>
 ///
 /// <param name="info">The file information.</param>
 /// <param name="extension">The extension information.</param>
 public FileItem(IScanFileInfo info, ExtensionItem extension)
     : base(info, FileItemType.File, FileItemFlags.FileType)
 {
     Debug.Assert(extension != null);
     ExtensionItem = extension;
 }
Exemplo n.º 12
0
        private void ReadNative(Queue <FolderState> subdirs, CancellationToken token)
        {
            Win32FindData find        = new Win32FindData();
            FolderState   folderState = subdirs.Dequeue();
            ScanningState state       = folderState.State;
            FolderItem    parent      = folderState.Folder;
            bool          findResult;
            string        parentPath    = parent.FullName;
            string        searchPattern = PathUtils.CombineNoChecks(parentPath, "*");

            if (!searchPattern.StartsWith(@"\\?\"))
            {
                searchPattern = @"\\?\" + searchPattern;
            }
            IntPtr hFind = FindFirstFileEx(searchPattern,
                                           FindExInfoLevels.Basic, out find,
                                           FindExSearchOps.NameMatch, IntPtr.Zero,
                                           FindExFlags.LargeFetch);

            if (hFind == InvalidHandle)
            {
                return;
            }

            FolderItem fileCollection = null;
            FileItem   firstFile      = null;
            bool       subdirsAdded   = false;

            try {
                do
                {
                    string filePath = PathUtils.CombineNoChecks(parentPath, find.cFileName);
                    if (find.IsRelativeDirectory || SkipFile(state, find.cFileName, filePath))
                    {
                        // Skip these types of entries
                        findResult = FindNextFile(hFind, out find);
                        continue;
                    }
                    FileItemBase child;
                    if (find.IsDirectory)
                    {
                        FolderItem folder = new FolderItem(new WindowsScanFileInfo(find, filePath));
                        child = folder;
                        if (!find.IsSymbolicLink)
                        {
                            subdirsAdded = true;
                            subdirs.Enqueue(new FolderState(folder, state));
                        }
                    }
                    else
                    {
                        ExtensionItem extension = Extensions.GetOrAddFromPath(filePath);
                        FileItem      file      = new FileItem(new WindowsScanFileInfo(find, filePath), extension);
                        child = file;
                        if (!find.IsSymbolicLink)
                        {
                            TotalScannedSize += child.Size;
                        }
                    }
                    parent.AddItem(child, ref fileCollection, ref firstFile);

                    if (AsyncChecks(token))
                    {
                        return;
                    }

                    findResult = FindNextFile(hFind, out find);
                } while (findResult);

                if (!subdirsAdded)
                {
                    parent.Finish();
                }
                //if (parent.IsWatched)
                //	parent.RaiseChanged(FileItemAction.ChildrenDone);
            }
            finally {
                FindClose(hFind);
            }
        }
 /// <summary>
 /// Constructs an <see cref="ExtensionItemViewModel"/> used to represent a non-file.
 /// </summary>
 private ExtensionItemViewModel()
 {
     Model = ExtensionItem.NotAFile;
 }