Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Core.Presentation / System / Activities / Core / Presentation / ResizeGrip.cs / 1305376 / ResizeGrip.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Core.Presentation { using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Runtime; using System.Activities.Presentation.Model; using System.Activities.Presentation; using System.ComponentModel; //This class is visual representation of ResizeGrip like control, which is used in a Grid to allow resizing. class ResizeGrip : Control { public static readonly DependencyProperty IconProperty = DependencyProperty.Register("Icon", typeof(DrawingBrush), typeof(ResizeGrip)); public static readonly DependencyProperty ParentFlowchartDesignerProperty = DependencyProperty.Register("ParentFlowchartDesigner", typeof(FlowchartDesigner), typeof(ResizeGrip)); public static readonly DependencyProperty ParentGridProperty = DependencyProperty.Register("ParentGrid", typeof(Grid), typeof(ResizeGrip)); public static readonly DependencyProperty DisabledProperty = DependencyProperty.Register("Disabled", typeof(bool), typeof(ResizeGrip), new UIPropertyMetadata(false)); Point offset; public DrawingBrush Icon { get { return (DrawingBrush)GetValue(IconProperty); } set { SetValue(IconProperty, value); } } public FlowchartDesigner ParentFlowchartDesigner { get { return (FlowchartDesigner)GetValue(ParentFlowchartDesignerProperty); } set { SetValue(ParentFlowchartDesignerProperty, value); } } public Grid ParentGrid { get { return (Grid)GetValue(ParentGridProperty); } set { SetValue(ParentGridProperty, value); } } public bool Disabled { get { return (bool)GetValue(DisabledProperty); } set { SetValue(DisabledProperty, value); } } protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) { if (!this.Disabled) { this.Cursor = Cursors.SizeNWSE; this.offset = e.GetPosition(this); this.CaptureMouse(); e.Handled = true; } base.OnPreviewMouseLeftButtonDown(e); } protected override void OnMouseMove(MouseEventArgs args) { base.OnMouseMove(args); if (!this.Disabled) { if (args.LeftButton == MouseButtonState.Pressed && this.IsMouseCaptured) { FlowchartDesigner flowchartDesigner = this.ParentFlowchartDesigner; FreeFormPanel panel = flowchartDesigner.panel; Grid flowchartGrid = this.ParentGrid; Point currentPosition = Mouse.GetPosition(flowchartGrid); currentPosition.Offset(this.offset.X, this.offset.Y); flowchartDesigner.FlowchartWidth = Math.Min(Math.Max(panel.RequiredWidth, currentPosition.X), flowchartGrid.MaxWidth); flowchartDesigner.FlowchartHeight = Math.Min(Math.Max(panel.RequiredHeight, currentPosition.Y), flowchartGrid.MaxHeight); } } } protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e) { if (!this.Disabled) { FlowchartDesigner flowchartDesigner = this.ParentFlowchartDesigner; ModelItem flowchartModelItem = this.ParentFlowchartDesigner.ModelItem; using (ModelEditingScope scope = flowchartModelItem.BeginEdit(SR.FCResizeUndoUnitName)) { TypeDescriptor.GetProperties(flowchartModelItem)[FlowchartSizeFeature.WidthPropertyName].SetValue(flowchartModelItem, flowchartDesigner.FlowchartWidth); TypeDescriptor.GetProperties(flowchartModelItem)[FlowchartSizeFeature.HeightPropertyName].SetValue(flowchartModelItem, flowchartDesigner.FlowchartHeight); scope.Complete(); } Mouse.OverrideCursor = null; Mouse.Capture(null); e.Handled = true; } base.OnPreviewMouseLeftButtonUp(e); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- GenericTextProperties.cs
- RichTextBox.cs
- TaiwanLunisolarCalendar.cs
- PaperSource.cs
- ClientFormsIdentity.cs
- FileSecurity.cs
- EnglishPluralizationService.cs
- DataBoundControl.cs
- Graphics.cs
- WebCategoryAttribute.cs
- WorkflowMessageEventHandler.cs
- CancellationHandler.cs
- GeometryHitTestResult.cs
- DbCommandDefinition.cs
- WebExceptionStatus.cs
- StopStoryboard.cs
- ConversionContext.cs
- OdbcUtils.cs
- DetailsViewRow.cs
- DeclarativeConditionsCollection.cs
- OleDbConnectionInternal.cs
- HwndHostAutomationPeer.cs
- GrammarBuilderDictation.cs
- XmlSchemaInclude.cs
- BulletChrome.cs
- BitmapMetadataBlob.cs
- Pen.cs
- ColorKeyFrameCollection.cs
- XmlAnyElementAttributes.cs
- Setter.cs
- TextSpanModifier.cs
- ContentPlaceHolder.cs
- DelegatingTypeDescriptionProvider.cs
- LayoutDump.cs
- ColorAnimationBase.cs
- Types.cs
- Repeater.cs
- MetadataHelper.cs
- WebAdminConfigurationHelper.cs
- BadImageFormatException.cs
- ProgressBarRenderer.cs
- ZeroOpNode.cs
- Configuration.cs
- XmlSignatureProperties.cs
- UnsafeNativeMethods.cs
- X509CertificateRecipientServiceCredential.cs
- ScrollItemPattern.cs
- DataGridPagerStyle.cs
- FtpRequestCacheValidator.cs
- SafeLocalMemHandle.cs
- GraphicsPathIterator.cs
- SafeSecurityHandles.cs
- DataGridViewDataConnection.cs
- IODescriptionAttribute.cs
- PathSegment.cs
- DesignerLinkAdapter.cs
- MissingManifestResourceException.cs
- SqlDependencyUtils.cs
- SendingRequestEventArgs.cs
- RemotingAttributes.cs
- WindowsRegion.cs
- StyleHelper.cs
- PropertyInfo.cs
- ScriptReferenceBase.cs
- UMPAttributes.cs
- DiffuseMaterial.cs
- WebBrowserSiteBase.cs
- NetSectionGroup.cs
- TypeReference.cs
- MemberJoinTreeNode.cs
- DataSetMappper.cs
- versioninfo.cs
- StorageEndPropertyMapping.cs
- SignatureDescription.cs
- NamespaceCollection.cs
- InternalEnumValidator.cs
- SharedUtils.cs
- LocalizationParserHooks.cs
- unitconverter.cs
- ContentOperations.cs
- SoapSchemaExporter.cs
- MessageRpc.cs
- SuppressMergeCheckAttribute.cs
- BitmapEffectGroup.cs
- KeyEventArgs.cs
- DropShadowEffect.cs
- MasterPage.cs
- VectorAnimation.cs
- NullableConverter.cs
- DecoderExceptionFallback.cs
- DataGridViewCellStyle.cs
- NumericUpDown.cs
- ServiceDescription.cs
- ClosableStream.cs
- SizeF.cs
- NativeMethodsOther.cs
- PngBitmapDecoder.cs
- PropertyChangingEventArgs.cs
- TriggerAction.cs
- GZipDecoder.cs