Make HighlightingManager thread-safe. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4972 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
@ -0,0 +1,8 @@ | 
				
			|||||||
 | 
					<Application x:Class="AvalonEdit.Sample.App" | 
				
			||||||
 | 
						xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | 
				
			||||||
 | 
						xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | 
				
			||||||
 | 
						StartupUri="Window1.xaml"> | 
				
			||||||
 | 
						<Application.Resources> | 
				
			||||||
 | 
							  | 
				
			||||||
 | 
						</Application.Resources> | 
				
			||||||
 | 
					</Application> | 
				
			||||||
@ -0,0 +1,19 @@ | 
				
			|||||||
 | 
					using System; | 
				
			||||||
 | 
					using System.Windows; | 
				
			||||||
 | 
					using System.Data; | 
				
			||||||
 | 
					using System.Xml; | 
				
			||||||
 | 
					using System.Configuration; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace AvalonEdit.Sample | 
				
			||||||
 | 
					{ | 
				
			||||||
 | 
						/// <summary>
 | 
				
			||||||
 | 
						/// Interaction logic for App.xaml
 | 
				
			||||||
 | 
						/// </summary>
 | 
				
			||||||
 | 
						public partial class App : Application | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							public App() | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								InitializeComponent(); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,100 @@ | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="utf-8"?> | 
				
			||||||
 | 
					<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> | 
				
			||||||
 | 
					  <PropertyGroup> | 
				
			||||||
 | 
					    <ProjectGuid>{13A5B497-BA12-45AE-9033-22620C3153FB}</ProjectGuid> | 
				
			||||||
 | 
					    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | 
				
			||||||
 | 
					    <Platform Condition=" '$(Platform)' == '' ">x86</Platform> | 
				
			||||||
 | 
					    <OutputType>WinExe</OutputType> | 
				
			||||||
 | 
					    <RootNamespace>AvalonEdit.Sample</RootNamespace> | 
				
			||||||
 | 
					    <AssemblyName>AvalonEdit.Sample</AssemblyName> | 
				
			||||||
 | 
					    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | 
				
			||||||
 | 
					    <AppDesignerFolder>Properties</AppDesignerFolder> | 
				
			||||||
 | 
					  </PropertyGroup> | 
				
			||||||
 | 
					  <PropertyGroup Condition=" '$(Platform)' == 'x86' "> | 
				
			||||||
 | 
					    <PlatformTarget>x86</PlatformTarget> | 
				
			||||||
 | 
					  </PropertyGroup> | 
				
			||||||
 | 
					  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | 
				
			||||||
 | 
					    <OutputPath>bin\Debug\</OutputPath> | 
				
			||||||
 | 
					    <DebugSymbols>True</DebugSymbols> | 
				
			||||||
 | 
					    <DebugType>Full</DebugType> | 
				
			||||||
 | 
					    <Optimize>False</Optimize> | 
				
			||||||
 | 
					    <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> | 
				
			||||||
 | 
					    <DefineConstants>DEBUG;TRACE</DefineConstants> | 
				
			||||||
 | 
					  </PropertyGroup> | 
				
			||||||
 | 
					  <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | 
				
			||||||
 | 
					    <OutputPath>bin\Release\</OutputPath> | 
				
			||||||
 | 
					    <DebugSymbols>False</DebugSymbols> | 
				
			||||||
 | 
					    <DebugType>None</DebugType> | 
				
			||||||
 | 
					    <Optimize>True</Optimize> | 
				
			||||||
 | 
					    <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | 
				
			||||||
 | 
					    <DefineConstants>TRACE</DefineConstants> | 
				
			||||||
 | 
					  </PropertyGroup> | 
				
			||||||
 | 
					  <ItemGroup> | 
				
			||||||
 | 
					    <Reference Include="PresentationCore"> | 
				
			||||||
 | 
					      <RequiredTargetFramework>3.0</RequiredTargetFramework> | 
				
			||||||
 | 
					    </Reference> | 
				
			||||||
 | 
					    <Reference Include="PresentationFramework"> | 
				
			||||||
 | 
					      <RequiredTargetFramework>3.0</RequiredTargetFramework> | 
				
			||||||
 | 
					    </Reference> | 
				
			||||||
 | 
					    <Reference Include="System" /> | 
				
			||||||
 | 
					    <Reference Include="System.Core"> | 
				
			||||||
 | 
					      <RequiredTargetFramework>3.5</RequiredTargetFramework> | 
				
			||||||
 | 
					    </Reference> | 
				
			||||||
 | 
					    <Reference Include="System.Data" /> | 
				
			||||||
 | 
					    <Reference Include="System.Data.DataSetExtensions"> | 
				
			||||||
 | 
					      <RequiredTargetFramework>3.5</RequiredTargetFramework> | 
				
			||||||
 | 
					    </Reference> | 
				
			||||||
 | 
					    <Reference Include="System.Drawing" /> | 
				
			||||||
 | 
					    <Reference Include="System.Windows.Forms" /> | 
				
			||||||
 | 
					    <Reference Include="System.Xml" /> | 
				
			||||||
 | 
					    <Reference Include="System.Xml.Linq"> | 
				
			||||||
 | 
					      <RequiredTargetFramework>3.5</RequiredTargetFramework> | 
				
			||||||
 | 
					    </Reference> | 
				
			||||||
 | 
					    <Reference Include="WindowsBase"> | 
				
			||||||
 | 
					      <RequiredTargetFramework>3.0</RequiredTargetFramework> | 
				
			||||||
 | 
					    </Reference> | 
				
			||||||
 | 
					    <Reference Include="WindowsFormsIntegration"> | 
				
			||||||
 | 
					      <RequiredTargetFramework>3.0</RequiredTargetFramework> | 
				
			||||||
 | 
					    </Reference> | 
				
			||||||
 | 
					  </ItemGroup> | 
				
			||||||
 | 
					  <ItemGroup> | 
				
			||||||
 | 
					    <ApplicationDefinition Include="App.xaml" /> | 
				
			||||||
 | 
					  </ItemGroup> | 
				
			||||||
 | 
					  <ItemGroup> | 
				
			||||||
 | 
					    <Compile Include="App.xaml.cs"> | 
				
			||||||
 | 
					      <SubType>Code</SubType> | 
				
			||||||
 | 
					      <DependentUpon>App.xaml</DependentUpon> | 
				
			||||||
 | 
					    </Compile> | 
				
			||||||
 | 
					    <Compile Include="Properties\AssemblyInfo.cs" /> | 
				
			||||||
 | 
					    <Compile Include="Properties\WPFAssemblyInfo.cs" /> | 
				
			||||||
 | 
					    <Compile Include="Window1.xaml.cs"> | 
				
			||||||
 | 
					      <SubType>Code</SubType> | 
				
			||||||
 | 
					      <DependentUpon>Window1.xaml</DependentUpon> | 
				
			||||||
 | 
					    </Compile> | 
				
			||||||
 | 
					  </ItemGroup> | 
				
			||||||
 | 
					  <ItemGroup> | 
				
			||||||
 | 
					    <Page Include="Window1.xaml" /> | 
				
			||||||
 | 
					  </ItemGroup> | 
				
			||||||
 | 
					  <ItemGroup> | 
				
			||||||
 | 
					    <Resource Include="Images\Copy.png" /> | 
				
			||||||
 | 
					    <Resource Include="Images\Cut.png" /> | 
				
			||||||
 | 
					    <Resource Include="Images\Delete.png" /> | 
				
			||||||
 | 
					    <Resource Include="Images\Open.png" /> | 
				
			||||||
 | 
					    <Resource Include="Images\Paste.png" /> | 
				
			||||||
 | 
					    <Resource Include="Images\Redo.png" /> | 
				
			||||||
 | 
					    <Resource Include="Images\Save.png" /> | 
				
			||||||
 | 
					    <Resource Include="Images\Undo.png" /> | 
				
			||||||
 | 
					    <Resource Include="Images\WordWrap.png" /> | 
				
			||||||
 | 
					  </ItemGroup> | 
				
			||||||
 | 
					  <ItemGroup> | 
				
			||||||
 | 
					    <Folder Include="Images" /> | 
				
			||||||
 | 
					    <Folder Include="Images" /> | 
				
			||||||
 | 
					  </ItemGroup> | 
				
			||||||
 | 
					  <ItemGroup> | 
				
			||||||
 | 
					    <ProjectReference Include="..\..\src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj"> | 
				
			||||||
 | 
					      <Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project> | 
				
			||||||
 | 
					      <Name>ICSharpCode.AvalonEdit</Name> | 
				
			||||||
 | 
					    </ProjectReference> | 
				
			||||||
 | 
					  </ItemGroup> | 
				
			||||||
 | 
					  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | 
				
			||||||
 | 
					</Project> | 
				
			||||||
| 
		 After Width: | Height: | Size: 676 B  | 
| 
		 After Width: | Height: | Size: 672 B  | 
| 
		 After Width: | Height: | Size: 575 B  | 
| 
		 After Width: | Height: | Size: 1.1 KiB  | 
| 
		 After Width: | Height: | Size: 646 B  | 
| 
		 After Width: | Height: | Size: 724 B  | 
| 
		 After Width: | Height: | Size: 501 B  | 
| 
		 After Width: | Height: | Size: 788 B  | 
| 
		 After Width: | Height: | Size: 1.1 KiB  | 
@ -0,0 +1,31 @@ | 
				
			|||||||
 | 
					#region Using directives
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using System; | 
				
			||||||
 | 
					using System.Reflection; | 
				
			||||||
 | 
					using System.Runtime.InteropServices; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// General Information about an assembly is controlled through the following 
 | 
				
			||||||
 | 
					// set of attributes. Change these attribute values to modify the information
 | 
				
			||||||
 | 
					// associated with an assembly.
 | 
				
			||||||
 | 
					[assembly: AssemblyTitle("AvalonEdit.Sample")] | 
				
			||||||
 | 
					[assembly: AssemblyDescription("")] | 
				
			||||||
 | 
					[assembly: AssemblyConfiguration("")] | 
				
			||||||
 | 
					[assembly: AssemblyCompany("")] | 
				
			||||||
 | 
					[assembly: AssemblyProduct("AvalonEdit.Sample")] | 
				
			||||||
 | 
					[assembly: AssemblyCopyright("Copyright 2009")] | 
				
			||||||
 | 
					[assembly: AssemblyTrademark("")] | 
				
			||||||
 | 
					[assembly: AssemblyCulture("")] | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// This sets the default COM visibility of types in the assembly to invisible.
 | 
				
			||||||
 | 
					// If you need to expose a type to COM, use [ComVisible(true)] on that type.
 | 
				
			||||||
 | 
					[assembly: ComVisible(false)] | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// The assembly version has following format :
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// Major.Minor.Build.Revision
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// You can specify all the values or you can use the default the Revision and 
 | 
				
			||||||
 | 
					// Build Numbers by using the '*' as shown below:
 | 
				
			||||||
 | 
					[assembly: AssemblyVersion("1.0.*")] | 
				
			||||||
@ -0,0 +1,27 @@ | 
				
			|||||||
 | 
					#region Using directives
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using System.Resources; | 
				
			||||||
 | 
					using System.Windows; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//In order to begin building localizable applications, set 
 | 
				
			||||||
 | 
					//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
 | 
				
			||||||
 | 
					//inside a <PropertyGroup>.  For example, if you are using US english
 | 
				
			||||||
 | 
					//in your source files, set the <UICulture> to en-US.  Then uncomment
 | 
				
			||||||
 | 
					//the NeutralResourceLanguage attribute below.  Update the "en-US" in
 | 
				
			||||||
 | 
					//the line below to match the UICulture setting in the project file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[assembly: ThemeInfo( | 
				
			||||||
 | 
					    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
 | 
				
			||||||
 | 
					    //(used if a resource is not found in the page, 
 | 
				
			||||||
 | 
					    // or application resource dictionaries)
 | 
				
			||||||
 | 
					    ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
 | 
				
			||||||
 | 
					    //(used if a resource is not found in the page, 
 | 
				
			||||||
 | 
					    // app, or any theme specific resource dictionaries)
 | 
				
			||||||
 | 
					)] | 
				
			||||||
@ -0,0 +1,69 @@ | 
				
			|||||||
 | 
					<Window x:Class="AvalonEdit.Sample.Window1" | 
				
			||||||
 | 
						xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | 
				
			||||||
 | 
						xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | 
				
			||||||
 | 
						xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit" | 
				
			||||||
 | 
					    xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" | 
				
			||||||
 | 
						Title="AvalonEdit.Sample" Height="500" Width="700" | 
				
			||||||
 | 
						> | 
				
			||||||
 | 
						<DockPanel> | 
				
			||||||
 | 
							<ToolBar DockPanel.Dock="Top"> | 
				
			||||||
 | 
								<ToolBar.Resources> | 
				
			||||||
 | 
									<Style TargetType="{x:Type Image}"> | 
				
			||||||
 | 
										<Style.Triggers> | 
				
			||||||
 | 
											<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ButtonBase}, AncestorLevel=1}, Path=IsEnabled}" Value="False"> | 
				
			||||||
 | 
												<Setter Property="Opacity" Value="0.30" /> | 
				
			||||||
 | 
											</DataTrigger> | 
				
			||||||
 | 
										</Style.Triggers> | 
				
			||||||
 | 
									</Style> | 
				
			||||||
 | 
								</ToolBar.Resources> | 
				
			||||||
 | 
								<Button Click="openFileClick"><Image Source="Images/Open.png" Height="16"/></Button> | 
				
			||||||
 | 
								<Button Click="saveFileClick"><Image Source="Images/Save.png" Height="16"/></Button> | 
				
			||||||
 | 
								<Separator/> | 
				
			||||||
 | 
								<Button Command="Cut"><Image Source="Images/Cut.png" Height="16"/></Button> | 
				
			||||||
 | 
								<Button Command="Copy"><Image Source="Images/Copy.png" Height="16"/></Button> | 
				
			||||||
 | 
								<Button Command="Paste"><Image Source="Images/Paste.png" Height="16"/></Button> | 
				
			||||||
 | 
								<Button Command="Delete"><Image Source="Images/Delete.png" Height="16"/></Button> | 
				
			||||||
 | 
							    <Separator/> | 
				
			||||||
 | 
								<Button Command="Undo"><Image Source="Images/Undo.png" Height="16"/></Button> | 
				
			||||||
 | 
								<Button Command="Redo"><Image Source="Images/Redo.png" Height="16"/></Button> | 
				
			||||||
 | 
								<Separator/> | 
				
			||||||
 | 
								<CheckBox IsChecked="{Binding ElementName=textEditor,Path=WordWrap}"> | 
				
			||||||
 | 
									<Image Source="Images/WordWrap.png" Height="16"/> | 
				
			||||||
 | 
								</CheckBox> | 
				
			||||||
 | 
								<CheckBox IsChecked="{Binding ElementName=textEditor,Path=ShowLineNumbers}"> | 
				
			||||||
 | 
									<TextBlock Width="16" TextAlignment="Center">#</TextBlock> | 
				
			||||||
 | 
								</CheckBox> | 
				
			||||||
 | 
								<CheckBox IsChecked="{Binding ElementName=textEditor,Path=Options.ShowEndOfLine}"> | 
				
			||||||
 | 
									<TextBlock Width="16" TextAlignment="Center">¶</TextBlock> | 
				
			||||||
 | 
								</CheckBox> | 
				
			||||||
 | 
								<ComboBox Name="highlightingComboBox" | 
				
			||||||
 | 
									SelectedItem="{Binding SyntaxHighlighting, ElementName=textEditor}" | 
				
			||||||
 | 
									ItemsSource="{Binding Source={x:Static avalonEdit:HighlightingManager.Instance}, Path=Highlightings}"/> | 
				
			||||||
 | 
							</ToolBar> | 
				
			||||||
 | 
							<Grid> | 
				
			||||||
 | 
								<Grid.ColumnDefinitions> | 
				
			||||||
 | 
									<ColumnDefinition Width="1*"/> | 
				
			||||||
 | 
									<ColumnDefinition Width="100"/> | 
				
			||||||
 | 
								</Grid.ColumnDefinitions> | 
				
			||||||
 | 
								<avalonEdit:TextEditor | 
				
			||||||
 | 
									Name="textEditor" | 
				
			||||||
 | 
									FontFamily="Consolas" | 
				
			||||||
 | 
									FontSize="10pt" | 
				
			||||||
 | 
								> | 
				
			||||||
 | 
									Initial Text | 
				
			||||||
 | 
								</avalonEdit:TextEditor> | 
				
			||||||
 | 
								<GridSplitter Grid.Column="1" Width="4" HorizontalAlignment="Left"/> | 
				
			||||||
 | 
								<DockPanel Grid.Column="1" Margin="4 0 0 0"> | 
				
			||||||
 | 
									<ComboBox Name="propertyGridComboBox" DockPanel.Dock="Top" | 
				
			||||||
 | 
									          SelectedIndex="0" SelectionChanged="propertyGridComboBoxSelectionChanged"> | 
				
			||||||
 | 
										<ComboBoxItem>TextEditor</ComboBoxItem> | 
				
			||||||
 | 
										<ComboBoxItem>Options</ComboBoxItem> | 
				
			||||||
 | 
										<ComboBoxItem>TextArea</ComboBoxItem> | 
				
			||||||
 | 
									</ComboBox> | 
				
			||||||
 | 
									<WindowsFormsHost DockPanel.Dock="Right" Name="propertyGridHost"> | 
				
			||||||
 | 
										<forms:PropertyGrid x:Name="propertyGrid"/> | 
				
			||||||
 | 
									</WindowsFormsHost> | 
				
			||||||
 | 
								</DockPanel> | 
				
			||||||
 | 
							</Grid> | 
				
			||||||
 | 
						</DockPanel> | 
				
			||||||
 | 
					</Window> | 
				
			||||||
@ -0,0 +1,78 @@ | 
				
			|||||||
 | 
					// <file>
 | 
				
			||||||
 | 
					//     <copyright see="prj:///doc/copyright.txt"/>
 | 
				
			||||||
 | 
					//     <license see="prj:///doc/license.txt"/>
 | 
				
			||||||
 | 
					//     <owner name="Daniel Grunwald"/>
 | 
				
			||||||
 | 
					//     <version>$Revision$</version>
 | 
				
			||||||
 | 
					// </file>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using System; | 
				
			||||||
 | 
					using System.Collections.Generic; | 
				
			||||||
 | 
					using System.IO; | 
				
			||||||
 | 
					using System.Text; | 
				
			||||||
 | 
					using System.Windows; | 
				
			||||||
 | 
					using System.Windows.Controls; | 
				
			||||||
 | 
					using System.Windows.Data; | 
				
			||||||
 | 
					using System.Windows.Documents; | 
				
			||||||
 | 
					using System.Windows.Input; | 
				
			||||||
 | 
					using System.Windows.Media; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using ICSharpCode.AvalonEdit.Highlighting; | 
				
			||||||
 | 
					using Microsoft.Win32; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace AvalonEdit.Sample | 
				
			||||||
 | 
					{ | 
				
			||||||
 | 
						/// <summary>
 | 
				
			||||||
 | 
						/// Interaction logic for Window1.xaml
 | 
				
			||||||
 | 
						/// </summary>
 | 
				
			||||||
 | 
						public partial class Window1 : Window | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							public Window1() | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								InitializeComponent(); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							string currentFileName; | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							void openFileClick(object sender, RoutedEventArgs e) | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								OpenFileDialog dlg = new OpenFileDialog(); | 
				
			||||||
 | 
								dlg.CheckFileExists = true; | 
				
			||||||
 | 
								if (dlg.ShowDialog() ?? false) { | 
				
			||||||
 | 
									currentFileName = dlg.FileName; | 
				
			||||||
 | 
									textEditor.Load(currentFileName); | 
				
			||||||
 | 
									textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(currentFileName)); | 
				
			||||||
 | 
								} | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							void saveFileClick(object sender, EventArgs e) | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								if (currentFileName == null) { | 
				
			||||||
 | 
									SaveFileDialog dlg = new SaveFileDialog(); | 
				
			||||||
 | 
									dlg.DefaultExt = ".txt"; | 
				
			||||||
 | 
									if (dlg.ShowDialog() ?? false) { | 
				
			||||||
 | 
										currentFileName = dlg.FileName; | 
				
			||||||
 | 
									} else { | 
				
			||||||
 | 
										return; | 
				
			||||||
 | 
									} | 
				
			||||||
 | 
								} | 
				
			||||||
 | 
								textEditor.Save(currentFileName); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							void propertyGridComboBoxSelectionChanged(object sender, RoutedEventArgs e) | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								if (propertyGrid == null) | 
				
			||||||
 | 
									return; | 
				
			||||||
 | 
								switch (propertyGridComboBox.SelectedIndex) { | 
				
			||||||
 | 
									case 0: | 
				
			||||||
 | 
										propertyGrid.SelectedObject = textEditor; | 
				
			||||||
 | 
										break; | 
				
			||||||
 | 
									case 1: | 
				
			||||||
 | 
										propertyGrid.SelectedObject = textEditor.Options; | 
				
			||||||
 | 
										break; | 
				
			||||||
 | 
									case 2: | 
				
			||||||
 | 
										propertyGrid.SelectedObject = textEditor.TextArea; | 
				
			||||||
 | 
										break; | 
				
			||||||
 | 
								} | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,59 @@ | 
				
			|||||||
 | 
					// <file>
 | 
				
			||||||
 | 
					//     <copyright see="prj:///doc/copyright.txt"/>
 | 
				
			||||||
 | 
					//     <license see="prj:///doc/license.txt"/>
 | 
				
			||||||
 | 
					//     <owner name="Daniel Grunwald"/>
 | 
				
			||||||
 | 
					//     <version>$Revision$</version>
 | 
				
			||||||
 | 
					// </file>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using System; | 
				
			||||||
 | 
					using System.Collections.Generic; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace ICSharpCode.AvalonEdit.Utils | 
				
			||||||
 | 
					{ | 
				
			||||||
 | 
						/// <summary>
 | 
				
			||||||
 | 
						/// This class is used to prevent stack overflows by representing a 'busy' flag
 | 
				
			||||||
 | 
						/// that prevents reentrance when another call is running.
 | 
				
			||||||
 | 
						/// However, using a simple 'bool busy' is not thread-safe, so we use a
 | 
				
			||||||
 | 
						/// thread-static BusyManager.
 | 
				
			||||||
 | 
						/// </summary>
 | 
				
			||||||
 | 
						static class BusyManager | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							public struct BusyLock : IDisposable | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								public static readonly BusyLock Failed = new BusyLock(null); | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								readonly List<object> objectList; | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								public BusyLock(List<object> objectList) | 
				
			||||||
 | 
								{ | 
				
			||||||
 | 
									this.objectList = objectList; | 
				
			||||||
 | 
								} | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								public bool Success { | 
				
			||||||
 | 
									get { return objectList != null; } | 
				
			||||||
 | 
								} | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								public void Dispose() | 
				
			||||||
 | 
								{ | 
				
			||||||
 | 
									if (objectList != null) { | 
				
			||||||
 | 
										objectList.RemoveAt(objectList.Count - 1); | 
				
			||||||
 | 
									} | 
				
			||||||
 | 
								} | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							[ThreadStatic] static List<object> _activeObjects; | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							public static BusyLock Enter(object obj) | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								List<object> activeObjects = _activeObjects; | 
				
			||||||
 | 
								if (activeObjects == null) | 
				
			||||||
 | 
									activeObjects = _activeObjects = new List<object>(); | 
				
			||||||
 | 
								for (int i = 0; i < activeObjects.Count; i++) { | 
				
			||||||
 | 
									if (activeObjects[i] == obj) | 
				
			||||||
 | 
										return BusyLock.Failed; | 
				
			||||||
 | 
								} | 
				
			||||||
 | 
								activeObjects.Add(obj); | 
				
			||||||
 | 
								return new BusyLock(activeObjects); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					} | 
				
			||||||