Skip to content

Commit b7388ed

Browse files
committed
Added newline + more
-The chat can now send multiple lines of text - Some optimizations on the backend code
1 parent 1ffb09c commit b7388ed

File tree

110 files changed

+2337
-79
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+2337
-79
lines changed
-41 KB
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Windows.Data;
6+
using System.Windows.Media;
7+
8+
namespace WpfPageTransitions
9+
{
10+
public class CenterConverter : IValueConverter
11+
{
12+
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
13+
{
14+
return (double)value / 2;
15+
}
16+
17+
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
18+
{
19+
throw new NotImplementedException();
20+
}
21+
}
22+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Windows.Data;
6+
7+
namespace WpfPageTransitions
8+
{
9+
public class HeightConverter : IValueConverter
10+
{
11+
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
12+
{
13+
return (double)value / 4;
14+
}
15+
16+
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
17+
{
18+
throw new NotImplementedException();
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Windows.Data;
6+
7+
namespace WpfPageTransitions
8+
{
9+
class InvertConverter : IValueConverter
10+
{
11+
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
12+
{
13+
return -(double)value;
14+
}
15+
16+
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
17+
{
18+
throw new NotImplementedException();
19+
}
20+
}
21+
}
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<UserControl x:Class="WpfPageTransitions.PageTransition"
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:WpfPageTransitions"
7+
mc:Ignorable="d"
8+
d:DesignHeight="300" d:DesignWidth="300">
9+
<UserControl.Resources>
10+
11+
<Style TargetType="{x:Type ContentPresenter}">
12+
<Setter Property="LayoutTransform">
13+
<Setter.Value>
14+
<ScaleTransform />
15+
</Setter.Value>
16+
</Setter>
17+
</Style>
18+
19+
<local:CenterConverter x:Key="centerConverter"/>
20+
21+
<!-- Slide and Fade -->
22+
<Storyboard x:Key="SlideAndFadeIn" >
23+
<ThicknessAnimation Duration="0:0:.75" Storyboard.TargetProperty="Margin" From="500,0,-500,0" To="0" DecelerationRatio=".9" />
24+
<DoubleAnimation Duration="0:0:.25" Storyboard.TargetProperty="Opacity" From="0" To="1" />
25+
</Storyboard>
26+
27+
<Storyboard x:Key="SlideAndFadeOut">
28+
<ThicknessAnimation Duration="0:0:.5" Storyboard.TargetProperty="Margin" To="-500,0,500,0" AccelerationRatio=".9"/>
29+
<DoubleAnimation Duration="0:0:.25" Storyboard.TargetProperty="Opacity" To="0" />
30+
</Storyboard>
31+
32+
<!-- Fade -->
33+
<Storyboard x:Key="FadeIn" >
34+
<DoubleAnimation Duration="0:0:.2" Storyboard.TargetProperty="Opacity" From="0" To="1" />
35+
</Storyboard>
36+
37+
<Storyboard x:Key="FadeOut">
38+
<DoubleAnimation Duration="0:0:.2" Storyboard.TargetProperty="Opacity" To="0" />
39+
</Storyboard>
40+
41+
<!-- Slide -->
42+
<Storyboard x:Key="SlideIn" >
43+
<ThicknessAnimation Duration="0:0:.75" Storyboard.TargetProperty="Margin" From="500,0,-500,0" To="0" DecelerationRatio=".9" />
44+
</Storyboard>
45+
46+
<Storyboard x:Key="SlideOut">
47+
<ThicknessAnimation Duration="0:0:.5" Storyboard.TargetProperty="Margin" To="-500,0,500,0" AccelerationRatio=".9"/>
48+
</Storyboard>
49+
50+
<!-- Grow -->
51+
<Storyboard x:Key="GrowIn" >
52+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" From="0" To="1" Duration="0:0:.75" DecelerationRatio=".9" />
53+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" From="0" To="1" Duration="0:0:.75" DecelerationRatio=".9" />
54+
</Storyboard>
55+
56+
<Storyboard x:Key="GrowOut">
57+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" To="0" Duration="0:0:.75" AccelerationRatio=".9" />
58+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" To="0" Duration="0:0:.75" AccelerationRatio=".9" />
59+
</Storyboard>
60+
61+
<!-- Grow and Fade -->
62+
<Storyboard x:Key="GrowAndFadeIn" >
63+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" From="0" To="1" Duration="0:0:.75" DecelerationRatio=".9" />
64+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" From="0" To="1" Duration="0:0:.75" DecelerationRatio=".9" />
65+
<DoubleAnimation Duration="0:0:.25" Storyboard.TargetProperty="Opacity" From="0" To="1" />
66+
</Storyboard>
67+
68+
<Storyboard x:Key="GrowAndFadeOut">
69+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" To="0" Duration="0:0:.75" AccelerationRatio=".9" />
70+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" To="0" Duration="0:0:.75" AccelerationRatio=".9" />
71+
<DoubleAnimation Duration="0:0:.75" Storyboard.TargetProperty="Opacity" To="0" />
72+
</Storyboard>
73+
74+
<!-- Flip -->
75+
<Storyboard x:Key="FlipIn" >
76+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)" From="-100" To="0" Duration="0:0:.75" DecelerationRatio=".9" />
77+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleY)" From="-100" To="0" Duration="0:0:.75" DecelerationRatio=".9" />
78+
</Storyboard>
79+
80+
<Storyboard x:Key="FlipOut">
81+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)" To="100" Duration="0:0:.75" AccelerationRatio=".9" />
82+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleY)" To="100" Duration="0:0:.75" AccelerationRatio=".9" />
83+
</Storyboard>
84+
85+
<!-- Flip and Fade -->
86+
<Storyboard x:Key="FlipAndFadeIn" >
87+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)" From="-100" To="0" Duration="0:0:.75" DecelerationRatio=".9" />
88+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleY)" From="-100" To="0" Duration="0:0:.75" DecelerationRatio=".9" />
89+
<DoubleAnimation Duration="0:0:.25" Storyboard.TargetProperty="Opacity" From="0" To="1" />
90+
</Storyboard>
91+
92+
<Storyboard x:Key="FlipAndFadeOut">
93+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)" To="100" Duration="0:0:.75" AccelerationRatio=".9" />
94+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleY)" To="100" Duration="0:0:.75" AccelerationRatio=".9" />
95+
<DoubleAnimation Duration="0:0:.75" Storyboard.TargetProperty="Opacity" To="0" />
96+
</Storyboard>
97+
98+
<!-- Spin -->
99+
<Storyboard x:Key="SpinIn" >
100+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" From="-360" To="0" Duration="0:0:.75" DecelerationRatio=".9" />
101+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" From="0" To="1" Duration="0:0:.75" DecelerationRatio=".9" />
102+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" From="0" To="1" Duration="0:0:.75" DecelerationRatio=".9" />
103+
</Storyboard>
104+
105+
<Storyboard x:Key="SpinOut">
106+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" To="360" Duration="0:0:.75" AccelerationRatio=".9" />
107+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" To="0" Duration="0:0:.75" AccelerationRatio=".9" />
108+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" To="0" Duration="0:0:.75" AccelerationRatio=".9" />
109+
</Storyboard>
110+
111+
<!-- Spin and Fade -->
112+
<Storyboard x:Key="SpinAndFadeIn" >
113+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" From="-360" To="0" Duration="0:0:.75" DecelerationRatio=".9" />
114+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" From="0" To="1" Duration="0:0:.75" DecelerationRatio=".9" />
115+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" From="0" To="1" Duration="0:0:.75" DecelerationRatio=".9" />
116+
<DoubleAnimation Duration="0:0:.25" Storyboard.TargetProperty="Opacity" From="0" To="1" />
117+
</Storyboard>
118+
119+
<Storyboard x:Key="SpinAndFadeOut">
120+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" To="360" Duration="0:0:.75" AccelerationRatio=".9" />
121+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" To="0" Duration="0:0:.75" AccelerationRatio=".9" />
122+
<DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" To="0" Duration="0:0:.75" AccelerationRatio=".9" />
123+
<DoubleAnimation Duration="0:0:.75" Storyboard.TargetProperty="Opacity" To="0" />
124+
</Storyboard>
125+
126+
</UserControl.Resources>
127+
128+
<Grid Name="page">
129+
130+
<ContentControl Name="contentPresenter">
131+
<ContentControl.RenderTransform>
132+
<TransformGroup>
133+
<ScaleTransform ScaleX="1" ScaleY="1"
134+
CenterX="{Binding RelativeSource={RelativeSource AncestorType=Grid, Mode=FindAncestor}, Path=ActualWidth, Converter={StaticResource centerConverter}}"
135+
CenterY="{Binding RelativeSource={RelativeSource AncestorType=Grid, Mode=FindAncestor}, Path=ActualHeight, Converter={StaticResource centerConverter}}" />
136+
<SkewTransform AngleX="0" AngleY="0"
137+
CenterX="{Binding RelativeSource={RelativeSource AncestorType=Grid, Mode=FindAncestor}, Path=ActualWidth, Converter={StaticResource centerConverter}}"
138+
CenterY="{Binding RelativeSource={RelativeSource AncestorType=Grid, Mode=FindAncestor}, Path=ActualHeight, Converter={StaticResource centerConverter}}" />
139+
<RotateTransform Angle="0"
140+
CenterX="{Binding RelativeSource={RelativeSource AncestorType=Grid, Mode=FindAncestor}, Path=ActualWidth, Converter={StaticResource centerConverter}}"
141+
CenterY="{Binding RelativeSource={RelativeSource AncestorType=Grid, Mode=FindAncestor}, Path=ActualHeight, Converter={StaticResource centerConverter}}" />
142+
<TranslateTransform X="0" Y="0" />
143+
</TransformGroup>
144+
</ContentControl.RenderTransform>
145+
</ContentControl>
146+
147+
</Grid>
148+
149+
</UserControl>
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Windows;
6+
using System.Windows.Controls;
7+
using System.Windows.Data;
8+
using System.Windows.Documents;
9+
using System.Windows.Input;
10+
using System.Windows.Media;
11+
using System.Windows.Media.Imaging;
12+
using System.Windows.Navigation;
13+
using System.Windows.Shapes;
14+
using System.Threading.Tasks;
15+
using System.Windows.Media.Animation;
16+
17+
namespace WpfPageTransitions
18+
{
19+
public partial class PageTransition : UserControl
20+
{
21+
Stack<UserControl> pages = new Stack<UserControl>();
22+
23+
public UserControl CurrentPage { get; set; }
24+
25+
public static readonly DependencyProperty TransitionTypeProperty = DependencyProperty.Register("TransitionType",
26+
typeof(PageTransitionType),
27+
typeof(PageTransition), new PropertyMetadata(PageTransitionType.SlideAndFade));
28+
29+
public PageTransitionType TransitionType
30+
{
31+
get
32+
{
33+
return (PageTransitionType)GetValue(TransitionTypeProperty);
34+
}
35+
set
36+
{
37+
SetValue(TransitionTypeProperty, value);
38+
}
39+
}
40+
41+
public PageTransition()
42+
{
43+
InitializeComponent();
44+
this.IsHitTestVisible = false;
45+
}
46+
47+
public void ShowPage(UserControl newPage)
48+
{
49+
this.IsHitTestVisible = true;
50+
pages.Push(newPage);
51+
52+
Task.Factory.StartNew(() => ShowNewPage());
53+
}
54+
55+
public void UnloadCurrentPage() {
56+
this.IsHitTestVisible = false;
57+
if (contentPresenter.Content != null) {
58+
UserControl oldPage = contentPresenter.Content as UserControl;
59+
60+
if (oldPage != null) {
61+
oldPage.Loaded -= newPage_Loaded;
62+
63+
UnloadPageClean(oldPage);
64+
}
65+
}
66+
}
67+
68+
public void UnloadAndDisposeOfCurrentPage() {
69+
this.IsHitTestVisible = false;
70+
if (contentPresenter.Content != null) {
71+
UserControl oldPage = contentPresenter.Content as UserControl;
72+
73+
if (oldPage != null) {
74+
oldPage.Loaded -= newPage_Loaded;
75+
76+
UnloadPageClean(oldPage);
77+
}
78+
79+
pages.Pop();
80+
oldPage = null;
81+
contentPresenter.Content = null;
82+
}
83+
}
84+
85+
void ShowNewPage()
86+
{
87+
Dispatcher.Invoke((Action)delegate
88+
{
89+
if (contentPresenter.Content != null)
90+
{
91+
UserControl oldPage = contentPresenter.Content as UserControl;
92+
93+
if (oldPage != null)
94+
{
95+
oldPage.Loaded -= newPage_Loaded;
96+
97+
UnloadPage(oldPage);
98+
}
99+
}
100+
else
101+
{
102+
ShowNextPage();
103+
}
104+
105+
});
106+
}
107+
108+
void ShowNextPage()
109+
{
110+
UserControl newPage = pages.Pop();
111+
112+
newPage.Loaded += newPage_Loaded;
113+
114+
contentPresenter.Content = newPage;
115+
}
116+
117+
void UnloadPageClean(UserControl page) {
118+
Storyboard hidePage = (Resources[string.Format("{0}Out", TransitionType.ToString())] as Storyboard).Clone();
119+
120+
//hidePage.Completed += hidePage_Completed;
121+
122+
hidePage.Begin(contentPresenter);
123+
}
124+
125+
void UnloadPage(UserControl page)
126+
{
127+
Storyboard hidePage = (Resources[string.Format("{0}Out", TransitionType.ToString())] as Storyboard).Clone();
128+
129+
hidePage.Completed += hidePage_Completed;
130+
131+
hidePage.Begin(contentPresenter);
132+
}
133+
134+
void newPage_Loaded(object sender, RoutedEventArgs e)
135+
{
136+
Storyboard showNewPage = Resources[string.Format("{0}In", TransitionType.ToString())] as Storyboard;
137+
138+
showNewPage.Begin(contentPresenter);
139+
140+
CurrentPage = sender as UserControl;
141+
}
142+
143+
void hidePage_Completed(object sender, EventArgs e)
144+
{
145+
contentPresenter.Content = null;
146+
147+
ShowNextPage();
148+
}
149+
}
150+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace WpfPageTransitions
7+
{
8+
public enum PageTransitionType
9+
{
10+
Fade,
11+
Slide,
12+
SlideAndFade,
13+
Grow,
14+
GrowAndFade,
15+
Flip,
16+
FlipAndFade,
17+
Spin,
18+
SpinAndFade
19+
}
20+
}

0 commit comments

Comments
 (0)