summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Application/Componentes/DialogCopiarCliente.cs
blob: bb3abfe74702d97085a53f346aa89fdb73a399c1 (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
using Gestor.Application.ViewModels.Financeiro;
using Gestor.Application.ViewModels.Generic;
using Gestor.Model.Domain.Seguros;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;

namespace Gestor.Application.Componentes
{
	public class DialogCopiarCliente : UserControl, IComponentConnector
	{
		internal CopiarClienteViewModel ViewModel;

		internal AutoCompleteBox PesquisaCliente;

		internal Loading LoadingAutoComplete;

		private bool _contentLoaded;

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

		public DialogCopiarCliente()
		{
			this.InitializeComponent();
			this.ViewModel = new CopiarClienteViewModel();
			base.DataContext = this.ViewModel;
		}

		private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e)
		{
			if (e.get_Parameter().Trim().Length < 3)
			{
				return;
			}
			e.set_Cancel(true);
			this.LoadingAutoComplete.Visibility = System.Windows.Visibility.Visible;
			this.ViewModel.BuscarCliente(e.get_Parameter().Trim(), null, 2).ContinueWith((Task<List<Cliente>> searchResult) => {
				this.LoadingAutoComplete.Visibility = System.Windows.Visibility.Collapsed;
				if (searchResult.Result == null)
				{
					return;
				}
				AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender;
				autoCompleteBox.set_ItemsSource(searchResult.Result);
				autoCompleteBox.PopulateComplete();
			}, TaskScheduler.FromCurrentSynchronizationContext());
		}

		[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/dialogcopiarcliente.xaml", UriKind.Relative));
		}

		[DebuggerNonUserCode]
		[EditorBrowsable(EditorBrowsableState.Never)]
		[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
		void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
		{
			if (connectionId == 1)
			{
				this.PesquisaCliente = (AutoCompleteBox)target;
				this.PesquisaCliente.add_Populating(new PopulatingEventHandler(this, DialogCopiarCliente.AutoCompleteBox_Populating));
				return;
			}
			if (connectionId != 2)
			{
				this._contentLoaded = true;
				return;
			}
			this.LoadingAutoComplete = (Loading)target;
		}
	}
}