コード例 #1
0
        private async void TextBox_KeyUp(object sender, KeyRoutedEventArgs e)
        {
            errorBox.Opacity = 0;
            if (e.Key == Windows.System.VirtualKey.Back)
            {
                return;
            }


            if (CodeTextBox.Text.Count() == 6)
            {
                // join party
                CodeTextBox.IsEnabled = false;
                ShowLoading("joining party");
                if (await DataService.Instance.InitDataServiceAsClient(CodeTextBox.Text))
                {
                    Frame.Navigate(typeof(MainPage), false);
                }
                else
                {
                    HideLoading();
                    CodeTextBox.IsEnabled = true;
                    CodeTextBox.Focus(FocusState.Keyboard);
                    errorBox.Opacity = 1;
                    errorBox.Offset(10).Then().Offset(-10).Then().Offset(10).Then().Offset(-10).Then().Offset(0).SetDurationForAll(30).Start();
                }
            }
            else if (CodeTextBox.Text.Count() > 6)
            {
                CodeTextBox.Text = CodeTextBox.Text.Substring(0, 6);
                e.Handled        = true;
                CodeTextBox.Select(6, 0);
            }
        }
コード例 #2
0
        public void SetOffset(int offset, int count = 0)
        {
            //CCSProfix = String.Empty;
            if (count > 0)
            {
                CodeTextBox.Select(offset, count);
            }
            else
            {
                CodeTextBox.CaretOffset = offset;
            }
            int          line   = CodeTextBox.Row;
            int          column = CodeTextBox.Column;
            ScrollViewer sv     = CodeTextBox.ScrollViewer;

            if (sv == null)
            {
                return;
            }
            double y = line * 19 - 25 - sv.ViewportHeight / 2;

            y = Math.Max(0, y);
            sv.ScrollToVerticalOffset(y);
            double x = column * 16 - sv.ViewportWidth / 2;

            x = Math.Max(0, x);
            sv.ScrollToHorizontalOffset(x);
        }
コード例 #3
0
        private void LexicalAnalyzerItem_Click(object sender, EventArgs e)
        {
            LexicalAnalyzer lexicalAnalyzer = new LexicalAnalyzer(this.CodeTextBox.Text);

            lexicalAnalyzer.Analyses(out tokenList, out errorList);
            int record_mouse = CodeTextBox.SelectionStart;

            ColorWord();
            CodeTextBox.Select(record_mouse, record_mouse);
            PrintResult(tokenList, errorList);
        }
コード例 #4
0
        private void OpenFileItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Filter = "text(*.txt)|*.txt|(*.yz)|*.yz";
            openFile.ShowDialog();
            filename = openFile.FileName;
            try
            {
                CodeTextBox.Text = File.ReadAllText(filename, System.Text.Encoding.Default).Replace("\r", "");
            }
            catch { }
            CodeTextBox.Select(0, 0);
        }
コード例 #5
0
        private void AboutItem_Click(object sender, EventArgs e)
        {
            string path = System.Environment.CurrentDirectory.Replace('\\', '/') + "/About.txt";

            try
            {
                FileInfo file = new FileInfo(path);
                if (!file.Exists)
                {
                    CodeTextBox.Text = "燕子编辑器";
                }
                else
                {
                    CodeTextBox.Text = File.ReadAllText(path, System.Text.Encoding.Default).Replace("\r", "");
                }
            }
            catch
            { }
            CodeTextBox.Select(0, 0);
        }
コード例 #6
0
        private void ColorWord()
        {
            CodeTextBox.Select(0, this.CodeTextBox.Text.Length);
            CodeTextBox.SelectionColor = Color.Black;
            foreach (Token token in tokenList)
            {
                switch (token.Type)
                {
                case WordType.Keyword:
                    CodeTextBox.Select(token.Index, token.Content.Length);
                    CodeTextBox.SelectionColor = Color.Blue;
                    break;

                case WordType.CharConstant:
                    CodeTextBox.Select(token.Index, token.Content.Length);
                    CodeTextBox.SelectionColor = Color.Brown;
                    break;

                case WordType.StringConstant:
                    CodeTextBox.Select(token.Index, token.Content.Length);
                    CodeTextBox.SelectionColor = Color.Green;
                    break;

                case WordType.Comment:
                    CodeTextBox.Select(token.Index, token.Content.Length);
                    CodeTextBox.SelectionColor = Color.YellowGreen;
                    break;

                case WordType.Decimal:
                case WordType.Octonary:
                case WordType.Hexadecimal:
                case WordType.FloatConstant:
                    CodeTextBox.Select(token.Index, token.Content.Length);
                    CodeTextBox.SelectionColor = Color.Purple;
                    break;
                }
            }
        }