1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.Activities.Presentation
9 using System.Diagnostics.CodeAnalysis;
10 using System.Runtime.InteropServices;
11 using System.Activities.Presentation.View;
12 using System.Windows.Interop;
13 using System.Windows.Input;
14 using System.ComponentModel;
16 [Fx.Tag.XamlVisible(false)]
17 internal partial class WorkflowElementDialogWindow
19 WorkflowElementDialog payload;
22 //default MinButton and MaxButton to true
23 private bool enableMinButton = true;
24 private bool enableMaxButton = true;
26 private Func<bool> onOk;
28 public WorkflowElementDialogWindow(WorkflowElementDialog payload, bool okCancel, bool enableMinButton, bool enableMaxButton, Func<bool> onOk)
30 this.payload = payload;
31 this.okCancel = okCancel;
32 this.enableMinButton = enableMinButton;
33 this.enableMaxButton = enableMaxButton;
35 InitializeComponent();
38 protected override void OnInitialized(EventArgs e)
40 base.OnInitialized(e);
41 this.payload.Window = this;
42 this.payloadHolder.Child = this.payload;
44 this.MinWidth = this.payload.MinWidth;
45 this.MinHeight = this.payload.MinHeight;
46 this.MaxWidth = this.payload.MaxWidth;
47 this.MaxHeight = this.payload.MaxHeight;
48 this.ResizeMode = this.payload.WindowResizeMode;
49 this.SizeToContent = this.payload.WindowSizeToContent;
51 this.Context = payload.Context;
52 if (payload.HelpKeyword != null)
54 this.HelpKeyword = payload.HelpKeyword;
57 if (0.0 != this.payload.MinWidth)
59 this.Width = this.payload.MinWidth;
61 if (0.0 != this.payload.MinHeight)
63 this.Height = this.payload.MinHeight;
66 this.payload.MinWidth = this.payload.MinHeight = 0.0;
67 this.payload.MaxWidth = this.payload.MaxWidth = double.PositiveInfinity;
71 this.buttonPanel.Children.Remove(this.cancelButton);
75 void OK_Click(object sender, RoutedEventArgs e)
77 if (this.onOk == null || this.onOk())
79 this.DialogResult = true;
83 [SuppressMessage(FxCop.Category.Performance, FxCop.Rule.AvoidUncalledPrivateCode,
84 Justification = "This function is called in the xaml file")]
85 void OnWindowClosed(object sender, EventArgs e)
87 this.payload.Window = null;
88 this.payloadHolder.Child = null;