Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / FileNameEditor.cs / 1 / FileNameEditor.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Windows.Forms.Design { using System.Runtime.Serialization.Formatters; using System; using System.ComponentModel; using System.ComponentModel.Design; using System.Design; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.Drawing.Design; using System.Windows.Forms; using Microsoft.Win32; ////// /// public class FileNameEditor : UITypeEditor { private OpenFileDialog openFileDialog; ////// Provides an /// editor for filenames. ////// /// Edits the given object value using the editor style provided by /// GetEditorStyle. A service provider is provided so that any /// required editing services can be obtained. /// [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] // everything in this assembly is full trust. public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { Debug.Assert(provider != null, "No service provider; we cannot edit the value"); if (provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); Debug.Assert(edSvc != null, "No editor service; we cannot edit the value"); if (edSvc != null) { if (openFileDialog == null) { openFileDialog = new OpenFileDialog(); InitializeDialog(openFileDialog); } if (value is string) { openFileDialog.FileName = (string)value; } if (openFileDialog.ShowDialog() == DialogResult.OK) { value = openFileDialog.FileName; } } } return value; } ////// /// [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] // everything in this assembly is full trust. public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { return UITypeEditorEditStyle.Modal; } ///Gets the editing style of the Edit method. If the method /// is not supported, this will return None. ////// /// Initializes the open file dialog when it is created. This gives you /// an opportunity to configure the dialog as you please. The default /// implementation provides a generic file filter and title. /// [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] protected virtual void InitializeDialog(OpenFileDialog openFileDialog) { openFileDialog.Filter = SR.GetString(SR.GenericFileFilter); openFileDialog.Title = SR.GetString(SR.GenericOpenFile); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SafeWaitHandle.cs
- ListViewEditEventArgs.cs
- ISO2022Encoding.cs
- PrintPreviewGraphics.cs
- StylusButtonCollection.cs
- TextBox.cs
- LinqDataSourceDeleteEventArgs.cs
- SQLDateTime.cs
- ClientSettingsSection.cs
- ResourceDictionary.cs
- Int16KeyFrameCollection.cs
- GraphicsContainer.cs
- DefaultMemberAttribute.cs
- ChannelServices.cs
- FaultDescriptionCollection.cs
- URLMembershipCondition.cs
- BasePropertyDescriptor.cs
- CardSpaceSelector.cs
- Rect.cs
- PatternMatcher.cs
- IriParsingElement.cs
- StubHelpers.cs
- ServiceRoute.cs
- FlowDocumentReaderAutomationPeer.cs
- BmpBitmapEncoder.cs
- TrackingProfileManager.cs
- OdbcConnectionHandle.cs
- WebConfigurationHost.cs
- ColorConvertedBitmapExtension.cs
- HostingPreferredMapPath.cs
- FontDialog.cs
- latinshape.cs
- SystemIPAddressInformation.cs
- TranslateTransform3D.cs
- FixedTextContainer.cs
- FunctionMappingTranslator.cs
- OptimizedTemplateContentHelper.cs
- PropertyPathConverter.cs
- StickyNoteHelper.cs
- DownloadProgressEventArgs.cs
- AnonymousIdentificationModule.cs
- SingletonConnectionReader.cs
- NavigationPropertyEmitter.cs
- StylusPointProperties.cs
- ItemsControl.cs
- SignatureDescription.cs
- SerializationFieldInfo.cs
- Rect3DConverter.cs
- DataGridComponentEditor.cs
- RewritingPass.cs
- Compilation.cs
- GroupBox.cs
- CounterCreationDataConverter.cs
- Point3DAnimationUsingKeyFrames.cs
- TableLayout.cs
- CorePropertiesFilter.cs
- FamilyTypeface.cs
- SqlRowUpdatingEvent.cs
- SparseMemoryStream.cs
- SqlUserDefinedAggregateAttribute.cs
- WindowsListViewItem.cs
- UrlMappingCollection.cs
- Helper.cs
- BindToObject.cs
- SplitContainer.cs
- DataGridRowHeader.cs
- SafeSystemMetrics.cs
- LineBreakRecord.cs
- AccessDataSource.cs
- Math.cs
- ServiceDescriptionImporter.cs
- BulletChrome.cs
- MonthChangedEventArgs.cs
- RoleManagerSection.cs
- LinqToSqlWrapper.cs
- ClrProviderManifest.cs
- WindowsFormsLinkLabel.cs
- ListViewUpdatedEventArgs.cs
- HtmlEncodedRawTextWriter.cs
- WebPartMinimizeVerb.cs
- ListViewTableRow.cs
- DataGridAutoFormatDialog.cs
- WmpBitmapDecoder.cs
- BindingValueChangedEventArgs.cs
- SafeReadContext.cs
- ActivityCollectionMarkupSerializer.cs
- KerberosTicketHashIdentifierClause.cs
- StrongNamePublicKeyBlob.cs
- ViewValidator.cs
- DataTableTypeConverter.cs
- StringArrayConverter.cs
- SQlBooleanStorage.cs
- PageAsyncTaskManager.cs
- DataTableReader.cs
- WebRequest.cs
- TypedElement.cs
- ParallelTimeline.cs
- LocatorBase.cs
- HandleTable.cs
- Profiler.cs