diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
| commit | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch) | |
| tree | e1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Gestor.Application/Views/BI/AcompanhamentoView.cs | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Gestor.Application/Views/BI/AcompanhamentoView.cs')
| -rw-r--r-- | Gestor.Application/Views/BI/AcompanhamentoView.cs | 339 |
1 files changed, 0 insertions, 339 deletions
diff --git a/Gestor.Application/Views/BI/AcompanhamentoView.cs b/Gestor.Application/Views/BI/AcompanhamentoView.cs deleted file mode 100644 index a509fdf..0000000 --- a/Gestor.Application/Views/BI/AcompanhamentoView.cs +++ /dev/null @@ -1,339 +0,0 @@ -using Gestor.Application.Helpers;
-using Gestor.Application.ViewModels;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Application.Views.Generic;
-using Gestor.Model.Domain.Ferramentas;
-using System;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-using System.Windows.Markup;
-using System.Windows.Media;
-
-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()
- {
- base.Tag = "CADASTRO DE TRILHAS";
- this.ViewModel = new TrilhaViewModel();
- base.DataContext = this.ViewModel;
- this.InitializeComponent();
- this.FasesListBox.DataContext = this.ViewModel;
- }
-
- private async Task AbrirTarefa(Tarefa data)
- {
- while (true)
- {
- Tarefa tarefa = await this.ViewModel.ShowTarefaDialog(data, false, false);
- if (tarefa == null)
- {
- return;
- }
- List<KeyValuePair<string, string>> keyValuePairs = await this.ViewModel.Salvar(tarefa);
- this.ViewModel.Loading(false);
- if (keyValuePairs == null || keyValuePairs.Count == 0)
- {
- break;
- }
- await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", "");
- }
- this.ViewModel.ToggleSnackBar("TAREFA SALVA COM SUCESSO.", true);
- this.ViewModel.Alterar(false);
- return;
- }
-
- private async void AdicionarTarefa_OnClick(object sender, RoutedEventArgs e)
- {
- Fase dataContext = ((Button)sender).DataContext as Fase;
- Tarefa tarefa = new Tarefa();
- tarefa.set_Agendamento(Funcoes.GetNetworkTime());
- tarefa.set_Titulo("NOVA TAREFA");
- tarefa.set_Usuario(Recursos.Usuario);
- tarefa.set_Trilha(this.ViewModel.SelectedTrilha);
- tarefa.set_Status(0);
- tarefa.set_Fase(dataContext);
- Tarefa tarefa1 = tarefa;
- this.ViewModel.Loading(true);
- while (true)
- {
- Tarefa tarefa2 = await this.ViewModel.ShowTarefaDialog(tarefa1, false, false);
- if (tarefa2 == null)
- {
- tarefa1 = null;
- return;
- }
- List<KeyValuePair<string, string>> keyValuePairs = await this.ViewModel.Salvar(tarefa2);
- this.ViewModel.Loading(false);
- if (keyValuePairs == null || keyValuePairs.Count == 0)
- {
- break;
- }
- await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", "");
- }
- this.ViewModel.ToggleSnackBar("TAREFA SALVA COM SUCESSO.", true);
- this.ViewModel.Alterar(false);
- tarefa1 = null;
- return;
- tarefa1 = null;
- }
-
- private async void EditarTarefa_OnClick(object sender, RoutedEventArgs e)
- {
- await this.AbrirTarefa(((Button)sender).DataContext as Tarefa);
- }
-
- private async void ExcluirTarefa_OnClick(object sender, RoutedEventArgs e)
- {
- Tarefa dataContext = ((Button)sender).DataContext as Tarefa;
- await this.ViewModel.Excluir(dataContext);
- }
-
- private void FasesListBox_OnDragOver(object sender, DragEventArgs e)
- {
- ListBox listBox = sender as ListBox;
- ScrollViewer scrollViewer = AcompanhamentoView.FindVisualChild<ScrollViewer>(this.FasesListBox);
- if (listBox != null)
- {
- double x = e.GetPosition(listBox).X;
- if (x < 100)
- {
- scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset - 30);
- return;
- }
- if (x > listBox.ActualWidth - 100)
- {
- scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset + 30);
- }
- }
- }
-
- 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 tChildItem = (TChildItem)(child as TChildItem);
- if (tChildItem != null)
- {
- return tChildItem;
- }
- TChildItem tChildItem1 = AcompanhamentoView.FindVisualChild<TChildItem>(child);
- if (tChildItem1 != null)
- {
- return tChildItem1;
- }
- }
- return default(TChildItem);
- }
-
- private static object GetDataFromListBox(ItemsControl source, Point point)
- {
- UIElement parent = source.InputHitTest(point) as UIElement;
- if (parent != null)
- {
- object unsetValue = DependencyProperty.UnsetValue;
- while (unsetValue == DependencyProperty.UnsetValue)
- {
- if (parent == null)
- {
- continue;
- }
- unsetValue = source.ItemContainerGenerator.ItemFromContainer(parent);
- if (unsetValue == DependencyProperty.UnsetValue)
- {
- parent = VisualTreeHelper.GetParent(parent) as UIElement;
- }
- if (parent != source)
- {
- continue;
- }
- return null;
- }
- if (unsetValue != DependencyProperty.UnsetValue)
- {
- return unsetValue;
- }
- }
- return null;
- }
-
- private void Info_OnClick(object sender, RoutedEventArgs e)
- {
- Button button = (Button)sender;
- bool isOpen = !((System.Windows.Controls.ToolTip)button.ToolTip).IsOpen;
- ((System.Windows.Controls.ToolTip)button.ToolTip).IsOpen = isOpen;
- }
-
- [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/views/bi/acompanhamentoview.xaml", UriKind.Relative));
- }
-
- private static bool IsMouseOverTarget(Visual target, Point point)
- {
- return VisualTreeHelper.GetDescendantBounds(target).Contains(point);
- }
-
- private void ListBox_Drop(object sender, DragEventArgs e)
- {
- ListBox listBox = (ListBox)sender;
- object data = e.Data.GetData(this._data.GetType());
- int num = -1;
- int num1 = 0;
- while (num1 < listBox.Items.Count)
- {
- ListBoxItem listBoxItem = listBox.ItemContainerGenerator.ContainerFromIndex(num1) as ListBoxItem;
- if (listBoxItem == null || !AcompanhamentoView.IsMouseOverTarget(listBoxItem, e.GetPosition(listBoxItem)))
- {
- num1++;
- }
- else
- {
- num = num1;
- break;
- }
- }
- Fase dataContext = this._dragSource.DataContext as Fase;
- Fase fase = listBox.DataContext as Fase;
- this.ViewModel.Excluir(dataContext, (Tarefa)data);
- this.ViewModel.Inserir(fase, (Tarefa)data, num, false);
- this.ViewModel.Update();
- }
-
- private async void ListBox_OnPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
- {
- ListBox listBox = (ListBox)sender;
- object dataFromListBox = AcompanhamentoView.GetDataFromListBox(listBox, e.GetPosition(listBox));
- if (dataFromListBox != null)
- {
- await this.AbrirTarefa((Tarefa)dataFromListBox);
- }
- }
-
- private void ListBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- if (!(sender is Button))
- {
- return;
- }
- Button button = (Button)sender;
- this._dragSource = ViewHelper.FindAncestor<ListBox>(button).FirstOrDefault<ListBox>();
- this._data = AcompanhamentoView.GetDataFromListBox(this._dragSource, e.GetPosition(button));
- if (this._data == null)
- {
- return;
- }
- DragDrop.DoDragDrop(button, this._data, DragDropEffects.Move);
- e.Handled = true;
- }
-
- [DebuggerNonUserCode]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
- void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
- {
- if (connectionId != 1)
- {
- this._contentLoaded = true;
- return;
- }
- this.FasesListBox = (ListBox)target;
- this.FasesListBox.DragOver += new DragEventHandler(this.FasesListBox_OnDragOver);
- }
-
- [DebuggerNonUserCode]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
- void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target)
- {
- switch (connectionId)
- {
- case 2:
- {
- ((Button)target).Click += new RoutedEventHandler(this.AdicionarTarefa_OnClick);
- return;
- }
- case 3:
- {
- ((Button)target).Click += new RoutedEventHandler(this.Info_OnClick);
- return;
- }
- case 4:
- {
- ((ListBox)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(this.ListBox_OnPreviewMouseDoubleClick);
- ((ListBox)target).MouseLeftButtonDown += new MouseButtonEventHandler(this.ListBox_PreviewMouseLeftButtonDown);
- ((ListBox)target).Drop += new DragEventHandler(this.ListBox_Drop);
- return;
- }
- case 5:
- {
- ((Button)target).Click += new RoutedEventHandler(this.ExcluirTarefa_OnClick);
- return;
- }
- case 6:
- {
- ((Button)target).PreviewMouseLeftButtonDown += new MouseButtonEventHandler(this.ListBox_PreviewMouseLeftButtonDown);
- return;
- }
- case 7:
- {
- ((Button)target).Click += new RoutedEventHandler(this.EditarTarefa_OnClick);
- return;
- }
- case 8:
- {
- ((Button)target).Click += new RoutedEventHandler(this.TarefaConcluida_OnClick);
- return;
- }
- default:
- {
- return;
- }
- }
- }
-
- private async void TarefaConcluida_OnClick(object sender, RoutedEventArgs e)
- {
- Tarefa dataContext = ((Button)sender).DataContext as Tarefa;
- if (dataContext != null)
- {
- dataContext.set_Conclusao(new DateTime?(Funcoes.GetNetworkTime()));
- dataContext.set_Status(2);
- await this.ViewModel.Salvar(dataContext);
- await this.ViewModel.CarregarTrilha(this.ViewModel.SelectedTrilha);
- }
- }
- }
-}
\ No newline at end of file |