Beispiel #1
0
        public static void DbSqlMobSkills(DbDebugItem <string> debug, AbstractDb <string> db)
        {
            DbSqlWriter writer = new DbSqlWriter();

            writer.Init(debug);
            DbIOMobSkills.Writer(debug, db);

            if (debug.DestinationServer == ServerType.RAthena)
            {
                writer.AppendHeader(ResourceString.Get("RAthenaMobSkillDbSqlHeader"));
            }
            else if (debug.DestinationServer == ServerType.Hercules)
            {
                writer.AppendHeader(ResourceString.Get("HerculesMobSkillDbSqlHeader"), writer.TableName.Replace("_re", ""));
                writer.TableName = "mob_skill_db";
            }

            foreach (string line in writer.Read())
            {
                string[] elements = TextFileHelper.ExcludeBrackets(line.Trim('\t'));
                if (!_getMobSkill(writer.IsHercules, writer.TableName, writer.Builder, elements))
                {
                    writer.Line(writer.IsHercules ? line.ReplaceFirst("//", "-- ") : line.ReplaceFirst("//", "#"));
                }
            }

            writer.Write();
        }
Beispiel #2
0
 public static string ChangeText(string text)
 {
     using (InputDialog dlg = new InputDialog {
         Text = text, Title = AppString.Menu.ChangeText
     })
     {
         if (dlg.ShowDialog() != DialogResult.OK)
         {
             return(null);
         }
         if (dlg.Text.Length == 0)
         {
             MessageBoxEx.Show(AppString.MessageBox.TextCannotBeEmpty);
             return(ChangeText(text));
         }
         else if (ResourceString.GetDirectString(dlg.Text).Length == 0)
         {
             MessageBoxEx.Show(AppString.MessageBox.StringParsingFailed);
             return(ChangeText(text));
         }
         else
         {
             return(dlg.Text);
         }
     }
 }
Beispiel #3
0
        public static void DbSqlItems(DbDebugItem <int> debug, AbstractDb <int> db)
        {
            DbSqlWriter writer = new DbSqlWriter();

            writer.Init(debug);

            if (debug.DestinationServer == ServerType.RAthena)
            {
                DbIOItems.DbItemsWriter(debug, db);
                writer.AppendHeader(ResourceString.Get(writer.IsRenewal ? "RAthenaItemDbSqlHeaderRenewal" : "RAthenaItemDbSqlHeader"));

                foreach (string line in writer.Read())
                {
                    string[] elements = TextFileHelper.ExcludeBrackets(line.Trim('\t'));
                    if (!_getItems(writer.IsRenewal, writer.TableName, writer.Builder, elements))
                    {
                        writer.Line(line.ReplaceFirst("//", "#"));
                    }
                }
            }
            else
            {
                var table = db.Table;
                writer.AppendHeader(ResourceString.Get("HerculesItemDbSqlHeader"), writer.TableName.Replace("_re", ""));

                foreach (var tuple in table.FastItems.OrderBy(p => p.GetKey <int>()))
                {
                    _getItemsHercules(writer.TableName, writer.Builder, tuple);
                }
            }

            writer.Write();
        }
Beispiel #4
0
 private void LoadShellExItems()
 {
     foreach (XmlElement itemXE in shellExXE.GetElementsByTagName("Item"))
     {
         if (!GuidInfo.TryGetGuid(itemXE.GetAttribute("Guid"), out Guid guid))
         {
             continue;
         }
         if (ShellExItem.GetPathAndGuids(ShellExPath).Values.Contains(guid))
         {
             continue;
         }
         ShellExCommonItem item = new ShellExCommonItem
         {
             Image          = ResourceIcon.GetIcon(itemXE.GetAttribute("Icon"))?.ToBitmap() ?? AppImage.DllDefaultIcon,
             Text           = ResourceString.GetDirectString(itemXE.GetAttribute("Text")),
             DefaultKeyName = itemXE.GetAttribute("KeyName"),
             Guid           = guid
         };
         if (string.IsNullOrWhiteSpace(item.Text))
         {
             item.Text = GuidInfo.GetText(guid);
         }
         if (string.IsNullOrWhiteSpace(item.DefaultKeyName))
         {
             item.DefaultKeyName = guid.ToString("B");
         }
         item.SetTip(itemXE.GetAttribute("Tip"));
         list.AddItem(item);
     }
 }
Beispiel #5
0
        Task<bool> IContentResolver.ExistsAsync(ResourceString resourceString, CancellationToken token)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(resourceString));
            Contract.Ensures(Contract.Result<Task<bool>>() != null);

            return null;
        }
 /// <summary>
 /// Gets a <see cref="Stream"/> around the specified asset.
 /// </summary>
 /// <param name="resourceString">The resource string of the asset to obtain a <see cref="Stream"/> around.</param>
 /// <param name="writable">Indicates whether the <see cref="Stream"/> needs to be writable.</param>
 /// <param name="token">A <see cref="CancellationToken"/> used to signal cancellation of the content resolving process.</param>
 /// <returns>The <see cref="Stream"/> around the asset or <c>null</c> if the asset could not be found.</returns>
 public Task<Stream> GetStreamAsync(ResourceString resourceString, bool writable, CancellationToken token)
 {
     Stream result = null;
     try
     {
         token.ThrowIfCancellationRequested();
         result = new FileStream(
             Path.GetFullPath(Path.Combine(this.RootPath, resourceString)),
             writable ? FileMode.OpenOrCreate : FileMode.Open,
             writable ? FileAccess.ReadWrite : FileAccess.Read
         );
     }
     catch (DirectoryNotFoundException ex)
     {
         Log.Warn("The directory containing asset '{0}' could not be found. Returning null.".FormatWith(resourceString), ex);
     }
     catch (FileNotFoundException ex)
     {
         Log.Warn("The file of asset '{0}' could not be found. Returning null.".FormatWith(resourceString), ex);
     }
     catch (Exception ex)
     {
         Log.Warn("An error of type '{0}' occured while obtaining the stream to asset '{1}'. Returning null.".FormatWith(ex.GetType().AssemblyQualifiedName, resourceString), ex);
     }
     return Task.FromResult(result);
 }
        public static void Writer(DbDebugItem <int> debug, AbstractDb <int> db)
        {
            var    gdb      = db.ProjectDatabase;
            string filename = ProjectConfiguration.ClientCheevo;

            if (gdb.MetaGrf.GetData(filename) == null)
            {
                Debug.Ignore(() => DbDebugHelper.OnWriteStatusUpdate(ServerDbs.CItems, filename, null, "Achievement table not saved."));
                return;
            }

            BackupEngine.Instance.BackupClient(filename, gdb.MetaGrf);

            StringBuilder builder = new StringBuilder();

            builder.AppendLine("achievement_tbl = {");

            List <ReadableTuple <int> > tuples = gdb.GetDb <int>(ServerDbs.CCheevo).Table.GetSortedItems().ToList();
            ReadableTuple <int>         tuple;

            for (int index = 0, count = tuples.Count; index < count; index++)
            {
                tuple = tuples[index];
                WriteEntry(builder, tuple, index == count - 1);
            }

            builder.AppendLine("}");
            builder.AppendLine();
            builder.AppendLine(ResourceString.Get("AchievementFunction"));

            gdb.MetaGrf.SetData(filename, EncodingService.Ansi.GetBytes(builder.ToString()));

            Debug.Ignore(() => DbDebugHelper.OnWriteStatusUpdate(ServerDbs.CItems, gdb.MetaGrf.FindTkPath(filename), null, "Saving Achievement table."));
        }
Beispiel #8
0
        /// <summary>
        /// Initializes a new <see cref="SceneManager"/> from a resource string.
        /// </summary>
        /// <param name="startScene">The <see cref="Scene"/> to load on startup.</param>
        /// <remarks>
        /// As the startup scene will be loaded synchronously, it is crucial to engine performance that the
        /// <see cref="Scene"/> is small and can be loaded quickly.
        /// </remarks>
        public SceneManager(ResourceString startScene)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(startScene));

            Log.Info(() => "Initializing scene manager from resource string '{0}'.".FormatWith(startScene));
            this.LoadAsync(1, startScene).Wait(); // Load into slot one to prevent instant-overdraw by a newly loaded scene
        }
 private void LoadShellExItems(XmlElement shellExXE, GroupPathItem groupItem)
 {
     foreach (XmlElement itemXE in shellExXE.SelectNodes("Item"))
     {
         if (!JudgeOSVersion(itemXE))
         {
             continue;
         }
         if (!GuidEx.TryParse(itemXE.GetAttribute("Guid"), out Guid guid))
         {
             continue;
         }
         EnhanceShellExItem item = new EnhanceShellExItem
         {
             FoldGroupItem  = groupItem,
             ShellExPath    = $@"{groupItem.TargetPath}\ShellEx",
             Image          = ResourceIcon.GetIcon(itemXE.GetAttribute("Icon"))?.ToBitmap() ?? AppImage.DllDefaultIcon,
             Text           = ResourceString.GetDirectString(itemXE.GetAttribute("Text")),
             DefaultKeyName = itemXE.GetAttribute("KeyName"),
             Guid           = guid
         };
         if (item.Text.IsNullOrWhiteSpace())
         {
             item.Text = GuidInfo.GetText(guid);
         }
         if (item.DefaultKeyName.IsNullOrWhiteSpace())
         {
             item.DefaultKeyName = guid.ToString("B");
         }
         item.ChkVisible.Checked = item.ItemVisible;
         MyToolTip.SetToolTip(item.ChkVisible, itemXE.GetAttribute("Tip"));
         this.AddItem(item);
     }
 }
        public override void LoadItems()
        {
            base.LoadItems();
            int         index = this.UseUserDic ? 1 : 0;
            XmlDocument doc   = XmlDicHelper.EnhanceMenusDic[index];

            if (doc?.DocumentElement == null)
            {
                return;
            }
            foreach (XmlNode xn in doc.DocumentElement.ChildNodes)
            {
                try
                {
                    Image  image = null;
                    string text  = null;
                    string path  = xn.SelectSingleNode("RegPath")?.InnerText;
                    foreach (XmlElement textXE in xn.SelectNodes("Text"))
                    {
                        if (XmlDicHelper.JudgeCulture(textXE))
                        {
                            text = ResourceString.GetDirectString(textXE.GetAttribute("Value"));
                        }
                    }
                    if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(text))
                    {
                        continue;
                    }
                    if (!string.IsNullOrEmpty(this.ScenePath) && !path.Equals(this.ScenePath, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    string iconLocation = xn.SelectSingleNode("Icon")?.InnerText;
                    using (Icon icon = ResourceIcon.GetIcon(iconLocation))
                    {
                        image = icon?.ToBitmap();
                        image = image ?? AppImage.NotFound;
                    }
                    FoldGroupItem groupItem = new FoldGroupItem(path, ObjectPath.PathType.Registry)
                    {
                        Image = image,
                        Text  = text
                    };
                    this.AddItem(groupItem);
                    XmlNode shellXN   = xn.SelectSingleNode("Shell");
                    XmlNode shellExXN = xn.SelectSingleNode("ShellEx");
                    if (shellXN != null)
                    {
                        LoadShellItems(shellXN, groupItem);
                    }
                    if (shellExXN != null)
                    {
                        LoadShellExItems(shellExXN, groupItem);
                    }
                    groupItem.SetVisibleWithSubItemCount();
                }
                catch { continue; }
            }
        }
Beispiel #11
0
 private void LoadItems(List <string> extensions)
 {
     foreach (string extension in ShellNewItem.UnableSortExtensions)
     {
         string str = extensions.Find(ext => ext.Equals(extension, StringComparison.OrdinalIgnoreCase));
         if (str != null)
         {
             extensions.Remove(str);
             extensions.Insert(0, str);
         }
     }
     using (RegistryKey root = Registry.ClassesRoot)
     {
         foreach (string extension in extensions)
         {
             using (RegistryKey extKey = root.OpenSubKey(extension))
             {
                 string defalutOpenMode = extKey.GetValue("")?.ToString();
                 if (string.IsNullOrEmpty(defalutOpenMode))
                 {
                     continue;
                 }
                 using (RegistryKey openModeKey = root.OpenSubKey(defalutOpenMode))
                 {
                     if (openModeKey == null)
                     {
                         continue;
                     }
                     string value1 = openModeKey.GetValue("FriendlyTypeName")?.ToString();
                     string value2 = openModeKey.GetValue("")?.ToString();
                     value1 = ResourceString.GetDirectString(value1);
                     if (value1.IsNullOrWhiteSpace() && value2.IsNullOrWhiteSpace())
                     {
                         continue;
                     }
                 }
                 using (RegistryKey tKey = extKey.OpenSubKey(defalutOpenMode))
                 {
                     foreach (string part in ShellNewItem.SnParts)
                     {
                         string snPart = part;
                         if (tKey != null)
                         {
                             snPart = $@"{defalutOpenMode}\{snPart}";
                         }
                         using (RegistryKey snKey = extKey.OpenSubKey(snPart))
                         {
                             if (ValueNames.Any(valueName => snKey?.GetValue(valueName) != null))
                             {
                                 this.AddItem(new ShellNewItem(this, snKey.Name));
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        /// <summary>
        /// Initializes a new <see cref="AssetNotFoundException"/>.
        /// </summary>
        /// <param name="resourceString">The path to the asset.</param>
        /// <param name="assetType">The <see cref="Type"/> of asset to be loaded.</param>
        public AssetNotFoundException(ResourceString resourceString, Type assetType)
            : base("Asset of type {0} could not be found.".FormatWith(assetType.FullName))
        {
            Contract.Requires<ArgumentNullException>(assetType != null);

            this.AssetType = assetType;
            this.ResourceString = resourceString;
        }
Beispiel #13
0
        public static string GetText(Guid guid)
        {
            string itemText = null;

            if (guid.Equals(Guid.Empty))
            {
                return(itemText);
            }
            if (ItemTextDic.ContainsKey(guid))
            {
                itemText = ItemTextDic[guid];
            }
            else
            {
                if (TryGetValue(guid, "Text", out itemText))
                {
                    itemText = GetAbsStr(guid, itemText, true);
                    itemText = ResourceString.GetDirectString(itemText);
                }
                if (itemText.IsNullOrWhiteSpace())
                {
                    foreach (string clsidPath in ClsidPaths)
                    {
                        foreach (string value in new[] { "LocalizedString", "InfoTip", "" })
                        {
                            itemText = Registry.GetValue($@"{clsidPath}\{guid:B}", value, null)?.ToString();
                            itemText = ResourceString.GetDirectString(itemText);
                            if (!itemText.IsNullOrWhiteSpace())
                            {
                                break;
                            }
                        }
                        if (!itemText.IsNullOrWhiteSpace())
                        {
                            break;
                        }
                    }
                }
                if (itemText.IsNullOrWhiteSpace())
                {
                    string filePath = GetFilePath(guid);
                    if (File.Exists(filePath))
                    {
                        itemText = FileVersionInfo.GetVersionInfo(filePath).FileDescription;
                        if (itemText.IsNullOrWhiteSpace())
                        {
                            itemText = Path.GetFileName(filePath);
                        }
                    }
                    else
                    {
                        itemText = null;
                    }
                }
                ItemTextDic.Add(guid, itemText);
            }
            return(itemText);
        }
Beispiel #14
0
 private void LoadItems(List<string> extensions)
 {
     foreach(string extension in ShellNewItem.UnableSortExtensions)
     {
         if(extensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
         {
             extensions.Remove(extension);
             extensions.Insert(0, extension);
         }
     }
     using(RegistryKey root = Registry.ClassesRoot)
     {
         foreach(string extension in extensions)
         {
             using(RegistryKey extKey = root.OpenSubKey(extension))
             {
                 string defalutOpenMode = extKey?.GetValue("")?.ToString();
                 if(string.IsNullOrEmpty(defalutOpenMode)) continue;
                 using(RegistryKey openModeKey = root.OpenSubKey(defalutOpenMode))
                 {
                     if(openModeKey == null) continue;
                     string value1 = openModeKey.GetValue("FriendlyTypeName")?.ToString();
                     string value2 = openModeKey.GetValue("")?.ToString();
                     value1 = ResourceString.GetDirectString(value1);
                     if(value1.IsNullOrWhiteSpace() && value2.IsNullOrWhiteSpace()) continue;
                 }
                 using(RegistryKey tKey = extKey.OpenSubKey(defalutOpenMode))
                 {
                     foreach(string part in ShellNewItem.SnParts)
                     {
                         string snPart = part;
                         if(tKey != null) snPart = $@"{defalutOpenMode}\{snPart}";
                         using(RegistryKey snKey = extKey.OpenSubKey(snPart))
                         {
                             if(ShellNewItem.EffectValueNames.Any(valueName => snKey?.GetValue(valueName) != null))
                             {
                                 ShellNewItem item = new ShellNewItem(this, snKey.Name);
                                 if(item.BeforeSeparator)
                                 {
                                     int index2 = this.GetItemIndex(Separator);
                                     this.InsertItem(item, index2);
                                 }
                                 else
                                 {
                                     this.AddItem(item);
                                 }
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 private void LoadShellExItems(XmlNode shellExXN, FoldGroupItem groupItem)
 {
     foreach (XmlNode itemXN in shellExXN.SelectNodes("Item"))
     {
         if (!XmlDicHelper.FileExists(itemXN))
         {
             continue;
         }
         if (!XmlDicHelper.JudgeCulture(itemXN))
         {
             continue;
         }
         if (!XmlDicHelper.JudgeOSVersion(itemXN))
         {
             continue;
         }
         if (!GuidEx.TryParse(itemXN.SelectSingleNode("Guid")?.InnerText, out Guid guid))
         {
             continue;
         }
         EnhanceShellExItem item = new EnhanceShellExItem
         {
             FoldGroupItem  = groupItem,
             ShellExPath    = $@"{groupItem.GroupPath}\ShellEx",
             Image          = ResourceIcon.GetIcon(itemXN.SelectSingleNode("Icon")?.InnerText)?.ToBitmap() ?? AppImage.SystemFile,
             DefaultKeyName = itemXN.SelectSingleNode("KeyName")?.InnerText,
             Guid           = guid
         };
         foreach (XmlNode textXE in itemXN.SelectNodes("Text"))
         {
             if (XmlDicHelper.JudgeCulture(textXE))
             {
                 item.Text = ResourceString.GetDirectString(textXE.InnerText);
             }
         }
         if (item.Text.IsNullOrWhiteSpace())
         {
             item.Text = GuidInfo.GetText(guid);
         }
         if (item.DefaultKeyName.IsNullOrWhiteSpace())
         {
             item.DefaultKeyName = guid.ToString("B");
         }
         string tip = "";
         foreach (XmlElement tipXE in itemXN.SelectNodes("Tip"))
         {
             if (XmlDicHelper.JudgeCulture(tipXE))
             {
                 tip = tipXE.GetAttribute("Text");
             }
         }
         ToolTipBox.SetToolTip(item.ChkVisible, tip);
         this.AddItem(item);
     }
 }
Beispiel #16
0
        Task<Stream> IContentResolver.GetStreamAsync(ResourceString resourceString, bool writable, CancellationToken token)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(resourceString));
            Contract.Ensures(Contract.Result<Task<Stream>>() != null);
            Contract.Ensures(
                Contract.Result<Task<Stream>>().Result == null ||
                (Contract.Result<Task<Stream>>().Result.CanRead && (!writable || Contract.Result<Task<Stream>>().Result.CanWrite))
            );

            return null;
        }
        private void ConvertToHtmlAndStore(ResourceString resource, Func <string, IEnumerable <KeyValuePair <string, string> > > subflowsSelector)
        {
            if (resource.Text.Count == 1 && resource.Text[0] is PlainText)
            {
                return;
            }
            var html = resource.Text.ConvertToHtml(subflowsSelector);

            resource.Text.Clear();
            resource.Text.Add(new CDataTag(html));
        }
Beispiel #18
0
        private void ConvertToHtmlAndStore(ResourceString resource)
        {
            if (resource.Text.Count == 1 && resource.Text[0] is PlainText)
            {
                return;
            }
            var html = resource.Text.ConvertToHtml();

            resource.Text.Clear();
            resource.Text.Add(new CDataTag(html));
        }
        public static string GetLocalizedFileNames(string filePath, bool translate = false)
        {
            IniWriter writer   = new IniWriter(GetDesktopIniPath(filePath));
            string    fileName = Path.GetFileName(filePath);
            string    name     = writer.GetValue(LocalizedFileNames, fileName);

            if (translate)
            {
                name = ResourceString.GetDirectString(name);
            }
            return(name);
        }
Beispiel #20
0
        private void SetResourceString(ResourceString text, Group group, Func <Segment, ResourceString> selector)
        {
            var content = RetrieveInnerContent(group, selector);

            if (content.IsHtml())
            {
                text.Text.Add(new CDataTag(content));
            }
            else
            {
                text.Text.Add(new PlainText(content.TrimEnd('\r', '\n')));
            }
        }
 public ChangeTextMenuItem(ITsiTextItem item) : base(AppString.Menu.ChangeText)
 {
     this.Click += (sender, e) =>
     {
         string name = ChangeText(item.Text);
         if (name == null)
         {
             return;
         }
         item.ItemText = name;
         item.Text     = ResourceString.GetDirectString(item.ItemText);
     };
 }
Beispiel #22
0
        private string GetTextContent(Unit nestedUnit, Func <Segment, ResourceString> selector, string attributeList)
        {
            if (nestedUnit.Resources.Count > 1)
            {
                throw new InvalidOperationException("At this stage I expect only one segment. This unit is invalid: " + nestedUnit.SelectorPath);
            }
            Segment segment = nestedUnit.Resources[0] as Segment;

            if (segment == null)
            {
                return("");
            }

            ResourceString item = selector(segment);

            if (item.Text.Count > 1)
            {
                throw new InvalidOperationException("At this stage I expect only a plain text or a CData, not multiple elements. This unit is invalid: " + nestedUnit.SelectorPath);
            }
            var cdata = item.Text[0] as CDataTag;
            var text  = item.Text[0] as PlainText;

            var unitType = nestedUnit.Type;

            if (string.IsNullOrEmpty(unitType))
            {
                if (cdata != null)
                {
                    return(cdata.Text);
                }
                else
                {
                    return(text.Text);
                }
            }
            else
            {
                if (cdata != null)
                {
                    return(string.Format("<{0}{2}>{1}</{0}>", _htmlParser.FromXliffHtmlType(unitType), cdata.Text, attributeList));
                }
                else if (text != null)
                {
                    return(string.Format("<{0}{2}>{1}</{0}>", _htmlParser.FromXliffHtmlType(unitType), text.Text, attributeList));
                }
                else
                {
                    throw new InvalidOperationException("At this stage I expect only a plain text or a CData. This unit is invalid: " + item.SelectableAncestor.SelectorPath);
                }
            }
        }
Beispiel #23
0
 public ParserResourceCatalog(Parser parser)
 {
     foreach (var unit in parser.Parse())
     {
         var str = unit as LocalizedString;
         if (str != null)
         {
             foreach (var resource in ResourceString.Generate(ResourceIdType, str))
             {
                 resources.Add(resource.Id, resource.Translated);
             }
         }
     }
 }
Beispiel #24
0
        private static void _saveItemDataToLua(SdeDatabase gdb, string filename, string output)
        {
            if (output == null && gdb.MetaGrf.GetData(filename) == null)
            {
                Debug.Ignore(() => DbDebugHelper.OnWriteStatusUpdate(ServerDbs.CItems, filename, null, "ItemInfo table not saved."));
                return;
            }

            if (output == null)
            {
                BackupEngine.Instance.BackupClient(filename, gdb.MetaGrf);
            }

            StringBuilder builder = new StringBuilder();

            builder.AppendLine("tbl = {");

            List <ReadableTuple <int> > tuples = gdb.GetDb <int>(ServerDbs.CItems).Table.GetSortedItems().ToList();
            ReadableTuple <int>         tuple;

            for (int index = 0, count = tuples.Count; index < count; index++)
            {
                tuple = tuples[index];
                WriteEntry(builder, tuple, index == count - 1);
            }

            builder.AppendLine("}");
            builder.AppendLine();
            builder.AppendLine(ResourceString.Get("ItemInfoFunction"));

            if (output == null)
            {
                gdb.MetaGrf.SetData(filename, EncodingService.Ansi.GetBytes(builder.ToString()));
            }
            else
            {
                string copyPath = Path.Combine(output, Path.GetFileName(filename));

                try {
                    File.WriteAllText(copyPath, builder.ToString(), EncodingService.Ansi);
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            }

            Debug.Ignore(() => DbDebugHelper.OnWriteStatusUpdate(ServerDbs.CItems, gdb.MetaGrf.FindTkPath(filename), null, "Saving ItemInfo table."));
        }
 private void AddGuidDic()
 {
     using (AddGuidDicDialog dlg = new AddGuidDicDialog())
     {
         dlg.ItemText = GuidInfo.GetText(Item.Guid);
         dlg.ItemIcon = GuidInfo.GetImage(Item.Guid);
         var location = GuidInfo.GetIconLocation(Item.Guid);
         dlg.ItemIconPath  = location.IconPath;
         dlg.ItemIconIndex = location.IconIndex;
         IniWriter writer = new IniWriter
         {
             FilePath            = AppConfig.UserGuidInfosDic,
             DeleteFileWhenEmpty = true
         };
         string     section  = Item.Guid.ToString();
         MyListItem listItem = (MyListItem)Item;
         if (dlg.ShowDialog() != DialogResult.OK)
         {
             if (dlg.IsDelete)
             {
                 writer.DeleteSection(section);
                 GuidInfo.RemoveDic(Item.Guid);
                 listItem.Text  = Item.ItemText;
                 listItem.Image = GuidInfo.GetImage(Item.Guid);
             }
             return;
         }
         if (dlg.ItemText.IsNullOrWhiteSpace())
         {
             AppMessageBox.Show(AppString.Message.TextCannotBeEmpty);
             return;
         }
         dlg.ItemText = ResourceString.GetDirectString(dlg.ItemText);
         if (dlg.ItemText.IsNullOrWhiteSpace())
         {
             AppMessageBox.Show(AppString.Message.StringParsingFailed);
             return;
         }
         else
         {
             GuidInfo.RemoveDic(Item.Guid);
             writer.SetValue(section, "Text", dlg.ItemText);
             writer.SetValue(section, "Icon", dlg.ItemIconLocation);
             listItem.Text  = dlg.ItemText;
             listItem.Image = dlg.ItemIcon;
         }
     }
 }
Beispiel #26
0
        public static string GetMenuName(string filePath)
        {
            string dirPath  = Path.GetDirectoryName(filePath);
            string fileName = Path.GetFileName(filePath);

            if (DesktopIniReaders.TryGetValue(dirPath, out IniReader reader))
            {
                string name = reader.GetValue("LocalizedFileNames", fileName);
                name = ResourceString.GetDirectString(name);
                return(name);
            }
            else
            {
                return(string.Empty);
            }
        }
 private void LoadShellItems(XmlElement shellXE, GroupPathItem groupItem)
 {
     foreach (XmlElement itemXE in shellXE.GetElementsByTagName("Item"))
     {
         XmlElement verXE = (XmlElement)itemXE.SelectSingleNode("OSVersion");
         if (!JudgeOSVersion(verXE))
         {
             continue;
         }
         XmlElement szXE    = (XmlElement)itemXE.SelectSingleNode("Value/REG_SZ");
         string     keyName = itemXE.GetAttribute("KeyName");
         if (keyName.IsNullOrWhiteSpace())
         {
             continue;
         }
         string           regPath = $@"{groupItem.TargetPath}\shell\{keyName}";
         EnhanceShellItem item    = new EnhanceShellItem()
         {
             RegPath       = $@"{groupItem.TargetPath}\shell\{keyName}",
             FoldGroupItem = groupItem,
             ItemXE        = itemXE
         };
         if (szXE != null)
         {
             item.Text = ResourceString.GetDirectString(szXE.GetAttribute("MUIVerb"));
             if (szXE.HasAttribute("Icon"))
             {
                 item.Image = ResourceIcon.GetIcon(szXE.GetAttribute("Icon"))?.ToBitmap();
             }
             else if (szXE.HasAttribute("HasLUAShield"))
             {
                 item.Image = AppImage.Shield;
             }
         }
         if (item.Image == null)
         {
             item.Image = AppImage.NotFound;
         }
         if (item.Text.IsNullOrWhiteSpace())
         {
             item.Text = keyName;
         }
         item.ChkVisible.Checked = item.ItemVisible;
         MyToolTip.SetToolTip(item.ChkVisible, itemXE.GetAttribute("Tip"));
         this.AddItem(item);
     }
 }
Beispiel #28
0
        public SkypeShareItem()
        {
            InitializeComponents();
            string path = ItemFilePath;

            if (File.Exists(path))
            {
                ChkVisible.Checked = this.ItemVisible;
                this.Text          = ResourceString.GetDirectString($"@{path},-101");
                string exePath = $@"{Path.GetDirectoryName(path)}\Skype.exe";
                this.Image = Icon.ExtractAssociatedIcon(exePath)?.ToBitmap();
            }
            else
            {
                this.Visible = false;
            }
        }
Beispiel #29
0
        public static void DbSqlMobs(DbDebugItem <int> debug, AbstractDb <int> db)
        {
            DbSqlWriter writer = new DbSqlWriter();

            writer.Init(debug);

            if (DbPathLocator.DetectPath(debug.DbSource).EndsWith(".conf"))
            {
                object value = db.Attached["EntireRewrite"];
                db.Attached["EntireRewrite"] = true;
                DbIOMethods.DbWriterComma(debug, db);
                db.Attached["EntireRewrite"] = value;
            }
            else
            {
                DbIOMethods.DbWriterComma(debug, db);
            }

            if (debug.DestinationServer == ServerType.RAthena)
            {
                writer.AppendHeader(ResourceString.Get("RAthenaMobDbSqlHeader"));
            }
            else if (debug.DestinationServer == ServerType.Hercules)
            {
                writer.AppendHeader(ResourceString.Get("HerculesMobDbSqlHeader"), writer.TableName.Replace("_re", ""));
                writer.TableName = "mob_db";
            }

            foreach (string line in writer.Read())
            {
                string[] elements = TextFileHelper.ExcludeBrackets(line.Trim('\t'));
                if (!_getMob(writer.IsHercules, writer.TableName, writer.Builder, elements))
                {
                    writer.Line(writer.IsHercules ? line.ReplaceFirst("//", "--" + (writer.NumberOfLinesProcessed > 1 ? " " : "")) : line.ReplaceFirst("//", "#"));
                }
                else
                {
                    writer.NumberOfLinesProcessed++;
                }
            }

            writer.Write();
        }
        public ResourceString Udf_GetResourceInformationForResourceVersionIDs(int resourceVersionId)
        {
            ResourceString result = new ResourceString();

            using SqlConnection con = new SqlConnection(m_connectionString);
            using SqlCommand cmd    = new SqlCommand("DECLARE @resourceVersionIDs utt_KeyedIntList" +
                                                     " INSERT @resourceVersionIDs" +
                                                     " select " + resourceVersionId +
                                                     " select * from [dbo].[udf_GetResourceInformationForResourceVersionIDs] (@resourceVersionIDs)", con)
                  {
                      CommandType = CommandType.Text
                  };
            con.Open();
            using (SqlDataReader reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    result.ResourceID             = (int)reader["ResourceID"];
                    result.BranchID               = (int)reader["BranchID"];
                    result.Status                 = (string)reader["Status"];
                    result.Folder                 = (string)reader["Folder"];
                    result.Name                   = (string)reader["Name"];
                    result.FullName               = (string)reader["FullName"];
                    result.ResourceTypeID         = (int)reader["ResourceTypeID"];
                    result.RepositoryPath         = (string)reader["RepositoryPath"];
                    result.ProjectVersion         = (int)reader["ProjectVersion"];
                    result.DataImportSessionID    = (int)reader["DataImportSessionID"];
                    result.ChangelistID           = (int)reader["ChangelistID"];
                    result.ModuleID               = (int)reader["ModuleID"];
                    result.WritingWorkflowStateID = (int)reader["WritingWorkflowStateID"];
                    result.ProductionStateID      = (int)reader["ProductionStateID"];
                    result.ModelTypeID            = (int)reader["ModelTypeID"];
                    result.ResourceUniqueID       = (string)reader["ResourceUniqueID"];
                    result.ScopeTag               = reader.IsNullOrEmpty() ? string.Empty : (string)reader["ScopeTag"];
                    result.ScopeSubTag            = reader.IsNullOrEmpty() ? string.Empty : (string)reader["ScopeSubTag"];
                    //result.TypeTag = (int)reader["TypeTag"];
                    //result.WritingPointOfContact = (string)reader["WritingPointOfContact"];
                }
            }
            con.Close();
            return(result);
        }
Beispiel #31
0
        public static string GetText(Guid guid)
        {
            string itemText = null;

            if (guid.Equals(Guid.Empty))
            {
                return(itemText);
            }
            if (ItemTextDic.ContainsKey(guid))
            {
                itemText = ItemTextDic[guid];
            }
            else
            {
                if (TryGetValue(guid.ToString(), "Text", out itemText))
                {
                    itemText = GetAbsStr(guid, itemText, true);
                }
                if (string.IsNullOrWhiteSpace(itemText))
                {
                    foreach (string clsidPath in ClsidPaths)
                    {
                        foreach (string value in new[] { "LocalizedString", "InfoTip", "" })
                        {
                            itemText = Registry.GetValue($@"{clsidPath}\{guid:B}", value, null)?.ToString();
                            if (!string.IsNullOrEmpty(itemText))
                            {
                                break;
                            }
                        }
                    }
                }
                itemText = ResourceString.GetDirectString(itemText);
                if (string.IsNullOrWhiteSpace(itemText))
                {
                    itemText = null;
                }
                ItemTextDic.Add(guid, itemText);
            }
            return(itemText);
        }
Beispiel #32
0
 private void LoadShellItems()
 {
     foreach (XmlElement itemXE in shellXE.GetElementsByTagName("Item"))
     {
         XmlElement szXE    = (XmlElement)itemXE.SelectSingleNode("Value/REG_SZ");
         string     keyName = itemXE.GetAttribute("KeyName");
         if (string.IsNullOrWhiteSpace(keyName))
         {
             continue;
         }
         ShellCommonItem item = new ShellCommonItem
         {
             DefaultKeyName = keyName,
             ItemXE         = itemXE
         };
         if (szXE != null)
         {
             item.Text = ResourceString.GetDirectString(szXE.GetAttribute("MUIVerb"));
             if (szXE.HasAttribute("Icon"))
             {
                 item.Image = ResourceIcon.GetIcon(szXE.GetAttribute("Icon"))?.ToBitmap();
             }
             else if (szXE.HasAttribute("HasLUAShield"))
             {
                 item.Image = AppImage.Shield;
             }
         }
         if (item.Image == null)
         {
             item.Image = AppImage.NotFound;
         }
         if (string.IsNullOrWhiteSpace(item.Text))
         {
             item.Text = item.DefaultKeyName;
         }
         item.SetTip(itemXE.GetAttribute("Tip"));
         list.AddItem(item);
     }
 }
Beispiel #33
0
        Task<object> IContentManager.LoadAsync(ResourceString resourceString, Type assetType, object parameter, CancellationToken token, bool forceReload)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(resourceString));
            Contract.Requires<ArgumentNullException>(assetType != null);
            Contract.Ensures(Contract.Result<Task<object>>() != null);

            return null;
        }
Beispiel #34
0
 private static void RenderFormatMethod(string indent, Lang language, StringBuilder strings, ResourceString resourceString)
 {
     strings.AppendLine($"{indent}internal static string Format{resourceString.Name}({resourceString.GetMethodParameters(language)})");
     if (resourceString.UsingNamedArgs)
     {
         strings.AppendLine($@"{indent}   => string.Format(Culture, GetResourceString(""{resourceString.Name}"", new [] {{ {resourceString.GetArgumentNames()} }}), {resourceString.GetArguments()});");
     }
     else
     {
         strings.AppendLine($@"{indent}   => string.Format(Culture, GetResourceString(""{resourceString.Name}""), {resourceString.GetArguments()});");
     }
     strings.AppendLine();
 }
Beispiel #35
0
        public override bool Execute()
        {
            string namespaceName;
            string className;

            if (string.IsNullOrEmpty(ResourceName))
            {
                Log.LogError("ResourceName not specified");
                return(false);
            }

            string resourceAccessName = string.IsNullOrEmpty(ResourceClassName) ? ResourceName : ResourceClassName;

            SplitName(resourceAccessName, out namespaceName, out className);

            Lang language;

            switch (Language.ToUpperInvariant())
            {
            case "C#":
                language = Lang.CSharp;
                break;

            case "VB":
                language = Lang.VisualBasic;
                break;

            default:
                Log.LogError($"GenerateResxSource doesn't support language: '{Language}'");
                return(false);
            }

            string classIndent  = (namespaceName == null ? "" : "    ");
            string memberIndent = classIndent + "    ";

            var strings = new StringBuilder();

            foreach (var node in XDocument.Load(ResourceFile).Descendants("data"))
            {
                string name = node.Attribute("name")?.Value;
                if (name == null)
                {
                    Log.LogError("Missing resource name");
                    return(false);
                }

                string value = node.Elements("value").FirstOrDefault()?.Value.Trim();
                if (value == null)
                {
                    Log.LogError($"Missing resource value: '{name}'");
                    return(false);
                }

                if (name == "")
                {
                    Log.LogError($"Empty resource name");
                    return(false);
                }

                string docCommentString = value.Length > maxDocCommentLength?value.Substring(0, maxDocCommentLength) + " ..." : value;

                RenderDocComment(language, memberIndent, strings, docCommentString);

                string identifier = IsLetterChar(CharUnicodeInfo.GetUnicodeCategory(name[0])) ? name : "_" + name;

                string defaultValue = IncludeDefaultValues ? ", " + CreateStringLiteral(value, language) : string.Empty;

                switch (language)
                {
                case Lang.CSharp:
                    if (AsConstants)
                    {
                        strings.AppendLine($"{memberIndent}internal const string {name} = nameof({name});");
                    }
                    else
                    {
                        strings.AppendLine($"{memberIndent}internal static string {identifier} => GetResourceString(\"{name}\"{defaultValue});");
                    }

                    if (EmitFormatMethods)
                    {
                        var resourceString = new ResourceString(name, value);

                        if (resourceString.HasArguments)
                        {
                            RenderDocComment(language, memberIndent, strings, docCommentString);
                            RenderFormatMethod(memberIndent, language, strings, resourceString);
                        }
                    }
                    break;

                case Lang.VisualBasic:
                    if (AsConstants)
                    {
                        strings.AppendLine($"{memberIndent}Friend Const {name} As String = \"{name}\"");
                    }
                    else
                    {
                        strings.AppendLine($"{memberIndent}Friend Shared ReadOnly Property {identifier} As String");
                        strings.AppendLine($"{memberIndent}  Get");
                        strings.AppendLine($"{memberIndent}    Return GetResourceString(\"{name}\"{defaultValue})");
                        strings.AppendLine($"{memberIndent}  End Get");
                        strings.AppendLine($"{memberIndent}End Property");
                    }

                    if (EmitFormatMethods)
                    {
                        throw new NotImplementedException();
                    }
                    break;

                default:
                    throw new InvalidOperationException();
                }
            }

            string getStringMethod;

            if (OmitGetResourceString)
            {
                getStringMethod = null;
            }
            else
            {
                switch (language)
                {
                case Lang.CSharp:
                    getStringMethod = $@"{memberIndent}internal static global::System.Globalization.CultureInfo Culture {{ get; set; }}

{memberIndent}[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
{memberIndent}internal static string GetResourceString(string resourceKey, string defaultValue = null) =>  ResourceManager.GetString(resourceKey, Culture);";
                    if (EmitFormatMethods)
                    {
                        getStringMethod += $@"

{memberIndent}private static string GetResourceString(string resourceKey, string[] formatterNames)
{memberIndent}{{
{memberIndent}   var value = GetResourceString(resourceKey);
{memberIndent}   if (formatterNames != null)
{memberIndent}   {{
{memberIndent}       for (var i = 0; i < formatterNames.Length; i++)
{memberIndent}       {{
{memberIndent}           value = value.Replace(""{{"" + formatterNames[i] + ""}}"", ""{{"" + i + ""}}"");
{memberIndent}       }}
{memberIndent}   }}
{memberIndent}   return value;
{memberIndent}}}
";
                    }
                    break;

                case Lang.VisualBasic:
                    getStringMethod = $@"{memberIndent}Friend Shared Property Culture As Global.System.Globalization.CultureInfo

{memberIndent}<Global.System.Runtime.CompilerServices.MethodImpl(Global.System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)>
{memberIndent}Friend Shared Function GetResourceString(ByVal resourceKey As String, Optional ByVal defaultValue As String = Nothing) As String
{memberIndent}  Get
{memberIndent}    Return ResourceManager.GetString(resourceKey, Culture)
{memberIndent}  End Get
{memberIndent}End Function";
                    if (EmitFormatMethods)
                    {
                        throw new NotImplementedException();
                    }
                    break;

                default:
                    throw new InvalidOperationException();
                }
            }


            string namespaceStart, namespaceEnd;

            if (namespaceName == null)
            {
                namespaceStart = namespaceEnd = null;
            }
            else
            {
                switch (language)
                {
                case Lang.CSharp:
                    namespaceStart = $@"namespace {namespaceName}{Environment.NewLine}{{";
                    namespaceEnd   = "}";
                    break;

                case Lang.VisualBasic:
                    namespaceStart = $"Namespace {namespaceName}";
                    namespaceEnd   = "End Namespace";
                    break;

                default:
                    throw new InvalidOperationException();
                }
            }

            string resourceTypeName;
            string resourceTypeDefinition;

            if (string.IsNullOrEmpty(ResourceClassName) || ResourceName == ResourceClassName)
            {
                // resource name is same as accessor, no need for a second type.
                resourceTypeName       = className;
                resourceTypeDefinition = null;
            }
            else
            {
                // resource name differs from the access class, need a type for specifying the resources
                // this empty type must remain as it is required by the .NETNative toolchain for locating resources
                // once assemblies have been merged into the application
                resourceTypeName = ResourceName;

                string resourceNamespaceName;
                string resourceClassName;
                SplitName(resourceTypeName, out resourceNamespaceName, out resourceClassName);
                string resourceClassIndent = (resourceNamespaceName == null ? "" : "    ");

                switch (language)
                {
                case Lang.CSharp:
                    resourceTypeDefinition = $"{resourceClassIndent}internal static class {resourceClassName} {{ }}";
                    if (resourceNamespaceName != null)
                    {
                        resourceTypeDefinition = $@"namespace {resourceNamespaceName}
{{
{resourceTypeDefinition}
}}";
                    }
                    break;

                case Lang.VisualBasic:
                    resourceTypeDefinition = $@"{resourceClassIndent}Friend Class {resourceClassName}
{resourceClassIndent}End Class";
                    if (resourceNamespaceName != null)
                    {
                        resourceTypeDefinition = $@"Namespace {resourceNamespaceName}
{resourceTypeDefinition}
End Namespace";
                    }
                    break;

                default:
                    throw new InvalidOperationException();
                }
            }

            // The ResourceManager property being initialized lazily is an important optimization that lets .NETNative
            // completely remove the ResourceManager class if the disk space saving optimization to strip resources
            // (/DisableExceptionMessages) is turned on in the compiler.
            string result;

            switch (language)
            {
            case Lang.CSharp:
                result = $@"// <auto-generated>
using System.Reflection;

{resourceTypeDefinition}
{namespaceStart}
{classIndent}internal static partial class {className}
{classIndent}{{
{memberIndent}private static global::System.Resources.ResourceManager s_resourceManager;
{memberIndent}internal static global::System.Resources.ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new global::System.Resources.ResourceManager(typeof({resourceTypeName})));
{getStringMethod}
{strings}
{classIndent}}}
{namespaceEnd}
";
                break;

            case Lang.VisualBasic:
                result = $@"' <auto-generated>
Imports System.Reflection

{resourceTypeDefinition}
{namespaceStart}
{classIndent}Friend Partial Class {className}
{memberIndent}Private Sub New
{memberIndent}End Sub
{memberIndent}
{memberIndent}Private Shared s_resourceManager As Global.System.Resources.ResourceManager
{memberIndent}Friend Shared ReadOnly Property ResourceManager As Global.System.Resources.ResourceManager
{memberIndent}    Get
{memberIndent}        If s_resourceManager Is Nothing Then
{memberIndent}            s_resourceManager = New Global.System.Resources.ResourceManager(GetType({resourceTypeName}))
{memberIndent}        End If
{memberIndent}        Return s_resourceManager
{memberIndent}    End Get
{memberIndent}End Property
{getStringMethod}
{strings}
{classIndent}End Class
{namespaceEnd}
";
                break;

            default:
                throw new InvalidOperationException();
            }

            File.WriteAllText(OutputPath, result);
            return(true);
        }
Beispiel #36
0
        /// <summary>
        /// Initializes a new <see cref="Game"/> from the specified <paramref name="startScene"/>.
        /// </summary>
        /// <param name="startScene">The <see cref="Scene"/> that will be run at startup.</param>
        public Game(ResourceString startScene)
            : base(GeneralSettings.Default.GameName)
        {
            Contract.Requires<ArgumentNullException>(startScene != null);

            if (!GLObject.IsOpenGLVersionSupported(OpenGLVersion))
            {
                throw new NotSupportedException(
                    "The required OpenGL-Version ({0}) is not supported by the current OS / hardware (max vesion {1}). LightClaw cannot run.".FormatWith(OpenGLVersion, GLObject.MaxOpenGLVersion)
                );
            }

            this.cachedOnTickAction = new Action(this.OnTick);

            this.GameWindow.Closed += (s, e) => this.OnClosed();
            this.GameWindow.Move += (s, e) => this.OnMove(this.GameWindow.Location);
            this.GameWindow.Resize += (s, e) => this.OnResize(this.GameWindow.Width, this.GameWindow.Height);
            this.GameWindow.Unload += (s, e) => this.OnUnload();
            
            Log.Debug(() => "Creating {0} from start scene '{1}.'".FormatWith(typeof(SceneManager).Name, startScene));
            this.SceneManager = new SceneManager(startScene);

            this.IocC.RegisterInstance<IGame>(this);
            this.IocC.RegisterInstance(this.SceneManager);
            this.IocC.RegisterInstance(this.Dispatcher);

            this.LoadIcon();

            Log.Debug(() => "Game successfully created.");
        }
 /// <summary>
 /// Checks whether the asset with the specified resource string exists.
 /// </summary>
 /// <param name="resourceString">The resource string of the asset to check for.</param>
 /// <param name="token">A <see cref="CancellationToken"/> used to signal cancellation of the process.</param>
 /// <returns><c>true</c> if the asset exists, otherwise <c>false</c>.</returns>
 public Task<bool> ExistsAsync(ResourceString resourceString, CancellationToken token)
 {
     Contract.Assume(Contract.Result<Task<bool>>() != null);
     return !token.IsCancellationRequested ? Task.FromResult(File.Exists(Path.Combine(this.RootPath, resourceString))) : finishedFalseTask;
 }
        private GroupPathItem GetGroupPathItem(XmlNode xn)
        {
            string path;
            string text;
            Image  image;

            switch (xn.Name)
            {
            case "File":
                path  = ShellList.MENUPATH_FILE;
                text  = AppString.SideBar.File;
                image = AppImage.File;
                break;

            case "Folder":
                path  = ShellList.MENUPATH_FOLDER;
                text  = AppString.SideBar.Folder;
                image = AppImage.Folder;
                break;

            case "Directory":
                path  = ShellList.MENUPATH_FOLDER;
                text  = AppString.SideBar.Directory;
                image = AppImage.Directory;
                break;

            case "Background":
                path  = ShellList.MENUPATH_BACKGROUND;
                text  = AppString.SideBar.Background;
                image = AppImage.Background;
                break;

            case "Desktop":
                path = ShellList.MENUPATH_DESKTOP;
                //Vista没有桌面右键菜单的独立注册表项
                if (WindowsOsVersion.IsEqualVista)
                {
                    path = ShellList.MENUPATH_BACKGROUND;
                }
                text  = AppString.SideBar.Desktop;
                image = AppImage.Desktop;
                break;

            case "Drive":
                path  = ShellList.MENUPATH_DRIVE;
                text  = AppString.SideBar.Drive;
                image = AppImage.Drive;
                break;

            case "AllObjects":
                path  = ShellList.MENUPATH_ALLOBJECTS;
                text  = AppString.SideBar.AllObjects;
                image = AppImage.AllObjects;
                break;

            case "Computer":
                path  = ShellList.MENUPATH_COMPUTER;
                text  = AppString.SideBar.Computer;
                image = AppImage.Computer;
                break;

            case "RecycleBin":
                path  = ShellList.MENUPATH_RECYCLEBIN;
                text  = AppString.SideBar.RecycleBin;
                image = AppImage.RecycleBin;
                break;

            default:
                XmlElement xe = (XmlElement)xn;
                path = xe.GetAttribute("RegPath");
                text = ResourceString.GetDirectString(xe.GetAttribute("Text"));
                if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(text))
                {
                    return(null);
                }
                image = ResourceIcon.GetIcon(xe.GetAttribute("Icon"))?.ToBitmap() ?? AppImage.NotFound;
                break;
            }
            GroupPathItem groupItem = new GroupPathItem(path, ObjectPath.PathType.Registry)
            {
                Image = image, Text = text
            };

            return(groupItem);
        }
Beispiel #39
0
 /// <summary>
 /// Asynchronously loads a <see cref="Scene"/> from the specified <paramref name="resourceString"/>.
 /// </summary>
 /// <param name="slot">The slot to load the <see cref="Scene"/> into.</param>
 /// <param name="resourceString">The resource string of the <see cref="Scene"/> to load.</param>
 /// <returns>The slot the <see cref="Scene"/> was inserted into in the end.</returns>
 /// <remarks>
 /// If the desired slot is already taken, the method tries to load the scene in the slot below. This is done
 /// until a free slot is found. However, moving the scene into a lower layer during rendering (final image is a
 /// composition of all scenes drawing on top of each other) poses a higher risk of being overdrawn by scenes
 /// that are not supposed to overdraw it.
 /// </remarks>
 /// <exception cref="InvalidOperationException">All slots below taken, scene could not be laoded.</exception>
 public async Task<int> LoadAsync(int slot, ResourceString resourceString)
 {
     return this.Load(slot, await IocC.Resolve<IContentManager>().LoadAsync<Scene>(resourceString).ConfigureAwait(false));
 }
Beispiel #40
0
        Task<Stream> IContentManager.GetStreamAsync(ResourceString resourceString, CancellationToken token)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(resourceString));
            Contract.Ensures(Contract.Result<Task<Stream>>() != null);

            return null;
        }
Beispiel #41
0
        /// <summary>
        /// Initializes a new <see cref="Mesh"/> and sets the resource string of the model to load.
        /// </summary>
        /// <param name="name">The <see cref="Mesh"/>s name.</param>
        /// <param name="resourceString">The resource string of the model to be drawn.</param>
        public Mesh(string name, ResourceString resourceString)
            : base(name)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(resourceString));

            Log.Info(() => "Initializing a new mesh from model '{0}'.".FormatWith(resourceString));
            this.Source = resourceString;
        }
Beispiel #42
0
        private Task<Shader> TryLoadAsync(ResourceString rs, ShaderType type, IContentManager contentManager, CancellationToken token)
        {
            Contract.Requires<ArgumentNullException>(contentManager != null);

            return rs.IsValid ? contentManager.LoadAsync<Shader>(rs, type, token) : finishedShaderTask;
        }
Beispiel #43
0
 /// <summary>
 /// Initializes a new <see cref="Mesh"/> and sets the resource string of the model to load.
 /// </summary>
 /// <param name="resourceString">The resource string of the model to be drawn.</param>
 public Mesh(ResourceString resourceString)
     : this(Path.GetFileName(resourceString), resourceString)
 {
     Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(resourceString));
 }