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
|
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
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.Media;
using Gestor.Application.Helpers;
using Gestor.Application.ViewModels;
using Gestor.Application.Views.Generic;
using Gestor.Model.Common;
using Gestor.Model.Domain.Ferramentas;
namespace Gestor.Application.Views.BI;
public class AcompanhamentoView : BaseUserControl, IComponentConnector, IStyleConnector
{
private ListBox _dragSource;
private object _data;
internal ListBox FasesListBox;
private bool _contentLoaded;
public TrilhaViewModel ViewModel { get; set; }
public AcompanhamentoView()
{
((FrameworkElement)this).Tag = "CADASTRO DE TRILHAS";
ViewModel = new TrilhaViewModel();
((FrameworkElement)this).DataContext = ViewModel;
InitializeComponent();
((FrameworkElement)FasesListBox).DataContext = ViewModel;
}
private static object GetDataFromListBox(ItemsControl source, Point point)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
IInputElement obj = ((UIElement)source).InputHitTest(point);
UIElement val = (UIElement)(object)((obj is UIElement) ? obj : null);
if (val != null)
{
object obj2 = DependencyProperty.UnsetValue;
while (obj2 == DependencyProperty.UnsetValue)
{
if (val != null)
{
obj2 = source.ItemContainerGenerator.ItemFromContainer((DependencyObject)(object)val);
if (obj2 == DependencyProperty.UnsetValue)
{
DependencyObject parent = VisualTreeHelper.GetParent((DependencyObject)(object)val);
val = (UIElement)(object)((parent is UIElement) ? parent : null);
}
if (val == source)
{
return null;
}
}
}
if (obj2 != DependencyProperty.UnsetValue)
{
return obj2;
}
}
return null;
}
private void ListBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (sender is Button)
{
Button val = (Button)sender;
ListBox dragSource = ((DependencyObject)(object)val).FindAncestor<ListBox>().FirstOrDefault();
_dragSource = dragSource;
_data = GetDataFromListBox((ItemsControl)(object)_dragSource, ((MouseEventArgs)e).GetPosition((IInputElement)(object)val));
if (_data != null)
{
DragDrop.DoDragDrop((DependencyObject)(object)val, _data, (DragDropEffects)2);
((RoutedEventArgs)e).Handled = true;
}
}
}
private void ListBox_Drop(object sender, DragEventArgs e)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Expected O, but got Unknown
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
ListBox val = (ListBox)sender;
object data = e.Data.GetData(_data.GetType());
int index = -1;
for (int i = 0; i < ((CollectionView)((ItemsControl)val).Items).Count; i++)
{
DependencyObject obj = ((ItemsControl)val).ItemContainerGenerator.ContainerFromIndex(i);
ListBoxItem val2 = (ListBoxItem)(object)((obj is ListBoxItem) ? obj : null);
if (val2 != null && IsMouseOverTarget((Visual)(object)val2, e.GetPosition((IInputElement)(object)val2)))
{
index = i;
break;
}
}
object dataContext = ((FrameworkElement)_dragSource).DataContext;
Fase origem = (Fase)((dataContext is Fase) ? dataContext : null);
object dataContext2 = ((FrameworkElement)val).DataContext;
Fase origem2 = (Fase)((dataContext2 is Fase) ? dataContext2 : null);
ViewModel.Excluir(origem, (Tarefa)data);
ViewModel.Inserir(origem2, (Tarefa)data, index);
ViewModel.Update();
}
private static bool IsMouseOverTarget(Visual target, Point point)
{
//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)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
Rect descendantBounds = VisualTreeHelper.GetDescendantBounds(target);
return ((Rect)(ref descendantBounds)).Contains(point);
}
private void Info_OnClick(object sender, RoutedEventArgs 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)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
Button val = (Button)sender;
bool isOpen = !((ToolTip)((FrameworkElement)val).ToolTip).IsOpen;
((ToolTip)((FrameworkElement)val).ToolTip).IsOpen = isOpen;
}
private async void AdicionarTarefa_OnClick(object sender, RoutedEventArgs e)
{
object dataContext = ((FrameworkElement)(Button)sender).DataContext;
Fase fase = (Fase)((dataContext is Fase) ? dataContext : null);
Tarefa data = new Tarefa
{
Agendamento = Funcoes.GetNetworkTime(),
Titulo = "NOVA TAREFA",
Usuario = Recursos.Usuario,
Trilha = ViewModel.SelectedTrilha,
Status = (StatusTarefa)0,
Fase = fase
};
ViewModel.Loading(isLoading: true);
while (true)
{
Tarefa val = await ViewModel.ShowTarefaDialog(data);
if (val == null)
{
return;
}
List<KeyValuePair<string, string>> list = await ViewModel.Salvar(val);
ViewModel.Loading(isLoading: false);
if (list == null || list.Count == 0)
{
break;
}
await ViewModel.ShowMessage(list, ViewModel.ErroCamposInvalidos, "OK");
}
ViewModel.ToggleSnackBar("TAREFA SALVA COM SUCESSO.");
ViewModel.Alterar(alterar: false);
}
private async void ListBox_OnPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
ListBox val = (ListBox)sender;
object dataFromListBox = GetDataFromListBox((ItemsControl)(object)val, ((MouseEventArgs)e).GetPosition((IInputElement)(object)val));
if (dataFromListBox != null)
{
await AbrirTarefa((Tarefa)dataFromListBox);
}
}
private async Task AbrirTarefa(Tarefa data)
{
while (true)
{
Tarefa val = await ViewModel.ShowTarefaDialog(data);
if (val == null)
{
return;
}
List<KeyValuePair<string, string>> list = await ViewModel.Salvar(val);
ViewModel.Loading(isLoading: false);
if (list == null || list.Count == 0)
{
break;
}
await ViewModel.ShowMessage(list, ViewModel.ErroCamposInvalidos, "OK");
}
ViewModel.ToggleSnackBar("TAREFA SALVA COM SUCESSO.");
ViewModel.Alterar(alterar: false);
}
private async void ExcluirTarefa_OnClick(object sender, RoutedEventArgs e)
{
object dataContext = ((FrameworkElement)(Button)sender).DataContext;
Tarefa tarefa = (Tarefa)((dataContext is Tarefa) ? dataContext : null);
await ViewModel.Excluir(tarefa);
}
private async void EditarTarefa_OnClick(object sender, RoutedEventArgs e)
{
object dataContext = ((FrameworkElement)(Button)sender).DataContext;
Tarefa data = (Tarefa)((dataContext is Tarefa) ? dataContext : null);
await AbrirTarefa(data);
}
private async void TarefaConcluida_OnClick(object sender, RoutedEventArgs e)
{
object dataContext = ((FrameworkElement)(Button)sender).DataContext;
Tarefa val = (Tarefa)((dataContext is Tarefa) ? dataContext : null);
if (val != null)
{
val.Conclusao = Funcoes.GetNetworkTime();
val.Status = (StatusTarefa)2;
await ViewModel.Salvar(val);
await ViewModel.CarregarTrilha(ViewModel.SelectedTrilha);
}
}
private void FasesListBox_OnDragOver(object sender, DragEventArgs e)
{
//IL_0018: 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)
ListBox val = (ListBox)((sender is ListBox) ? sender : null);
ScrollViewer val2 = AcompanhamentoView.FindVisualChild<ScrollViewer>((DependencyObject)(object)FasesListBox);
if (val != null)
{
Point position = e.GetPosition((IInputElement)(object)val);
double x = ((Point)(ref position)).X;
if (x < 100.0)
{
val2.ScrollToHorizontalOffset(val2.HorizontalOffset - 30.0);
}
else if (x > ((FrameworkElement)val).ActualWidth - 100.0)
{
val2.ScrollToHorizontalOffset(val2.HorizontalOffset + 30.0);
}
}
}
public static TChildItem FindVisualChild<TChildItem>(DependencyObject obj) where TChildItem : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(obj, i);
TChildItem val = (TChildItem)(object)((child is TChildItem) ? child : null);
if (val != null)
{
return val;
}
TChildItem val2 = FindVisualChild<TChildItem>(child);
if (val2 != null)
{
return val2;
}
}
return default(TChildItem);
}
[DebuggerNonUserCode]
[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent()
{
if (!_contentLoaded)
{
_contentLoaded = true;
Uri uri = new Uri("/Gestor.Application;component/views/bi/acompanhamentoview.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_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
if (connectionId == 1)
{
FasesListBox = (ListBox)target;
((UIElement)FasesListBox).DragOver += new DragEventHandler(FasesListBox_OnDragOver);
}
else
{
_contentLoaded = true;
}
}
[DebuggerNonUserCode]
[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
[EditorBrowsable(EditorBrowsableState.Never)]
void IStyleConnector.Connect(int connectionId, object target)
{
//IL_0026: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Expected O, but got Unknown
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Expected O, but got Unknown
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Expected O, but got Unknown
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Expected O, but got Unknown
switch (connectionId)
{
case 2:
((ButtonBase)(Button)target).Click += new RoutedEventHandler(AdicionarTarefa_OnClick);
break;
case 3:
((ButtonBase)(Button)target).Click += new RoutedEventHandler(Info_OnClick);
break;
case 4:
((Control)(ListBox)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(ListBox_OnPreviewMouseDoubleClick);
((UIElement)(ListBox)target).MouseLeftButtonDown += new MouseButtonEventHandler(ListBox_PreviewMouseLeftButtonDown);
((UIElement)(ListBox)target).Drop += new DragEventHandler(ListBox_Drop);
break;
case 5:
((ButtonBase)(Button)target).Click += new RoutedEventHandler(ExcluirTarefa_OnClick);
break;
case 6:
((UIElement)(Button)target).PreviewMouseLeftButtonDown += new MouseButtonEventHandler(ListBox_PreviewMouseLeftButtonDown);
break;
case 7:
((ButtonBase)(Button)target).Click += new RoutedEventHandler(EditarTarefa_OnClick);
break;
case 8:
((ButtonBase)(Button)target).Click += new RoutedEventHandler(TarefaConcluida_OnClick);
break;
}
}
}
|