Exemplo n.º 1
0
        private void ProcessSelectedCell(object sender)
        {
            if (isSeatMapOverview || !(sender is GridMap grid))
            {
                return;
            }

            var selectedCell     = (Coordinates)grid.GetValue(SelectedCellProperty);
            var contentPresenter = grid.Children.Cast <ContentPresenter>().
                                   SingleOrDefault(x => GetRow(x) == selectedCell.Row && GetColumn(x) == selectedCell.Column);

            if (contentPresenter is null)
            {
                return;
            }

            var label = VisualTreeChildrenHelper.FindVisualChildren <Label>(contentPresenter).FirstOrDefault();

            label.SetValue(BackgroundProperty, SelectedCellBrush);

            grid.Children.Cast <ContentPresenter>().Where(x => !ReferenceEquals(x, contentPresenter)).ToList().ForEach(x =>
            {
                label = VisualTreeChildrenHelper.FindVisualChildren <Label>(x).FirstOrDefault();
                label.SetValue(BackgroundProperty, DefaultCellBrush);
            });
        }
        private async void Click(object sender, MouseButtonEventArgs e)
        {
            if (!(AssociatedObject is ICommandSource element) || !(element.Command is RelayCommandAsync))
            {
                return;
            }

            e.Handled = true;
            var window = Window.GetWindow(AssociatedObject);

            var animation = VisualTreeChildrenHelper.FindVisualChildren <Border>(window).
                            SingleOrDefault(x => x.Name.Equals("PulseBox", StringComparison.OrdinalIgnoreCase));
            var text = (string)this.GetValue(AnimationTextProperty);

            VisualTreeChildrenHelper.FindVisualChildren <TextBlock>(animation).SingleOrDefault().Text =
                string.IsNullOrEmpty(text) ?
                (string)this.GetValue(AnimationTextProperty) :
                TranslateSource.Instance[nameof(l10n.Shared.SharedResources.BusyText), l10n.Shared.SharedResources.ResourceManager.BaseName];

            ShowAnimation(animation);

            try
            {
                await(element.Command as RelayCommandAsync).ExecuteAsync(element.CommandParameter);
            }
            catch (Exception)
            {
                HideAnimation(animation);
                throw;
            }

            HideAnimation(animation);
        }
Exemplo n.º 3
0
        private void DoDrag(object sender, MouseButtonEventArgs e)
        {
            var grid = sender as GridMap;

            if (isSeatMapOverview)
            {
                return;
            }

            var selectedCell = (Coordinates)grid.GetValue(SelectedCellProperty);
            var cellContent  = grid.Children.Cast <ContentPresenter>().SingleOrDefault(x =>
                                                                                       GetRow(x) == selectedCell.Row && GetColumn(x) == selectedCell.Column);

            if (cellContent is null || isSeatMapOverview || !(cellContent.Content is IGridMapItem))
            {
                return;
            }

            var label = VisualTreeChildrenHelper.FindVisualChildren <Label>(cellContent).SingleOrDefault();
            var data  = new DraggedData(cellContent.Content);

            DragDrop.DoDragDrop(label, data, DragDropEffects.All);
        }