private void DoSaveLocalizationProfile() { LocalizationProfile.InputFiles = tbInputFiles.Text; LocalizationProfile.LocalizerType = LocalizerType; LocalizationProfile.RootFolderPath = tbRootFolder.Text; LocalizationProfile.ReferenceFilePath = tbReferenceFile.Text; try { using (XmlTextWriter xml = new XmlTextWriter(LocalizationProfileFilePath, Encoding.UTF8)) { xml.Formatting = Formatting.Indented; xml.Indentation = 4; System.Xml.Serialization.XmlSerializer s = new XmlSerializer(typeof(LocalizationProfile)); s.Serialize(xml, LocalizationProfile); } UpdateWindowTitle(); WindowLogger.Log("Profile saved successfully."); } catch (Exception ex) { MessageBox.Show("Localizer could not save the file. Check status for more details!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); WindowLogger.Log(ex.Message); } }
private void DoLoadLocalizationProfile() { try { using (XmlTextReader xml = new XmlTextReader(LocalizationProfileFilePath)) { System.Xml.Serialization.XmlSerializer s = new XmlSerializer(typeof(LocalizationProfile)); LocalizationProfile = (LocalizationProfile)s.Deserialize(xml); } tbInputFiles.Text = LocalizationProfile.InputFiles; cbLocalizerType.SelectedItem = LocalizationProfile.LocalizerType; tbRootFolder.Text = LocalizationProfile.RootFolderPath; tbReferenceFile.Text = LocalizationProfile.ReferenceFilePath; UpdateWindowTitle(); WindowLogger.Log("Profile loaded successfully."); DoLoadEnvironment(); } catch (Exception ex) { WindowLogger.Log(ex.Message); MessageBox.Show("Localizer could not open this file. File format is not supported", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public WndMain() { InitializeComponent(); _context = new DataServerDataContext(); this.DataContext = _context; _logger = UnityContainerHost.Container.Resolve <IWindowLogger>() as WindowLogger; if (_logger != null) { _logger.NewLogEvent += NewLogEvent; _logger.Info("数据服务器", "程序启动"); } _dataSourceWorker = new BackgroundWorker(); _dataSourceWorker.DoWork += _dataSourceWorker_DoWork; _dataSourceWorker.RunWorkerCompleted += _dataSourceWorker_RunWorkerCompleted; _serverWorker = new BackgroundWorker(); _serverWorker.DoWork += _serverWorker_DoWork; _serverWorker.RunWorkerCompleted += _serverWorker_RunWorkerCompleted; _isStartDataSource = false; _isStartServer = false; }
private void Run() { List <String> fileNames = tbInputFiles.Text.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToList(); List <String> includes = new List <string>(); List <String> excludes = new List <string>(); foreach (var fileName in fileNames) { if (fileName.StartsWith("-")) { excludes.Add(fileName.Substring(1)); } else if (!fileName.StartsWith("#")) { includes.Add(fileName); } } try { EntityExtractor ext = LocalizationModule.Create(LocalizerType).Extractor; ext.Logger = WindowLogger; Dictionary <String, LocalizableEntity> map1 = new Dictionary <string, LocalizableEntity>(); ext.ProcessFileList(includes.ToArray(), excludes.ToArray(), RootPathResolved, FileExtension, map1); map1 = map1.OrderBy(a => a.Value.ShallowEntityPath).ToDictionary(a => a.Key, a => a.Value); Dictionary <String, LocalizableEntity> map2 = new Dictionary <string, LocalizableEntity>(); try { ext.ProcessFile(ReferenceResolved, map2); } catch (Exception ex) { WindowLogger.LogFormat("Warning: error parsing reference input ({0})", ex.Message); } map2 = map2.OrderBy(a => a.Value.ShallowEntityPath).ToDictionary(a => a.Key, a => a.Value); Dictionary <String, LocalizableEntity> map3 = new Dictionary <string, LocalizableEntity>(); Diff(map1, map2, map3); map3 = map3.OrderBy(a => a.Value.ShallowEntityPath).ToDictionary(a => a.Key, a => a.Value); dgvNew.DataSource = GetLocalizationGridDataSource(map1, false); dgvCurrent.DataSource = GetLocalizationGridDataSource(map2, true); dgvDeleted.DataSource = GetLocalizationGridDataSource(map3, false); } catch (Exception ex) { WindowLogger.Log(ex.Message); } }
static void Main(string[] args) { IList <ILogger> loggers = new List <ILogger>(); ILogger consoleLogger = new ConsoleLogger(); ILogger databaseLogger = new DatabaseLogger(); ILogger windowLogger = new WindowLogger(); loggers.Add(consoleLogger); loggers.Add(databaseLogger); loggers.Add(windowLogger); Loguear(loggers); }
public static void Decorator() { IWindow windowWithScroll = new HorizontalScrollWindow(new Window()); Console.WriteLine(windowWithScroll.Draw()); Console.WriteLine("------------------"); IWindow windowWithBorderAndScroll = new WindowLogger(windowWithScroll); Console.WriteLine(windowWithBorderAndScroll.Draw()); Console.ReadLine(); }
public MainWindow() { InitializeComponent(); LocalizationProfile = new LocalizationProfile(); LocalizationProfileFilePath = null; EnvironmentVariables = new Windows.EnvironmentVariables(); dgvNew.AutoGenerateColumns = false; dgvCurrent.AutoGenerateColumns = false; dgvDeleted.AutoGenerateColumns = false; WindowLogger = new WindowLogger(lbStatus); }
private void DoSaveEnvironment() { try { var defaults = Path.Combine(ProjectFolder ?? "", "defaults.xml"); using (XmlTextWriter xml = new XmlTextWriter(defaults, Encoding.UTF8)) { System.Xml.Serialization.XmlSerializer s = new XmlSerializer(typeof(EnvironmentVariables)); s.Serialize(xml, EnvironmentVariables); } WindowLogger.Log("Environment variables saved successfully."); } catch (Exception ex) { WindowLogger.Log("Could not save environment: " + ex.Message); } }
private void DoLoadEnvironment() { try { var defaults = Path.Combine(ProjectFolder ?? "", "defaults.xml"); if (!File.Exists(defaults)) { throw new Exception("No defaults.xml file provided in project folder!"); } using (XmlTextReader xml = new XmlTextReader(defaults)) { System.Xml.Serialization.XmlSerializer s = new XmlSerializer(typeof(EnvironmentVariables)); EnvironmentVariables = (EnvironmentVariables)s.Deserialize(xml); } WindowLogger.Log("Environment variables loaded successfully."); } catch (Exception ex) { WindowLogger.Log("Could not load environment: " + ex.Message); EnvironmentVariables = new Dextop.Localizer.Windows.EnvironmentVariables(); } }