summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Application/Componentes/DialogTransferencia.cs
blob: 30f31c5bd79b6e86a157dce4422206200e77133c (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
using Assinador.Infrastructure.Helpers;
using CurrencyTextBoxControl;
using Gestor.Application.ViewModels.Financeiro;
using Gestor.Common.Validation;
using Gestor.Model.Domain.Financeiro;
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Markup;

namespace Gestor.Application.Componentes
{
	public class DialogTransferencia : UserControl, IComponentConnector
	{
		internal ComboBox ContaOrigemBox;

		internal CurrencyTextBox ValorBox;

		internal DatePicker VencimentoBox;

		internal ComboBox ContaDestinoBox;

		private bool _contentLoaded;

		private TranferenciaViewModel ViewModel
		{
			get;
		}

		public DialogTransferencia(Transferencia transferencia)
		{
			this.ViewModel = new TranferenciaViewModel(transferencia);
			base.DataContext = this.ViewModel;
			this.InitializeComponent();
		}

		private void DataAtual_OnDoubleClick(object sender, RoutedEventArgs e)
		{
			((DatePicker)sender).SelectedDate = new DateTime?(Functions.GetNetworkTime().Date);
		}

		public void DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
		{
			DatePicker datePicker = (DatePicker)sender;
			datePicker.Text = ValidationHelper.FormatDate(datePicker.Text);
		}

		public void DatePicker_PreviewKeyDown(object sender, KeyEventArgs e)
		{
			if (e.Key != Key.Return)
			{
				return;
			}
			DatePicker str = (DatePicker)sender;
			DateTime date = Functions.GetNetworkTime().Date;
			str.Text = date.ToString("dd/MM/yyyy");
		}

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

		[DebuggerNonUserCode]
		[EditorBrowsable(EditorBrowsableState.Never)]
		[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
		void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
		{
			switch (connectionId)
			{
				case 1:
				{
					this.ContaOrigemBox = (ComboBox)target;
					return;
				}
				case 2:
				{
					this.ValorBox = (CurrencyTextBox)target;
					return;
				}
				case 3:
				{
					this.VencimentoBox = (DatePicker)target;
					this.VencimentoBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown);
					this.VencimentoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					this.VencimentoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					return;
				}
				case 4:
				{
					this.ContaDestinoBox = (ComboBox)target;
					return;
				}
			}
			this._contentLoaded = true;
		}
	}
}