public static void ChangeLocale(this CultureInfo culture) { if (culture is CultureInfo && resourceCulture != culture) { resourceSet = resourceMan.GetResourceSet(culture, true, true); //Properties.Resources.Culture = culture; resourceCulture = culture; if (_be_locale_ == null) { _be_locale_ = new Dictionary <FrameworkElement, bool>(); } else { _be_locale_.Clear(); } } }
public static List <string> GetImageListFromDLL(string assemblyName) { Assembly asm = Assembly.LoadFrom(assemblyName + (assemblyName.Contains(".dll") ? "" : ".dll")); System.Globalization.CultureInfo culture = System.Threading.Thread.CurrentThread.CurrentCulture; string resourceName = asm.GetName().Name + ".g"; System.Resources.ResourceManager rm = new System.Resources.ResourceManager(resourceName, asm); System.Resources.ResourceSet resourceSet = rm.GetResourceSet(culture, true, true); List <string> resources = new List <string>(); foreach (System.Collections.DictionaryEntry resource in resourceSet) { resources.Add((string)resource.Key); } rm.ReleaseAllResources(); return(resources); }
private static string GetResourceString(string name, Assembly assembly) { var names = assembly.GetManifestResourceNames(); for (int i = 0; i < names.Length; i++) { using var stream = assembly.GetManifestResourceStream(names[i]); using var resource = new System.Resources.ResourceSet(stream); var value = resource.GetString(name); if (value != null) { return(value); } } return(name); }
public static List <string> GetDoors() { List <string> doors = new List <string>(); System.Resources.ResourceSet resourceSet = Properties.Resources.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, false); foreach (DictionaryEntry entry in resourceSet) { if (entry.Key.ToString().StartsWith("Door_")) { doors.Add(entry.Key.ToString()); } } doors.Sort(delegate(string x, string y) { return(x.CompareTo(y)); }); return(doors); }
public static List <string> GetCharacters() { List <string> characters = new List <string>(); //Not sure why, but try parents had to be true for this one System.Resources.ResourceSet resourceSet = Properties.Resources.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true); foreach (DictionaryEntry entry in resourceSet) { if (entry.Key.ToString().StartsWith("Character_")) { characters.Add(entry.Key.ToString()); } } characters.Sort(delegate(string x, string y) { return(x.CompareTo(y)); }); return(characters); }
static public string ResourceAsString(this Type type, string resourceName) { // string[] names = typeof(Extensions).Assembly.GetManifestResourceNames(); string[] names = type.Assembly.GetManifestResourceNames(); foreach (var name in names) { if (name.EndsWith(resourceName)) { using (var s = type.Assembly.GetManifestResourceStream(name)) { using (var reader = new System.IO.StreamReader(s)) { return(reader.ReadToEnd()); } } } else { try { var set = new System.Resources.ResourceSet(type.Assembly.GetManifestResourceStream(names[0])); foreach (System.Collections.DictionaryEntry resource in set) { // Log.Information("\n[{0}] \t{1}", resource.Key, resource.Value); if (((string)resource.Key).EndsWith(resourceName.ToLower())) { using (var reader = new System.IO.StreamReader(resource.Value as System.IO.Stream)) { return(reader.ReadToEnd()); } } } } catch (Exception ex) { Log.Debug(ex.ToString()); } } } return(null); }
private void mySearchImages() { string sFilter = "C" + sCartridgeModel + "_*_datasheet"; string[] aSplit = null; listImgs.Clear(); try { List <string> aImgs = new List <string>(); System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo(""); System.Resources.ResourceSet resSet = My.Resources.ResourceCartridge.ResourceManager.GetResourceSet(culture, true, false); IDictionaryEnumerator listaCartuchos = resSet.GetEnumerator(); listaCartuchos.Reset(); bool bOk = listaCartuchos.MoveNext(); while (bOk) { if (StringType.StrLike((string)listaCartuchos.Key, sFilter, CompareMethod.Binary)) { aImgs.Add((string)listaCartuchos.Key); } bOk = listaCartuchos.MoveNext(); } aImgs.Sort(); for (var i = 0; i <= aImgs.Count - 1; i++) { string sDummy = aImgs[i]; aSplit = sDummy.Split('_'); sDummy = aSplit[1]; var str = new strImgs(); str.sFilename = aImgs[i]; str.sCartridgeModel = sCartridgeModel; str.iCartridgeNbr = int.Parse(sDummy); listImgs.Add(str); } } catch (Exception) { } }
/* * Page Events */ protected void Page_Init() { if (Request.IsAuthenticated && Session["client"] == null) { if (log.IsDebugEnabled) { log.Debug(System.String.Concat("Session [", this.Session.SessionID, "] has inconsistent state, restarting.")); } this.closeSession(); } if (this.centralPanel != null) { this.centralPanel.InstantiateIn(this.centralPanelHolder); } if (this.inbox == null) { this.inbox = (anmar.SharpWebMail.CTNInbox)Session["inbox"]; } this.resources = (System.Resources.ResourceSet)Session["resources"]; }
private void WindowBase_Loaded(object sender, RoutedEventArgs e) { //System.Windows.Resources.StreamResourceInfo sri = Application.GetResourceStream(new Uri("/Images/bg01.jpg", UriKind.RelativeOrAbsolute)); //Console.WriteLine(sri.ContentType); //System.Windows.Media.Imaging.BitmapImage image = new BitmapImage(); //image.BeginInit(); //image.StreamSource = sri.Stream; //image.EndInit(); //Image1.Source = image; //System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly(this.GetType()); //string resourceName = assembly.GetName().Name + ".g"; //System.Resources.ResourceManager rsManager = new System.Resources.ResourceManager(resourceName, assembly); //using (System.Resources.ResourceSet set = rsManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true)) //{ // System.IO.UnmanagedMemoryStream umn = (System.IO.UnmanagedMemoryStream)set.GetObject("Images/bg01.jpg", true); // System.Windows.Media.Imaging.BitmapImage image = new BitmapImage(); // image.BeginInit(); // image.StreamSource = umn; // image.EndInit(); // Image1.Source = image; //} System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly(this.GetType()); string resourceName = assembly.GetName().Name + ".g"; System.Resources.ResourceManager rsManager = new System.Resources.ResourceManager(resourceName, assembly); using (System.Resources.ResourceSet set = rsManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true)) { foreach (System.Collections.DictionaryEntry res in set) { TextBox1.AppendText(res.Key.ToString()); TextBox1.AppendText("\t"); TextBox1.AppendText(res.Value.GetType().ToString()); TextBox1.AppendText("\r"); } } }
public string GetConclusion(int row, int col, System.Globalization.CultureInfo culture, bool bStrict) { System.Resources.ResourceManager rm = GetResourceManager(); if (null != rm) { string stringId = GetStringId(row, col); string result = null; if (bStrict) { System.Resources.ResourceSet rs = rm.GetResourceSet(culture, true, false); if (null != rs) { result = rs.GetString(stringId); } else { _log.Debug($"ResourceSet could not be acquired for culture '{culture}' (strict)."); } } else { result = rm.GetString(stringId, culture); } if ((null == result) || (0 == result.Length)) { _log.Debug($"No string with id='{stringId}' found for culture '{culture}'. ResourceManager: {rm.BaseName}"); return(string.Empty); } return(result); } else { _log.Debug("Resource manager not acquired."); } return(string.Empty); }
protected override System.Resources.ResourceSet InternalGetResourceSet(System.Globalization.CultureInfo culture, bool createIfNotExists, bool tryParents) { if (Path == null && FileFormat == null) { return(null); } if (culture == null || culture.Equals(CultureInfo.InvariantCulture)) { return(null); } System.Resources.ResourceSet rs = null; Hashtable resourceSets = this.ResourceSets; if (!TryFetchResourceSet(resourceSets, culture, out rs)) { Stream resourceFullPath = this.GetAssemblyResource(culture); if (resourceFullPath == null) { if (tryParents) { CultureInfo parent = culture.Parent; rs = this.InternalGetResourceSet(parent, createIfNotExists, tryParents); AddResourceSet(resourceSets, culture, ref rs); return(rs); } } else { rs = this.CreateResourceSet(resourceFullPath); AddResourceSet(resourceSets, culture, ref rs); return(rs); } } return(rs); }
/// <summary> /// Get message from resource /// </summary> /// <param name="module"></param> /// <param name="code"></param> /// <param name="param"></param> /// <returns></returns> public static MessageModel GetMessage(string module, string code, params string[] param) { MessageModel msg = new MessageModel(); msg.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; msg.Code = code; try { string assembly = string.Format("{0}.{1}.dll", CommonValue.MESSAGE_ASSEMBLY, module); CommonUtil util = new CommonUtil(); System.Resources.ResourceSet rs = util.GetResource(assembly, CommonValue.MESSAGE_NAMESPACE); msg.Message = string.Format(rs.GetString(code), param == null ? new string[] { "" } : param); } catch { msg.Message = CommonValue.MESSAGE_NOTFOUND; } return(msg); }
private string GetImage() { System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); System.Globalization.CultureInfo culture = Thread.CurrentThread.CurrentCulture; string resourceName = asm.GetName().Name + ".g"; System.Resources.ResourceManager rm = new System.Resources.ResourceManager(resourceName, asm); System.Resources.ResourceSet resourceSet = rm.GetResourceSet(culture, true, true); List <string> resources = new List <string>(); foreach (DictionaryEntry resource in resourceSet) { if (((string)resource.Key).StartsWith("images/splash%20screens/")) { resources.Add((string)resource.Key); } } rm.ReleaseAllResources(); Random r = new Random(); int i = r.Next(0, resources.Count()); return(resources[i]); }
protected new virtual System.Resources.ResourceSet InternalGetResourceSet(System.Globalization.CultureInfo culture, bool createIfNotExists, bool tryParents) { if (path == null && fileformat == null) { return(null); } if (culture == null || culture.Equals(CultureInfo.InvariantCulture)) { return(null); } System.Resources.ResourceSet rs = null; Hashtable resourceSets = this.ResourceSets; if (!TryFetchResourceSet(resourceSets, culture, out rs)) { string resourceFileName = this.FindResourceFile(culture); if (resourceFileName == null) { if (tryParents) { CultureInfo parent = culture.Parent; rs = this.InternalGetResourceSet(parent, createIfNotExists, tryParents); AddResourceSet(resourceSets, culture, ref rs); return(rs); } } else { rs = this.CreateResourceSet(resourceFileName); AddResourceSet(resourceSets, culture, ref rs); return(rs); } } return(rs); }
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { saveData(); TranslationData.Clear(); _overrideData.Clear(); string lng = null; switch (languageSelectCombo.SelectedIndex) { case 0: lng = "en"; break; case 1: lng = "de"; break; case 2: lng = "nl"; break; case 3: lng = "fr"; break; } if (!string.IsNullOrEmpty(lng)) { string xmlFileContents = null; //user file string fn = System.IO.Path.Combine(Core.Settings.Default.SettingsFolder, string.Format("Language.{0}.xml", lng)); if (System.IO.File.Exists(fn)) { xmlFileContents = System.IO.File.ReadAllText(fn); } if (xmlFileContents != null) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlFileContents); XmlElement root = doc.DocumentElement; XmlNodeList strngs = root.SelectNodes("string"); if (strngs != null) { foreach (XmlNode sn in strngs) { if (!string.IsNullOrEmpty(sn.Attributes["value"].InnerText)) { TranslationData.Add(new LanguageItem(sn.Attributes["name"].InnerText.ToLower(), sn.Attributes["value"].InnerText)); } } } } //override xmlFileContents = null; StreamResourceInfo sri = Application.GetResourceStream(new Uri(string.Format("pack://application:,,,/Resources/Language.{0}.xml", lng))); if (sri != null) { using (System.IO.StreamReader textStreamReader = new System.IO.StreamReader(sri.Stream)) { xmlFileContents = textStreamReader.ReadToEnd(); } if (xmlFileContents != null) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlFileContents); XmlElement root = doc.DocumentElement; XmlNodeList strngs = root.SelectNodes("string"); if (strngs != null) { foreach (XmlNode sn in strngs) { string s = sn.Attributes["name"].InnerText.ToLower(); if (_overrideData[s] == null) { _overrideData.Add(s, sn.Attributes["value"].InnerText); if ((from a in TranslationData where string.Compare(a.Item1, s) == 0 select a).Count() == 0) { TranslationData.Add(new LanguageItem(s, sn.Attributes["value"].InnerText)); } } } } } } //resource, but not in override System.Resources.ResourceSet rset = Localization.TranslationManager.Instance.TranslationProvider.ResourceManager.GetResourceSet(CultureInfo.InvariantCulture, false, true); if (rset != null) { foreach (DictionaryEntry entry in rset) { string s = entry.Value as string; if (s != null) { s = s.ToLower(); if ((from a in TranslationData where string.Compare(a.Item1, s) == 0 select a).Count() == 0) { TranslationData.Add(new LanguageItem(s, "")); } } } } } _prevLng = lng; }
/// <summary> /// Writes scripts (including localized script resources) to the specified stream /// </summary> /// <param name="scriptEntries">list of scripts to write</param> /// <param name="outputWriter">writer for output stream</param> private static void WriteScripts(List <ScriptEntry> scriptEntries, TextWriter outputWriter) { foreach (ScriptEntry scriptEntry in scriptEntries) { if (!scriptEntry.Loaded) { if (!IsScriptCombinable(scriptEntry)) { throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Combined script request includes uncombinable script \"{0}\".", scriptEntry.Name)); } // This script hasn't been loaded by the browser, so add it to the combined script file outputWriter.Write("//START "); outputWriter.WriteLine(scriptEntry.Name); string script = scriptEntry.GetScript(); if (WebResourceRegex.IsMatch(script)) { // This script uses script substitution which isn't supported yet, so throw an exception since it's too late to fix throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "ToolkitScriptManager does not support <%= WebResource/ScriptResource(...) %> substitution as used by script file \"{0}\".", scriptEntry.Name)); } outputWriter.WriteLine(script); // Save current culture and set the specified culture CultureInfo currentUiCulture = Thread.CurrentThread.CurrentUICulture; try { try { Thread.CurrentThread.CurrentUICulture = new CultureInfo(scriptEntry.Culture); } catch (ArgumentException) { // Invalid culture; proceed with default culture (just as for unsupported cultures) } // Write out the associated script resources (if any) in the proper culture Assembly scriptAssembly = scriptEntry.LoadAssembly(); foreach (ScriptResourceAttribute scriptResourceAttribute in GetScriptResourceAttributes(scriptAssembly)) { if (scriptResourceAttribute.ScriptName == scriptEntry.Name) { #pragma warning disable 0618 // obsolete members of ScriptResourceAttribute are used but necessary in the 3.5 build // Found a matching script resource; write it out outputWriter.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0}={{", scriptResourceAttribute.TypeName)); // Get the script resource name (without the trailing ".resources") string scriptResourceName = scriptResourceAttribute.ScriptResourceName; if (scriptResourceName.EndsWith(".resources", StringComparison.OrdinalIgnoreCase)) { scriptResourceName = scriptResourceName.Substring(0, scriptResourceName.Length - 10); } #pragma warning restore 0618 // Load a ResourceManager/ResourceSet and walk through the list to output them all System.Resources.ResourceManager resourceManager = new System.Resources.ResourceManager(scriptResourceName, scriptAssembly); using (System.Resources.ResourceSet resourceSet = resourceManager.GetResourceSet(CultureInfo.InvariantCulture, true, true)) { bool first = true; foreach (System.Collections.DictionaryEntry de in resourceSet) { if (!first) { // Need a comma between all entries outputWriter.Write(","); } // Output the entry string name = (string)de.Key; string value = resourceManager.GetString(name); outputWriter.Write(string.Format(CultureInfo.InvariantCulture, "\"{0}\":\"{1}\"", QuoteString(name), QuoteString(value))); first = false; } } outputWriter.WriteLine("};"); } } } finally { // Restore culture Thread.CurrentThread.CurrentUICulture = currentUiCulture; } // Done with this script outputWriter.Write("//END "); outputWriter.WriteLine(scriptEntry.Name); } // This script is now (or will be soon) loaded by the browser scriptEntry.Loaded = true; } }
private bool TryFetchResourceSet(Hashtable localResourceSets, CultureInfo culture, out System.Resources.ResourceSet set) { lock (localResourceSets) { if (ResourceSets.Contains(culture)) { set = (System.Resources.ResourceSet)ResourceSets[culture]; return(true); } set = null; return(false); } }
private void AddResourceSet(Hashtable localResourceSets, CultureInfo culture, ref System.Resources.ResourceSet rs) { lock (localResourceSets) { if (localResourceSets.Contains(culture)) { var existing = (System.Resources.ResourceSet)localResourceSets[culture]; if (existing != null && !object.Equals(existing, rs)) { rs.Dispose(); rs = existing; var a = (System.Collections.Specialized.NameValueCollection)System.Configuration.ConfigurationManager.GetSection("appSettings"); } } else { localResourceSets.Add(culture, rs); } } }
/* * Page Events */ protected void Page_Init() { if ( Request.IsAuthenticated && Session["client"]==null ) { if ( log.IsDebugEnabled ) log.Debug (System.String.Concat("Session [", this.Session.SessionID, "] has inconsistent state, restarting.")); this.closeSession(); } if ( this.centralPanel!=null ) { this.centralPanel.InstantiateIn (this.centralPanelHolder); } if ( this.inbox==null) { this.inbox = (anmar.SharpWebMail.CTNInbox)Session["inbox"]; } this.resources = (System.Resources.ResourceSet) Session["resources"]; }
public void CreateOrUpdateXmlFiles() { var resourceList = new List <LanguageItem>(); var sc = Localization.TranslationManager.Instance.TranslationProvider.ResourceManager.GetString("Cancel", CultureInfo.InvariantCulture); System.Resources.ResourceSet rset = Localization.TranslationManager.Instance.TranslationProvider.ResourceManager.GetResourceSet(CultureInfo.InvariantCulture, false, true); if (rset != null) { foreach (DictionaryEntry entry in rset) { string s = entry.Value as string; if (s != null) { s = s.ToLower(); resourceList.Add(new LanguageItem(s, "")); } } } //for each possible language, read file patch and save foreach (var l in TranslationProvider.Languages) { var emptyList = (from a in resourceList select new LanguageItem(a.Original, "")).OrderBy(x => x.Original).Distinct().ToList(); if (l.TwoLetterISOLanguageName.ToLower().Length == 2 && l.TwoLetterISOLanguageName.ToLower() != "iv") { XmlDocument doc; XmlElement root; StreamResourceInfo sri = Application.GetResourceStream(new Uri(string.Format("pack://application:,,,/Resources/Language.{0}.xml", l.TwoLetterISOLanguageName.ToLower()))); if (sri != null) { using (StreamReader textStreamReader = new StreamReader(sri.Stream)) { var xmlFileContents = textStreamReader.ReadToEnd(); doc = new XmlDocument(); doc.LoadXml(xmlFileContents); root = doc.DocumentElement; XmlNodeList strngs = root.SelectNodes("string"); if (strngs != null) { foreach (XmlNode sn in strngs) { if (!string.IsNullOrEmpty(sn.Attributes["value"].InnerText)) { var k = emptyList.FirstOrDefault(x => x.Original == sn.Attributes["name"].InnerText.ToLower()); if (k != null) { k.Translation = sn.Attributes["value"].InnerText; } } } } } } //write xml file string fn = Path.Combine(Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GSAKWrapper"), string.Format("Language.{0}.xml", l.TwoLetterISOLanguageName.ToLower())); doc = new XmlDocument(); root = doc.CreateElement("resources"); foreach (LanguageItem di in emptyList) { XmlElement lngElement = doc.CreateElement("string"); lngElement.SetAttribute("name", di.Original); lngElement.SetAttribute("value", di.Translation); root.AppendChild(lngElement); } doc.AppendChild(root); using (System.IO.TextWriter sw = new System.IO.StreamWriter(fn, false, Encoding.UTF8)) //Set encoding { doc.Save(sw); } } } }
public static DateTime ConvertDate(string xDateString, DateFormat xDateFormat, bool isMutiLang) { if (string.IsNullOrEmpty(xDateString)) { return(DateTime.MinValue); } switch (xDateFormat) { case DateFormat.ddMMyyyys: string[] dateInfo = xDateString.Split('/'); string dd = string.Empty; string MM = string.Empty; string yyyy = string.Empty; if (dateInfo.Length == 3) { dd = dateInfo[0].Trim(); if (dd.Length != 2) { if (dd.Length > 2) { dd = dd.Substring(0, 2); } else if (dd.Length == 1 && dd != "0") { dd = "0" + dd; } else { dd = "01"; } } else if (dd == "00") { dd = "01"; } MM = dateInfo[1].Trim(); if (MM.Length != 2) { if (MM.Length > 2) { MM = MM.Substring(0, 2); } else if (MM.Length == 1) { MM = "0" + MM; } else { MM = "01"; } } else if (MM == "00") { MM = "01"; } yyyy = dateInfo[2].Trim(); if (yyyy.Length == 2) { yyyy += "20"; } else if (yyyy.Length != 4) { if (yyyy.Length > 4) { yyyy = yyyy.Substring(0, 4); } else { yyyy = DateTime.Now.ToString("yyyy"); } } else if (yyyy == "0000") { yyyy = DateTime.Now.ToString("yyyy"); } } else { return(DateTime.MinValue); } xDateString = string.Format("{0}/{1}/{2}", dd, MM, yyyy); break; case DateFormat.ddMMyyyyn: break; case DateFormat.ddMMyyyysp: break; case DateFormat.ddMMyyyyd: break; case DateFormat.ddMMMyyyys: break; case DateFormat.ddMMMyyyyn: break; case DateFormat.ddMMMyyyysp: break; case DateFormat.ddMMMyyyyd: break; case DateFormat.MMMddyyyyspcm: break; case DateFormat.ddMMMyyyyspwt: break; case DateFormat.ddMMMyyyyHHmm: break; case DateFormat.yyyyMMMdd: break; case DateFormat.yyyyMMdd: break; case DateFormat.yyMMddHHmm: break; case DateFormat.MMMdd: break; case DateFormat.ddMMMyyyyddd: break; case DateFormat.ddMMMyyyyml: break; default: break; } MutiLanguage.Languages lang = MutiLanguage.GetCultureType(); lang = isMutiLang ? lang : MutiLanguage.Languages.en_us; string langstr = isMutiLang ? MutiLanguage.EnumToString(lang) : MutiLanguage.EnumToString(MutiLanguage.Languages.en_us); System.Resources.ResourceManager rm = new System.Resources.ResourceManager(typeof(Date)); System.Resources.ResourceSet rs = rm.GetResourceSet(new System.Globalization.CultureInfo(langstr), true, true); return(DateTime.ParseExact(xDateString, rs.GetString(xDateFormat.ToString()), System.Globalization.DateTimeFormatInfo.InvariantInfo)); }
private void NKMDViewer_Load(object sender, EventArgs e) { Gl.glEnable(Gl.GL_COLOR_MATERIAL); Gl.glEnable(Gl.GL_DEPTH_TEST); Gl.glDepthFunc(Gl.GL_ALWAYS); Gl.glEnable(Gl.GL_LOGIC_OP); Gl.glDisable(Gl.GL_CULL_FACE); Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glEnable(Gl.GL_LINE_SMOOTH); Gl.glEnable(Gl.GL_BLEND); Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA); ViewableFile[] v = EveryFileExplorerUtil.GetOpenFilesOfType(typeof(KCL)); menuItem1.MenuItems.Clear(); foreach (var vv in v) { menuItem1.MenuItems.Add(vv.File.Name); } if (v.Length != 0) { menuItem1.MenuItems[0].Checked = true; KCL = v[0].FileFormat; } if (NKMD.ObjectInformation != null) { AddTab <MKDS.NKM.OBJI.OBJIEntry>("OBJI", NKMD.ObjectInformation); } if (NKMD.Path != null) { AddTab <PATH.PATHEntry>("PATH", NKMD.Path); } if (NKMD.Point != null) { AddTab <POIT.POITEntry>("POIT", NKMD.Point); } if (NKMD.KartPointStart != null) { AddTab <KTPS.KTPSEntry>("KTPS", NKMD.KartPointStart); } if (NKMD.KartPointJugem != null) { AddTab <KTPJ.KTPJEntry>("KTPJ", NKMD.KartPointJugem); } if (NKMD.KartPointSecond != null) { AddTab <KTP2.KTP2Entry>("KTP2", NKMD.KartPointSecond); } if (NKMD.KartPointCannon != null) { AddTab <KTPC.KTPCEntry>("KTPC", NKMD.KartPointCannon); } if (NKMD.KartPointMission != null) { AddTab <KTPM.KTPMEntry>("KTPM", NKMD.KartPointMission); } if (NKMD.CheckPoint != null) { AddTab <CPOI.CPOIEntry>("CPOI", NKMD.CheckPoint); } if (NKMD.CheckPointPath != null) { AddTab <CPAT.CPATEntry>("CPAT", NKMD.CheckPointPath); } if (NKMD.ItemPoint != null) { AddTab <IPOI.IPOIEntry>("IPOI", NKMD.ItemPoint); } if (NKMD.ItemPath != null) { AddTab <IPAT.IPATEntry>("IPAT", NKMD.ItemPath); } if (NKMD.EnemyPoint != null) { AddTab <EPOI.EPOIEntry>("EPOI", NKMD.EnemyPoint); } if (NKMD.EnemyPath != null) { AddTab <EPAT.EPATEntry>("EPAT", NKMD.EnemyPath); } if (NKMD.MiniGameEnemyPoint != null) { AddTab <MEPO.MEPOEntry>("MEPO", NKMD.MiniGameEnemyPoint); } if (NKMD.MiniGameEnemyPath != null) { AddTab <MEPA.MEPAEntry>("MEPA", NKMD.MiniGameEnemyPath); } if (NKMD.Area != null) { AddTab <AREA.AREAEntry>("AREA", NKMD.Area); } if (NKMD.Camera != null) { AddTab <CAME.CAMEEntry>("CAME", NKMD.Camera); } Bitmap b3 = OBJI.OBJ_2D01; System.Resources.ResourceSet s = OBJI.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, false, false); foreach (Object b in s) { Bitmap b2 = ((Bitmap)((System.Collections.DictionaryEntry)b).Value); BitmapData bd = b2.LockBits(new Rectangle(0, 0, b2.Width, b2.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); Gl.glTexEnvf(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_MODULATE); if ((String)((System.Collections.DictionaryEntry)b).Key != "start") { Gl.glBindTexture(Gl.GL_TEXTURE_2D, BitConverter.ToUInt16(BitConverter.GetBytes(ushort.Parse(((String)((System.Collections.DictionaryEntry)b).Key).Split('_')[1], System.Globalization.NumberStyles.HexNumber)).Reverse().ToArray(), 0)); } else { Gl.glBindTexture(Gl.GL_TEXTURE_2D, -1); } Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA8, b2.Width, b2.Height, 0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, bd.Scan0); b2.UnlockBits(bd); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_NEAREST); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_NEAREST); } init = true; Render(); Render(); }
protected void Page_PreRender(System.Object sender, System.EventArgs args) { System.Collections.Specialized.ListDictionary addressbook = GetAddressbook(addressbookselect.Value, Application["sharpwebmail/send/addressbook"]); if (addressbook != null && !addressbook["type"].Equals("none")) { this.AddressBookDataGrid.PageSize = (int)addressbook["pagesize"]; System.Data.DataTable data = GetDataSource(addressbook, false, Session["client"] as anmar.SharpWebMail.IEmailClient); if (data != null) { if (this._sort_expression != null && this._sort_expression.Length > 0) { if (this._sort_expression.IndexOf("[NameColumn]") != -1) { this._sort_expression = this._sort_expression.Replace("[NameColumn]", addressbook["NameColumn"].ToString()); } else if (this._sort_expression.IndexOf("[EmailColumn]") != -1) { this._sort_expression = this._sort_expression.Replace("[EmailColumn]", addressbook["EmailColumn"].ToString()); } else { this._sort_expression = null; } if (this._sort_expression != null) { data.DefaultView.Sort = this._sort_expression; } } this.AddressBookDataGrid.DataSource = data.DefaultView; } // Full Page Mode if (this.SharpUI != null) { bool allowupdate = (bool)addressbook["allowupdate"]; // Editable columns? if (this.AddressBookDataGrid.Columns.Count > 1) { this.AddressBookDataGrid.Columns[this.AddressBookDataGrid.Columns.Count - 1].Visible = allowupdate; this.AddressBookDataGrid.Columns[this.AddressBookDataGrid.Columns.Count - 2].Visible = allowupdate; } // Editable links? System.Web.UI.HtmlControls.HtmlAnchor link = (System.Web.UI.HtmlControls.HtmlAnchor) this.SharpUI.FindControl("addressbookEntryInsert"); if (link != null) { link.HRef = System.String.Concat("addressbook_edit.aspx?book=", System.Web.HttpUtility.UrlEncode(this.addressbookselect.Value)); link.Visible = allowupdate; } // Editable links? link = (System.Web.UI.HtmlControls.HtmlAnchor) this.SharpUI.FindControl("addressbookImportExport"); if (link != null) { link.HRef = System.String.Concat("addressbook_data.aspx?book=", System.Web.HttpUtility.UrlEncode(this.addressbookselect.Value)); link.Visible = allowupdate; } } } System.Resources.ResourceSet resources = (System.Resources.ResourceSet)Session["resources"];; // Pop-up mode if (this.SharpUI == null) { this.AddressBookDataGrid.Columns[0].HeaderText = resources.GetString("addressbookNameLabel"); } this.AddressBookDataGrid.Columns[0].HeaderStyle.Wrap = false; this.AddressBookDataGrid.DataBind(); }
private void frmMain_Load(object sender, EventArgs e) { mapViewer1.DrawImages = new List <Texture2D>(); string defaultTilesetPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Resources\\default.tileset"; if (!File.Exists(defaultTilesetPath)) { if (MessageBox.Show("No default tileset found. Create one now?", "", MessageBoxButtons.YesNo) == DialogResult.No) { Application.Exit(); return; } EditTileset(); if (tileset.Tiles.Count == 0) { Application.Exit(); return; } } else { tileset.LoadFromFile(defaultTilesetPath); mapViewer1.TileSize = tileset.Images.ImageSize.Width; RegistryAccess.AddRecentFile(tileset.FileName, RegistrySetting.RecentTilesets); RefreshListViewer(); } //set up graphics device to pass to the created content manager GraphicsDeviceService gds = GraphicsDeviceService.AddRef(Handle, ClientSize.Width, ClientSize.Height); ServiceContainer service = new ServiceContainer(); service.AddService <IGraphicsDeviceService>(gds); ContentManager cont = new ContentManager(service, EditorConst.CONTENT_ROOT_DIR); Left = (int)RegistryAccess.GetValue(RegistrySetting.WindowX); Top = (int)RegistryAccess.GetValue(RegistrySetting.WindowY); Size = new Size((int)RegistryAccess.GetValue(RegistrySetting.WindowWidth), (int)RegistryAccess.GetValue(RegistrySetting.WindowHeight)); //if (((int)RegistryAccess.GetValueOrDefault(RegistrySetting.WindowMaximized, EditorConst.WINDOW_DEFAULT_MAXIMIZATION)).ToBool()) WindowState = FormWindowState.Maximized; //WindowState = FormWindowState.Maximized; // WindowState = FormWindowState.Maximized; mapViewer1.GridText = cont.Load <Texture2D>("gridbox"); mapViewer1.SelectorText = cont.Load <Texture2D>("selector"); System.Resources.ResourceSet res = GenericMapEditor.Properties.Resources.ResourceManager.GetResourceSet(new System.Globalization.CultureInfo("en-us"), true, true); for (int i = 0; i < (int)SpecialTileSpec.NUM_VALS; ++i) { cmbSpecialType.Items.Add(Enum.GetName(typeof(SpecialTileSpec), (SpecialTileSpec)i)); } cmbSpecialType.SelectedIndex = 0; for (int i = (int)WarpAnim.NONE; i < (int)WarpAnim.NUM_VALS; ++i) { cmbWarpAnim.Items.Add(Enum.GetName(typeof(WarpAnim), (WarpAnim)i)); } cmbWarpAnim.SelectedIndex = 0; RefreshRecentList(mnuFileRecent, RegistrySetting.RecentMaps); RefreshRecentList(recentToolStripMenuItem, RegistrySetting.RecentTilesets); }