private void AppendSearchPaths(ProtoCore.Options options)
        {
            string assemblyPath = Assembly.GetAssembly(typeof(ExecutionSession)).Location;

            options.IncludeDirectories.Add(Path.GetDirectoryName(assemblyPath));

            ITextEditorSettings editorSettings = TextEditorCore.Instance.TextEditorSettings;

            if (Directory.Exists(editorSettings.IncludePath))
            {
                options.IncludeDirectories.Add(editorSettings.IncludePath);
            }

            IScriptObject entryPointScript = Solution.Current.ActiveScript;

            if (null != entryPointScript)
            {
                IParsedScript parsedScript = entryPointScript.GetParsedScript();
                if (null != parsedScript)
                {
                    string scriptPath = parsedScript.GetScriptPath();
                    options.RootModulePathName = parsedScript.GetScriptPath();

                    if (string.IsNullOrEmpty(scriptPath) == false)
                    {
                        string directoryName = Path.GetDirectoryName(scriptPath);
                        options.IncludeDirectories.Add(directoryName);
                    }
                }
            }
        }
        internal bool GetStackValueData(ProtoCore.Lang.Obj stackValue, ref string data)
        {
            data = string.Empty;
            if ((null != internalWorker) && internalWorker.IsBusy)
            {
                return(false);
            }

            if (null == currentWatchedMirror)
            {
                return(false);
            }

            try
            {
                ITextEditorSettings editorSettings = TextEditorCore.Instance.TextEditorSettings;
                data = currentWatchedMirror.GetStringValue(stackValue.DsasmValue,
                                                           core.Heap, 0, editorSettings.MaxArrayDisplaySize, editorSettings.MaxOutputDepth);
            }
            catch (Exception exception)
            {
                HandleException(exception);
                return(false);
            }

            return(true);
        }
        private void OnMouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Control)
            {
                if (e.Delta > 0 && lstOutputMessages.FontSize < 24)
                {
                    lstOutputMessages.FontSize = lstOutputMessages.FontSize + 1;
                    ITextEditorSettings settings = TextEditorControl.Instance.TextCore.TextEditorSettings;
                    settings.FontMultiplier = settings.FontMultiplier + 1;
                }
                else if (e.Delta < 0 && lstOutputMessages.FontSize > 12)
                {
                    lstOutputMessages.FontSize = lstOutputMessages.FontSize - 1;
                    ITextEditorSettings settings = TextEditorControl.Instance.TextCore.TextEditorSettings;
                    settings.FontMultiplier = settings.FontMultiplier + 1;
                }

                e.Handled = true;
            }
            else
            {
                if (e.Delta > 0 && offset < outputWindow.Height)
                {
                    OutputScrollViewer.ScrollToVerticalOffset(offset);
                }
                else if (e.Delta < 0 && offset > 0)
                {
                    OutputScrollViewer.ScrollToVerticalOffset(offset--);
                }
            }
        }
Exemplo n.º 4
0
        public bool GetCollectInfoOption()
        {
            string filepath = DesignScript.Editor.Configurations.GetSettingsFilePath();
            ITextEditorSettings editorSettings = EditorSettingsData.Deserialize(filepath);

            return(editorSettings.CollectFeedback);
        }
Exemplo n.º 5
0
        private void CreateNewRecordSession()
        {
            commandSerializer = new XmlSerializer(typeof(TextEditorCommand));
            string recordPath = Path.GetTempPath() + "\\" + Configurations.RecordFolderName;

            if (!(Directory.Exists(recordPath)))
            {
                Directory.CreateDirectory(recordPath);
            }

            string format = "{0}{1}Recorder-{2:yyyy-MM-dd_hh-mm-ss-tt}.xml";

            xmlFilePath     = string.Format(format, recordPath, Path.DirectorySeparatorChar, DateTime.Now);
            outputXmlFile   = new FileStream(xmlFilePath, FileMode.Create);
            xmlStreamWriter = new StreamWriter(outputXmlFile);

            string smartFormatAttrib     = string.Empty;
            ITextEditorSettings settings = TextEditorControl.Instance.GetEditorSettings();

            if (false != settings.EnableSmartFormatting)
            {
                smartFormatAttrib = "EnableSmartFormatting=\"true\"";
            }

            // Write out XML file header.
            xmlStreamWriter.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            xmlStreamWriter.WriteLine("<Commands xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
                                      + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + smartFormatAttrib + ">");

            currentCommandIndex = 1;
        }
Exemplo n.º 6
0
 ReplEditorCreator(IThemeManager themeManager, IWpfCommandManager wpfCommandManager, IMenuManager menuManager, ITextEditorSettings textEditorSettings)
 {
     this.themeManager       = themeManager;
     this.wpfCommandManager  = wpfCommandManager;
     this.menuManager        = menuManager;
     this.textEditorSettings = textEditorSettings;
 }
        TextEditorFontSettingsService(IThemeManager themeManager, ITextEditorSettings textEditorSettings, [ImportMany] IEnumerable <Lazy <TextEditorFormatDefinition, ITextEditorFormatDefinitionMetadata> > textEditorFormatDefinitions)
        {
            themeManager.ThemeChangedHighPriority += ThemeManager_ThemeChangedHighPriority;
            var provider = new TextEditorFontSettingsDictionaryProvider(textEditorSettings, textEditorFormatDefinitions);

            this.toTextEditorFontSettings      = provider.Result;
            this.defaultTextEditorFontSettings = provider.DefaultSettings;
        }
        TextEditorFontSettings CreateDefaultTextEditorFontSettings(ITextEditorSettings textEditorSettings)
        {
            var md             = new TextEditorFormatDefinitionMetadata(AppearanceCategoryConstants.TextEditor);
            var def            = new DefaultTextEditorFormatDefinition(textEditorSettings);
            var lazy           = new Lazy <TextEditorFormatDefinition, ITextEditorFormatDefinitionMetadata>(() => def, md);
            var dummyInitValue = lazy.Value;

            return(new TextEditorFontSettings(textEditorSettings, lazy, null));
        }
Exemplo n.º 9
0
 public static void IncreaseFontSize()
 {
     if (FontHeight <= 24)
     {
         ChangeFontSize(1);
         ITextEditorSettings settings = TextEditorCore.Instance.TextEditorSettings;
         settings.FontMultiplier = settings.FontMultiplier + 1;
     }
 }
Exemplo n.º 10
0
 public static void DecreaseFontSize()
 {
     if (FontHeight >= 12)
     {
         ChangeFontSize(-1);
         ITextEditorSettings settings = TextEditorCore.Instance.TextEditorSettings;
         settings.FontMultiplier = settings.FontMultiplier - 1;
     }
 }
Exemplo n.º 11
0
 public TextEditorFontSettings(ITextEditorSettings textEditorSettings, Lazy <TextEditorFormatDefinition, ITextEditorFormatDefinitionMetadata> textEditorFormatDefinition, TextEditorFontSettings baseType)
 {
     this.textEditorFormatDefinition = textEditorFormatDefinition;
     this.baseType = baseType;
     if (baseType != null)
     {
         baseType.SettingsChanged += BaseType_SettingsChanged;
     }
     //TODO: Don't use the global settings
     textEditorSettings.PropertyChanged += TextEditorSettings_PropertyChanged;
 }
Exemplo n.º 12
0
        public void SetCollectInfoOption(bool collectFeedback)
        {
            this.CollectFeedback = collectFeedback;

            string filepath = DesignScript.Editor.Configurations.GetSettingsFilePath();
            ITextEditorSettings editorSettings = EditorSettingsData.Deserialize(filepath);

            EnableDisableLogger(collectFeedback);
            editorSettings.CollectFeedback = collectFeedback;
            EditorSettingsData.Serialize(filepath, editorSettings);
        }
Exemplo n.º 13
0
 TextEditorUIContextCreator(IThemeManager themeManager, IImageManager imageManager, IWpfCommandManager wpfCommandManager, IMenuManager menuManager, ICodeToolTipManager codeToolTipManager, ITextEditorSettings textEditorSettings, ITextLineObjectManager textLineObjectManager, ITextEditorUIContextManagerImpl textEditorUIContextManagerImpl, IIconBarCommandManager iconBarCommandManager)
 {
     this.themeManager                   = themeManager;
     this.imageManager                   = imageManager;
     this.wpfCommandManager              = wpfCommandManager;
     this.menuManager                    = menuManager;
     this.codeToolTipManager             = codeToolTipManager;
     this.textEditorSettings             = textEditorSettings;
     this.textLineObjectManager          = textLineObjectManager;
     this.textEditorUIContextManagerImpl = textEditorUIContextManagerImpl;
     this.iconBarCommandManager          = iconBarCommandManager;
 }
Exemplo n.º 14
0
        public TextEditorControl(IThemeManager themeManager, ToolTipHelper toolTipHelper, ITextEditorSettings textEditorSettings, ITextEditorUIContextImpl uiContext, ITextEditorHelper textEditorHelper, ITextLineObjectManager textLineObjectManager, IImageManager imageManager, IIconBarCommandManager iconBarCommandManager)
        {
            this.references         = new TextSegmentCollection <ReferenceSegment>();
            this.themeManager       = themeManager;
            this.toolTipHelper      = toolTipHelper;
            this.textEditorSettings = textEditorSettings;
            this.textEditorHelper   = textEditorHelper;
            InitializeComponent();
            this.textEditorSettings.PropertyChanged += TextEditorSettings_PropertyChanged;

            themeManager.ThemeChanged += ThemeManager_ThemeChanged;

            textEditor = new NewTextEditor(themeManager, textEditorSettings);
            this.toolTipHelper.Initialize(TextEditor);
            RemoveCommands(TextEditor);
            newTextEditor.Content      = TextEditor;
            TextEditor.IsReadOnly      = true;
            TextEditor.ShowLineNumbers = true;

            referenceElementGenerator = new ReferenceElementGenerator(JumpToReference, a => true);
            // Add the ref elem generator first in case one of the refs looks like a http link etc
            TextEditor.TextArea.TextView.ElementGenerators.Insert(0, referenceElementGenerator);
            this.uiElementGenerator = new UIElementGenerator();
            textEditor.TextArea.TextView.ElementGenerators.Add(uiElementGenerator);

            iconBarMargin = new IconBarMargin(uiContext, textLineObjectManager, imageManager, themeManager);
            iconBarCommandManager.Initialize(iconBarMargin);
            TextEditor.TextArea.LeftMargins.Insert(0, iconBarMargin);
            TextEditor.TextArea.TextView.VisualLinesChanged += (s, e) => iconBarMargin.InvalidateVisual();

            textMarkerService = new TextMarkerService(this, uiContext, textLineObjectManager);
            TextEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
            TextEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);

            TextEditor.TextArea.Caret.PositionChanged += Caret_PositionChanged;

            InputBindings.Add(new KeyBinding(new RelayCommand(a => MoveReference(true)), Key.Tab, ModifierKeys.None));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => MoveReference(false)), Key.Tab, ModifierKeys.Shift));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => MoveReference(true)), Key.Down, ModifierKeys.Control | ModifierKeys.Shift));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => MoveReference(false)), Key.Up, ModifierKeys.Control | ModifierKeys.Shift));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => MoveToNextDefinition(true)), Key.Down, ModifierKeys.Alt));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => MoveToNextDefinition(false)), Key.Up, ModifierKeys.Alt));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => FollowReference()), Key.F12, ModifierKeys.None));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => FollowReference()), Key.Enter, ModifierKeys.None));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => FollowReferenceNewTab()), Key.F12, ModifierKeys.Control));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => FollowReferenceNewTab()), Key.Enter, ModifierKeys.Control));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => ClearMarkedReferencesAndToolTip()), Key.Escape, ModifierKeys.None));

            TextEditor.OnShowLineNumbersChanged();
            OnAutoHighlightRefsChanged();
        }
Exemplo n.º 15
0
        public CollectInfoManager(ILoggerWrapper logger)
        {
            this.logger          = logger;
            this.CollectFeedback = false;
            string filepath = DesignScript.Editor.Configurations.GetSettingsFilePath();

            if (!File.Exists(filepath))
            {
                SetCollectInfoOption(ShowCollectInfoDialog());
            }
            else
            {
                ITextEditorSettings editorSettings = EditorSettingsData.Deserialize(filepath);
                EnableDisableLogger(editorSettings.CollectFeedback);
            }
        }
Exemplo n.º 16
0
        public NewTextEditor(IThemeManager themeManager, ITextEditorSettings textEditorSettings)
        {
            this.themeManager       = themeManager;
            this.textEditorSettings = textEditorSettings;
            this.textEditorSettings.PropertyChanged        += TextEditorSettings_PropertyChanged;
            this.themeManager.ThemeChanged                 += ThemeManager_ThemeChanged;
            Options.AllowToggleOverstrikeMode               = true;
            Options.RequireControlModifierForHyperlinkClick = false;
            UpdateColors(false);

            searchPanel = SearchPanel.Install(TextArea);
            searchPanel.RegisterCommands(this.CommandBindings);
            searchPanel.Localization = new AvalonEditSearchPanelLocalization();

            TextArea.SelectionCornerRadius = 0;
            TextArea.PreviewKeyDown       += TextArea_PreviewKeyDown;
            TextArea.InputBindings.Add(new KeyBinding(new RelayCommand(a => PageUp()), Key.PageUp, ModifierKeys.Control));
            TextArea.InputBindings.Add(new KeyBinding(new RelayCommand(a => PageDown()), Key.PageDown, ModifierKeys.Control));
            TextArea.InputBindings.Add(new KeyBinding(new RelayCommand(a => UpDownLine(false)), Key.Down, ModifierKeys.Control));
            TextArea.InputBindings.Add(new KeyBinding(new RelayCommand(a => UpDownLine(true)), Key.Up, ModifierKeys.Control));
            this.AddHandler(GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(OnGotKeyboardFocus), true);
            this.AddHandler(LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(OnLostKeyboardFocus), true);

            TextArea.MouseRightButtonDown += (s, e) => GoToMousePosition();

            SetBinding(FontFamilyProperty, new Binding {
                Source = textEditorSettings,
                Path   = new PropertyPath("FontFamily"),
                Mode   = BindingMode.OneWay,
            });
            SetBinding(FontSizeProperty, new Binding {
                Source = textEditorSettings,
                Path   = new PropertyPath("FontSize"),
                Mode   = BindingMode.OneWay,
            });
            SetBinding(WordWrapProperty, new Binding {
                Source = textEditorSettings,
                Path   = new PropertyPath("WordWrap"),
                Mode   = BindingMode.OneWay,
            });

            OnHighlightCurrentLineChanged();
            OnShowLineNumbersChanged();
        }
        public TextEditorFontSettingsDictionaryProvider(ITextEditorSettings textEditorSettings, IEnumerable <Lazy <TextEditorFormatDefinition, ITextEditorFormatDefinitionMetadata> > textEditorFormatDefinitions)
        {
            Result          = new Dictionary <string, TextEditorFontSettings>(StringComparer.Ordinal);
            DefaultSettings = CreateDefaultTextEditorFontSettings(textEditorSettings);
            Result.Add(AppearanceCategoryConstants.TextEditor, DefaultSettings);
            this.textEditorSettings = textEditorSettings;
            this.toDef = new Dictionary <string, Lazy <TextEditorFormatDefinition, ITextEditorFormatDefinitionMetadata> >(StringComparer.Ordinal);
            var allDefs = textEditorFormatDefinitions.ToArray();

            foreach (var def in allDefs)
            {
                Debug.Assert(!toDef.ContainsKey(def.Metadata.Name));
                toDef[def.Metadata.Name] = def;
            }
            foreach (var def in allDefs)
            {
                Create(def.Metadata.Name);
            }
        }
Exemplo n.º 18
0
		public ReplEditorUI(ReplEditorOptions options, IThemeManager themeManager, IWpfCommandManager wpfCommandManager, IMenuManager menuManager, ITextEditorSettings textEditorSettings) {
			this.dispatcher = Dispatcher.CurrentDispatcher;
			this.options = (options ?? new ReplEditorOptions()).Clone();
			this.textEditor = new NewTextEditor(themeManager, textEditorSettings);
			this.textEditor.TextArea.AllowDrop = false;
			this.textEditor.TextArea.Document = new TextDocument();
			this.textEditor.TextArea.Document.UndoStack.SizeLimit = 100;
			this.textEditor.TextArea.LeftMargins.Insert(0, new FrameworkElement { Margin = new Thickness(LEFT_MARGIN, 0, 0, 0) });
			this.textEditor.TextArea.TextEntering += TextArea_TextEntering;
			this.textEditor.TextArea.PreviewKeyDown += TextArea_PreviewKeyDown;
			AddBinding(ApplicationCommands.Paste, (s, e) => Paste(), (s, e) => e.CanExecute = CanPaste && IsAtEditingPosition);
			AddBinding(ApplicationCommands.Cut, (s, e) => CutSelection(), (s, e) => e.CanExecute = CanCutSelection && IsAtEditingPosition);

			if (this.options.TextEditorCommandGuid != null)
				wpfCommandManager.Add(this.options.TextEditorCommandGuid.Value, textEditor);
			if (this.options.TextAreaCommandGuid != null)
				wpfCommandManager.Add(this.options.TextAreaCommandGuid.Value, textEditor.TextArea);
			if (this.options.MenuGuid != null)
				menuManager.InitializeContextMenu(this.textEditor, this.options.MenuGuid.Value, new GuidObjectsCreator(this), new ContextMenuInitializer(textEditor, textEditor));
		}
        private void DisplayCoreDump(ExecutionMirror executionMirror, IOutputStream outputStream)
        {
            if (null == executionMirror)
            {
                return; // This can be "null" if there's compilation errors.
            }
            ITextEditorSettings editorSettings = TextEditorCore.Instance.TextEditorSettings;

            if (false == editorSettings.DisplayOutput)
            {
                return; // The output display has been disabled, don't display.
            }
            try
            {
                List <string> variableList = null;
                executionMirror.GetCoreDump(out variableList,
                                            editorSettings.MaxArrayDisplaySize,
                                            editorSettings.MaxOutputDepth);

                if (null != variableList)
                {
                    foreach (string variable in variableList)
                    {
                        outputStream.Write(new ProtoCore.OutputMessage(
                                               OutputMessage.MessageType.Info, variable));

                        Logger.LogPerf("CoreDump-ExecSession", variable);
                    }
                }
            }
            catch (System.Exception ex)
            {
                outputStream.Write(new ProtoCore.OutputMessage(OutputMessage.MessageType.Error, ex.Message));
                Logger.LogPerf("CoreDumpEx", ex.Message);
            }
        }
Exemplo n.º 20
0
        public TextEditorControl(IThemeManager themeManager, ToolTipHelper toolTipHelper, ITextEditorSettings textEditorSettings, ITextEditorUIContextImpl uiContext, ITextEditorHelper textEditorHelper, ITextLineObjectManager textLineObjectManager, IImageManager imageManager, IIconBarCommandManager iconBarCommandManager)
        {
            this.references         = new TextSegmentCollection <ReferenceSegment>();
            this.themeManager       = themeManager;
            this.toolTipHelper      = toolTipHelper;
            this.textEditorSettings = textEditorSettings;
            this.textEditorHelper   = textEditorHelper;
            InitializeComponent();
            this.textEditorSettings.PropertyChanged += TextEditorSettings_PropertyChanged;

            themeManager.ThemeChanged += ThemeManager_ThemeChanged;

            textEditor = new NewTextEditor(themeManager);
            this.toolTipHelper.Initialize(TextEditor);
            RemoveCommands(TextEditor);
            newTextEditor.Content      = TextEditor;
            TextEditor.IsReadOnly      = true;
            TextEditor.ShowLineNumbers = true;
            TextEditor.Options.RequireControlModifierForHyperlinkClick = false;

            referenceElementGenerator = new ReferenceElementGenerator(JumpToReference, a => true);
            // Add the ref elem generator first in case one of the refs looks like a http link etc
            TextEditor.TextArea.TextView.ElementGenerators.Insert(0, referenceElementGenerator);
            this.uiElementGenerator = new UIElementGenerator();
            textEditor.TextArea.TextView.ElementGenerators.Add(uiElementGenerator);

            TextEditor.SetBinding(FontFamilyProperty, new Binding {
                Source = textEditorSettings,
                Path   = new PropertyPath("FontFamily"),
                Mode   = BindingMode.OneWay,
            });
            TextEditor.SetBinding(FontSizeProperty, new Binding {
                Source = textEditorSettings,
                Path   = new PropertyPath("FontSize"),
                Mode   = BindingMode.OneWay,
            });
            TextEditor.SetBinding(ICSharpCode.AvalonEdit.TextEditor.WordWrapProperty, new Binding {
                Source = textEditorSettings,
                Path   = new PropertyPath("WordWrap"),
                Mode   = BindingMode.OneWay,
            });

            iconBarMargin = new IconBarMargin(uiContext, textLineObjectManager, imageManager, themeManager);
            iconBarCommandManager.Initialize(iconBarMargin);
            TextEditor.TextArea.LeftMargins.Insert(0, iconBarMargin);
            TextEditor.TextArea.TextView.VisualLinesChanged += (s, e) => iconBarMargin.InvalidateVisual();

            textMarkerService = new TextMarkerService(this, uiContext, textLineObjectManager);
            TextEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
            TextEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);

            searchPanel = SearchPanel.Install(TextEditor.TextArea);
            searchPanel.RegisterCommands(this.CommandBindings);
            searchPanel.Localization = new AvalonEditSearchPanelLocalization();

            TextEditor.TextArea.Caret.PositionChanged += Caret_PositionChanged;

            TextEditor.TextArea.MouseRightButtonDown += (s, e) => TextEditor.GoToMousePosition();

            InputBindings.Add(new KeyBinding(new RelayCommand(a => MoveReference(true)), Key.Tab, ModifierKeys.None));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => MoveReference(false)), Key.Tab, ModifierKeys.Shift));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => MoveToNextDefinition(true)), Key.Down, ModifierKeys.Alt));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => MoveToNextDefinition(false)), Key.Up, ModifierKeys.Alt));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => FollowReference()), Key.F12, ModifierKeys.None));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => FollowReference()), Key.Enter, ModifierKeys.None));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => FollowReferenceNewTab()), Key.F12, ModifierKeys.Control));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => FollowReferenceNewTab()), Key.Enter, ModifierKeys.Control));
            InputBindings.Add(new KeyBinding(new RelayCommand(a => ClearMarkedReferencesAndToolTip()), Key.Escape, ModifierKeys.None));

            this.AddHandler(GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(OnGotKeyboardFocus), true);
            this.AddHandler(LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(OnLostKeyboardFocus), true);

            OnHighlightCurrentLineChanged();
            OnShowLineNumbersChanged();
            OnAutoHighlightRefsChanged();
        }
Exemplo n.º 21
0
        public static bool Serialize(string filePath, ITextEditorSettings settingsData)
        {
            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(EditorSettingsData));
                using (FileStream fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write))
                {
                    serializer.Serialize(fileStream, settingsData);
                }
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
Exemplo n.º 22
0
        private bool PlaybackNextXmlFile()
        {
            bool donePlayingAllXmlFiles = false;

            currentXmlFile = currentXmlFile + 1;
            if (currentXmlFile < 0 || (null == xmlTestFiles))
            {
                donePlayingAllXmlFiles = true;
            }
            if (currentXmlFile >= xmlTestFiles.Count)
            {
                donePlayingAllXmlFiles = true;
            }

            if (false != donePlayingAllXmlFiles)
            {
                if (null != playbackTimer)
                {
                    playbackTimer.Stop();
                }

                playbackTimer = null;
                SerialiseTestResults();
                textEditorCore.EnableRegularCommands = true;

                // Close out the editor for multi-playback.
                if (xmlTestFiles.Count > 1)
                {
                    System.Windows.Application.Current.Shutdown();
                }

                return(false);
            }

            string xmlFilePath = xmlTestFiles[currentXmlFile];

            if (File.Exists(xmlFilePath) == false)
            {
                return(false);
            }

            if (null == editorCommands)
            {
                editorCommands = new List <TextEditorCommand>();
            }
            editorCommands.Clear(); // Clear up any existing steps.

            string baseFilePath = FindMatchingBaseFile(xmlFilePath);

            if (string.IsNullOrEmpty(baseFilePath) == false)
            {
                Commands baseSteps = DeserializeFromXml(baseFilePath);
                editorCommands.AddRange(baseSteps.TextEditorCommands);
            }

            Commands            recordedSteps = DeserializeFromXml(xmlFilePath);
            ITextEditorSettings settings      = textEditorCore.TextEditorSettings;

            if (settings.EnableSmartFormatting != recordedSteps.EnableSmartFormatting)
            {
                settings.ToggleSmartFormatting(); // Formatting on a per-test basis.
            }
            editorCommands.AddRange(recordedSteps.TextEditorCommands);
            PlaybackVisualizer.Instance.SetCurrentFilePath(xmlFilePath);
            PlaybackVisualizer.Instance.SetEditorCommands(editorCommands);

            if (null == playbackTimer)
            {
                playbackTimer          = new DispatcherTimer();
                playbackTimer.Tick    += new EventHandler(OnPlaybackTimerTick);
                playbackTimer.Interval = new TimeSpan(0, 0, 0, 0, 1);
            }

            commandIndex     = -1;
            playbackComplete = false;
            playbackTimer.Start();
            Solution.CloseSolution(Solution.Current, true);
            return(true);
        }
Exemplo n.º 23
0
        public static void InitializeFontSizes()
        {
            ITextEditorSettings settings = TextEditorCore.Instance.TextEditorSettings;

            ChangeFontSize(settings.FontMultiplier);
        }
Exemplo n.º 24
0
 public DefaultTextEditorFormatDefinition(ITextEditorSettings textEditorSettings)
 {
     this.textEditorSettings = textEditorSettings;
 }
Exemplo n.º 25
0
		public NewTextEditor(IThemeManager themeManager, ITextEditorSettings textEditorSettings) {
			this.themeManager = themeManager;
			this.textEditorSettings = textEditorSettings;
			this.textEditorSettings.PropertyChanged += TextEditorSettings_PropertyChanged;
			this.themeManager.ThemeChanged += ThemeManager_ThemeChanged;
			Options.AllowToggleOverstrikeMode = true;
			Options.RequireControlModifierForHyperlinkClick = false;
			UpdateColors(false);

			searchPanel = SearchPanel.Install(TextArea);
			searchPanel.RegisterCommands(this.CommandBindings);
			searchPanel.Localization = new AvalonEditSearchPanelLocalization();

			TextArea.SelectionCornerRadius = 0;
			TextArea.PreviewKeyDown += TextArea_PreviewKeyDown;
			TextArea.InputBindings.Add(new KeyBinding(new RelayCommand(a => PageUp()), Key.PageUp, ModifierKeys.Control));
			TextArea.InputBindings.Add(new KeyBinding(new RelayCommand(a => PageDown()), Key.PageDown, ModifierKeys.Control));
			TextArea.InputBindings.Add(new KeyBinding(new RelayCommand(a => UpDownLine(false)), Key.Down, ModifierKeys.Control));
			TextArea.InputBindings.Add(new KeyBinding(new RelayCommand(a => UpDownLine(true)), Key.Up, ModifierKeys.Control));
			this.AddHandler(GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(OnGotKeyboardFocus), true);
			this.AddHandler(LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(OnLostKeyboardFocus), true);

			TextArea.MouseRightButtonDown += (s, e) => GoToMousePosition();

			SetBinding(FontFamilyProperty, new Binding {
				Source = textEditorSettings,
				Path = new PropertyPath("FontFamily"),
				Mode = BindingMode.OneWay,
			});
			SetBinding(FontSizeProperty, new Binding {
				Source = textEditorSettings,
				Path = new PropertyPath("FontSize"),
				Mode = BindingMode.OneWay,
			});
			SetBinding(WordWrapProperty, new Binding {
				Source = textEditorSettings,
				Path = new PropertyPath("WordWrap"),
				Mode = BindingMode.OneWay,
			});

			OnHighlightCurrentLineChanged();
			OnShowLineNumbersChanged();
		}
Exemplo n.º 26
0
        public ReplEditorUI(ReplEditorOptions options, IThemeManager themeManager, IWpfCommandManager wpfCommandManager, IMenuManager menuManager, ITextEditorSettings textEditorSettings)
        {
            this.dispatcher = Dispatcher.CurrentDispatcher;
            this.options    = (options ?? new ReplEditorOptions()).Clone();
            this.textEditor = new NewTextEditor(themeManager, textEditorSettings);
            this.textEditor.TextArea.Document = new TextDocument();
            this.textEditor.TextArea.Document.UndoStack.SizeLimit = 100;
            this.textEditor.TextArea.LeftMargins.Insert(0, new FrameworkElement {
                Margin = new Thickness(LEFT_MARGIN, 0, 0, 0)
            });
            this.textEditor.TextArea.TextEntering   += TextArea_TextEntering;
            this.textEditor.TextArea.PreviewKeyDown += TextArea_PreviewKeyDown;
            AddBinding(ApplicationCommands.Paste, (s, e) => Paste(), (s, e) => e.CanExecute      = CanPaste && IsAtEditingPosition);
            AddBinding(ApplicationCommands.Cut, (s, e) => CutSelection(), (s, e) => e.CanExecute = CanCutSelection && IsAtEditingPosition);

            if (this.options.TextEditorCommandGuid != null)
            {
                wpfCommandManager.Add(this.options.TextEditorCommandGuid.Value, textEditor);
            }
            if (this.options.TextAreaCommandGuid != null)
            {
                wpfCommandManager.Add(this.options.TextAreaCommandGuid.Value, textEditor.TextArea);
            }
            if (this.options.MenuGuid != null)
            {
                menuManager.InitializeContextMenu(this.textEditor, this.options.MenuGuid.Value, new GuidObjectsCreator(this), new ContextMenuInitializer(textEditor, textEditor));
            }
        }
Exemplo n.º 27
0
        private void NumericSliderExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            ITextEditorSettings settings = textCore.TextEditorSettings;

            settings.ToggleNumericSlider(); // Toggle Numeric Slider option.
        }
Exemplo n.º 28
0
        private void SmartFormatterExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            ITextEditorSettings settings = textCore.TextEditorSettings;

            settings.ToggleSmartFormatting(); // Toggle SmartFormatter option.
        }
Exemplo n.º 29
0
		ReplEditorCreator(IThemeManager themeManager, IWpfCommandManager wpfCommandManager, IMenuManager menuManager, ITextEditorSettings textEditorSettings) {
			this.themeManager = themeManager;
			this.wpfCommandManager = wpfCommandManager;
			this.menuManager = menuManager;
			this.textEditorSettings = textEditorSettings;
		}
Exemplo n.º 30
0
		Plugin(ITextEditorSettings textEditorSettings) {
			textEditorSettings.PropertyChanged += TextEditorSettings_PropertyChanged;
			Initialize(textEditorSettings);
		}
Exemplo n.º 31
0
		void Initialize(ITextEditorSettings textEditorSettings) {
			Application.Current.Resources["TextEditorFontFamily"] = textEditorSettings.FontFamily;
		}
Exemplo n.º 32
0
        private void DisplayOutputExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            ITextEditorSettings settings = textCore.TextEditorSettings;

            settings.ToggleDisplayOutput(); // Toggle display output option.
        }