added some development tools
[windows-sources.git] / developer / VSSDK / VisualStudioIntegration / Common / Source / CSharp / Shell90 / LogicalView.cs
blob1f0bd340514502134872a400cffcbc2a26288eb3
1 //------------------------------------------------------------------------------
2 // <copyright file="LogicalView.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 // </copyright>
5 //------------------------------------------------------------------------------
7 namespace Microsoft.VisualStudio.Shell {
9 using System;
10 using System.ComponentModel;
11 using System.Diagnostics;
12 using System.Globalization;
14 /// <include file='doc\LogicalView.uex' path='docs/doc[@for="LogicalView"]' />
15 /// <devdoc>
16 /// This enum lists the supported logical views.
17 /// </devdoc>
18 [TypeConverter(typeof(LogicalViewConverter))]
19 public enum LogicalView {
21 /// <include file='doc\LogicalView.uex' path='docs/doc[@for="LogicalView.Primary"]/*' />
22 Primary,
23 /// <include file='doc\LogicalView.uex' path='docs/doc[@for="LogicalView.Any"]/*' />
24 Any,
25 /// <include file='doc\LogicalView.uex' path='docs/doc[@for="LogicalView.Debugging"]/*' />
26 Debugging,
27 /// <include file='doc\LogicalView.uex' path='docs/doc[@for="LogicalView.Code"]/*' />
28 Code,
29 /// <include file='doc\LogicalView.uex' path='docs/doc[@for="LogicalView.Designer"]/*' />
30 Designer,
31 /// <include file='doc\LogicalView.uex' path='docs/doc[@for="LogicalView.Text"]/*' />
32 Text,
33 /// <include file='doc\LogicalView.uex' path='docs/doc[@for="LogicalView.UserChoose"]/*' />
34 UserChoose,
35 /// <include file='doc\LogicalView.uex' path='docs/doc[@for="LogicalView.ProjectSpecific"]/*' />
36 ProjectSpecific
39 /// <devdoc>
40 /// This type converter inherits from the normal enum
41 /// converter. It adds the ability to convert to/from
42 /// GUID types.
43 /// </devdoc>
44 internal class LogicalViewConverter : EnumConverter {
46 private Guid[] _guids = new Guid[] {
47 new Guid("00000000-0000-0000-0000-000000000000"),
48 new Guid("FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"),
49 new Guid("7651A700-06E5-11D1-8EBD-00A0C90F26EA"),
50 new Guid("7651A701-06E5-11D1-8EBD-00A0C90F26EA"),
51 new Guid("7651A702-06E5-11D1-8EBD-00A0C90F26EA"),
52 new Guid("7651A703-06E5-11D1-8EBD-00A0C90F26EA"),
53 new Guid("7651A704-06E5-11D1-8EBD-00A0C90F26EA"),
54 new Guid("80A3471A-6B87-433E-A75A-9D461DE0645F")
57 private LogicalView[] _views = new LogicalView[] {
58 LogicalView.Primary,
59 LogicalView.Any,
60 LogicalView.Debugging,
61 LogicalView.Code,
62 LogicalView.Designer,
63 LogicalView.Text,
64 LogicalView.UserChoose,
65 LogicalView.ProjectSpecific
68 public LogicalViewConverter(Type enumType) : base(enumType) {
69 Debug.Assert(_views.Length == _guids.Length, "Mismatch in view / guid relationship");
72 /// <devdoc>
73 /// Gets a value indicating whether this converter
74 /// can convert an object in the given source type to an enumeration object using
75 /// the specified context.
76 /// </devdoc>
77 public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
78 if (sourceType == typeof(Guid)) {
79 return true;
81 return base.CanConvertFrom(context, sourceType);
84 /// <devdoc>
85 /// Gets a value indicating whether this converter can
86 /// convert an object to the given destination type using the context.
87 /// </devdoc>
88 public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) {
89 if (destinationType == typeof(Guid)) {
90 return true;
92 return base.CanConvertTo(context, destinationType);
95 /// <devdoc>
96 /// Converts the specified value object to an enumeration object.
97 /// </devdoc>
98 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
99 if (value is Guid) {
100 for (int i = 0; i < _guids.Length; i++) {
101 if (value.Equals(_guids[i])) {
102 return _views[i];
106 return base.ConvertFrom(context, culture, value);
109 /// <devdoc>
110 /// Converts the given value object to the specified destination type.
111 /// </devdoc>
112 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
113 if (destinationType == null) {
114 throw new ArgumentNullException("destinationType");
117 if (destinationType == typeof(Guid) && value != null) {
118 for (int i = 0; i < _views.Length; i++) {
119 if (value.Equals(_views[i])) {
120 return _guids[i];
125 return base.ConvertTo(context, culture, value, destinationType);