Example #1
0
        private static void ColumnHeader_Click(object sender, RoutedEventArgs e)
        {
            GridViewColumnHeader headerClicked = e.OriginalSource as GridViewColumnHeader;

            if (headerClicked != null && headerClicked.Column != null)
            {
                string propertyName = GetPropertyName(headerClicked.Column);
                if (!string.IsNullOrEmpty(propertyName))
                {
                    ListView listView = VisualTreeHelpers.FindAncestor <ListView>(headerClicked);;
                    if (listView != null)
                    {
                        ICommand command = GetCommand(listView);
                        if (command != null)
                        {
                            if (command.CanExecute(propertyName))
                            {
                                command.Execute(propertyName);
                            }
                        }
                        else if (GetAutoSort(listView))
                        {
                            ApplySort(listView.Items, propertyName, listView, headerClicked);
                        }
                    }
                }
            }
        }
Example #2
0
        private void sceneDot_MouseMove(object sender, MouseEventArgs e)
        {
            if (!isRectDragInProg)
            {
                return;
            }

            Border border = sender as Border;

            if (border != null)
            {
                var canvas   = VisualTreeHelpers.FindAncestor <Canvas>(border);
                var mousePos = e.GetPosition(canvas);

                double left = mousePos.X - (border.ActualWidth / 2);
                double top  = mousePos.Y - (border.ActualHeight / 2);
                border.Margin = new Thickness(left, top, 0, 0);

                var       imageWidth   = sceneImage.ActualWidth;
                var       imageHeight  = sceneImage.ActualHeight;
                SceneItem selectedItem = border.DataContext as SceneItem;
                selectedItem.XPos = ((border.Margin.Left + (border.Width / 2)) * 100) / imageWidth;
                selectedItem.YPos = ((border.Margin.Top + (border.Height / 2)) * 100) / imageHeight;
                ChangedItems.Add(selectedItem);
            }
        }
        List <item> selectedItems = new List <item>(); // list of items checked off

        private void CheckBoxChanged(object sender, RoutedEventArgs e)
        {
            CheckBox    checkBox    = (CheckBox)e.OriginalSource;                             // get checkbox selected
            DataGridRow dataGridRow = VisualTreeHelpers.FindAncestor <DataGridRow>(checkBox); // get row correspodning to that check box

            if ((bool)checkBox.IsChecked)                                                     // item is checked
            {
                // convert row to item and add to list
                selectedItems.Add((item)dataGridRow.DataContext);
                // put the id of the item in the id field so item can be updated, item last checked off
                id.Text = selectedItems[selectedItems.Count - 1].id.ToString();
            }
            else // item is unchecked
            {
                // get index of unchecked item in list and remove it
                int i = selectedItems.IndexOf((item)dataGridRow.DataContext);
                selectedItems.RemoveAt(i);
                if (selectedItems.Count == 0)
                {
                    // if no more items checked off clear id field
                    id.Text = "";
                }
                else
                {
                    // if more items checked off, take id of last one and put in id field so quantity can be updated
                    id.Text = selectedItems[selectedItems.Count - 1].id.ToString();
                }
            }
        }
        private void CheckBoxChanged(object sender, RoutedEventArgs e)
        {
            CheckBox    checkBox    = (CheckBox)e.OriginalSource;
            DataGridRow dataGridRow = VisualTreeHelpers.FindAncestor <DataGridRow>(checkBox);

            if ((bool)checkBox.IsChecked)
            {
                if (selectedPunch == null)
                {
                    // store selected punch
                    selectedPunch = (punch)dataGridRow.DataContext;
                    checkedBox    = checkBox;
                }
                else
                {
                    //  if another box already checked, uncheck the most recently checked box without triggering function call
                    checkBox.Unchecked -= CheckBoxChanged;
                    checkBox.IsChecked  = false;
                    checkBox.Unchecked += CheckBoxChanged;
                    snackbar.MessageQueue.Enqueue("One selection at a time.");
                }
            }
            else
            {
                // it was unchecked
                selectedPunch = null;
                checkedBox    = null;
            }
        }
Example #5
0
        private void chkCell_Unchecked(object sender, RoutedEventArgs e)
        {
            CheckBox        checkBox        = (CheckBox)e.OriginalSource;
            DataGridRow     dataGridRow     = VisualTreeHelpers.FindAncestor <DataGridRow>(checkBox);
            Data_Documentos data_Documentos = (Data_Documentos)dataGridRow.DataContext;

            data_Documentos.Selectable = false;
        }
        public void BtnRemoveAnimation_OnClick(object sender, RoutedEventArgs e)
        {
            AnimationViewModel animationViewModel = (AnimationViewModel)((Button)sender).DataContext;
            Button             dataContext        = (Button)sender;
            ItemsControl       itemsControl       = VisualTreeHelpers.FindAncestor <ItemsControl>(dataContext);

            ((StageViewModel)itemsControl.DataContext).Animations.Remove(animationViewModel);
        }
        private void OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            var treeViewItem = VisualTreeHelpers.FindAncestor <TreeViewItem>((DependencyObject)e.OriginalSource);

            if (treeViewItem == null)
            {
                return;
            }

            treeViewItem.IsSelected = true;
            e.Handled = true;
        }
Example #8
0
        private static void HandleMouseHorizontalWheel([NotNull] Window handledWindow, IntPtr wParam)
        {
            if (handledWindow == null)
            {
                throw new ArgumentNullException(nameof(handledWindow));
            }

            int tilt = (short)Win32.HiWord(wParam);

            if (tilt == 0)
            {
                return;
            }

            IInputElement element = Mouse.DirectlyOver;

            if (element == null)
            {
                return;
            }

            if (!(element is UIElement))
            {
                element = VisualTreeHelpers.FindAncestor <UIElement>(element as DependencyObject);
            }
            if (element == null)
            {
                return;
            }

            // make sure the ancestor is this window
            if (!ReferenceEquals(VisualTreeHelpers.FindAncestor <Window>((DependencyObject)element), handledWindow))
            {
                return;
            }

            var ev = new MouseHorizontalWheelEventArgs(Mouse.PrimaryDevice, Environment.TickCount, tilt)
            {
                RoutedEvent = PreviewMouseHorizontalWheelEvent
                              //Source = handledWindow
            };

            // first raise preview
            element.RaiseEvent(ev);
            if (ev.Handled)
            {
                return;
            }

            // then bubble it
            ev.RoutedEvent = MouseHorizontalWheelEvent;
            element.RaiseEvent(ev);
        }
Example #9
0
        //Evento uncheck para los items de la grilla.
        private void chkDiscontinue_Unchecked(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.CheckBox checkBox = (System.Windows.Controls.CheckBox)e.OriginalSource;
            DataGridRow      dataGridRow = VisualTreeHelpers.FindAncestor <DataGridRow>(checkBox);
            ReporteDocumento produit     = (ReporteDocumento)dataGridRow.DataContext;

            if ((bool)checkBox.IsChecked == false)
            {
                produit.Check = false;
            }
            // e.Handled = true;
        }
Example #10
0
        //Evento check para los items de la grilla.
        private void chkDiscontinue_Checked(object sender, RoutedEventArgs e)
        {
            //Obtener el elemento seleccionado en la grilla.
            System.Windows.Controls.CheckBox checkBox = (System.Windows.Controls.CheckBox)e.OriginalSource;
            //Obtner la fila seleccionada y el objeto asociado.
            DataGridRow      dataGridRow = VisualTreeHelpers.FindAncestor <DataGridRow>(checkBox);
            ReporteDocumento doc         = (ReporteDocumento)dataGridRow.DataContext;

            if ((bool)checkBox.IsChecked)
            {
                doc.Check = true;
            }
            //e.Handled = true;
        }
Example #11
0
        private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
        {
            var checkBox    = (CheckBox)e.OriginalSource;
            var dataGridRow = VisualTreeHelpers.FindAncestor <DataGridRow>(checkBox);

            if (dataGridRow == null)
            {
                return;
            }

            var item = dataGridRow.DataContext as AddonToInstall;

            item.Install = checkBox.IsChecked ?? false;
        }
        //Evento de cambio de estado en el checkbox check
        private void chkDiscontinue_Checked(object sender, RoutedEventArgs e)
        {
            //Obtener elemento seleccionado.
            System.Windows.Controls.CheckBox checkBox = (System.Windows.Controls.CheckBox)e.OriginalSource;
            //Obtener objeto asociado al elemento seleccionado
            DataGridRow    dataGridRow = VisualTreeHelpers.FindAncestor <DataGridRow>(checkBox);
            ReporteResumen resumen     = (ReporteResumen)dataGridRow.DataContext;

            if ((bool)checkBox.IsChecked)
            {
                resumen.Check = true;
            }
            e.Handled = true;
        }
Example #13
0
        //Evento uncheck para cada item del listado.
        private void chkDiscontinue_Unchecked(object sender, RoutedEventArgs e)
        {
            //Obtener el elemento seleccionado.
            System.Windows.Controls.CheckBox checkBox = (System.Windows.Controls.CheckBox)e.OriginalSource;
            //Obtener la fila seleccionada y objeto asociado.
            DataGridRow    dataGridRow = VisualTreeHelpers.FindAncestor <DataGridRow>(checkBox);
            ReporteEmpresa comprobante = (ReporteEmpresa)dataGridRow.DataContext;

            if ((bool)checkBox.IsChecked == false)
            {
                comprobante.Check = false;
            }
            e.Handled = true;
        }
Example #14
0
        //Evento uncheck pra los comprobantes en la grilla de resumenes diarios
        private void chkDiscontinue_Unchecked(object sender, RoutedEventArgs e)
        {
            //Obtener el elemento seleccionado en la grilla.
            System.Windows.Controls.CheckBox checkBox = (System.Windows.Controls.CheckBox)e.OriginalSource;
            //Obtener el objeto asociado a la fila seleccionada.
            DataGridRow    dataGridRow = VisualTreeHelpers.FindAncestor <DataGridRow>(checkBox);
            ReporteResumen resumen     = (ReporteResumen)dataGridRow.DataContext;

            //Cambiar estado de objeto.
            if ((bool)checkBox.IsChecked == false)
            {
                resumen.Check = false;
            }
            e.Handled = true;
        }
        private static void HandleMouseHorizontalWheel(IntPtr wParam)
        {
            int tilt = Win32.HiWord(wParam);

            if (tilt == 0)
            {
                return;
            }

            IInputElement element = Mouse.DirectlyOver;

            if (element == null)
            {
                return;
            }

            if (!(element is UIElement))
            {
                element = VisualTreeHelpers.FindAncestor <UIElement>(element as DependencyObject);
            }
            if (element == null)
            {
                return;
            }

            var ev = new MouseHorizontalWheelEventArgs(Mouse.PrimaryDevice, Environment.TickCount, tilt)
            {
                RoutedEvent = PreviewMouseHorizontalWheelEvent
                              //Source = handledWindow
            };

            // first raise preview
            element.RaiseEvent(ev);
            if (ev.Handled)
            {
                return;
            }

            // then bubble it
            ev.RoutedEvent = MouseHorizontalWheelEvent;
            element.RaiseEvent(ev);
        }
Example #16
0
        //[DELETE] Checked and UnChecked Output
        private void checkBoxDelete_CheckedUnChecked(object sender, RoutedEventArgs e)
        {
            CheckBox    checkBox    = (CheckBox)e.OriginalSource;
            DataGridRow dataGridRow = VisualTreeHelpers.FindAncestor <DataGridRow>(checkBox);
            int         index       = dataGridRow.GetIndex();

            if (index < listOutputs.Count)
            {
                if (checkBox.IsChecked == false)
                {
                    dataGridRow.Background        = Brushes.Transparent;
                    listOutputs[index].isSelected = false;
                }
                if (checkBox.IsChecked == true)
                {
                    dataGridRow.Background        = Brushes.Red;
                    listOutputs[index].isSelected = true;
                }
            }
        }
        public void BtnEditAnimation_OnClick(object sender, RoutedEventArgs e)
        {
            AnimationViewModel animationViewModel = (AnimationViewModel)((Button)sender).DataContext;
            Button             dataContext        = (Button)sender;
            ItemsControl       itemsControl       = VisualTreeHelpers.FindAncestor <ItemsControl>(dataContext);

            var dllConfigurationsClone = new List <AnimationConfigurationBase>();

            foreach (var config in ((StageViewModel)itemsControl.DataContext).DllConfigurations)
            {
                var newDllConfig = Activator.CreateInstance(config.GetType(), config.Variables) as AnimationConfigurationBase;
                dllConfigurationsClone.Add(newDllConfig);
            }

            try
            {
                var addAnimationPopUp = new AddAnimationPopUp(animationViewModel, dllConfigurationsClone);

                addAnimationPopUp.ShowDialog();
                switch (addAnimationPopUp.Result)
                {
                case UI.SharedWPF.DialogResult.Accept:
                {
                    var newAnimationFromDlls = ((StageViewModel)itemsControl.DataContext).DllAnimations.Where(x => x.ConfigurationType == addAnimationPopUp.ResultConfig.GetType().Name).First();
                    var newAnimation         = Activator.CreateInstance(newAnimationFromDlls.GetType()) as AnimationViewModel;
                    newAnimation.InitializeAnimation(addAnimationPopUp.ResultConfig);
                    newAnimation.BindSimulationVariableValues();
                    newAnimation.X = animationViewModel.X;                                            //NO funciona
                    newAnimation.Y = animationViewModel.Y;                                            //NO funciona
                    ((StageViewModel)itemsControl.DataContext).Animations.Remove(animationViewModel); //borro y creo nueva
                    ((StageViewModel)itemsControl.DataContext).Animations.Add(newAnimation);
                }
                break;
                }
            }
            catch (Exception ex)
            {
                var viewException = new AlertPopUp("Se produjo un error al editar una animacion. Para ver detalles, despliegue el control correspondiente.");
                viewException.ShowDialog();
            }
        }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            ContentPresenter cp = container as ContentPresenter;
            Boolean          allowMergeExtract = true;

            MediaItemsView miv = VisualTreeHelpers.FindAncestor <MediaItemsView>(container);

            if (miv != null)
            {
                allowMergeExtract = miv.AllowMergeExtract;
            }

            if (allowMergeExtract)
            {
                MediaItem mediaItem = item as MediaItem;

                if (mediaItem.Parts.Count > 1)
                {
                    return((DataTemplate)cp.FindResource("mediaItemPartsRowDetailsTemplate"));
                }
            }

            return((DataTemplate)cp.FindResource("emptyDataTemplate"));
        }
Example #19
0
        private void Sortear_Click(object sender, RoutedEventArgs e)
        {
            var main = VisualTreeHelpers.FindAncestor <MainPage>(this);

            main.Sorteio.IsChecked = true;
        }
 private void me_Loaded(object sender, RoutedEventArgs e)
 {
     w = VisualTreeHelpers.FindAncestor <Window>(this);
     w.MouseLeftButtonDown += Window_MouseLeftDown;
     FocusTextBox();
 }
Example #21
0
 void SceneMenuFlyout_Loaded(object sender, RoutedEventArgs e)
 {
     sceneMenu   = sender as SceneMenuFlyout;
     metroWindow = VisualTreeHelpers.FindAncestor <MetroWindow>(sceneMenu); //Find instance of MainWindow
 }