public void Save(Stream stream, ResourceStore resourceStore)
			{
				this.WriteResourcesToBuffer();
				if (buffer == null || buffer.Length == 0) return;
				stream.Write(buffer, 0, buffer.Length);
				// SD2-1588:
				// The possible call to AddFileToProject below
				// can cause a Subversion add command for the file to be issued.
				// For this command to succeed,
				// Subversion seems to require delete access to the file.
				// Since the OpenedFile implementation does not grant
				// delete access (what is very reasonable imho),
				// close the stream here to "unlock" it.
				// Of course this only works as long as the OpenedFile
				// implementation does not require the stream to be left open
				// after the save operation.
				stream.Close();
				
				// Check for file existance before adding it to the project
				// because this may as well be a save operation to a
				// MemoryStream before the file has been written to disk
				// for the first time.
				if (IsNewFile && File.Exists(this.OpenedFile.FileName)) {
					resourceStore.AddFileToProject(this);
					IsNewFile = false;
				}
			}
		public DesignerResourceService(ResourceStore store)
		{
			if (store == null)
				throw new ArgumentNullException("store");
			this.store = store;
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectResourceInfo"/> class
        /// and stores the resource value in the <see cref="OriginalValue"/> property
        /// if the resource file is found and it contains the specified key.
        /// </summary>
        /// <param name="resourceFile">The full name of the resource file that contains the resource.</param>
        /// <param name="resourceKey">The resource key.</param>
        public ProjectResourceInfo(string resourceFile, string resourceKey)
        {
            if (resourceFile == null)
            {
                throw new ArgumentNullException("resourceFile");
            }
            if (resourceKey == null)
            {
                throw new ArgumentNullException("resourceKey");
            }
            this.resourceFile = resourceFile;
            this.resourceKey  = resourceKey;

            if (File.Exists(resourceFile))
            {
                OpenedFile openedFile = FileService.GetOpenedFile(resourceFile);
                Stream     s;
                if (openedFile != null)
                {
                    s = openedFile.OpenRead();
                }
                else
                {
                    s = new FileStream(resourceFile, FileMode.Open, FileAccess.Read, FileShare.Read);
                }

                using (s) {
                    using (IResourceReader reader = ResourceStore.CreateResourceReader(s, ResourceStore.GetResourceType(resourceFile))) {
                        ResXResourceReader resXReader = reader as ResXResourceReader;
                        if (resXReader != null)
                        {
                            resXReader.BasePath = Path.GetDirectoryName(resourceFile);
                        }

                        foreach (DictionaryEntry entry in reader)
                        {
                            if (String.Equals(resourceKey, entry.Key as string, StringComparison.Ordinal))
                            {
                                this.originalValue = entry.Value;
                                break;
                            }
                        }
                    }
                }
            }
        }
		FormsDesignerViewContent(IViewContent primaryViewContent)
			: base()
		{
			this.TabPageText = "${res:FormsDesigner.DesignTabPages.DesignTabPage}";
			
			if (!FormKeyHandler.inserted) {
				FormKeyHandler.Insert();
			}
			
			this.primaryViewContent = primaryViewContent;
			
			this.UserContent = this.pleaseWaitLabel;
			
			this.sourceCodeStorage = new DesignerSourceCodeStorage();
			this.resourceStore = new ResourceStore(this);
			
			this.IsActiveViewContentChanged += this.IsActiveViewContentChangedHandler;
			
			FileService.FileRemoving += this.FileServiceFileRemoving;
			ICSharpCode.SharpDevelop.Debugging.DebuggerService.DebugStarting += this.DebugStarting;
		}
		FormsDesignerViewContent(IViewContent primaryViewContent)
			: base()
		{
			this.TabPageText = "${res:FormsDesigner.DesignTabPages.DesignTabPage}";
			
			if (!FormKeyHandler.inserted) {
				FormKeyHandler.Insert();
			}
			
			this.primaryViewContent = primaryViewContent;
			
			this.Control.BackColor = Color.White;
			this.Control.RightToLeft = RightToLeft.No;
			// Make sure auto-scaling is based on the correct font.
			// This is required on Vista, I don't know why it works correctly in XP
			this.Control.Font = Control.DefaultFont;
			
			this.UserControl = this.pleaseWaitLabel;
			
			this.sourceCodeStorage = new DesignerSourceCodeStorage();
			this.resourceStore = new ResourceStore(this);
			
			// null check is required to support running in unit test mode
			if (WorkbenchSingleton.Workbench != null) {
				this.IsActiveViewContentChanged += this.IsActiveViewContentChangedHandler;
			}
			
			FileService.FileRemoving += this.FileServiceFileRemoving;
			ICSharpCode.SharpDevelop.Debugging.DebuggerService.DebugStarting += this.DebugStarting;
		}