WpfTheme 1.0.0

dotnet add package WpfTheme --version 1.0.0
                    
NuGet\Install-Package WpfTheme -Version 1.0.0
                    
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="WpfTheme" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WpfTheme" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="WpfTheme" />
                    
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 WpfTheme --version 1.0.0
                    
#r "nuget: WpfTheme, 1.0.0"
                    
#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 WpfTheme@1.0.0
                    
#: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=WpfTheme&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=WpfTheme&version=1.0.0
                    
Install as a Cake Tool

бД CREATE Table Dishes( id INTEGER PRIMARY KEY AUTOINCREMENT, name Text NOT NULL, price Text NOT NULL, opisanie Text NOT NULL, category Text NOT NULL, image_path Text FOREIGN KEY (TypePartners) REFERENCES Partners(TypePartners), FOREIGN KEY (TypePartners) REFERENCES Partners(TypePartners), ); обьявление переменных { public class Dishes { public int id { get; set; } public string? name { get; set; } public string? price { get; set; } public string? opisanie { get; set; } public string? category { get; set; } public string? image_path { get; set; } } }

Подключение к БД: public class DB { public const string ConnectionString = "Data Source = Dish.db;Version=3"; public static List<Dishes> GetAllDish() { List<Dishes> dish = new(); using var conn = new SQLiteConnection(ConnectionString); conn.Open(); using var cmd = new SQLiteCommand("Select * From Dishes", conn); using var reader = cmd.ExecuteReader(); while (reader.Read()) { dish.Add(new Dishes { id = reader.GetInt32(0), name = reader.GetString(1), price=reader.GetString(2), opisanie = reader.GetString(3), category = reader.GetString(4), image_path = reader.GetString(5), }) ;

              }
     return dish ;

 }

} Функция Добавления public static void AddDish (Dishes dish){ using var conn = new SQLiteConnection(ConnectionString); conn.Open(); using var cmd = new SQLiteCommand("INSERT INTO Dishes (name,price,opisanie,category,image_path) VALUES(@name,@price,@opisanie,@category,@image_path)", conn); cmd.Parameters.AddWithValue ("@name", dish.name); cmd.Parameters.AddWithValue("@price", dish.price); cmd.Parameters.AddWithValue("@opisanie", dish.opisanie); cmd.Parameters.AddWithValue("@category", dish.category); cmd.Parameters.AddWithValue("@image_path", dish.image_path); cmd.ExecuteNonQuery(); } Функция апдейта в xaml.cs public partial class EditDishWindow : Window { private Dishes _dish;

 public EditDishWindow(Dishes dish)
 {
     InitializeComponent();
     _dish = dish;
     NameBox.Text = _dish.name;
     ImagePathBox.Text = _dish.image_path;
 }

 private void Save_Click(object sender, RoutedEventArgs e)
 {
     _dish.name = NameBox.Text;
     _dish.image_path = ImagePathBox.Text;

     SaveToDatabase(_dish); // сохраняем в БД

     this.DialogResult = true;
     this.Close();
 }
 private void SaveToDatabase(Dishes dish)
 {
     using var conn = new SQLiteConnection("Data Source=Dish.db"); // или NpgsqlConnection, если PostgreSQL
     conn.Open();

     string query = "UPDATE Dishes SET name = @name, image_path = @image WHERE id = @id";
     using var cmd = new SQLiteCommand(query, conn);
     cmd.Parameters.AddWithValue("@name", dish.name);
     cmd.Parameters.AddWithValue("@image", dish.image_path);
     cmd.Parameters.AddWithValue("@id", dish.id);
     cmd.ExecuteNonQuery();
 }

} это в mainwindow xaml <Window x:Class="WpfApp8.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApp8" mc:Ignorable="d" Title="MainWindow" Height="600" Width="900" Background="White"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="90"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions>

    <StackPanel Background="Black" Grid.Column="0" VerticalAlignment="Stretch">
        <TextBlock Text="S." FontSize="26" FontWeight="Bold" Foreground="White" 
                   HorizontalAlignment="Center" Margin="0,20,0,40"/>
        <Button Content="🍴" Height="50" Margin="10" Foreground="Black"/>
        <Button Content="🛒" Height="50" Margin="10" Background="Transparent" Foreground="White"/>
    </StackPanel>
    
    <ScrollViewer Grid.Column="1" VerticalScrollBarVisibility="Auto">
        <StackPanel Margin="20">
            <TextBlock Text="SUSHI FOOD" FontSize="28" FontWeight="Bold" Margin="0,20,0,30"/>
            <ItemsControl x:Name="DishesLastView">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel HorizontalAlignment="Left" ItemWidth="150" ItemHeight="170"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Width="150" Margin="10">
                            <Border BorderBrush="LightGray" BorderThickness="1" CornerRadius="6" MouseDown="DishItem_Click">
                                <Image Source="{Binding image_path}" Height="100" Width="150" Stretch="UniformToFill"/>
                            </Border>
                            <TextBlock Text="{Binding name}" FontWeight="SemiBold" FontSize="12" TextAlignment="Center" Margin="0,8,0,0"/>
                            <Button Content="Удалить" Margin="0,5,0,0" Click="DeleteDish_Click"
                Tag="{Binding id}" Background="Crimson" Foreground="White"/>
                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
            <Button Content="Добавить блюдо"
    Width="150" Height="40" Margin="0,0,30,0"
    HorizontalAlignment="Left"
    Click="AddDish_Click"/>
           
        </StackPanel>
    </ScrollViewer>
</Grid>

</Window>

Это в mainwinow.cs
using System.Collections.ObjectModel; using System.Data.SQLite; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes;

namespace WpfApp8 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { private ObservableCollection<Dishes> dishes = new ObservableCollection<Dishes>();

    public MainWindow()
    {
        InitializeComponent();
        GetDish();
    }
    public  void GetDish()
    {
        var dishes = DB.GetAllDish(); // получаем из базы
        DishesLastView.ItemsSource = dishes;
    }
    private void DishItem_Click(object sender, MouseButtonEventArgs e)
    {
        if (sender is Border border && border.DataContext is Dishes dish)
        {
            var editWindow = new EditDishWindow(dish); // передаём блюдо
            if (editWindow.ShowDialog() == true)
            {
                // можно обновить ItemsControl вручную, если нужно
                DishesLastView.Items.Refresh();
            }
        }
    }
    public void AddDish_Click(object sender, RoutedEventArgs e)
    {
        var addWindow = new AddDishWindow();
        if (addWindow.ShowDialog() == true)
        {
            // dish добавлен — обновим список
            GetDish();
        }
    }
    private void DeleteDish_Click(object sender, RoutedEventArgs e)
    {
        if (sender is Button btn && btn.Tag is int dishId)
        {
            var result = MessageBox.Show("Удалить это блюдо?", "Подтверждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
            if (result == MessageBoxResult.Yes)
            {
                // Удалить из БД
                using var conn = new SQLiteConnection("Data Source=Dish.db");
                conn.Open();
                var cmd = new SQLiteCommand("DELETE FROM Dishes WHERE id = @id", conn);
                cmd.Parameters.AddWithValue("@id", dishId);
                cmd.ExecuteNonQuery();

                // Обновить список
                GetDish(); // метод, который перезагружает список из БД
            }
        }
    }



}

} Страница добавления <Window x:Class="WpfApp8.AddDishWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Добавить блюдо" Height="250" Width="300"> <StackPanel Margin="20"> <TextBlock Text="Название:"/> <TextBox x:Name="NameBox" Margin="0,5"/>

    <TextBlock Text="Цена:"/>
    <TextBox x:Name="PriceBox" Margin="0,5"/>

    <TextBlock Text="Описание:"/>
    <TextBox x:Name="OpisanieBox" Margin="0,5"/>

    <TextBlock Text="Категория:"/>
    <TextBox x:Name="CategoryBox" Margin="0,5"/>

    <TextBlock Text="Путь к изображению:"/>
    <TextBox x:Name="ImagePathBox" Margin="0,5"/>

    <Button Content="Сохранить" Margin="0,20,0,0" Click="Save_Click"/>
</StackPanel>

</Window>

Cs using System; using System.Collections.Generic; using System.Data.SQLite; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes;

namespace WpfApp8 { /// <summary> /// Логика взаимодействия для AddDishWindow.xaml /// </summary> public partial class AddDishWindow : Window { public Dishes NewDish { get; private set; }

    public AddDishWindow()
    {
        InitializeComponent();
    }

    private void Save_Click(object sender, RoutedEventArgs e)
    {
        string name = NameBox.Text.Trim();
        string price = PriceBox.Text.Trim();
        string opisanie = OpisanieBox.Text.Trim();
        string category = CategoryBox.Text.Trim();
        string imagePath = ImagePathBox.Text.Trim();

        using var conn = new SQLiteConnection("Data Source=Dish.db");
        conn.Open();

        string query = @"INSERT INTO Dishes (name, price, opisanie, category, image_path) 
                 VALUES (@name, @price, @opisanie, @category, @imagePath); 
                 SELECT last_insert_rowid();";

        using var cmd = new SQLiteCommand(query, conn);
        cmd.Parameters.AddWithValue("@name", name);
        cmd.Parameters.AddWithValue("@price", price);
        cmd.Parameters.AddWithValue("@opisanie", opisanie);
        cmd.Parameters.AddWithValue("@category", category);
        cmd.Parameters.AddWithValue("@imagePath", imagePath);

        long newId = (long)cmd.ExecuteScalar();

        NewDish = new Dishes
        {
            id = (int)newId,
            name = name,
            price = price,
            opisanie = opisanie,
            category = category,
            image_path = imagePath
        };

        DialogResult = true;
        Close();
    }

}

}

Редоктирование <Window x:Class="WpfApp8.EditDishWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Edit Dish" Height="250" Width="300"> <StackPanel Margin="20"> <TextBlock Text="Название:" /> <TextBox x:Name="NameBox" Margin="0,5"/>

    <TextBlock Text="Путь к изображению:" Margin="0,10,0,0"/>
    <TextBox x:Name="ImagePathBox" Margin="0,5"/>

    <Button Content="Сохранить" Margin="0,20,0,0" Click="Save_Click"/>
</StackPanel>

</Window>

Cs using System; using System.Collections.Generic; using System.Data.SQLite; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes;

namespace WpfApp8 { /// <summary> /// Логика взаимодействия для EditDishWindow.xaml /// </summary> public partial class EditDishWindow : Window { private Dishes _dish;

    public EditDishWindow(Dishes dish)
    {
        InitializeComponent();
        _dish = dish;
        NameBox.Text = _dish.name;
        ImagePathBox.Text = _dish.image_path;
    }

    private void Save_Click(object sender, RoutedEventArgs e)
    {
        _dish.name = NameBox.Text;
        _dish.image_path = ImagePathBox.Text;

        SaveToDatabase(_dish); // сохраняем в БД

        this.DialogResult = true;
        this.Close();
    }
    private void SaveToDatabase(Dishes dish)
    {
        using var conn = new SQLiteConnection("Data Source=Dish.db"); // или NpgsqlConnection, если PostgreSQL
        conn.Open();

        string query = "UPDATE Dishes SET name = @name, image_path = @image WHERE id = @id";
        using var cmd = new SQLiteCommand(query, conn);
        cmd.Parameters.AddWithValue("@name", dish.name);
        cmd.Parameters.AddWithValue("@image", dish.image_path);
        cmd.Parameters.AddWithValue("@id", dish.id);
        cmd.ExecuteNonQuery();
    }

}

}

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.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
1.0.0 152 6/20/2025