~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/Main/Base/Project/Src/Gui/IViewContent.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using System.Collections.Generic;
 
6
using System.IO;
 
7
using System.Windows.Forms;
 
8
 
 
9
using ICSharpCode.Core;
 
10
 
 
11
namespace ICSharpCode.SharpDevelop.Gui
 
12
{
 
13
        public delegate void SaveEventHandler(object sender, SaveEventArgs e);
 
14
        
 
15
        public class SaveEventArgs : System.EventArgs
 
16
        {
 
17
                bool successful;
 
18
                
 
19
                public bool Successful {
 
20
                        get {
 
21
                                return successful;
 
22
                        }
 
23
                }
 
24
                
 
25
                public SaveEventArgs(bool successful)
 
26
                {
 
27
                        this.successful = successful;
 
28
                }
 
29
        }
 
30
        
 
31
        /// <summary>
 
32
        /// IViewContent is the base interface for "windows" in the document area of SharpDevelop.
 
33
        /// A view content is a view onto multiple files, or other content that opens like a document
 
34
        /// (e.g. the start page).
 
35
        /// </summary>
 
36
        public interface IViewContent : IDisposable, ICanBeDirty, IServiceProvider
 
37
        {
 
38
                /// <summary>
 
39
                /// This is the UI element for the view.
 
40
                /// You can use both Windows.Forms and WPF controls.
 
41
                /// </summary>
 
42
                object Control {
 
43
                        get;
 
44
                }
 
45
                
 
46
                /// <summary>
 
47
                /// Gets the control which has focus initially.
 
48
                /// </summary>
 
49
                object InitiallyFocusedControl {
 
50
                        get;
 
51
                }
 
52
                
 
53
                /// <summary>
 
54
                /// The workbench window in which this view is displayed.
 
55
                /// </summary>
 
56
                IWorkbenchWindow WorkbenchWindow {
 
57
                        get;
 
58
                        set;
 
59
                }
 
60
                
 
61
                /// <summary>
 
62
                /// Is raised when the value of the TabPageText property changes.
 
63
                /// </summary>
 
64
                event EventHandler TabPageTextChanged;
 
65
                
 
66
                /// <summary>
 
67
                /// The text on the tab page when more than one view content
 
68
                /// is attached to a single window.
 
69
                /// </summary>
 
70
                string TabPageText {
 
71
                        get;
 
72
                }
 
73
                
 
74
                /// <summary>
 
75
                /// The title of the view content. This normally is the title of the primary file being edited.
 
76
                /// </summary>
 
77
                string TitleName {
 
78
                        get;
 
79
                }
 
80
                
 
81
                /// <summary>
 
82
                /// Is called each time the name for the content has changed.
 
83
                /// </summary>
 
84
                event EventHandler TitleNameChanged;
 
85
                
 
86
                /// <summary>
 
87
                /// The tooltip that will be shown when you hover the mouse over the title
 
88
                /// </summary>
 
89
                string InfoTip {
 
90
                        get;
 
91
                }
 
92
 
 
93
                /// <summary>
 
94
                /// Is called each time the info tip for the content has changed.
 
95
                /// </summary>
 
96
                event EventHandler InfoTipChanged;
 
97
 
 
98
                /// <summary>
 
99
                /// Saves the content to the location <code>fileName</code>
 
100
                /// </summary>
 
101
                /// <remarks>
 
102
                /// When the user switches between multiple views editing the same file, a view
 
103
                /// change will trigger one view content to save that file into a memory stream
 
104
                /// and the other view content will load the file from that memory stream.
 
105
                /// </remarks>
 
106
                void Save(OpenedFile file, Stream stream);
 
107
                
 
108
                /// <summary>
 
109
                /// Load or reload the content of the specified file from the stream.
 
110
                /// </summary>
 
111
                /// <remarks>
 
112
                /// When the user switches between multiple views editing the same file, a view
 
113
                /// change will trigger one view content to save that file into a memory stream
 
114
                /// and the other view content will load the file from that memory stream.
 
115
                /// </remarks>
 
116
                void Load(OpenedFile file, Stream stream);
 
117
                
 
118
                /// <summary>
 
119
                /// Gets the list of files that are being edited using this view content.
 
120
                /// The returned collection usually is read-only.
 
121
                /// </summary>
 
122
                IList<OpenedFile> Files { get; }
 
123
                
 
124
                /// <summary>
 
125
                /// Gets the primary file being edited. Might return null if no file is edited.
 
126
                /// </summary>
 
127
                OpenedFile PrimaryFile { get; }
 
128
                
 
129
                /// <summary>
 
130
                /// Gets the name of the primary file being edited. Might return null if no file is edited.
 
131
                /// </summary>
 
132
                FileName PrimaryFileName { get; }
 
133
                
 
134
                /// <summary>
 
135
                /// Builds an <see cref="INavigationPoint"/> for the current position.
 
136
                /// </summary>
 
137
                INavigationPoint BuildNavPoint();
 
138
                
 
139
                bool IsDisposed { get; }
 
140
                
 
141
                event EventHandler Disposed;
 
142
                
 
143
                /// <summary>
 
144
                /// Gets if the view content is read-only (can be saved only when choosing another file name).
 
145
                /// </summary>
 
146
                bool IsReadOnly { get; }
 
147
                
 
148
                /// <summary>
 
149
                /// Gets if the view content is view-only (cannot be saved at all).
 
150
                /// </summary>
 
151
                bool IsViewOnly { get; }
 
152
                
 
153
                /// <summary>
 
154
                /// Gets whether this view content should be closed when the solution is closed.
 
155
                /// </summary>
 
156
                bool CloseWithSolution { get; }
 
157
                
 
158
                #region Secondary view content support
 
159
                /// <summary>
 
160
                /// Gets the collection that stores the secondary view contents.
 
161
                /// </summary>
 
162
                ICollection<IViewContent> SecondaryViewContents { get; }
 
163
                
 
164
                
 
165
                /// <summary>
 
166
                /// Gets switching without a Save/Load cycle for <paramref name="file"/> is supported
 
167
                /// when switching from this view content to <paramref name="newView"/>.
 
168
                /// </summary>
 
169
                bool SupportsSwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView);
 
170
                
 
171
                /// <summary>
 
172
                /// Gets switching without a Save/Load cycle for <paramref name="file"/> is supported
 
173
                /// when switching from <paramref name="oldView"/> to this view content.
 
174
                /// </summary>
 
175
                bool SupportsSwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView);
 
176
                
 
177
                /// <summary>
 
178
                /// Executes an action before switching from this view content to the new view content.
 
179
                /// </summary>
 
180
                void SwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView);
 
181
                
 
182
                /// <summary>
 
183
                /// Executes an action before switching from the old view content to this view content.
 
184
                /// </summary>
 
185
                void SwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView);
 
186
                #endregion
 
187
        }
 
188
}