示例#1
0
        private void ScrollToTarget(BarcodeHistoryUserControl target, string textToSet = "")
        {
            if (CurrentBarcode != null)
            {
                CurrentBarcode.MainGrid.Background = (SolidColorBrush) new BrushConverter().ConvertFrom(ColorConstants.Blue);
            }
            CurrentBarcode = target;
            CurrentBarcode.MainGrid.Background = (SolidColorBrush) new BrushConverter().ConvertFrom(ColorConstants.Orange);
            HistoryScrollViewer.ScrollToVerticalOffset(target.TranslatePoint(new System.Windows.Point(), HistoryStackpanel).Y);

            if (string.IsNullOrEmpty(textToSet))
            {
                ScanTextBox.Text = target.Barcode.Text.Replace(BarcodeConstants.FNC1.ToString(), BarcodeConstants.FNC1_DisplayPlaceholder);
            }
            else
            {
                ScanTextBox.Text = textToSet.Replace(BarcodeConstants.FNC1.ToString(), BarcodeConstants.FNC1_DisplayPlaceholder);
            }

            BarcodeTypeComboBox.SelectedItem = target.Barcode.Format;
            ScanTextBox.SelectAll();
        }
示例#2
0
        private void EvaluateLine(string line)
        {
            switch (line)
            {
            case "#reset":
                ResetCode();
                return;

            case "#open":
                FileOpen();
                return;

            case "#save":
                FileSave();
                return;
            }

            AddUserInput(line);

            SetComputing(true);

            var token = _tokenSource.Token;

            MobLang.Program.RecursionDelegate checkIfCancelled = token.ThrowIfCancellationRequested;
            MobLang.Program.OnRecursion += checkIfCancelled;
            _task = Task.Factory.StartNew(() => _interpreter.Execute(line, true), token);
            _task.ContinueWith(async _ =>
            {
                await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    SetComputing(false);
                    HistoryScrollViewer.UpdateLayout();
                    HistoryScrollViewer.ChangeView(null, HistoryScrollViewer.ScrollableHeight, null);
                    SavedCode.Add(line);
                });
            }, token);
        }
 private void ChangeGridWidth()
 {
     HistoryChartGrid.Width = widthForSinglePeriod * periods.Count - 1;
     HistoryScrollViewer.ScrollToRightEnd();
 }