Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / DialogWindow.cs / 1407647 / DialogWindow.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation { using System.Windows; using System.Activities.Presentation.View; using System.Windows.Interop; using System.Windows.Input; using System.ComponentModel; internal class DialogWindow : Window { public static readonly DependencyProperty ContextProperty = DependencyProperty.Register("Context", typeof(EditingContext), typeof(DialogWindow)); string helpKeyword = HelpKeywords.HomePage; public EditingContext Context { get { return (EditingContext)GetValue(ContextProperty); } set { SetValue(ContextProperty, value); } } protected string HelpKeyword { get { return this.helpKeyword; } set { this.helpKeyword = value; } } protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); this.HideMinMaxButton(); this.ShowContextHelpButton(); this.HideIcon(); this.AddWindowsHook(OnHookedWindowMessage); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, new ExecutedRoutedEventHandler(OnHelpExecuted))); this.Closing += new CancelEventHandler(OnWindowClosing); } static IntPtr OnHookedWindowMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == Win32Interop.WM_SYSCOMMAND && wParam.ToInt64() == (long)Win32Interop.SC_CONTEXTHELP) { var rootVisual = HwndSource.FromHwnd(hwnd).RootVisual; var focusedElement = FocusManager.GetFocusedElement(rootVisual); if (focusedElement == null) { focusedElement = rootVisual as IInputElement; } ApplicationCommands.Help.Execute(null, focusedElement); handled = true; } // According to MSDN, zero should be returned after handling WM_SYSCOMMAND. // If this message is unhandled, it's still safe to return zero // because WPF framework (HwndSource) will return zero anyway if the // message is unhandled. return IntPtr.Zero; } void OnWindowClosing(object sender, CancelEventArgs e) { // Note: Do NOT remove the hook if the close operation needs to be canceled. this.RemoveWindowsHook(OnHookedWindowMessage); } void OnHelpExecuted(Object sender, ExecutedRoutedEventArgs e) { if (this.Context != null) { IIntegratedHelpService help = this.Context.Services.GetService(); if (help != null) { help.ShowHelpFromKeyword(this.helpKeyword); return; } } System.Diagnostics.Process.Start(SR.DefaultHelpUrl); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation { using System.Windows; using System.Activities.Presentation.View; using System.Windows.Interop; using System.Windows.Input; using System.ComponentModel; internal class DialogWindow : Window { public static readonly DependencyProperty ContextProperty = DependencyProperty.Register("Context", typeof(EditingContext), typeof(DialogWindow)); string helpKeyword = HelpKeywords.HomePage; public EditingContext Context { get { return (EditingContext)GetValue(ContextProperty); } set { SetValue(ContextProperty, value); } } protected string HelpKeyword { get { return this.helpKeyword; } set { this.helpKeyword = value; } } protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); this.HideMinMaxButton(); this.ShowContextHelpButton(); this.HideIcon(); this.AddWindowsHook(OnHookedWindowMessage); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, new ExecutedRoutedEventHandler(OnHelpExecuted))); this.Closing += new CancelEventHandler(OnWindowClosing); } static IntPtr OnHookedWindowMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == Win32Interop.WM_SYSCOMMAND && wParam.ToInt64() == (long)Win32Interop.SC_CONTEXTHELP) { var rootVisual = HwndSource.FromHwnd(hwnd).RootVisual; var focusedElement = FocusManager.GetFocusedElement(rootVisual); if (focusedElement == null) { focusedElement = rootVisual as IInputElement; } ApplicationCommands.Help.Execute(null, focusedElement); handled = true; } // According to MSDN, zero should be returned after handling WM_SYSCOMMAND. // If this message is unhandled, it's still safe to return zero // because WPF framework (HwndSource) will return zero anyway if the // message is unhandled. return IntPtr.Zero; } void OnWindowClosing(object sender, CancelEventArgs e) { // Note: Do NOT remove the hook if the close operation needs to be canceled. this.RemoveWindowsHook(OnHookedWindowMessage); } void OnHelpExecuted(Object sender, ExecutedRoutedEventArgs e) { if (this.Context != null) { IIntegratedHelpService help = this.Context.Services.GetService (); if (help != null) { help.ShowHelpFromKeyword(this.helpKeyword); return; } } System.Diagnostics.Process.Start(SR.DefaultHelpUrl); } } } // 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
- CompositeDuplexBindingElementImporter.cs
- TypeBrowser.xaml.cs
- ipaddressinformationcollection.cs
- HtmlToClrEventProxy.cs
- HttpBufferlessInputStream.cs
- ThumbAutomationPeer.cs
- XPathNavigatorKeyComparer.cs
- AutomationIdentifierGuids.cs
- ProfileEventArgs.cs
- EntityTypeEmitter.cs
- SqlExpressionNullability.cs
- WindowExtensionMethods.cs
- FSWPathEditor.cs
- WorkflowApplicationAbortedEventArgs.cs
- InstanceHandleReference.cs
- KeyConstraint.cs
- Rotation3DAnimation.cs
- TaskHelper.cs
- ValidatingReaderNodeData.cs
- Environment.cs
- FontFamilyValueSerializer.cs
- CharacterShapingProperties.cs
- Aes.cs
- SqlMetaData.cs
- basevalidator.cs
- Marshal.cs
- AsymmetricKeyExchangeDeformatter.cs
- BuildManagerHost.cs
- AutoResizedEvent.cs
- AppModelKnownContentFactory.cs
- CapabilitiesRule.cs
- SafeRegistryHandle.cs
- GridEntryCollection.cs
- DataServiceQueryException.cs
- NavigationPropertyEmitter.cs
- WindowsNonControl.cs
- XmlChildEnumerator.cs
- newitemfactory.cs
- PropertySourceInfo.cs
- ToolStripDropDownMenu.cs
- QuaternionRotation3D.cs
- HttpEncoder.cs
- BatchStream.cs
- DeviceSpecificDesigner.cs
- EntityConnectionStringBuilder.cs
- BlurBitmapEffect.cs
- DependencyPropertyHelper.cs
- MethodCallTranslator.cs
- XmlQualifiedName.cs
- TextElement.cs
- FileDialog_Vista_Interop.cs
- ExtendedPropertyCollection.cs
- HttpResponseHeader.cs
- GridItemCollection.cs
- EndOfStreamException.cs
- LabelAutomationPeer.cs
- TrustManagerMoreInformation.cs
- DataException.cs
- PackageRelationship.cs
- PathParser.cs
- AdjustableArrowCap.cs
- BuildProviderInstallComponent.cs
- CqlLexer.cs
- TraceContextEventArgs.cs
- TypeDescriptionProviderAttribute.cs
- ElementAtQueryOperator.cs
- ArgumentNullException.cs
- DispatcherSynchronizationContext.cs
- WebConfigManager.cs
- WmlMobileTextWriter.cs
- SoapEnvelopeProcessingElement.cs
- PerfCounterSection.cs
- SendingRequestEventArgs.cs
- IncomingWebRequestContext.cs
- PeerNodeTraceRecord.cs
- RequestReplyCorrelator.cs
- CompiledRegexRunner.cs
- DocumentOrderQuery.cs
- SchemaElementDecl.cs
- TreeViewImageKeyConverter.cs
- SoapExtensionReflector.cs
- HttpHandlerAction.cs
- ParameterModifier.cs
- ByteStack.cs
- ResourceBinder.cs
- ColumnClickEvent.cs
- ProjectionPathSegment.cs
- UnsafeNativeMethods.cs
- XamlReaderConstants.cs
- regiisutil.cs
- UnaryNode.cs
- RC2.cs
- PermissionSetEnumerator.cs
- UnaryNode.cs
- CompilationUtil.cs
- EntitySetBaseCollection.cs
- SafeThreadHandle.cs
- ThrowHelper.cs
- DataControlFieldCell.cs
- XmlObjectSerializerReadContextComplex.cs