Пример #1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // NON-PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Handles the <c>Click</c> event of the toggle clock state button.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void OnToggleClockStateButtonClick(object sender, RoutedEventArgs e)
        {
            ListBoxItem item = VisualTreeHelperExtended.GetCurrentOrAncestor(sender as DependencyObject, typeof(ListBoxItem)) as ListBoxItem;

            if (null != item)
            {
                Employee employee = item.DataContext as Employee;
                if (null != employee)
                {
                    if (employee.ClockState == ClockInOutState.Out)
                    {
                        if (this.InactiveEmployees.Remove(employee))
                        {
                            this.ActiveEmployees.Add(employee);
                            employee.ClockState             = ClockInOutState.In;
                            this.activeListBox.SelectedItem = employee;
                        }
                    }
                    else
                    {
                        if (this.ActiveEmployees.Remove(employee))
                        {
                            this.InactiveEmployees.Add(employee);
                            employee.ClockState = ClockInOutState.Out;
                            this.inactiveListBox.SelectedItem = employee;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Occurs when the list is double-clicked.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">A <see cref="MouseButtonEventArgs"/> that contains the event data.</param>
        private void OnQatItemsListBoxMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DependencyObject mouseOver = e.OriginalSource as DependencyObject;

            if (mouseOver != null)
            {
                ListBoxItem item = (ListBoxItem)VisualTreeHelperExtended.GetCurrentOrAncestor(mouseOver, typeof(ListBoxItem));
                if ((item != null) && (removeFromQatButton.IsEnabled))
                {
                    removeFromQatButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                }
            }
        }