//--------------------// #region Handlers /// <inheritdoc/> protected override void OnInitialize() { #region File handling if (Path.IsPathRooted(FilePath)) { _fullPath = FilePath; if (!_overwrite && File.Exists(_fullPath)) { // Load existing file Log.Info("Load file: " + _fullPath); locale = LocaleFile.Load(_fullPath); } else { // Create new file Log.Info("Create file: " + _fullPath); locale = new XmlDictionary { { "Test", "A" } }; LocaleFile.Save(_fullPath, locale); } } else { // File name only? Might not save to same dir loaded from! Log.Info("Load file: " + FilePath); locale = LocaleFile.FromContent(FilePath); _fullPath = ContentManager.CreateFilePath("GUI/Language", FilePath); } #endregion base.OnInitialize(); }
public bool ApplyChanges() { try { fSettings.HideClosedTanks = fView.HideClosedTanksCheck.Checked; fSettings.ExitOnClose = fView.ExitOnCloseCheck.Checked; fSettings.HideAtStartup = fView.HideAtStartupCheck.Checked; fSettings.HideLosses = fView.HideLossesCheck.Checked; LocaleFile currentLocale = (fView.LocaleCombo.SelectedItem as LocaleFile); fSettings.CurrentLocale = (currentLocale != null) ? currentLocale.Code : Localizer.LS_DEF_CODE; fSettings.LengthUoM = fView.LengthUoMCombo.GetSelectedTag <MeasurementUnit>(); fSettings.VolumeUoM = fView.VolumeUoMCombo.GetSelectedTag <MeasurementUnit>(); fSettings.MassUoM = fView.MassUoMCombo.GetSelectedTag <MeasurementUnit>(); fSettings.TemperatureUoM = fView.TemperatureUoMCombo.GetSelectedTag <MeasurementUnit>(); fSettings.ChannelEnabled = fView.ChannelEnabledCheck.Checked; fSettings.ChannelName = fView.ChannelNameCombo.Text; fSettings.ChannelParameters = fView.ChannelParametersCombo.Text; if (fView.AutorunCheck.Checked) { AppHost.RegisterStartup(); } else { AppHost.UnregisterStartup(); } return(true); } catch (Exception ex) { fLogger.WriteError("ApplyChanges()", ex); return(false); } }
/// <inheritdoc/> protected override void OnSaveFile() { // Sort alphabetically before saving locale.Sort(); // OnUpdate() will automatically be called Log.Info("Save file: " + _fullPath); string directory = Path.GetDirectoryName(_fullPath); if (!string.IsNullOrEmpty(directory)) { Directory.CreateDirectory(directory); } LocaleFile.Save(_fullPath, locale); base.OnSaveFile(); }
public IEnumerable <Run> Bibliography(LocaleFile locale, IEnumerable <Citation> citations) { Interpreter interpreter = new Interpreter(Style, locale) { CurrentEntry = Style.Bibliography }; var runs = new List <Run>(); foreach (var citation in citations) { interpreter.Citation = citation; Style.Bibliography !.Layout !.Evaluate(interpreter); runs.Add(interpreter.Run); interpreter.Clear(); } return(runs); }
public Run Cite(LocaleFile locale, IEnumerable <Citation> citations) { Interpreter interpreter = new Interpreter(Style, locale) { CurrentEntry = Style.Citation }; if (Style.Citation?.Sort != null) { citations = Style.Citation.Sort.Sort(interpreter, citations); } var runs = new List <Run>(); var layout = Style.Citation !.Layout !; foreach (var citation in citations) { interpreter.Citation = citation; layout.Evaluate(interpreter); runs.Add(interpreter.Run); interpreter.Clear(); } var multiRun = new List <Run>(); var delimiter = interpreter.Create(layout.Delimiter, layout); var composedRuns = runs.Where(e => !e.IsEmpty).Cast <ComposedRun>().ToArray(); for (int i = 0; i < composedRuns.Length; i++) { multiRun.AddRange(composedRuns[i].Children); if (delimiter != null && i < composedRuns.Length - 1) { multiRun.Add(delimiter); } } return(new ComposedRun(string.Empty, multiRun, false)); }
public Citations(Processor processor, LocaleFile locale) { Processor = processor; Locale = locale; }
public Locale(LocaleFile file) { Culture = Culture.GetCulture(file.XmlLang !); File = file; }
public Locale(Culture culture) { Culture = culture; File = LocaleFile.Defaults.FirstOrDefault(e => e.XmlLang == culture.ToString()); }
public Locale(LocaleFile file) { Culture = new Culture(file.XmlLang); File = file; }