Esempio n. 1
0
        /// <summary>
        /// Загрузить ресурсы.
        /// </summary>
        public static RootCategory Load(string file, out CultureInfo[] loadedCultures,
                                        out DateTime lastModifiedTime)
        {
            // Fill cultures hash
            foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
            {
                _cultures[ci.Name] = ci;
            }

            string fnwe   = Path.GetFileNameWithoutExtension(file);
            string locExt = Path.GetExtension(fnwe);
            string sn     = !string.IsNullOrEmpty(locExt) && _cultures.ContainsKey(locExt.Substring(1))
                                ? fnwe.Substring(0, fnwe.Length - locExt.Length)
                                : fnwe;
            RootCategory       root   = new RootCategory(sn);
            List <CultureInfo> loaded = new List <CultureInfo>();

            lastModifiedTime = File.GetLastWriteTime(file);
            foreach (string fn in Directory.GetFiles(Path.GetDirectoryName(file),
                                                     _resxFileExtension))
            {
                if (Path.GetFileName(fn).IndexOf(sn) == 0)
                {
                    loaded.Add(AppendResX(root, fn));
                    DateTime lmt = File.GetLastWriteTime(fn);
                    if (lmt > lastModifiedTime)
                    {
                        lastModifiedTime = lmt;
                    }
                }
            }
            loadedCultures = loaded.ToArray();
            return(root);
        }
Esempio n. 2
0
 public RootCategory GetRootCategoryWithSubs(int id)
 {
     using (PyramidFinalContext dbContext = new PyramidFinalContext())
     {
         var efCat = dbContext.Categories.FirstOrDefault(i => i.Id == id);
         if (efCat != null)
         {
             var rootCategory = new RootCategory()
             {
                 Category = new Pyramid.Entity.Category()
                 {
                     Id        = efCat.Id,
                     Thumbnail = efCat.CategoryImages.FirstOrDefault(f => f.CategoryId == efCat.Id && f.TypeImage == (int)Common.TypeImage.Thumbnail) != null?
                                 ConvertImageToEntity.Convert(efCat.CategoryImages.FirstOrDefault(f => f.CategoryId == efCat.Id && f.TypeImage == (int)Common.TypeImage.Thumbnail).Images) : null,
                                     Title = efCat.Title,
                                     //Products = efCat.Products
                 },
                 SubCategories = dbContext.Categories.Where(i => i.ParentId == efCat.Id).Select(s => new Pyramid.Entity.Category()
                 {
                     Id        = s.Id,
                     Thumbnail = s.CategoryImages.FirstOrDefault(f => f.CategoryId == s.Id && f.TypeImage == (int)Common.TypeImage.Thumbnail) != null ?
                                 ConvertImageToEntity.Convert(s.CategoryImages.FirstOrDefault(f => f.CategoryId == s.Id && f.TypeImage == (int)Common.TypeImage.Thumbnail).Images) : null,
                     Title = s.Title,
                     // Products = s.Products
                 })
             };
             return(rootCategory);
         }
         return(new RootCategory());
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Генерировать хелпер.
        /// </summary>
        public static CodeCompileUnit Generate(RootCategory cat, string ns,
                                               bool isInternal)
        {
            var ccu = new CodeCompileUnit();
            var cn  = new CodeNamespace(ns);

            ccu.Namespaces.Add(cn);
            GenerateCategory(cn.Types, cat, null, isInternal);
            return(ccu);
        }
Esempio n. 4
0
        internal void SetSelectedCategory(RootCategory category)
        {
            _selectedCategory = category;

            _selectedFiles = new string[0];
            _selectedFile  = string.Empty;
            RaisePropertyChanged("SelectedCategory");
            RaisePropertyChanged("SelectedDirectory");
            RaisePropertyChanged("SelectedFiles");
            RaisePropertyChanged("SelectedFile");
        }
Esempio n. 5
0
        private static CultureInfo AppendResX(RootCategory root, string file)
        {
            CultureInfo        locale = GetLocale(file);
            ResXResourceReader rxrr   = new ResXResourceReader(file);

            foreach (DictionaryEntry de in rxrr)
            {
                ResourceItem item = root.GetItem((string)de.Key);
                item.ValueCollection[locale] = de.Value.ToString();
            }
            return(locale);
        }
Esempio n. 6
0
 private void OpenFile()
 {
     if (_openFileDialog.ShowDialog() == DialogResult.OK)
     {
         CultureInfo[] loadedCultures;
         DateTime      lwt;
         _rootCategory = Loader.Load(_openFileDialog.FileName, out loadedCultures, out lwt);
         IEditContext ec = (IEditContext)Site.GetService(typeof(IEditContext));
         ec.AvailableCultures = loadedCultures;
         _directory           = Path.GetDirectoryName(_openFileDialog.FileName);
         FakeNodeCollection fnc = new FakeNodeCollection();
         fnc.Add(_rootCategory);
         _rootCategory.TreeParent = fnc;
         ClearSelection();
         _categoryTree.Nodes = fnc;
         EnableCommandItems();
     }
 }
Esempio n. 7
0
        private void _categoryTree_GetData(object sender, GetDataEventArgs e)
        {
            Category     cat  = (Category)e.Node;
            RootCategory rCat = e.Node as RootCategory;

            if (rCat != null)
            {
                e.CellInfos[0].ImageKey = "root";
                e.CellInfos[0].Text     = rCat.TreeName;
            }
            else
            {
                e.CellInfos[0].ImageKey = "category";
                e.CellInfos[0].Text     = cat.ShortName;
            }

            e.CellInfos[1].Text = string.Format("{0}/{1}", cat.ResourceItems.Count, cat.GetAllResCount());
        }
Esempio n. 8
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }
            disposed = true;

            if (disposing)
            {
                // free managed resources
                foreach (Tag tag in item_cache.Values)
                {
                    tag.Dispose();
                }
                item_cache.Clear();
                if (RootCategory != null)
                {
                    RootCategory.Dispose();
                    RootCategory = null;
                }
            }
            // free unmanaged resources
        }
Esempio n. 9
0
 private int GetInsertNodeIndex(RootCategory category)
 {
     int targetIndex = 0;
     switch (category)
     {
         case RootCategory.MyComputer:
             if (TreeView1.Nodes.Contains(NodeDesktop))
                 targetIndex++;
             break;
         case RootCategory.MyDocuments:
             if (TreeView1.Nodes.Contains(NodeDesktop))
                 targetIndex++;
             if (TreeView1.Nodes.Contains(NodeMyComputer))
                 targetIndex++;
             break;
         case RootCategory.SpecialFolders:
             if (TreeView1.Nodes.Contains(NodeDesktop))
                 targetIndex++;
             if (TreeView1.Nodes.Contains(NodeMyComputer))
                 targetIndex++;
             if (TreeView1.Nodes.Contains(NodeMyDocuments))
                 targetIndex++;
             break;
         case RootCategory.TemplateFolders:
             if (TreeView1.Nodes.Contains(NodeDesktop))
                 targetIndex++;
             if (TreeView1.Nodes.Contains(NodeMyComputer))
                 targetIndex++;
             if (TreeView1.Nodes.Contains(NodeMyDocuments))
                 targetIndex++;
             if (TreeView1.Nodes.Contains(NodeSpecialFolders))
                 targetIndex++;
             break;
         default:
             return 0;
     }
     return targetIndex;
 }
Esempio n. 10
0
        internal void SetSelectedCategory(RootCategory category)
        {
            _selectedCategory = category;

            _selectedFiles = new string[0];
            _selectedFile = string.Empty;
            RaisePropertyChanged("SelectedCategory");
            RaisePropertyChanged("SelectedDirectory");
            RaisePropertyChanged("SelectedFiles");
            RaisePropertyChanged("SelectedFile");
        }