public override void DoPrint(string[] lines)
        {
            var document = new FormattedDocument(lines, Printer.CharsPerLine).GetFormattedDocument().ToArray();

            foreach (var line in document)
            {
                var data = line.Contains("<") ? line.Split('<').Where(x => !string.IsNullOrEmpty(x)).Select(x => '<' + x) : line.Split('#');
                foreach (var s in data)
                {
                    if (s.Trim().ToLower() == "<w>")
                    {
                        System.Threading.Thread.Sleep(100);
                    }
                    if (s.ToLower().StartsWith("<lb"))
                    {
                        SerialPortService.WritePort(Printer.ShareName, RemoveTag(s) + "\n\r");
                    }
                    else if (s.ToLower().StartsWith("<xct"))
                    {
                        var lineData = s.ToLower().Replace("<xct", "").Trim(new[] { ' ', '<', '>' });
                        SerialPortService.WriteCommand(Printer.ShareName, lineData, Printer.CodePage);
                    }
                    else
                    {
                        SerialPortService.WritePort(Printer.ShareName, RemoveTag(s), Printer.CodePage);
                    }
                }
            }
            SerialPortService.ResetCache();
        }
Beispiel #2
0
        public Shell(IApplicationState applicationState)
        {
            _applicationState = applicationState;
            InitializeComponent();
            LanguageProperty.OverrideMetadata(
                typeof(FrameworkElement),
                new FrameworkPropertyMetadata(
                    XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            var selectedIndexChange = DependencyPropertyDescriptor.FromProperty(Selector.SelectedIndexProperty, typeof(TabControl));

            selectedIndexChange.AddValueChanged(MainTabControl, MainTabControlSelectedIndexChanged);

            EventServiceFactory.EventService.GetEvent <GenericEvent <User> >().Subscribe(x =>
            {
                if (x.Topic == EventTopicNames.UserLoggedIn)
                {
                    UserLoggedIn(x.Value);
                }
                if (x.Topic == EventTopicNames.UserLoggedOut)
                {
                    UserLoggedOut(x.Value);
                }
            });

            EventServiceFactory.EventService.GetEvent <GenericEvent <UserControl> >().Subscribe(
                x =>
            {
                if (x.Topic == EventTopicNames.DashboardClosed)
                {
                    SerialPortService.ResetCache();
                    EventServiceFactory.EventService.PublishEvent(EventTopicNames.ResetCache, true);
                }
            });

            UserRegion.Visibility      = Visibility.Collapsed;
            RightUserRegion.Visibility = Visibility.Collapsed;
            Height = Properties.Settings.Default.ShellHeight;
            Width  = Properties.Settings.Default.ShellWidth;

            _timer         = new DispatcherTimer();
            _timer.Tick   += TimerTick;
            TimeLabel.Text = "...";

#if !DEBUG
            WindowStyle = WindowStyle.None;
            WindowState = WindowState.Maximized;
#endif
        }