예제 #1
0
        private async void SortDown_Click_1(object sender, RoutedEventArgs e)
        {
            var scene = SceneGrid.SelectedItem as Scene;

            if (scene == null)
            {
                return;
            }
            var sceneWeAreReplacing = _sceneCollection.FirstOrDefault(s => s.SortOrder == scene.SortOrder + 1);

            if (sceneWeAreReplacing != null)
            {
                sceneWeAreReplacing.SortOrder--;
            }

            scene.SortOrder++;

            SortSceneGridBySortOrder();
            await NormalizeSortOrderAsync();

            SortSceneGridBySortOrder();

            SceneGrid.SelectedItem = scene;
            SceneGrid.Focus();
        }
예제 #2
0
        private async Task <bool> DeleteSelectedScene(Scene scene)
        {
            if (
                MessageBox.Show($"Are you sure you want to delete the '{scene.Name}' scene?",
                                "Are you sure?", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return(false);
            }
            if (scene.IsRunning)
            {
                ShowSceneEditWarning(scene.Name);
            }
            else
            {
                _context.Scenes.Local.Remove(scene);
            }

            var result = await _context.TrySaveChangesAsync(_app.Cts.Token);

            if (result.HasError)
            {
                await Log.ReportErrorFormatAsync(_app.Cts.Token, "Error deleting scene. {0}", result.Message);
            }

            SceneGrid.Focus();
            return(true);
        }
예제 #3
0
        private void UserControl_Loaded_1(object sender, RoutedEventArgs e)
        {
            if (SceneGrid.Items.Count > 0)
            {
                SceneGrid.SelectedIndex = 0;
            }

            SceneGrid.Focus();
        }
예제 #4
0
        private async void ButtonDuplicate_OnClick(object sender, RoutedEventArgs e)
        {
            var scene = SceneGrid.SelectedItem as Scene;

            if (scene == null)
            {
                return;
            }

            if (MessageBox.Show("Are you sure you want to duplicate this scene?",
                                "Are you sure?", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return;
            }

            var newScene = new Scene {
                Name = "Copy of " + scene.Name, SortOrder = SceneGrid.Items.Count + 1
            };

            foreach (var sc in scene.Commands)
            {
                newScene.Commands.Add(new SceneStoredCommand
                {
                    Argument         = sc.Argument,
                    Argument2        = sc.Argument2,
                    CommandId        = sc.CommandId,
                    Description      = sc.Description,
                    TargetObjectName = sc.TargetObjectName,
                    SortOrder        = sc.SortOrder
                });
                SceneGrid.Focus();
            }
            _context.Scenes.Local.Add(newScene);
            var result = await _context.TrySaveChangesAsync(_app.Cts.Token);

            if (result.HasError)
            {
                await Log.ReportErrorFormatAsync(_app.Cts.Token, "Error duplicating scene. {0}", result.Message);
            }
        }