powered by simpleCommunicator - 2.0.51     © 2025 Programmizd 02
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / Как сохранить фоновую картинку
2 сообщений из 2, страница 1 из 1
Как сохранить фоновую картинку
    #39031975
caro1223
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
В приложении есть выбор фоновой картинки и языка. Как сделать что бы при повторном открытии приложения картинка и язык были те которые пользователь выбрал перед закрытием приложения.
Код: c#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
using System;
using System.Collections.Generic;
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.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Images
{
    /// <summary>
    /// Логика взаимодействия для MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            RandomImage1 = RandomImage2;
            RandomImage2 = (Image)this.FindName("mImage1");

            DoubleAnimation animationDown = new DoubleAnimation();
            animationDown.From = 1;
            animationDown.To = 0;
            animationDown.Duration = new Duration(TimeSpan.FromSeconds(0));
            RandomImage1.BeginAnimation(Image.OpacityProperty, animationDown);

            DoubleAnimation animationUp = new DoubleAnimation();
            animationUp.From = 0;
            animationUp.To = 1;
            animationUp.Duration = new Duration(TimeSpan.FromSeconds(0));
            RandomImage2.BeginAnimation(Image.OpacityProperty, animationUp);
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            RandomImage1 = RandomImage2;
            RandomImage2 = (Image)this.FindName("mImage2");

            DoubleAnimation animationDown = new DoubleAnimation();
            animationDown.From = 1;
            animationDown.To = 0;
            animationDown.Duration = new Duration(TimeSpan.FromSeconds(0));
            RandomImage1.BeginAnimation(Image.OpacityProperty, animationDown);

            DoubleAnimation animationUp = new DoubleAnimation();
            animationUp.From = 0;
            animationUp.To = 1;
            animationUp.Duration = new Duration(TimeSpan.FromSeconds(0));
            RandomImage2.BeginAnimation(Image.OpacityProperty, animationUp);
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            RandomImage1 = RandomImage2;
            RandomImage2 = (Image)this.FindName("mImage3");

            DoubleAnimation animationDown = new DoubleAnimation();
            animationDown.From = 1;
            animationDown.To = 0;
            animationDown.Duration = new Duration(TimeSpan.FromSeconds(0));
            RandomImage1.BeginAnimation(Image.OpacityProperty, animationDown);

            DoubleAnimation animationUp = new DoubleAnimation();
            animationUp.From = 0;
            animationUp.To = 1;
            animationUp.Duration = new Duration(TimeSpan.FromSeconds(0));
            RandomImage2.BeginAnimation(Image.OpacityProperty, animationUp);
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            RandomImage1 = RandomImage2;
            RandomImage2 = (Image)this.FindName("mImage1");

            DoubleAnimation animationDown = new DoubleAnimation();
            animationDown.From = 1;
            animationDown.To = 0;
            animationDown.Duration = new Duration(TimeSpan.FromSeconds(0));
            RandomImage1.BeginAnimation(Image.OpacityProperty, animationDown);

            DoubleAnimation animationUp = new DoubleAnimation();
            animationUp.From = 0;
            animationUp.To = 1;
            animationUp.Duration = new Duration(TimeSpan.FromSeconds(0));
            RandomImage2.BeginAnimation(Image.OpacityProperty, animationUp);

        }

        private void button4_Click(object sender, RoutedEventArgs e)
        {
            RandomImage1 = RandomImage2;
            RandomImage2 = (Image)this.FindName("mImage2");

            DoubleAnimation animationDown = new DoubleAnimation();
            animationDown.From = 1;
            animationDown.To = 0;
            animationDown.Duration = new Duration(TimeSpan.FromSeconds(0));
            RandomImage1.BeginAnimation(Image.OpacityProperty, animationDown);

            DoubleAnimation animationUp = new DoubleAnimation();
            animationUp.From = 0;
            animationUp.To = 1;
            animationUp.Duration = new Duration(TimeSpan.FromSeconds(0));
            RandomImage2.BeginAnimation(Image.OpacityProperty, animationUp);
        }

        private void button5_Click(object sender, RoutedEventArgs e)
        {
            RandomImage1 = RandomImage2;
            RandomImage2 = (Image)this.FindName("mImage3");

            DoubleAnimation animationDown = new DoubleAnimation();
            animationDown.From = 1;
            animationDown.To = 0;
            animationDown.Duration = new Duration(TimeSpan.FromSeconds(0));
            RandomImage1.BeginAnimation(Image.OpacityProperty, animationDown);

            DoubleAnimation animationUp = new DoubleAnimation();
            animationUp.From = 0;
            animationUp.To = 1;
            animationUp.Duration = new Duration(TimeSpan.FromSeconds(0));
            RandomImage2.BeginAnimation(Image.OpacityProperty, animationUp);
        }

        private void button6_Click(object sender, RoutedEventArgs e)
        {
            this.lang.Visibility = Visibility.Visible;
            this.lang_en.Visibility = Visibility.Hidden;

            this.b1en.Visibility = Visibility.Visible;
            this.b1.Visibility = Visibility.Hidden;
            this.b2en.Visibility = Visibility.Visible;
            this.b2.Visibility = Visibility.Hidden;
            this.b3en.Visibility = Visibility.Visible;
            this.b3.Visibility = Visibility.Hidden;
        }

        private void button7_Click(object sender, RoutedEventArgs e)
        {
            this.lang_en.Visibility = Visibility.Visible;
            this.lang.Visibility = Visibility.Hidden;

            this.b1.Visibility = Visibility.Visible;
            this.b1en.Visibility = Visibility.Hidden;
            this.b2.Visibility = Visibility.Visible;
            this.b2en.Visibility = Visibility.Hidden;
            this.b3.Visibility = Visibility.Visible;
            this.b3en.Visibility = Visibility.Hidden;
        }
    }
}



Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
<Window x:Class="Images.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:Images"
        mc:Ignorable="d"
        Title="MainWindow" Width="600" Height="393.6" ResizeMode="CanMinimize">
    <Grid Height="371" VerticalAlignment="Top">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="184*"/>
            <ColumnDefinition Width="184*"/>
            <ColumnDefinition Width="184*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="18"/>
            <RowDefinition Height="28"/>
            <RowDefinition Height="28"/>
            <RowDefinition Height="28"/>
            <RowDefinition Height="28"/>
            <RowDefinition Height="28"/>
            <RowDefinition Height="28"/>
            <RowDefinition Height="28"/>
            <RowDefinition Height="28"/>
            <RowDefinition Height="28"/>
            <RowDefinition Height="28"/>
            <RowDefinition Height="28"/>
            <RowDefinition Height="28"/>

        </Grid.RowDefinitions>
        <Image x:Name="_3_jpg" Margin="0" Source="images\3.jpg" Stretch="Fill" Grid.RowSpan="13" Grid.ColumnSpan="3"/>
        <Button x:Name="b1" Content="Картинка 1" Margin="62,4,62,5" Click="button_Click" Panel.ZIndex="1" Grid.Row="1"/>
        <Button x:Name="b2" Content="Картинка 2" Click="button1_Click" Margin="62,4,62,5" Panel.ZIndex="2" Grid.Row="1" Grid.Column="1"/>
        <Button x:Name="b3" Content="Картинка 3" Click="button2_Click" Margin="62,4,62,5" Panel.ZIndex="3" Grid.Row="1" Grid.Column="2"/>

        <Image x:Name="RandomImage1" Grid.RowSpan="13" Grid.ColumnSpan="3" />
        <Image x:Name="RandomImage2" Grid.RowSpan="13" Grid.ColumnSpan="3" />
        <Image x:Name="mImage1" Source="images\1.jpg" Opacity ="0" Grid.Row="0" Grid.Column="0" Margin="0" Grid.RowSpan="13" IsHitTestVisible="True" Stretch="Fill" Grid.ColumnSpan="3"/>
        <Image x:Name="mImage2" Source="images\2.jpg" Opacity ="0" Grid.Row="0" Grid.Column="0" Margin="0" Grid.RowSpan="13" IsHitTestVisible="True" Stretch="Fill" Grid.ColumnSpan="3"/>
        <Image x:Name="mImage3" Source="images\3.jpg" Opacity ="0" Grid.Row="0" Grid.Column="0" Margin="0" Grid.RowSpan="13" IsHitTestVisible="True" Stretch="Fill" Grid.ColumnSpan="3"/>
        <Button x:Name="b1en" Content="Image 1" Click="button3_Click" Margin="62,4,62,5" Grid.Row="1" Visibility="Hidden"/>
        <Button x:Name="b2en" Content="Image 2" Click="button4_Click" Margin="62,4,62,5" Grid.Row="1" Grid.Column="1" Visibility="Hidden"/>
        <Button x:Name="b3en" Content="Image 3" Click="button5_Click" Margin="62,4,62,5" Grid.Row="1" RenderTransformOrigin="0.447,0.777" Grid.Column="2" Visibility="Hidden"/>
        <Button x:Name="lang_en" Content="English" Click="button6_Click" Margin="62,4,62,5" Grid.Row="11" Grid.Column="1"/>
        <Button x:Name="lang" Content="Русский" Click="button7_Click" Margin="62,4,62,5" Grid.Row="11" Grid.Column="1" Width="74" Visibility="Hidden"/>
    </Grid>
</Window>



Вот приложение
...
Рейтинг: 0 / 0
Как сохранить фоновую картинку
    #39031976
caro1223
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / Как сохранить фоновую картинку
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]