public FormSIDCConverter() { InitializeComponent(); _librarian = new Librarian(); _librarian.IsLogging = true; _badSymbol = _librarian.MakeSymbol(1001980000, 1000000000); _symbol = _badSymbol; updateControls(); }
public Symbol MakeSymbol(SIDC sidc) { Symbol s = new Symbol(this, sidc, _drawColoredOCABars, _drawCivilianFrames); if (s.SymbolStatus == SymbolStatusEnum.statusEnumInvalid) { s = null; } return s; }
public Symbol MakeSymbol(UInt32 partA, UInt32 partB) { SIDC sid = new SIDC(partA, partB); Symbol s = new Symbol(this, sid, _drawColoredOCABars, _drawCivilianFrames); if (s.SymbolStatus == SymbolStatusEnum.statusEnumInvalid) { s = null; } return s; }
public Symbol MakeSymbol(string legacyStandard, string legacySIDC) { Symbol s = null; if (legacySIDC.Length == 15) { legacyStandard = legacyStandard.ToUpper(); legacySIDC = legacySIDC.Replace('*', '-'); legacySIDC = legacySIDC.ToUpper(); s = new Symbol(this, legacyStandard, legacySIDC, _drawColoredOCABars, _drawCivilianFrames); if (s.SymbolStatus == SymbolStatusEnum.statusEnumInvalid) { logger.Warn("SIDC " + legacySIDC + " is an invalid symbol."); s = null; } } else { logger.Error("SIDC " + legacySIDC + " is not 15 characters in length."); } return s; }
public Librarian(string configPath = "") { InitializeNLog(); // // Deserialize the configuration xml to get the location of the symbology library // XmlSerializer serializer = new XmlSerializer(typeof(JMSMLConfig)); serializer.UnknownNode += new XmlNodeEventHandler(serializer_UnknownNode); serializer.UnknownAttribute += new XmlAttributeEventHandler(serializer_UnknownAttribute); if (configPath != "") { _configPath = configPath; } else { string s = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); _configPath = Path.Combine(s, "jmsml.config"); } if (File.Exists(_configPath)) { using(FileStream fs = new FileStream(_configPath, FileMode.Open, FileAccess.Read)) { if (fs.CanRead) { _configData = (JMSMLConfig)serializer.Deserialize(fs); } else { logger.Error("Unreadable config file: " + _configPath); } } } else { logger.Error("Config file is missing: " + _configPath); } // // If the config data was good then... // if(_configData != null) { // // Deserialize the library's base xml to get the base contents of the symbology standard // serializer = new XmlSerializer(typeof(Library)); string path = _configData.LibraryPath + "/" + _configData.LibraryName; if (File.Exists(path)) { using (FileStream fsLibrary = new FileStream(path, FileMode.Open, FileAccess.Read)) { if (fsLibrary.CanRead) { this._library = (Library)serializer.Deserialize(fsLibrary); // // Deserialize each symbolSet xml // foreach (LibraryDimension dimension in this._library.Dimensions) { foreach (LibraryDimensionSymbolSetRef ssRef in dimension.SymbolSets) { ushort ssCode = CodeToShort(ssRef.SymbolSetCode); if (!_sortedSymbolSets.ContainsKey(ssCode)) { path = _configData.LibraryPath + "/" + ssRef.Instance; if (File.Exists(path)) { using (FileStream fsSymbolSet = new FileStream(path, FileMode.Open, FileAccess.Read)) { if (fsSymbolSet.CanRead) { serializer = new XmlSerializer(typeof(SymbolSet)); SymbolSet ss = (SymbolSet)serializer.Deserialize(fsSymbolSet); if (ss != null) { _sortedSymbolSets.Add(ssCode, ss); _symbolSets.Add(ss); } } else { logger.Error("Unreadable symbol set: " + path); } } } else { logger.Error("Symbol set is missing: " + path); } } } } // // Create special invalid and retired symbols for this library // _invalidSymbol = new Symbol(this, SIDC.INVALID); _retiredSymbol = new Symbol(this, SIDC.RETIRED); } else { logger.Error("Unreadable symbol library: " + path); } } } else { logger.Error("Specified library is missing: " + path); } } }
private void text2525D_2_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Return) { _symbol = _librarian.MakeSymbol(new SIDC(text2525D_1.Text, text2525D_2.Text)); updateControls(); } }
private void text2525C_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Return) { _symbol = _librarian.MakeSymbol("2525C", text2525C.Text); updateControls(); } else { TextBox Box = (sender as TextBox); if (Box.SelectionStart < Box.TextLength && !Char.IsControl(e.KeyChar)) { int CacheSelectionStart = Box.SelectionStart; //Cache SelectionStart as its reset when the Text property of the TextBox is set. StringBuilder sb = new StringBuilder(Box.Text); //Create a StringBuilder as Strings are immutable sb[Box.SelectionStart] = e.KeyChar; //Add the pressed key at the right position Box.Text = sb.ToString(); //SelectionStart is reset after setting the text, so restore it Box.SelectionStart = CacheSelectionStart + 1; //Advance to the next char } } }
private void listBox2_SelectedIndexChanged(object sender, EventArgs e) { string s = listBox2.SelectedItem.ToString(); string[] l = s.Split('\t'); string[] ll = l[0].Split(','); _symbol = _librarian.MakeSymbol(new SIDC(ll[0],ll[1])); updateControls(); }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { string s = listBox1.SelectedItem.ToString(); string[] l = s.Split('\t'); _symbol = _librarian.MakeSymbol("2525C", l[0]); updateControls(); }