[reflection] Coop handles icalls in System.Reflection and System.RuntimeTypeHandle...
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / WorkflowElementDialogWindow.xaml.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4
5 namespace System.Activities.Presentation
6 {
7     using System.Runtime;
8     using System.Windows;
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;
15
16     [Fx.Tag.XamlVisible(false)]
17     internal partial class WorkflowElementDialogWindow
18     {
19         WorkflowElementDialog payload;
20         bool okCancel;
21
22         //default MinButton and MaxButton to true
23         private bool enableMinButton = true;
24         private bool enableMaxButton = true;
25
26         private Func<bool> onOk;
27
28         public WorkflowElementDialogWindow(WorkflowElementDialog payload, bool okCancel, bool enableMinButton, bool enableMaxButton, Func<bool> onOk)
29         {
30             this.payload = payload;
31             this.okCancel = okCancel;
32             this.enableMinButton = enableMinButton;
33             this.enableMaxButton = enableMaxButton;
34             this.onOk = onOk;
35             InitializeComponent();
36         }
37
38         protected override void OnInitialized(EventArgs e)
39         {
40             base.OnInitialized(e);
41             this.payload.Window = this;
42             this.payloadHolder.Child = this.payload;
43
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;
50
51             this.Context = payload.Context;
52             if (payload.HelpKeyword != null)
53             {
54                 this.HelpKeyword = payload.HelpKeyword;
55             }
56
57             if (0.0 != this.payload.MinWidth)
58             {
59                 this.Width = this.payload.MinWidth;
60             }
61             if (0.0 != this.payload.MinHeight)
62             {
63                 this.Height = this.payload.MinHeight;
64             }
65
66             this.payload.MinWidth = this.payload.MinHeight = 0.0;
67             this.payload.MaxWidth = this.payload.MaxWidth = double.PositiveInfinity;
68
69             if (!this.okCancel)
70             {
71                 this.buttonPanel.Children.Remove(this.cancelButton);
72             }
73         }
74
75         void OK_Click(object sender, RoutedEventArgs e)
76         {
77             if (this.onOk == null || this.onOk())
78             {
79                 this.DialogResult = true;
80             }
81         }
82
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)
86         {
87             this.payload.Window = null;
88             this.payloadHolder.Child = null;
89         }
90     }
91 }