G

Untitled

public
Guest Feb 12, 2024 Never 146
Clone
Plaintext paste1.txt
Plaintext paste2.txt
Plaintext paste3.txt
Plaintext paste4.txt
Plaintext paste5.txt
1
using System.Windows.Navigation;
2
using Prism.Commands;
3
using Prism.Mvvm;
4
using Prism.Navigation;
5
using Prism.Unity;
6
using Prism.Regions;
7
using DataTransfer.Views;
8
using System.Windows.Controls;
9
using System.Windows;
10
11
namespace DataTransfer.ViewModel
12
{
13
public class SourceViewModel : BindableBase
14
{
15
private string _name;
16
public string Name
17
{
18
get { return _name; }
19
set { SetProperty(ref _name, value); }
20
}
21
22
private int _mobileNumber;
23
public int MobileNumber
24
{
25
get { return _mobileNumber; }
26
set { SetProperty(ref _mobileNumber, value); }
27
}
28
//public event EventHandler<PersonModel> DataTransferred;
29
public DelegateCommand SaveCommand { get; private set; }
30
31
public SourceViewModel()
32
{
33
SaveCommand = new DelegateCommand(Execute, CanExecute).ObservesProperty(() => Name).ObservesProperty(() => MobileNumber);
34
}
35
36
private bool CanExecute()
37
{
38
return !String.IsNullOrWhiteSpace(Name) && Name.Length > 3 && Name.Length < 40 && Math.Floor(Math.Log10(MobileNumber) + 1) == 10;
39
}
40
private void Execute()
41
{
42
((MainWindow)Application.Current.MainWindow).Content = new TargetView(Name, MobileNumber);
43
//var targetViewModel = new TargetViewModel(Name, MobileNumber);
44
45
46
}
47
48
}
49
}
50
51
/*using System.Windows.Navigation;
52
using Prism.Commands;
53
using Prism.Mvvm;
54
using Prism.Navigation;
55
using Prism.Unity;
56
using Prism.Regions;
57
using DataTransfer.Views;
58
using System.Windows.Controls;
59
using System.Windows;
60
using DataTransfer.Model;
61
62
namespace DataTransfer.ViewModel
63
{
64
public class SourceViewModel : BindableBase
65
{
66
public PersonModel _person;
67
public DelegateCommand SaveCommand { get; private set; }
68
69
public SourceViewModel()
70
{
71
if(SaveCommand != null)
72
{
73
SaveCommand = new DelegateCommand(Execute, CanExecute).ObservesProperty(() => _person.Name).ObservesProperty(() => _person.MobileNumber);
74
}
75
}
76
77
private bool CanExecute()
78
{
79
return !String.IsNullOrWhiteSpace(_person.Name) && !String.IsNullOrWhiteSpace(_person.MobileNumber);
80
}
81
private void Execute()
82
{
83
*//*((MainWindow)Application.Current.MainWindow).Content = new TargetView(_person.Name, _person.MobileNumber);
84
//var targetViewModel = new TargetViewModel(_person.Name, _person.MobileNumber);*//*
85
86
var mainWindow = Application.Current.MainWindow as MainWindow;
87
if (mainWindow != null && mainWindow.MainFrame != null)
88
{
89
mainWindow.MainFrame.Navigate(new TargetView(_person.Name, _person.MobileNumber));
90
}
91
else
92
{
93
Console.WriteLine("Error: MainWindow or MainFrame is null.");
94
}
95
}
96
97
}
98
}*/
Plaintext paste2.txt 45 lines (41 loc) | 1.08 KB
1
using Prism.Events;
2
using Prism.Mvvm;
3
4
namespace DataTransfer.ViewModel
5
{
6
public class TargetViewModel : BindableBase
7
{
8
private string _name;
9
public string Name
10
{
11
get { return _name; }
12
set { SetProperty(ref _name, value); }
13
}
14
15
private int _mobileNumber;
16
public int MobileNumber
17
{
18
get { return _mobileNumber; }
19
set { SetProperty(ref _mobileNumber, value); }
20
}
21
//public SourceViewModel sourceViewModel;
22
public TargetViewModel(string name, int mobileNumber)
23
{
24
Name = name;
25
MobileNumber = mobileNumber;
26
}
27
}
28
}
29
30
/*using DataTransfer.Model;
31
using Prism.Events;
32
using Prism.Mvvm;
33
34
namespace DataTransfer.ViewModel
35
{
36
public class TargetViewModel : BindableBase
37
{
38
public PersonModel _person;
39
public TargetViewModel(string name, string mobileNumber)
40
{
41
_person.Name = name;
42
_person.MobileNumber = mobileNumber;
43
}
44
}
45
}*/
Plaintext paste3.txt 51 lines (46 loc) | 2.41 KB
1
<Page x:Class="DataTransfer.Views.SourceView"
2
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
xmlns:local="clr-namespace:DataTransfer.Views"
7
mc:Ignorable="d"
8
d:DesignHeight="450" d:DesignWidth="800"
9
Title="SourceView" Background="White">
10
11
<!--<Grid>
12
<StackPanel>
13
<TextBlock Text="Source View" FontWeight="Bold" FontSize="16" Margin="5"/>
14
<TextBox Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="5"/>
15
<TextBox Text="{Binding MobileNumber, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="5"/>
16
<Button Content="Publish" Command="{Binding PublishCommand}" Margin="5"/>
17
</StackPanel>
18
</Grid>-->
19
20
<Page.Resources>
21
<Style TargetType="TextBlock" x:Key="txtCss">
22
<Setter Property="FontSize" Value="20"/>
23
<Setter Property="Margin" Value="0 10 0 10"/>
24
</Style>
25
<Style TargetType="TextBox" x:Key="txtBox">
26
<Setter Property="Width" Value="140"/>
27
<Setter Property="Height" Value="20"/>
28
</Style>
29
</Page.Resources>
30
31
<Grid>
32
<WrapPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
33
<TextBlock Text="Name" Style="{StaticResource txtCss}"/>
34
<TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource txtBox}"/>
35
<TextBlock Text="Mobile Number" Style="{StaticResource txtCss}"/>
36
<TextBox Text="{Binding MobileNumber, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource txtBox}"/>
37
<Button Content="Save" Command="{Binding SaveCommand}" Margin=" 0 10 0 0" Width="70" Height="25"/>
38
</WrapPanel>
39
</Grid>
40
41
<!--<Grid>
42
<StackPanel Margin="20">
43
<TextBlock Text="Name:"/>
44
<TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}"/>
45
<TextBlock Text="Mobile Number:"/>
46
<TextBox Text="{Binding MobileNumber, UpdateSourceTrigger=PropertyChanged}"/>
47
<Button Content="Save" Command="{Binding SaveCommand}"/>
48
</StackPanel>
49
</Grid>-->
50
51
</Page>
Plaintext paste4.txt 37 lines (34 loc) | 1.59 KB
1
<Page x:Class="DataTransfer.Views.TargetView"
2
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
xmlns:local="clr-namespace:DataTransfer.Views"
7
mc:Ignorable="d"
8
d:DesignHeight="450" d:DesignWidth="800"
9
Title="TargetView" Background="White">
10
11
<!--<Grid>
12
<StackPanel>
13
<TextBlock Text="Target View" FontWeight="Bold" FontSize="16" Margin="5"/>
14
<TextBlock Text="{Binding Name}" Margin="5"/>
15
<TextBlock Text="{Binding MobileNumber}" Margin="5"/>
16
</StackPanel>
17
</Grid>-->
18
19
<Page.Resources>
20
<Style TargetType="TextBlock" x:Key="txtCss">
21
<Setter Property="FontSize" Value="20"/>
22
<Setter Property="Margin" Value="0 10 0 10"/>
23
</Style>
24
<Style TargetType="Label" x:Key="label">
25
<Setter Property="FontSize" Value="20"/>
26
</Style>
27
</Page.Resources>
28
29
<Grid>
30
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
31
<Label Content="Name" Style="{StaticResource label}"/>
32
<TextBlock Text="{Binding Name, Mode=OneWay}" Style="{StaticResource txtCss}"/>
33
<Label Content="Mobile Number" Style="{StaticResource label}"/>
34
<TextBlock Text="{Binding MobileNumber, Mode=OneWay}" Style="{StaticResource txtCss}"/>
35
</StackPanel>
36
</Grid>
37
</Page>
Plaintext paste5.txt 31 lines (30 loc) | 845 Bytes
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Windows;
7
using System.Windows.Controls;
8
using System.Windows.Data;
9
using System.Windows.Documents;
10
using System.Windows.Input;
11
using System.Windows.Media;
12
using System.Windows.Media.Imaging;
13
using System.Windows.Navigation;
14
using System.Windows.Shapes;
15
using DataTransfer.ViewModel;
16
17
namespace DataTransfer.Views
18
{
19
/// <summary>
20
/// Interaction logic for TargetView.xaml
21
/// </summary>
22
public partial class TargetView : Page
23
{
24
public TargetView(string name, int mobileNumber)
25
{
26
InitializeComponent();
27
//DataContext = new TargetViewModel();
28
DataContext = new TargetViewModel(name, mobileNumber);
29
}
30
}
31
}