EintityCorePacage12 9.0.17

dotnet add package EintityCorePacage12 --version 9.0.17
                    
NuGet\Install-Package EintityCorePacage12 -Version 9.0.17
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EintityCorePacage12" Version="9.0.17" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EintityCorePacage12" Version="9.0.17" />
                    
Directory.Packages.props
<PackageReference Include="EintityCorePacage12" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EintityCorePacage12 --version 9.0.17
                    
#r "nuget: EintityCorePacage12, 9.0.17"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EintityCorePacage12@9.0.17
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EintityCorePacage12&version=9.0.17
                    
Install as a Cake Addin
#tool nuget:?package=EintityCorePacage12&version=9.0.17
                    
Install as a Cake Tool

1. Entity Framework Core (База данных)

Команда для генерации моделей из БД (Scaffold):

Scaffold-DbContext "Server=ser;Database=baleva;Trusted_Connection=true;MultipleActiveResultSets=true;TrustServerCertificate=true;encrypt=false" Microsoft.EntityFrameworkCore.SqlServer -outputdir Models


2. Авторизация (Authorization)

Логика (C#)

public partial class Authorization : Window
{
    private DemoZubenContext context;
    public Authorization()
    {
        InitializeComponent();
        context = new DemoZubenContext();
    }

    private void Button_authorization(object sender, RoutedEventArgs e)
    {
        if(!string.IsNullOrWhiteSpace(BoxLogin.Text) && !string.IsNullOrWhiteSpace(BoxPassword.Text))
        {
            User user = context.Users.FirstOrDefault(q => q.Login == BoxLogin.Text && q.Password == BoxPassword.Text);
            user.Role = context.Roles.FirstOrDefault(q => q.Id == user.RoleId);
            if (user != null)
            {
                Main main = new Main(user);
                main.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("Пользователь не найден");
            }
        }
        else
        {
            MessageBox.Show("Заполните все поля");
        }
    }

    private void Button_authorization_gouest(object sender, RoutedEventArgs e)
    {
        Main main = new Main();
        main.Show();
        this.Close();
    }
}


3. Главное окно (Main)

Разметка (XAML)

<DockPanel>
    <DockPanel DockPanel.Dock="Top" Margin="5">
        <TextBlock DockPanel.Dock="Right">
            <Run Text="Добро пожаловать: "/>
            <Run Name="BoxUserName"/>
        </TextBlock>
        <StackPanel>
            
        </StackPanel>
    </DockPanel>
    <StackPanel Name="PanelBottomButton" Orientation="Horizontal" DockPanel.Dock="Bottom">
        <StackPanel Name="PanelBottomAdmin" Orientation="Vertical">
            <Button Content="Добавить" Width="80" Margin="0 0 0 0" Click="Button_add_product"/>
            <Button Content="Удалить" Width="80" Margin="0 0 0 0" Click="Buutton_delite_product"/>
            <Button Content=" Выход " Width="150" Click="Button_exit_user" Margin="1050 0 0 0"/>
        </StackPanel>
    </StackPanel>
    <StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5" Name="PanelFind">
            <TextBox Width="100" Name="BoxFind" TextChanged="BoxFind_TextChanged"/>
            <TextBlock Text="Поиск" Margin=" 5 0 5 0"/>
            <ComboBox Name="ComboBoxItem" SelectedIndex="0" Width="100" SelectionChanged="ComboSuppliers_SelectionChanged"/>
            <Label Content="Фильтрация" Margin=" 0 0 0 0"/>
            <Label Content="Сортировка" Margin=" 120 0 0 0"/>
            <RadioButton Content="по возрастанию" Margin="0 0 0 0"
                         Checked="RadioUpp_Checked"
                         IsChecked="True"/>
            <RadioButton Content="по убыванию"
                         Margin="20 0 0 0"
                         Checked="RadioUpp_Checked"/>
        </StackPanel>
        <ListBox Name="BoxProduct" Width="1240" Height="730"/>
    </StackPanel>
</DockPanel>

Логика (C#)

public partial class Main : Window
{
    private DemoZubenContext context;
    private User currentUser;
    private List<Product> products;
    private readonly string projPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

    private string SortParam = "по возрастанию";
    private string FiltParam = "все поставщики";

    public Main()
    {
        context = new DemoZubenContext();
        InitializeComponent();
        BoxUserName.Text = "гость";
        PanelFind.Visibility = Visibility.Collapsed;
        PanelBottomButton.Visibility = Visibility.Collapsed;
        DrawProductItem(products);
    }
    
    public Main(User user)
    {
        context = new DemoZubenContext();
        InitializeComponent();

        BoxUserName.Text = user.FullName;
        currentUser = user;
        
        DrawProductItem(products);
        DrawSuppliers();

        if (user.Role.Name == "Администратор")
        {
            BoxProduct.MouseDoubleClick += BoxProduct_MouseDoubleClick;
        }
        else
        {
            PanelBottomAdmin.Visibility = Visibility.Collapsed;
        }
    }

    public void DrawSuppliers()
    {
        List<Supplier> suppliers = new List<Supplier>()
        {
            new Supplier()
            {
                Id = -1,
                Name = "все поставщики",
            }
        };
        suppliers.AddRange(context.Suppliers.ToList());
        ComboBoxItem.ItemsSource = suppliers;
    }

    private void DrawProductItem(List<Product> product)
    {
        if(BoxProduct != null)
        {
            BoxProduct.Items.Clear();
            foreach (var item in products)
            {
                if (item != null)
                {
                    ItemProduct xml = new ItemProduct(item);
                    BoxProduct.Items.Add(xml);
                }
            }
        }
    }

    private void Button_exit_user(object sender, RoutedEventArgs e)
    {
        Authorization authorization = new Authorization();
        authorization.Show();
        this.Close();
    }

    private void BoxProduct_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
        ListBox list = sender as ListBox;
        ItemProduct controller = list.SelectedItem as ItemProduct;
        Product product = controller.DataContext as Product;
        EditProduct edit = new EditProduct(product);

        if (edit.ShowDialog() == true)
        {
            DrawProductItem(products);
        }
    }

    private void Button_add_product(object sender, RoutedEventArgs e)
    {
        AddProduct add = new AddProduct();
        if (add.ShowDialog() == true)
        {
            DrawProductItem(products);
        }
    }

    private void BoxFind_TextChanged(object sender, TextChangedEventArgs e)
    {
        Sort();
    }
    
    private void RadioUpp_Checked(object sender, RoutedEventArgs e)
    {
        RadioButton radio = sender as RadioButton;

        if (radio.Content.ToString() == "по возрастанию")
        {
            SortParam = "по возрастанию";
        }
        else if (radio.Content.ToString() == "по убыванию")
        {
            SortParam = "по убыванию";
        }
        Sort();
    }
    
    private void ComboSuppliers_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        ComboBox box = sender as ComboBox;
        if (box.SelectedItem != null)
        {
            FiltParam = box.SelectedItem.ToString();
        }
        Sort();
    }

    public void Sort()
    {
        products = context.Products.Include(q => q.Supplier)
            .Include(q => q.Manufacturer)
            .Include(q => q.Name)
            .Include(q => q.Category)
            .ToList();

        products = products.Where(q =>
            (q.Description?.Contains(BoxFind.Text) ?? false)
            || (q.Article?.Contains(BoxFind.Text) ?? false)
            || (q.Name?.Name?.Contains(BoxFind.Text) ?? false)
            ).Where(q => q.Supplier.Name == FiltParam
            || FiltParam == "все поставщики").ToList();

        if (SortParam == "по возрастанию")
        {
            products = products.OrderBy(q => q.Count).ToList();
        }
        else if (SortParam == "по убыванию")
        {
            products = products.OrderByDescending(q => q.Count).ToList();
        }

        DrawProductItem(products);
    }

    private void Buutton_delite_product(object sender, RoutedEventArgs e)
    {
        Product prod = (Product)(BoxProduct.SelectedItem as ItemProduct).DataContext;
        if (prod != null)
        {
            var order = context.OrderArticles.FirstOrDefault(q => q.ProductId == prod.Id);

            if (order != null)
            {
                MessageBox.Show("Продукт не можен быть удален, он участвует в заказе");
                return;
            }
            context.Products.Remove(prod);
            context.SaveChanges();
            products = context.Products.ToList();
            DrawProductItem(products);
            if (prod.ImagePath != null)
            {
                File.Delete(Path.Combine(projPath,"Images", prod.ImagePath));
            }
        }
        else
        {
            MessageBox.Show("Выберете продукт для удаления");
        }
    }
}


4. Карточка товара (ItemProduct)

Разметка (XAML)

<UserControl x:Class="demo.UserControllers.ItemProduct"
             xmlns="[http://schemas.microsoft.com/winfx/2006/xaml/presentation](http://schemas.microsoft.com/winfx/2006/xaml/presentation)"
             xmlns:x="[http://schemas.microsoft.com/winfx/2006/xaml](http://schemas.microsoft.com/winfx/2006/xaml)"
             xmlns:mc="[http://schemas.openxmlformats.org/markup-compatibility/2006](http://schemas.openxmlformats.org/markup-compatibility/2006)" 
             xmlns:d="[http://schemas.microsoft.com/expression/blend/2008](http://schemas.microsoft.com/expression/blend/2008)" 
             xmlns:local="clr-namespace:demo.UserControllers"
             mc:Ignorable="d" 
             d:DesignHeight="200" d:DesignWidth="1200"
             Background="White">
    <DockPanel Width="1200">
        <Border DockPanel.Dock="Left"
                BorderBrush="Black"
                BorderThickness="1"
                Margin="5">
            <Image Height="200" Width="300" Name="BoxImage"/>
        </Border>
        
        <Border DockPanel.Dock="Right"
                BorderBrush="Black"
                BorderThickness="1"
                Margin="5"
                MinWidth="250"
                Name="BoxDiscount">
            <TextBlock FontSize="40" 
                       HorizontalAlignment="Center" 
                       VerticalAlignment="Center">
                <Run Text="{Binding Discount}"/>
                <Run Text="%"/>
            </TextBlock>
        </Border>
        
        <Border BorderBrush="Black"
                BorderThickness="1"
                Margin="5">
            <StackPanel Margin="5 0 0 0">
                <TextBlock FontSize="25" FontWeight="Bold" Margin="5 0 0 0">
                    <Run Text="{Binding Manufacturer.Name}"/>
                    <Run Text=" | "/>
                    <Run Text="{Binding Name.Name}"/>
                </TextBlock>
                <TextBlock FontSize="18" TextWrapping="Wrap" Margin="5 0 0 0">
                    <Run Text="Описание товара: "/>
                    <Run Text="{Binding Description}"/>
                </TextBlock>
                <TextBlock FontSize="18" Margin="5 0 0 0">
                    <Run Text="Поставщик: "/>
                    <Run Text="{Binding Supplier.Name}"/>
                </TextBlock>
                <TextBlock FontSize="18" Margin="5 0 0 0">
                    <Run Text="Производитель: "/>
                    <Run Text="{Binding Manufacturer.Name}"/>
                </TextBlock>
                <TextBlock FontSize="18" Margin="5 0 0 0">
                    <Run Text="Единица измерения: "/>
                    <Run Text="{Binding Unit}"/>
                </TextBlock>
                <TextBlock FontSize="18" Name="BoxCount" Margin="5 0 0 0">
                    <Run Text="Количество на складе: "/>
                    <Run Text="{Binding Count}"/>
                </TextBlock>
                <TextBlock FontSize="18" Margin="5 0 0 0">
                    <Run Text="Цена: "/>
                    <Run Text="{Binding Price}" Name="BoxPrice"/>
                    <Run Name="BoxNewPrice"/>
                </TextBlock>
            </StackPanel>
        </Border>
    </DockPanel>
</UserControl>

Логика (C#)

public partial class ItemProduct : UserControl
{
    private string projPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
    public double discount { get; set; } = 0;
    
    public ItemProduct(Product product)
    {
        InitializeComponent();
        DataContext = product;

        string path = product.ImagePath == null 
            ? Path.Combine(projPath, "Images", "Defaults", "picture.png") 
            : Path.Combine(projPath, "Images", product.ImagePath);
        
        Uri uri = new Uri(path);
        try
        {
            BitmapImage bitmap = new(uri);
            BoxImage.Source = bitmap;
        }
        catch (Exception ex) // любая ошибка с изображением
        {
            Console.WriteLine(ex.Message);
            BitmapImage bitmap = new(new Uri(Path.Combine(projPath, "Images", "Defaults", "picture.png")));
            BoxImage.Source = bitmap;
        }

        if (product.Discount >= 15)
        {
            BoxDiscount.Background = new BrushConverter().ConvertFrom("#2E8B57") as SolidColorBrush;
        }
        
        if (product.Discount > 0)
        {
            BoxPrice.Foreground = Brushes.Red;
            BoxPrice.TextDecorations.Add(TextDecorations.Strikethrough);

            BoxNewPrice.Text = (product.Price * (1 - product.Discount / 100.0)).ToString();
        }

        if (product.Count == 0)
        {
            BoxCount.Foreground = Brushes.Blue;
        }
    }
}


5. Окно добавления товара (AddProduct)

Разметка (XAML)

<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"
            Orientation="Horizontal">
    <StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <TextBox Width="120" Name="BoxName"/>
            <Label Content="Название"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <ComboBox Width="120" Name="BoxCategory" SelectedIndex="0"/>
            <Label Content="Категория товара"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <TextBox Width="120" Name="BoxDescription"/>
            <Label Content="Описание"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <ComboBox Width="120" Name="BoxManufacturer" SelectedIndex="0"/>
            <Label Content="Производитель"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <ComboBox Width="120" Name="BoxSupplier" SelectedIndex="0"/>
            <Label Content="Поставщик"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <TextBox Width="120" Name="BoxPrice"/>
            <Label Content="Цена"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <TextBox Width="120" Name="BoxUnit"/>
            <Label Content="единица измерения,"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <TextBox Width="120" Name="BoxCount"/>
            <Label Content="количество на складе"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <TextBox Width="120" Name="BoxDiscount"/>
            <Label Content="скидка"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
            <Button Content="  Добавить продукт  " Click="ButtonAddProduct" Margin="5"/>
            <Button Content="Отмена" Click="ButtonExit" Margin="5"/>
        </StackPanel>
    </StackPanel>
    <StackPanel>
        <Image Name="BoxImage" Height="200" Width="200"/>
        <Button Content="добавить изображение" Margin="5" Click="ButtonLoadImage"/>
    </StackPanel>
</StackPanel>

Логика (C#)

public partial class AddProduct : Window
{
    private readonly string projPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
    private string? imageName = null;
    private BitmapImage selectImage;
    private DemoZubenContext context;
    
    public AddProduct()
    {
        InitializeComponent();
        context = new DemoZubenContext();

        selectImage = new BitmapImage(new Uri(Path.Combine(projPath, "Images", "Defaults", "picture.png")));
        BoxImage.Source = selectImage;
        BoxCategory.ItemsSource = context.Categories.ToList();
        BoxManufacturer.ItemsSource = context.Manufacturers.ToList();
        BoxSupplier.ItemsSource = context.Suppliers.ToList();
    }

    private void ButtonAddProduct(object sender, RoutedEventArgs e)
    {
        if (string.IsNullOrWhiteSpace(BoxDescription.Text) ||
            string.IsNullOrWhiteSpace(BoxDiscount.Text) ||
            string.IsNullOrWhiteSpace(BoxName.Text) ||
            string.IsNullOrWhiteSpace(BoxPrice.Text) ||
            string.IsNullOrWhiteSpace(BoxUnit.Text))
        {
            MessageBox.Show("Заполните все поля");
            return;
        }
        try
        {
            var name = context.ProductNames.FirstOrDefault(q => q.Name == BoxName.Text);
            if (name == null)
            {
                context.ProductNames.Add(new ProductName() { Id = context.ProductNames.Max(q => q.Id) + 1, Name = BoxName.Text });
                context.SaveChanges();
                name = context.ProductNames.FirstOrDefault(q => q.Name == BoxName.Text);
            }
            
            Product newProduct = new Product()
            {
                Id = context.Products.Max(q => q.Id) + 1,
                Name = name,
                Category = context.Categories.FirstOrDefault(q => q.Name == BoxCategory.SelectedItem.ToString()),
                Description = BoxDescription.Text,
                Manufacturer = context.Manufacturers.FirstOrDefault(q => q.Name == BoxManufacturer.SelectedItem.ToString()),
                Supplier = context.Suppliers.FirstOrDefault(q => q.Name == BoxSupplier.SelectedItem.ToString()),
                Price = int.Parse(BoxPrice.Text),
                Unit = BoxUnit.Text,
                Count = int.Parse(BoxCount.Text),
                Discount = int.Parse(BoxDiscount.Text),
                ImagePath = imageName,
            };
            context.Products.Add(newProduct);
            context.SaveChanges();

            DialogResult = true;
        }
        catch (Exception ex)
        {
            MessageBox.Show($"не верный формат ввода {ex.Message}");
        }
    }

    private void ButtonExit(object sender, RoutedEventArgs e)
    {
        DialogResult = false;
    }

    private void ButtonLoadImage(object sender, RoutedEventArgs e)
    {
        OpenFileDialog openFile = new OpenFileDialog();

        if (openFile.ShowDialog() == true)
        {
            Uri uri = new Uri(openFile.FileName);

            BitmapImage select = new(uri);
            if (select.Width > 400 || select.Height > 300)
            {
                MessageBox.Show("Размеры изображения имеют не верный формат");
                return;
            }

            selectImage = select;
            imageName = openFile.SafeFileName;
            BoxImage.Source = selectImage;
        }
    }
}


6. Окно редактирования товара (EditProduct)

Разметка (XAML)

<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"
            Orientation="Horizontal">
    <StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <TextBox Width="120" Name="BoxName"/>
            <Label Content="Название"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <ComboBox Width="120" Name="BoxCategory" SelectedIndex="0"/>
            <Label Content="Категория товара"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <TextBox Width="120" Name="BoxDescription"/>
            <Label Content="Описание"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <ComboBox Width="120" Name="BoxManufacturer" SelectedIndex="0"/>
            <Label Content="Производитель"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <ComboBox Width="120" Name="BoxSupplier" SelectedIndex="0"/>
            <Label Content="Поставщик"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <TextBox Width="120" Name="BoxPrice"/>
            <Label Content="Цена"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <TextBox Width="120" Name="BoxUnit"/>
            <Label Content="единица измерения,"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <TextBox Width="120" Name="BoxCount"/>
            <Label Content="количество на складе"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="5">
            <TextBox Width="120" Name="BoxDiscount"/>
            <Label Content="скидка"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
            <Button Content="  Сохранить изменения  " Click="ButtonSaveProduct" Margin="5"/>
            <Button Content="Отмена" Click="ButtonExit" Margin="5"/>
        </StackPanel>
    </StackPanel>
    <StackPanel>
        <Image Name="BoxImage" Height="200" Width="200"/>
        <Button Content="Изменить изображение" Margin="5" Click="ButtonLoadImage"/>
    </StackPanel>
</StackPanel>

Логика (C#)

public partial class EditProduct : Window
{
    private readonly string projPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
    DemoZubenContext context;
    private Product product;
    private BitmapImage selectImage;
    private string? imageName = null;
    
    public EditProduct(Product product)
    {
        InitializeComponent();

        context = new DemoZubenContext();
        this.product = product;
        Load();
    }

    private void Load()
    {
        BoxCategory.ItemsSource = context.Categories.ToList();
        BoxCategory.SelectedItem = product.Category;
        BoxSupplier.ItemsSource = context.Suppliers.ToList();
        BoxSupplier.SelectedItem = product.Supplier;
        BoxManufacturer.ItemsSource = context.Manufacturers.ToList();
        BoxManufacturer.SelectedItem = product.Manufacturer;
        BoxName.Text = product.Name.Name;
        BoxDescription.Text = product.Description;
        BoxDiscount.Text = product.Discount.ToString();
        BoxPrice.Text = product.Price.ToString();
        BoxUnit.Text = product.Unit.ToString();
        BoxCount.Text = product.Count.ToString();
    }

    private void ButtonSaveProduct(object sender, RoutedEventArgs e)
    {
        if (string.IsNullOrWhiteSpace(BoxDescription.Text) ||
            string.IsNullOrWhiteSpace(BoxDiscount.Text) ||
            string.IsNullOrWhiteSpace(BoxName.Text) ||
            string.IsNullOrWhiteSpace(BoxPrice.Text) ||
            string.IsNullOrWhiteSpace(BoxUnit.Text))
        {
            MessageBox.Show("Заполните все поля");
            return;
        }
        try
        {
            product.Name = context.ProductNames.FirstOrDefault(q => q.Name == BoxName.Text) ?? new ProductName() { Id = context.ProductNames.Max(q => q.Id) + 1, Name = BoxName.Text };
            product.Category = context.Categories.FirstOrDefault(q => q.Name == BoxCategory.SelectedItem.ToString());
            product.Description = BoxDescription.Text;
            product.Manufacturer = context.Manufacturers.FirstOrDefault(q => q.Name == BoxManufacturer.SelectedItem.ToString());
            product.Supplier = context.Suppliers.FirstOrDefault(q => q.Name == BoxSupplier.SelectedItem.ToString());
            product.Price = int.Parse(BoxPrice.Text);
            product.Unit = BoxUnit.Text;
            product.Count = int.Parse(BoxCount.Text);
            product.Discount = int.Parse(BoxDiscount.Text);
            if (imageName != null)
            {
                product.ImagePath = imageName;
            }

            context.Entry(product).State = EntityState.Modified;
            context.SaveChanges();

            DialogResult = true;
        }
        catch (Exception ex)
        {
            MessageBox.Show($"не верный формат ввода {ex.Message}");
        }
    }

    private void ButtonExit(object sender, RoutedEventArgs e)
    {
        DialogResult = false;
    }

    private void ButtonLoadImage(object sender, RoutedEventArgs e)
    {
        OpenFileDialog openFile = new OpenFileDialog();

        if (openFile.ShowDialog() == true)
        {
            Uri uri = new Uri(openFile.FileName);

            BitmapImage select = new(uri);
            if (select.Width > 400 || select.Height > 300)
            {
                MessageBox.Show("Размеры изображения имеют не верный формат");
                return;
            }

            File.Copy(Path.Combine(projPath, "Images"), openFile.FileName);

            selectImage = select;
            imageName = openFile.SafeFileName;
            BoxImage.Source = selectImage;
        }
    }
}

Product Compatible and additional computed target framework versions.
.NET net9.0-windows7.0 is compatible.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0-windows7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.17 117 6/12/2026