summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Views/ConnectionRetryView.cs
blob: b76f86c4a9802167ab18864f21025f56d40bd25f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Shell;
using Gestor.Application.Helpers;
using Gestor.Infrastructure.UnitOfWork.Generic;
using Gestor.Infrastructure.UnitOfWork.Logic;

namespace Gestor.Application.Views;

public class ConnectionRetryView : Window, IComponentConnector
{
	public TaskCompletionSource<object> CloseTask = new TaskCompletionSource<object>();

	private bool _buttonClickable;

	internal WindowChrome WindowChrome;

	internal Grid MinimizeButton;

	internal Grid CloseButton;

	internal ProgressBar ProgressRing;

	internal ItemsControl Controls;

	private bool _contentLoaded;

	public UnitOfWork UnitOfWOrk { get; set; }

	public ConnectionRetryView()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Expected O, but got Unknown
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Expected O, but got Unknown
		InitializeComponent();
		((UIElement)MinimizeButton).MouseEnter += new MouseEventHandler(TopControls_OnMouseEnter);
		((UIElement)MinimizeButton).MouseLeave += new MouseEventHandler(TopControls_OnMouseLeave);
		((UIElement)CloseButton).MouseEnter += new MouseEventHandler(TopControls_OnMouseEnter);
		((UIElement)CloseButton).MouseLeave += new MouseEventHandler(TopControls_OnMouseLeave);
		((Window)this).Closed += delegate
		{
			CloseTask.SetResult(null);
		};
	}

	private void TopControls_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Expected O, but got Unknown
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected O, but got Unknown
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Expected O, but got Unknown
		_buttonClickable = true;
		if (((FrameworkElement)(Grid)sender).Name == "CloseButton")
		{
			((Panel)(Grid)sender).Background = (Brush)new SolidColorBrush(Color.FromRgb((byte)241, (byte)112, (byte)123));
			DependencyObject child = VisualTreeHelper.GetChild((DependencyObject)(Grid)sender, 0);
			Path val = (Path)(object)((child is Path) ? child : null);
			if (val != null)
			{
				((Shape)val).Stroke = (Brush)new SolidColorBrush(Colors.Black);
			}
		}
		else
		{
			((Panel)(Grid)sender).Background = (Brush)new SolidColorBrush(Colors.Blue);
		}
	}

	private void TopControls_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		if (_buttonClickable)
		{
			((object)this).GetType().GetMethod(((FrameworkElement)(Grid)sender).Name + "_Click")?.Invoke(this, null);
		}
	}

	private static void TopControls_OnMouseEnter(object sender, MouseEventArgs e)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Expected O, but got Unknown
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Expected O, but got Unknown
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		((Panel)(Grid)sender).Background = (Brush)((((FrameworkElement)(Grid)sender).Name == "CloseButton") ? new SolidColorBrush(Color.FromRgb((byte)232, (byte)17, (byte)35)) : new SolidColorBrush(Colors.Blue));
		DependencyObject child = VisualTreeHelper.GetChild((DependencyObject)(Grid)sender, 0);
		Path val = (Path)(object)((child is Path) ? child : null);
		if (val != null)
		{
			((Shape)val).Stroke = (Brush)new SolidColorBrush(Colors.White);
		}
	}

	private void TopControls_OnMouseLeave(object sender, MouseEventArgs e)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Expected O, but got Unknown
		_buttonClickable = false;
		((Panel)(Grid)sender).Background = (Brush)new SolidColorBrush(Colors.Transparent);
		DependencyObject child = VisualTreeHelper.GetChild((DependencyObject)(Grid)sender, 0);
		Path val = (Path)(object)((child is Path) ? child : null);
		if (val != null)
		{
			((Shape)val).Stroke = (Brush)new SolidColorBrush(Colors.White);
		}
	}

	public void MinimizeButton_Click()
	{
		((Window)this).WindowState = (WindowState)1;
	}

	public void CloseButton_Click()
	{
		((Window)this).Close();
	}

	private void Loading(bool isLoading)
	{
		((UIElement)Controls).Visibility = (Visibility)(isLoading ? 2 : 0);
		((UIElement)ProgressRing).Visibility = (Visibility)((!isLoading) ? 2 : 0);
		((UIElement)this).IsEnabled = !isLoading;
	}

	private async void btnRetry_Click(object sender, RoutedEventArgs e)
	{
		Loading(isLoading: true);
		UnitOfWork val = await Task.Run((Func<UnitOfWork>)delegate
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			try
			{
				Instancia.Conexao = Instancia.Conexao ?? Connection.GetConnection();
				return new UnitOfWork(Instancia.Conexao, true);
			}
			catch (Exception)
			{
				return (UnitOfWork)null;
			}
		});
		Loading(isLoading: false);
		if (val != null && ((GenericUnitOfWork)val).HasSession)
		{
			UnitOfWOrk = val;
			((Window)this).Close();
		}
	}

	private void btnRestart_OnClick(object sender, RoutedEventArgs e)
	{
		Instancia.App.Restart();
	}

	[DebuggerNonUserCode]
	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	public void InitializeComponent()
	{
		if (!_contentLoaded)
		{
			_contentLoaded = true;
			Uri uri = new Uri("/Gestor.Application;component/views/connectionretryview.xaml", UriKind.Relative);
			Application.LoadComponent((object)this, uri);
		}
	}

	[DebuggerNonUserCode]
	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	[EditorBrowsable(EditorBrowsableState.Never)]
	void IComponentConnector.Connect(int connectionId, object target)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Expected O, but got Unknown
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Expected O, but got Unknown
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Expected O, but got Unknown
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Expected O, but got Unknown
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Expected O, but got Unknown
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Expected O, but got Unknown
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Expected O, but got Unknown
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Expected O, but got Unknown
		switch (connectionId)
		{
		case 1:
			WindowChrome = (WindowChrome)target;
			break;
		case 2:
			MinimizeButton = (Grid)target;
			((UIElement)MinimizeButton).MouseLeftButtonDown += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonDown);
			((UIElement)MinimizeButton).MouseLeftButtonUp += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonUp);
			break;
		case 3:
			CloseButton = (Grid)target;
			((UIElement)CloseButton).MouseLeftButtonDown += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonDown);
			((UIElement)CloseButton).MouseLeftButtonUp += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonUp);
			break;
		case 4:
			ProgressRing = (ProgressBar)target;
			break;
		case 5:
			Controls = (ItemsControl)target;
			break;
		case 6:
			((ButtonBase)(RepeatButton)target).Click += new RoutedEventHandler(btnRetry_Click);
			break;
		case 7:
			((ButtonBase)(RepeatButton)target).Click += new RoutedEventHandler(btnRestart_OnClick);
			break;
		default:
			_contentLoaded = true;
			break;
		}
	}
}