Ejemplo n.º 1
0
        public ScriptEditor(EngineDescription buildInfo, IScriptFile scriptFile, IStreamManager streamManager, ICacheFile casheFile, Endian endian)
        {
            _endian        = endian;
            _buildInfo     = buildInfo;
            _opcodes       = _buildInfo.ScriptInfo;
            _scriptFile    = scriptFile;
            _streamManager = streamManager;
            _cashefile     = casheFile;

            // If a game contains hsdt tags, it uses a newer Blam Script syntax. Currently the compiler only supports the old syntax.
            _hasNewSyntax = _buildInfo.Layouts.HasLayout("hsdt");

            InitializeComponent();

            // Disable user input. Enable it again when all background tasks have been completed.
            txtScript.IsReadOnly = true;

            // Enable code completion only if the compiler supports this game.
            if (!_hasNewSyntax)
            {
                txtScript.TextArea.GotFocus         += EditorGotFocus;
                txtScript.TextArea.LostFocus        += EditorLostFocus;
                txtScript.TextArea.TextEntering     += EditorTextEntering;
                txtScript.TextArea.TextEntered      += EditorTextEntered;
                txtScript.TextArea.Document.Changed += EditorTextChanged;
            }

            App.AssemblyStorage.AssemblySettings.PropertyChanged += Settings_SettingsChanged;
            SetHighlightColor();
            SearchPanel srch     = SearchPanel.Install(txtScript);
            var         bconv    = new System.Windows.Media.BrushConverter();
            var         srchbrsh = (System.Windows.Media.Brush)bconv.ConvertFromString("#40F0F0F0");

            srch.MarkerBrush = srchbrsh;

            txtScript.SyntaxHighlighting = LoadSyntaxHighlighting();

            // With syntax highlighting and HTML formatting, copying text takes ages. Disable the HTML formatting for copied text.
            DataObject.AddSettingDataHandler(txtScript, onTextViewSettingDataHandler);

            _progress = new Progress <int>(i =>
            {
                progressBar.Value = i;
            });

            itemShowInformation.IsChecked = App.AssemblyStorage.AssemblySettings.ShowScriptInfo;
            itemDebugData.IsChecked       = App.AssemblyStorage.AssemblySettings.OutputCompilerDebugData;

            // Enable compilation only for supported games.
            if (_buildInfo.Name.Contains("Reach") || _buildInfo.Name.Contains("Halo 3") && _buildInfo.HeaderSize != 0x800 && !_buildInfo.Name.Contains("ODST"))
            {
                compileButton.Visibility    = Visibility.Visible;
                progressReporter.Visibility = Visibility.Visible;
            }
        }
Ejemplo n.º 2
0
        public TextViewerControl()
        {
            InitializeComponent();

            var textArea = textEditor.TextArea;

            SearchPanel.Install(textArea);

            foldingManager = FoldingManager.Install(textEditor.TextArea);

            textArea.MouseRightButtonDown += TextAreaMouseRightButtonDown;
            DataObject.AddSettingDataHandler(textArea, OnSettingData);

            var textView = textArea.TextView;

            textView.Options.HighlightCurrentLine  = true;
            textView.Options.EnableEmailHyperlinks = false;
            textView.Options.EnableHyperlinks      = false;
            textEditor.IsReadOnly = true;

            if (SettingsService.UseDarkTheme)
            {
                textEditor.Background          = ThemeManager.BackgroundBrush;
                textEditor.Foreground          = ThemeManager.ControlTextBrush;
                textView.CurrentLineBackground = (Brush) new BrushConverter().ConvertFromString("#505050");
                textArea.SelectionBrush        = (Brush) new BrushConverter().ConvertFromString("#264F78");
                textArea.SelectionForeground   = (Brush) new BrushConverter().ConvertFromString("#C8C8C8");
                var foldingMargin = textArea.LeftMargins.OfType <FoldingMargin>().First();
                foldingMargin.FoldingMarkerBackgroundBrush         = ThemeManager.BackgroundBrush;
                foldingMargin.FoldingMarkerBrush                   = ThemeManager.ControlTextBrush;
                foldingMargin.SelectedFoldingMarkerBackgroundBrush = ThemeManager.BackgroundBrush;
                foldingMargin.SelectedFoldingMarkerBrush           = ThemeManager.ControlTextBrush;
            }
            else
            {
                textView.CurrentLineBackground = new SolidColorBrush(Color.FromRgb(224, 224, 224));
                textView.CurrentLineBorder     = new Pen(Brushes.Transparent, 0);
            }

            textEditor.ApplyTemplate();

            var scrollViewer = textEditor.FindVisualChild <ScrollViewer>();

            if (scrollViewer != null)
            {
                textEditor.PreviewMouseWheel += (s, e) =>
                {
                    if (Keyboard.Modifiers == ModifierKeys.Shift)
                    {
                        scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset - e.Delta);
                        e.Handled = true;
                    }
                };
            }
        }
 public HighLight_Hash_Links_in_RicharTextBox_WPF(RichTextBox initRichTextBox)
 {
     DataObject.AddSettingDataHandler(initRichTextBox, MySettingDataCommand);
     DataObject.AddPastingHandler(initRichTextBox, MyPasteCommand);
     DataObject.AddCopyingHandler(initRichTextBox, MyCopyCommand);
     _DispatcherTimer = new DispatcherTimer( )
     {
         Interval = new TimeSpan(0, 0, 0, 0, 10)
     };
     _DispatcherTimer.Tick    += new EventHandler(DelayedUpdate);
     _RichTextBox              = initRichTextBox;
     _RichTextBox.TextChanged += new System.Windows.Controls.TextChangedEventHandler(TextChanged);
     _RichTextBox.KeyDown     += new System.Windows.Input.KeyEventHandler(KeyDown);
     _RichTextBox.KeyUp       += new System.Windows.Input.KeyEventHandler(KeyUp);
     _RichTextBox.MouseDown   += new System.Windows.Input.MouseButtonEventHandler(MouseDown);
     _RichTextBox.MouseUp     += new System.Windows.Input.MouseButtonEventHandler(MouseUp);
     StartMagic( );
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds the copy data event handler.
 /// </summary>
 protected void AddCopyDataEventHandler()
 {
     DataObject.AddSettingDataHandler(DecisionCodeRichTextBox, new DataObjectSettingDataEventHandler(OnDataSetting));
 }