示例#1
0
        private void ErrorList_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                ListViewItem item  = sender as ListViewItem;
                CompileError error = item.Content as CompileError;

                if (error.IsActive)
                {
                    // Позиционируем на позицию курсор
                    CodeEditorView.SetCaretTo(error.File, error.BeginOffset);
                }

                e.Handled = true;
            }
            else if (e.Key == Key.Space)
            {
                ListViewItem item = sender as ListViewItem;
                CompileError obj  = item.Content as CompileError;

                if (CodeEditorView.GetIfAnotherErrorColor(obj.ErrorType))
                {
                    CodeEditorView.UnSetAnotherErrorColor(obj.ErrorType);
                }
                else
                {
                    CodeEditorView.SetAnotherErrorColor(obj.ErrorType);
                }

                Dict.DoPulse();
            }
        }
示例#2
0
        // ----------------------------------------------------------------------------------------
        public void HighlightError(CodeFile file, CompileError error)
        {
            OpenTab(file, false);

            _colorizeErrorForPopUp.Error = error;
            Redraw();
        }
示例#3
0
        // ----------------------------------------------------------------------------------------
        #region Errors Selecting
        private void ScrollToErrorInCurrentLine()
        {
            CompileError lastError = null;

            foreach (CompileError err in _errorListView.ErrorsList)
            {
                if (err.IsActive && err.File == CurrentCodeFile && err.BeginLine == Line)
                {
                    lastError = err;
                    //break;
                }
            }

            if (lastError != null)
            {
                _errorListView.ScrollToError(lastError);
            }

            foreach (CompileError err in _errorListView.ErrorsList)
            {
                if (err.IsActive && err.File == CurrentCodeFile && err.BeginLine == Line)
                {
                    _errorListView.ScrollToError(err);
                    break;
                }
            }
        }
示例#4
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            CompileError error0 = values[0] as CompileError;    // Current selected error
            CompileError error1 = values[1] as CompileError;    // LastSelectedError

            bool isFocused = (bool)values[2];

            return(isFocused && error0 == error1);
        }
示例#5
0
        private void ErrorItem_UnSelected(object sender, RoutedEventArgs e)
        {
            ListViewItem item  = sender as ListViewItem;
            CompileError error = item.Content as CompileError;

            if (error != null && error.IsActive && IsFocused)
            {
                CodeEditorView.UnHighlightError();
            }

            //e.Handled = true;
        }
示例#6
0
        /*
         * err.IsActive && err.File == CurrentCodeFile && err.BeginLine == Line
         * err.IsActive && err.File == CurrentCodeFile && err.BeginLine == Line
         * err.IsActive && err.File == CurrentCodeFile && err.BeginOffset == AvalonEditor.TextArea.Caret.Offset
         */

        public void SelectError(CompileError err, bool setFocus, bool setEditorFocus)
        {
            _needSetEditorFocus    = setEditorFocus;
            _needSetFocus          = setFocus;
            listView1.SelectedItem = err;
            listView1.ScrollIntoView(err);

            if (err != null)
            {
                LastSelectedError = err;
            }
        }
示例#7
0
        private void ErrorItem_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            ListViewItem item  = sender as ListViewItem;
            CompileError error = item.Content as CompileError;

            if (error.IsActive)
            {
                // Позиционируем на позицию курсор
                CodeEditorView.SetCaretTo(error.File, error.BeginOffset);
            }

            e.Handled = true;
        }
示例#8
0
        private void InitPopups()
        {
            AvalonEditor.MouseHover += (sender, args) =>
            {
                if (CurrentCodeFile == null)
                {
                    return;     // Текущего файла нет совсем
                }
                TextViewPosition?pos = AvalonEditor.GetPositionFromPoint(Mouse.GetPosition(AvalonEditor.TextArea));
                if (!pos.HasValue)
                {
                    return;     // Не в области редактора
                }
                int          offset = AvalonEditor.Document.GetOffset(pos.Value.Location);
                CompileError error  = CurrentCodeFile.GetErrorByOffset(offset);

                if (error == null)
                {
                    return;     // Ошибки в этом месте нет
                }
                _errorPopup                    = new InsightWindow(AvalonEditor.TextArea);
                _errorPopup.StartOffset        = offset + 1;
                _errorPopup.EndOffset          = offset + 1;
                _errorPopup.Padding            = new Thickness(10, 0, 10, 0);
                _errorPopup.Content            = error.GetDiagnostic();
                _errorPopup.CloseAutomatically = false;

                _colorizeErrorForPopUp.Error = error;       // Выделить цветом ошибку, над которой аэростат
                Redraw();
                AvalonEditor.TextArea.Cursor             = Cursors.Hand;
                AvalonEditor.PreviewMouseLeftButtonDown += GoToMouseError;

                //_errorListView.SelectError(error, false);

                _errorPopup.Show();
            };

            AvalonEditor.MouseHoverStopped += (sender, args) =>
            {
                if (_errorPopup != null)
                {
                    AvalonEditor.PreviewMouseLeftButtonDown -= GoToMouseError;
                    _colorizeErrorForPopUp.Error             = null;
                    AvalonEditor.TextArea.Cursor             = null;
                    Redraw();

                    _errorPopup.Close();
                }
            };
        }
示例#9
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            CompileError.Type err = (CompileError.Type)values[0];
            //int lang = (int) values[1];
            switch (err)
            {
            case CompileError.Type.Type0:
                return(CompileError.NeedFullDiagnostic(CompileError.Type.Type0) ? _localString.Dict["Err_0_full"] : _localString.Dict["Err_0_short"]);

            case CompileError.Type.Type1:
                return(CompileError.NeedFullDiagnostic(CompileError.Type.Type1) ? _localString.Dict["Err_1_full"] : _localString.Dict["Err_1_short"]);

            case CompileError.Type.Type2:
                return(CompileError.NeedFullDiagnostic(CompileError.Type.Type2) ? _localString.Dict["Err_2_full"] : _localString.Dict["Err_2_short"]);

            case CompileError.Type.Type3:
                return(CompileError.NeedFullDiagnostic(CompileError.Type.Type3) ? _localString.Dict["Err_3_full"] : _localString.Dict["Err_3_short"]);

            case CompileError.Type.Type4:
                return(CompileError.NeedFullDiagnostic(CompileError.Type.Type4) ? _localString.Dict["Err_4_full"] : _localString.Dict["Err_4_short"]);

            case CompileError.Type.Type5:
                return(CompileError.NeedFullDiagnostic(CompileError.Type.Type5) ? _localString.Dict["Err_5_full"] : _localString.Dict["Err_5_short"]);

            case CompileError.Type.Type6:
                return(CompileError.NeedFullDiagnostic(CompileError.Type.Type6) ? _localString.Dict["Err_6_full"] : _localString.Dict["Err_6_short"]);

            case CompileError.Type.Type7:
                return(CompileError.NeedFullDiagnostic(CompileError.Type.Type7) ? _localString.Dict["Err_7_full"] : _localString.Dict["Err_7_short"]);

            case CompileError.Type.Type8:
                return(CompileError.NeedFullDiagnostic(CompileError.Type.Type8) ? _localString.Dict["Err_8_full"] : _localString.Dict["Err_8_short"]);

            case CompileError.Type.Type9:
                return(CompileError.NeedFullDiagnostic(CompileError.Type.Type9) ? _localString.Dict["Err_9_full"] : _localString.Dict["Err_9_short"]);

            default:
                return("");
            }
        }
示例#10
0
 public void ScrollToError(CompileError err)
 {
     listView1.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => listView1.ScrollIntoView(err)));
     //listView1.ScrollIntoView(err);
 }