summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Componentes/DialogTarefa.cs
blob: a177436df2d5a225b6166a7b830d695b8ab66a3e (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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Threading;
using Gestor.Application.Helpers;
using Gestor.Application.ViewModels.Generic;
using Gestor.Application.Views.Generic;
using Gestor.Application.Views.Seguros;
using Gestor.Common.Validation;
using Gestor.Model.Common;
using Gestor.Model.Domain.Ferramentas;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Seguros;
using MaterialDesignThemes.Wpf;
using Xceed.Wpf.AvalonDock.Controls;

namespace Gestor.Application.Componentes;

public class DialogTarefa : UserControl, IComponentConnector, IStyleConnector
{
	internal Button ClienteButton;

	internal Button ApoliceButton;

	internal Button SinistroButton;

	internal TextBox TituloBox;

	internal DatePicker AgendamentoBox;

	internal RadioButton AnotacoesButton;

	internal TextBox AnotacoesBox;

	internal ComboBox ResponsavelBox;

	internal DatePicker ConclusaoBox;

	internal MenuItem SalvarButton;

	internal Snackbar Snackbar;

	private bool _contentLoaded;

	private DialogTarefaViewModel ViewModel { get; }

	public DialogTarefa(Tarefa tarefa, List<TelefoneBase> telefones, bool nota = false, bool agendamento = false)
	{
		ViewModel = new DialogTarefaViewModel(tarefa, telefones, nota, agendamento);
		((FrameworkElement)this).DataContext = ViewModel;
		InitializeComponent();
		Dispatcher dispatcher = ((DispatcherObject)this).Dispatcher;
		if (dispatcher != null)
		{
			dispatcher.BeginInvoke((DispatcherPriority)7, (Delegate)new Action(ContentLoad));
		}
	}

	private void ContentLoad()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: 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_0071: Expected I4, but got Unknown
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Expected O, but got Unknown
		((UIElement)AgendamentoBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(DatePicker_OnLostKeyboardFocus);
		((UIElement)AgendamentoBox).PreviewKeyDown += new KeyEventHandler(DatePicker_PreviewKeyDown);
		ViewModel.PermissaoWhatsapp = ViewModel.Restricao((TipoRestricao)32);
		TipoTarefa entidade = ViewModel.Tarefa.Entidade;
		switch ((int)entidade)
		{
		default:
			((UIElement)ClienteButton).Visibility = (Visibility)2;
			((UIElement)ApoliceButton).Visibility = (Visibility)2;
			break;
		case 0:
			((UIElement)ClienteButton).Visibility = (Visibility)0;
			((UIElement)ApoliceButton).Visibility = (Visibility)0;
			break;
		case 3:
			((UIElement)ClienteButton).Visibility = (Visibility)0;
			((UIElement)ApoliceButton).Visibility = (Visibility)0;
			break;
		case 2:
			((UIElement)ClienteButton).Visibility = (Visibility)0;
			break;
		case 4:
			((UIElement)ClienteButton).Visibility = (Visibility)0;
			((UIElement)SinistroButton).Visibility = (Visibility)0;
			break;
		}
		((ToggleButton)AnotacoesButton).IsChecked = ViewModel.IsAnotacoes;
		((ToggleButton)AnotacoesButton).Checked += new RoutedEventHandler(Anotacoes_OnChecked);
	}

	private void Anotacoes_OnChecked(object sender, RoutedEventArgs e)
	{
		ViewModel.IsAnotacoes = true;
	}

	private void AnotacoesInternas_OnChecked(object sender, RoutedEventArgs e)
	{
		ViewModel.IsAnotacoes = false;
	}

	private void CopyTelefoneToClipBoard_Click(object sender, RoutedEventArgs e)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		TelefoneBase val = (TelefoneBase)((FrameworkElement)(Button)sender).DataContext;
		(val.Prefixo + val.Numero).CopyToClipboard();
		ToggleSnackBar("NÚMERO COPIADO COM SUCESSO");
	}

	private async void WhatsAppMessage_Click(object sender, RoutedEventArgs e)
	{
		TelefoneBase val = (TelefoneBase)((FrameworkElement)(Button)sender).DataContext;
		if (!((val.Tipo.HasValue && (int)val.Tipo.GetValueOrDefault() == 8) ? (val.Prefixo + val.Numero).Clear() : ("55" + val.Prefixo + val.Numero.Clear())).EnviarWhatsapp())
		{
			await ViewModel.ShowMessage("HOUVE UM PROBLEMA AO ABRIR LINK DO WHATSAPP, O LINK FOI COPIADO EM SUA MAQUINA, BASTA ABRIR O NAVEGADOR DE INTERNET E COLAR NA BARRA DE ENDEREÇOS");
		}
	}

	private void SnackbarMessage_ActionClick(object sender, RoutedEventArgs e)
	{
		Snackbar.IsActive = false;
	}

	public void ToggleSnackBar(string message, bool active = true)
	{
		((ContentControl)Snackbar.Message).Content = message;
		Snackbar.IsActive = active;
		if (active)
		{
			Task.Factory.StartNew(CloseSlackBar);
		}
	}

	private void CloseSlackBar()
	{
		Thread.Sleep(3000);
		Dispatcher dispatcher = ((DispatcherObject)App.ProgressRing).Dispatcher;
		if (dispatcher != null)
		{
			dispatcher.BeginInvoke((DispatcherPriority)4, (Delegate)(Action)delegate
			{
				ToggleSnackBar("", active: false);
			});
		}
	}

	private void DatePicker_PreviewKeyDown(object sender, KeyEventArgs e)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Invalid comparison between Unknown and I4
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		if ((int)e.Key == 6)
		{
			((DatePicker)sender).Text = Funcoes.GetNetworkTime().Date.ToString("dd/MM/yyyy");
		}
	}

	private void DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		DatePicker val = (DatePicker)sender;
		val.Text = ValidationHelper.FormatDate(val.Text);
	}

	private void TimePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		TimePicker val = (TimePicker)sender;
		val.TextBox.Text = ValidationHelper.FormatTime(val.TextBox.Text);
	}

	private async void AcessarApolice_OnClick(object sender, RoutedEventArgs e)
	{
		Documento documentoSelecionado = (((int)ViewModel.Tarefa.Entidade != 3) ? (await ViewModel.CarregaApolice(ViewModel.Tarefa.IdEntidade)) : (await ViewModel.CarregaApoliceParcela(ViewModel.Tarefa.IdEntidade)));
		((Window)new HosterWindow((ContentControl)(object)new ApoliceView(documentoSelecionado, lockInsert: true, invoke: false, (AcessoApolice)0, 0L), "CADASTRO DE APÓLICES - " + ViewModel.Tarefa.Cliente)).Show();
	}

	private async void AcessarCliente_OnClick(object sender, RoutedEventArgs e)
	{
		((Window)new HosterWindow((ContentControl)(object)new ClienteView(await ViewModel.CarregaCliente(ViewModel.Tarefa.IdCliente), lockInsert: true), "CADASTRO DE CLIENTE - " + ViewModel.Tarefa.Cliente)).Show();
	}

	private async void AcessarSinistro_OnClick(object sender, RoutedEventArgs e)
	{
		Sinistro val = await ViewModel.CarregaSinistroApolice(ViewModel.Tarefa.IdEntidade);
		((Window)new HosterWindow((ContentControl)(object)new SinistroView(val.ControleSinistro.Item, attached: false), "CADASTRO DE SINISTRO - " + val.ControleSinistro.Item.Descricao)).Show();
	}

	private void DataAtual_OnDoubleClick(object sender, RoutedEventArgs e)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		((DatePicker)sender).SelectedDate = Funcoes.GetNetworkTime().Date;
	}

	private void AdicionarResponsavel_OnClick(object sender, RoutedEventArgs e)
	{
		ViewModel.AdcionarResponsavel();
	}

	private void ExcluirResponsavel_OnClick(object sender, RoutedEventArgs e)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown
		Chip val = (Chip)((sender is Chip) ? sender : null);
		if (val != null)
		{
			ListBox val2 = Extentions.FindVisualAncestor<ListBox>((DependencyObject)(object)val);
			Usuario val3 = (Usuario)((ItemsControl)val2).Items[((CollectionView)((ItemsControl)val2).Items).IndexOf(((FrameworkElement)val).DataContext)];
			if (val3 != null)
			{
				ViewModel.RemoverResponsavel(val3);
			}
		}
	}

	private void MenuItem_OnClick(object sender, RoutedEventArgs e)
	{
		if (ViewModel.Tarefa.UsuariosVinculados == null)
		{
			ViewModel.Tarefa.UsuariosVinculados = new List<Usuario>();
		}
		DialogHost.CloseDialogCommand.Execute((object)ViewModel.Tarefa, (IInputElement)(object)SalvarButton);
	}

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

	[DebuggerNonUserCode]
	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	internal Delegate _CreateDelegate(Type delegateType, string handler)
	{
		return Delegate.CreateDelegate(delegateType, this, handler);
	}

	[DebuggerNonUserCode]
	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	[EditorBrowsable(EditorBrowsableState.Never)]
	void IComponentConnector.Connect(int connectionId, object target)
	{
		//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_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Expected O, but got Unknown
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Expected O, but got Unknown
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Expected O, but got Unknown
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Expected O, but got Unknown
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Expected O, but got Unknown
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Expected O, but got Unknown
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Expected O, but got Unknown
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Expected O, but got Unknown
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Expected O, but got Unknown
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Expected O, but got Unknown
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Expected O, but got Unknown
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Expected O, but got Unknown
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Expected O, but got Unknown
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Expected O, but got Unknown
		switch (connectionId)
		{
		case 1:
			ClienteButton = (Button)target;
			((ButtonBase)ClienteButton).Click += new RoutedEventHandler(AcessarCliente_OnClick);
			break;
		case 2:
			ApoliceButton = (Button)target;
			((ButtonBase)ApoliceButton).Click += new RoutedEventHandler(AcessarApolice_OnClick);
			break;
		case 3:
			SinistroButton = (Button)target;
			((ButtonBase)SinistroButton).Click += new RoutedEventHandler(AcessarSinistro_OnClick);
			break;
		case 6:
			TituloBox = (TextBox)target;
			break;
		case 7:
			AgendamentoBox = (DatePicker)target;
			((UIElement)AgendamentoBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(DatePicker_OnLostKeyboardFocus);
			((Control)AgendamentoBox).MouseDoubleClick += new MouseButtonEventHandler(DataAtual_OnDoubleClick);
			break;
		case 8:
			AnotacoesButton = (RadioButton)target;
			break;
		case 9:
			AnotacoesBox = (TextBox)target;
			break;
		case 10:
			ResponsavelBox = (ComboBox)target;
			break;
		case 11:
			((ButtonBase)(Button)target).Click += new RoutedEventHandler(AdicionarResponsavel_OnClick);
			break;
		case 13:
			ConclusaoBox = (DatePicker)target;
			((UIElement)ConclusaoBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(DatePicker_OnLostKeyboardFocus);
			((Control)ConclusaoBox).MouseDoubleClick += new MouseButtonEventHandler(DataAtual_OnDoubleClick);
			break;
		case 14:
			SalvarButton = (MenuItem)target;
			SalvarButton.Click += new RoutedEventHandler(MenuItem_OnClick);
			break;
		case 15:
			Snackbar = (Snackbar)target;
			break;
		case 16:
			((SnackbarMessage)target).ActionClick += new RoutedEventHandler(SnackbarMessage_ActionClick);
			break;
		default:
			_contentLoaded = true;
			break;
		}
	}

	[DebuggerNonUserCode]
	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	[EditorBrowsable(EditorBrowsableState.Never)]
	void IStyleConnector.Connect(int connectionId, object target)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Expected O, but got Unknown
		switch (connectionId)
		{
		case 4:
			((ButtonBase)(Button)target).Click += new RoutedEventHandler(CopyTelefoneToClipBoard_Click);
			break;
		case 5:
			((ButtonBase)(Button)target).Click += new RoutedEventHandler(WhatsAppMessage_Click);
			break;
		case 12:
			((Chip)target).DeleteClick += new RoutedEventHandler(ExcluirResponsavel_OnClick);
			break;
		}
	}
}