Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / StatusCommandUI.cs / 1 / StatusCommandUI.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Windows.Forms.Design { using System.Design; using System.Runtime.InteropServices; using System.ComponentModel; using System.Diagnostics; using System; using System.Collections; using Microsoft.Win32; using System.ComponentModel.Design; using System.Drawing; using System.Windows.Forms; using System.Windows.Forms.ComponentModel; using System.Windows.Forms.Design; using System.Windows.Forms.Design.Behavior; ////// /// This class provides a single entrypoint used by the Behaviors, KeySize and KeyMoves (in CommandSets) and SelectionService to update /// the StatusBar Information. /// internal class StatusCommandUI { MenuCommand statusRectCommand = null; IMenuCommandService menuService = null; IServiceProvider serviceProvider; public StatusCommandUI(IServiceProvider provider) { this.serviceProvider = provider; } ////// /// Retrieves the menu editor service, which we cache for speed. /// private IMenuCommandService MenuService { get { if (menuService == null) { menuService = (IMenuCommandService)serviceProvider.GetService(typeof(IMenuCommandService)); } return menuService; } } ////// /// Retrieves the actual StatusRectCommand, which we cache for speed. /// private MenuCommand StatusRectCommand { get { if (statusRectCommand == null) { if (MenuService != null) { statusRectCommand = MenuService.FindCommand(MenuCommands.SetStatusRectangle); } } return statusRectCommand; } } ////// /// Actual Function which invokes the command. /// public void SetStatusInformation(Component selectedComponent, Point location) { if (selectedComponent == null) { return; } Rectangle bounds = Rectangle.Empty; Control c = selectedComponent as Control; if (c != null) { bounds = c.Bounds; } else{ PropertyDescriptor BoundsProp = TypeDescriptor.GetProperties(selectedComponent)["Bounds"]; if (BoundsProp != null && typeof(Rectangle).IsAssignableFrom(BoundsProp.PropertyType)) { bounds = (Rectangle)BoundsProp.GetValue(selectedComponent); } } if (location != Point.Empty) { bounds.X = location.X; bounds.Y = location.Y; } if (StatusRectCommand != null) { StatusRectCommand.Invoke(bounds); } } ////// /// Actual Function which invokes the command. /// public void SetStatusInformation(Component selectedComponent) { if (selectedComponent == null) { return; } Rectangle bounds = Rectangle.Empty; Control c = selectedComponent as Control; if (c != null) { bounds = c.Bounds; } else{ PropertyDescriptor BoundsProp = TypeDescriptor.GetProperties(selectedComponent)["Bounds"]; if (BoundsProp != null && typeof(Rectangle).IsAssignableFrom(BoundsProp.PropertyType)) { bounds = (Rectangle)BoundsProp.GetValue(selectedComponent); } } if (StatusRectCommand != null) { StatusRectCommand.Invoke(bounds); } } ////// /// Actual Function which invokes the command. /// public void SetStatusInformation(Rectangle bounds) { if (StatusRectCommand != null) { StatusRectCommand.Invoke(bounds); } } } } // 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
- AssemblyInfo.cs
- JpegBitmapEncoder.cs
- XamlRtfConverter.cs
- ProfessionalColors.cs
- StringExpressionSet.cs
- SplineQuaternionKeyFrame.cs
- GifBitmapDecoder.cs
- NumericExpr.cs
- ADMembershipProvider.cs
- HttpChannelBindingToken.cs
- _ServiceNameStore.cs
- SrgsSubset.cs
- FileClassifier.cs
- FamilyMapCollection.cs
- DataList.cs
- RuntimeIdentifierPropertyAttribute.cs
- SmiEventSink_Default.cs
- Timer.cs
- ObjectTokenCategory.cs
- StrongNameSignatureInformation.cs
- String.cs
- OleDbParameter.cs
- CodePrimitiveExpression.cs
- ObjectConverter.cs
- LicenseProviderAttribute.cs
- TreeNodeMouseHoverEvent.cs
- IIS7UserPrincipal.cs
- ObjectSecurityT.cs
- CodeStatement.cs
- ListItem.cs
- XmlCustomFormatter.cs
- ToolStripSystemRenderer.cs
- SqlDependencyListener.cs
- BindingWorker.cs
- ControlPropertyNameConverter.cs
- GlyphShapingProperties.cs
- TabletDeviceInfo.cs
- UIInitializationException.cs
- sqlcontext.cs
- DataTableClearEvent.cs
- MDIControlStrip.cs
- MimeReflector.cs
- InvalidDataContractException.cs
- XPathCompileException.cs
- ReverseComparer.cs
- XamlWriter.cs
- DocumentSequence.cs
- GridViewSortEventArgs.cs
- TargetFrameworkAttribute.cs
- XdrBuilder.cs
- AdCreatedEventArgs.cs
- UnsignedPublishLicense.cs
- WeakReferenceKey.cs
- MDIClient.cs
- SerializableReadOnlyDictionary.cs
- UpdateCompiler.cs
- WeakRefEnumerator.cs
- SafeMarshalContext.cs
- Drawing.cs
- ResXResourceReader.cs
- WebBaseEventKeyComparer.cs
- MessageQueuePermissionAttribute.cs
- _OverlappedAsyncResult.cs
- StylusPointProperty.cs
- XPathMultyIterator.cs
- NetStream.cs
- XmlCharCheckingWriter.cs
- XmlILIndex.cs
- LassoHelper.cs
- XmlCharCheckingWriter.cs
- ClrProviderManifest.cs
- CodeDelegateInvokeExpression.cs
- TablePattern.cs
- BitSet.cs
- NetSectionGroup.cs
- ToolBarButtonClickEvent.cs
- CodeTypeReference.cs
- RegexGroupCollection.cs
- CodeAttachEventStatement.cs
- cryptoapiTransform.cs
- PngBitmapEncoder.cs
- ButtonField.cs
- JsonGlobals.cs
- BindingValueChangedEventArgs.cs
- RequestValidator.cs
- ExpressionHelper.cs
- InnerItemCollectionView.cs
- XmlEncodedRawTextWriter.cs
- ZipPackage.cs
- RowSpanVector.cs
- GcHandle.cs
- RuleSettingsCollection.cs
- FileClassifier.cs
- XmlCharacterData.cs
- TrackingMemoryStreamFactory.cs
- XmlArrayItemAttributes.cs
- ViewStateModeByIdAttribute.cs
- Vector3DAnimation.cs
- RelatedPropertyManager.cs
- ObjectSet.cs