<commit_before>﻿using System;
using System.ComponentModel;
using System.Windows.Controls;
using BCad.EventArguments;
using BCad.Services;

namespace BCad.UI.View
{
    /// <summary>
    /// Interaction logic for SharpDXRenderer.xaml
    /// </summary>
    public partial class SharpDXRenderer : UserControl, IRenderer
    {
        private IWorkspace workspace;
        private RenderCanvasViewModel viewModel = new RenderCanvasViewModel();

        public SharpDXRenderer()
        {
            InitializeComponent();
        }

        public SharpDXRenderer(IViewControl viewControl, IWorkspace workspace, IInputService inputService)
            : this()
        {
            this.workspace = workspace;
            var game = new CadGame(workspace);
            game.Run(surface);

            viewModel = new RenderCanvasViewModel();
            DataContext = viewModel;
            workspace.WorkspaceChanged += Workspace_WorkspaceChanged;
            workspace.SettingsManager.PropertyChanged += SettingsManager_PropertyChanged;
            workspace.SelectedEntities.CollectionChanged += SelectedEntities_CollectionChanged;

            this.Loaded += (_, __) =>
            {
                foreach (var setting in new[] { Constants.BackgroundColorString })
                    SettingsManager_PropertyChanged(workspace.SettingsManager, new PropertyChangedEventArgs(setting));
                Workspace_WorkspaceChanged(workspace, WorkspaceChangeEventArgs.Reset());
            };
        }

        private void SettingsManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
                case Constants.BackgroundColorString:
                    viewModel.BackgroundColor = workspace.SettingsManager.BackgroundColor;
                    break;
                case Constants.ColorMapString:
                    viewModel.ColorMap = workspace.SettingsManager.ColorMap;
                    break;
            }
        }

        private void Workspace_WorkspaceChanged(object sender, WorkspaceChangeEventArgs e)
        {
            if (e.IsActiveViewPortChange)
            {<commit_msg>ensure render size is correct on initial load<commit_after>﻿using System;
using System.ComponentModel;
using System.Windows.Controls;
using BCad.EventArguments;
using BCad.Services;

namespace BCad.UI.View
{
    /// <summary>
    /// Interaction logic for SharpDXRenderer.xaml
    /// </summary>
    public partial class SharpDXRenderer : UserControl, IRenderer
    {
        private IWorkspace workspace;
        private RenderCanvasViewModel viewModel = new RenderCanvasViewModel();

        public SharpDXRenderer()
        {
            InitializeComponent();
        }

        public SharpDXRenderer(IViewControl viewControl, IWorkspace workspace, IInputService inputService)
            : this()
        {
            this.workspace = workspace;
            var game = new CadGame(workspace);
            game.Run(surface);

            viewModel = new RenderCanvasViewModel();
            DataContext = viewModel;
            workspace.WorkspaceChanged += Workspace_WorkspaceChanged;
            workspace.SettingsManager.PropertyChanged += SettingsManager_PropertyChanged;
            workspace.SelectedEntities.CollectionChanged += SelectedEntities_CollectionChanged;

            this.Loaded += (_, __) =>
            {
                foreach (var setting in new[] { Constants.BackgroundColorString })
                    SettingsManager_PropertyChanged(workspace.SettingsManager, new PropertyChangedEventArgs(setting));
                Workspace_WorkspaceChanged(workspace, WorkspaceChangeEventArgs.Reset());
            };

            this.SizeChanged += (_, e) => game.Resize((int)e.NewSize.Width, (int)e.NewSize.Height);
        }

        private void SettingsManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
                case Constants.BackgroundColorString:
                    viewModel.BackgroundColor = workspace.SettingsManager.BackgroundColor;
                    break;
                case Constants.ColorMapString:
                    viewModel.ColorMap = workspace.SettingsManager.ColorMap;
                    break;
            }
        }

        private void Workspace_WorkspaceChanged(object sender, WorkspaceChangeEventArgs e)
        {
            if (e.IsActiveViewPortChange)
            {
{'fraction_non_alphanumeric': 0.07290969899665552, 'fraction_numerical': 0.0, 'mean_word_length': 2.204285714285714, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3206029', 'n_tokens_mistral': 1034, 'n_tokens_neox': 1017, 'n_words': 209}