Commit 55227173 authored by Margaux Clerc's avatar Margaux Clerc

Clean & fix

parent 5c65112e
......@@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
using System;
using System.Diagnostics;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace Linphone.Controls
......@@ -23,7 +23,6 @@ namespace Linphone.Controls
public partial class AddressBox : UserControl
{
public String Text
{
get { return address.Text; }
......@@ -45,15 +44,16 @@ namespace Linphone.Controls
this.DataContext = this;
}
private void backspace_Hold_1(object sender, Windows.UI.Xaml.RoutedEventArgs e)
private void backspace_Hold_1(object sender, RoutedEventArgs e)
{
address.Text = "";
}
private void backspace_Click_1(object sender, Windows.UI.Xaml.RoutedEventArgs e)
private void backspace_Click_1(object sender, RoutedEventArgs e)
{
if (address.Text.Length > 0)
address.Text = address.Text.Substring(0, address.Text.Length - 1);
}
private void address_TextChanged(object sender, TextChangedEventArgs e)
......
This diff is collapsed.
......@@ -14,32 +14,15 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using Linphone.Model;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media.Imaging;
namespace Linphone.Controls
{
public partial class CallControlsP : UserControl
{
private const string speakerOn = "/Assets/Incall_Icons/speaker_on.png";
private const string speakerOff = "/Assets/Incall_Icons/speaker_off.png";
private const string bluetoothOn = "/Assets/Incall_Icons/bluetooth_on.png";
private const string bluetoothOff = "/Assets/Incall_Icons/bluetooth_off.png";
private const string videoOn = "/Assets/Incall_Icons/video_on.png";
private const string videoOff = "/Assets/Incall_Icons/video_off.png";
private const string pauseOn = "/Assets/Incall_Icons/pause.png";
private const string pauseOff = "/Assets/Incall_Icons/play.png";
private const string micOn = "/Assets/Incall_Icons/micro_on.png";
private const string micOff = "/Assets/Incall_Icons/micro_off.png";
public delegate void HangUpClickEventHandler(object sender);
public event HangUpClickEventHandler HangUpClick;
......@@ -67,26 +50,33 @@ namespace Linphone.Controls
public delegate void BluetoothClickEventHandler(object sender, bool isBluetoothOn);
public event DialpadClickEventHandler BluetoothClick;
/// <summary>
/// Public constructor
/// </summary>
public CallControlsP()
{
InitializeComponent();
microphone.IsChecked = LinphoneManager.Instance.Core.IsMicEnabled;
video.IsEnabled = LinphoneManager.Instance.Core.IsVideoSupported;
camera.IsEnabled = LinphoneManager.Instance.Core.IsVideoSupported && LinphoneManager.Instance.NumberOfCameras > 1;
}
#region Button enabled/disabled
public void enabledDialpad(bool isDialpadShown)
{
dialpad.Visibility = isDialpadShown ? Visibility.Visible : Visibility.Collapsed;
}
public void enabledVideo(bool isDialpadShown)
public void enabledVideo(bool isVideoEnabled)
{
video.IsEnabled = isVideoEnabled;
}
public void enabledPause(bool isPauseEnabled)
{
video.IsEnabled = isDialpadShown;
pause.IsEnabled = isPauseEnabled;
}
#endregion
#region Click Event
private void hangUp_Click(object sender, RoutedEventArgs e)
{
HangUpClick(this);
......@@ -95,42 +85,32 @@ namespace Linphone.Controls
private void bluetooth_Click_1(object sender, RoutedEventArgs e)
{
bool isBluetoothToggled = (bool)bluetooth.IsChecked;
//bluetoothImg.Source = new BitmapImage(new Uri(isBluetoothToggled ? bluetoothOn : bluetoothOff, UriKind.RelativeOrAbsolute));
BluetoothClick(this, isBluetoothToggled);
}
private void speaker_Click_1(object sender, RoutedEventArgs e)
{
bool isSpeakerToggled = (bool)speaker.IsChecked;
if (SpeakerClick(this, isSpeakerToggled)) {
//speakerImg.Source = new BitmapImage(new Uri((bool)speaker.IsChecked ? speakerOn : speakerOff, UriKind.RelativeOrAbsolute));
}
SpeakerClick(this, isSpeakerToggled);
}
private void microphone_Click_1(object sender, RoutedEventArgs e)
{
bool isMicToggled = (bool)microphone.IsChecked;
//microImg.Source = new BitmapImage(new Uri(isMicToggled ? micOff : micOn, UriKind.RelativeOrAbsolute));
MuteClick(this, isMicToggled);
}
public void enabledPause(bool v)
{
pause.IsEnabled = true;
}
private void stats_Click_1(object sender, RoutedEventArgs e)
{
bool areStatsVisible = (bool)stats.IsChecked;
stats.IsChecked = areStatsVisible;
statsPanel.Visibility = areStatsVisible ? Visibility.Visible : Visibility.Collapsed;
StatsClick(this, areStatsVisible);
StatsClick(this, areStatsVisible);
}
private void video_Click_1(object sender, RoutedEventArgs e)
{
bool isVideoToggled = (bool)video.IsChecked;
// videoImg.Source = new BitmapImage(new Uri((bool)video.IsChecked ? videoOn : videoOff, UriKind.RelativeOrAbsolute));
video.IsChecked = isVideoToggled;
VideoClick(this, isVideoToggled);
}
......@@ -145,14 +125,14 @@ namespace Linphone.Controls
bool isDialpadChecked = (bool)dialpad.IsChecked;
dialpad.IsChecked = isDialpadChecked;
numpad.Visibility = isDialpadChecked ? Visibility.Visible : Visibility.Collapsed;
//DialpadClick(this, isDialpadChecked);
DialpadClick(this, isDialpadChecked);
}
private void pause_Click_1(object sender, RoutedEventArgs e)
{
bool isPauseToggled = (bool)pause.IsChecked;
//pauseImg.Source = new BitmapImage(new Uri(isPauseToggled ? pauseOn : pauseOff, UriKind.RelativeOrAbsolute));
PauseClick(this, isPauseToggled);
}
#endregion
}
}
......@@ -15,11 +15,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
using BelledonneCommunications.Linphone.Native;
using Linphone.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Documents;
......@@ -54,7 +51,7 @@ namespace Linphone.Controls
{
get
{
return FormatText();
return Utils.FormatText(ChatMessage.Text);
}
}
......@@ -65,8 +62,7 @@ namespace Linphone.Controls
{
get
{
DateTime date = new DateTime(ChatMessage.Time * TimeSpan.TicksPerSecond, DateTimeKind.Utc).AddYears(1969).ToLocalTime();
return FormatDate(date);
return Utils.FormatDate(ChatMessage.Time);
}
}
......@@ -78,50 +74,5 @@ namespace Linphone.Controls
this.InitializeComponent();
ChatMessage = message;
}
private Paragraph FormatText()
{
Paragraph paragraph = new Paragraph();
if (ChatMessage != null)
{
string text = ChatMessage.Text;
if (text.Contains("http://") || text.Contains("https://"))
{
string[] split = text.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
foreach (string word in split)
{
if (word.StartsWith("http://") || word.StartsWith("https://"))
{
Hyperlink link = new Hyperlink();
link.NavigateUri = new Uri(word);
//link.Inlines.Add(word);
//link.TargetName = "_blank";
paragraph.Inlines.Add(link);
}
else
{
//paragraph.Inlines.Add(word);
}
//paragraph.Inlines.Add();
}
}
else
{
// paragraph.Inlines.Add(text);
}
}
return paragraph;
}
private string FormatDate(DateTime date)
{
DateTime now = DateTime.Now;
if (now.Year == date.Year && now.Month == date.Month && now.Day == date.Day)
return String.Format("{0:HH:mm}", date);
else if (now.Year == date.Year)
return String.Format("{0:ddd d MMM, HH:mm}", date);
else
return String.Format("{0:ddd d MMM yyyy, HH:mm}", date);
}
}
}
......@@ -6,20 +6,6 @@
xmlns:linphone="using:Linphone.Controls"
mc:Ignorable="d">
<UserControl.Resources>
<Style TargetType="TextBlock" x:Key="TimestampStyle">
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Opacity" Value="0.5"/>
<Setter Property="Margin" Value="0,0,5,5"/>
</Style>
<Style TargetType="TextBlock" x:Key="MessageStyle">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Margin" Value="5,5,5,3"/>
</Style>
</UserControl.Resources>
<Grid Margin="5,0,100,5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
......@@ -41,10 +27,11 @@
Grid.RowSpan="2"
Grid.Row="1"/>
<TextBlock
<RichTextBlock
Grid.Row="1"
x:Name="Message"
TextWrapping="Wrap"
IsTextSelectionEnabled="True"
Style="{StaticResource MessageStyle}"
TextAlignment="Left"/>
......
......@@ -15,31 +15,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using Linphone.Model;
using Linphone.Views;
using Linphone.Controls;
using BelledonneCommunications.Linphone.Native;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Imaging;
namespace Linphone.Controls
{
/// <summary>
/// Control to display received chat messages.
/// </summary>
public partial class IncomingChatBubble : UserControl
{
private ChatMessage _message;
/// <summary>
/// Chat message associated with this bubble
/// </summary>
public ChatMessage ChatMessage
{
get
......@@ -51,44 +39,41 @@ namespace Linphone.Controls
_message = value;
}
}
/// <summary>
/// Public constructor.
/// </summary>
public IncomingChatBubble(ChatMessage message)
{
InitializeComponent();
Message.Text = message.Text;
ChatMessage = message;
Timestamp.Text = HumanFriendlyTimeStamp;
/*string fileName = message.FileTransferName;
string filePath = message.AppData;
bool isImageMessage = fileName != null && fileName.Length > 0;
if (isImageMessage)
{
Message.Visibility = Visibility.Collapsed;
// Copy.Visibility = Visibility.Collapsed;
if (filePath != null && filePath.Length > 0)
{
// Image already downloaded
Image.Visibility = Visibility.Visible;
// Save.Visibility = Visibility.Visible;
BitmapImage image = Utils.ReadImageFromIsolatedStorage(filePath);
Image.Source = image;
}
else
{
// Image needs to be downloaded
Download.Visibility = Visibility.Visible;
}
}
else
{
Message.Visibility = Visibility.Visible;
Image.Visibility = Visibility.Collapsed;
// Message.Blocks.Add(TextWithLinks);
}*/
string fileName = message.FileTransferName;
string filePath = message.AppData;
bool isImageMessage = fileName != null && fileName.Length > 0;
if (isImageMessage)
{
Message.Visibility = Visibility.Collapsed;
//Copy.Visibility = Visibility.Collapsed;
if (filePath != null && filePath.Length > 0)
{
// Image already downloaded
Image.Visibility = Visibility.Visible;
// Save.Visibility = Visibility.Visible;
BitmapImage image = Utils.ReadImageFromIsolatedStorage(filePath);
Image.Source = image;
}
else
{
// Image needs to be downloaded
Download.Visibility = Visibility.Visible;
}
}
else
{
Message.Visibility = Visibility.Visible;
Image.Visibility = Visibility.Collapsed;
Message.Blocks.Add(Utils.FormatText(message.Text));
}
}
private void Delete_Click(object sender, RoutedEventArgs e)
......@@ -144,10 +129,7 @@ namespace Linphone.Controls
{
get
{
DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
long unixTimeStampInTicks = (long)(ChatMessage.Time * TimeSpan.TicksPerSecond);
DateTime date = new DateTime(unixStart.Ticks + unixTimeStampInTicks).ToLocalTime();
return FormatDate(date);
return Utils.FormatDate(ChatMessage.Time);
}
}
......
......@@ -6,76 +6,6 @@
mc:Ignorable="d"
d:DesignHeight="480" d:DesignWidth="480">
<UserControl.Resources>
<Style x:Key="DialpadButtonStyle"
TargetType="Button">
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0,0,1,0" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Height" Value="60" />
<Setter Property="ClickMode" Value="Press" />
<Setter Property="Foreground" Value="{ThemeResource SystemBaseHighColor}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="IsTextScaleFactorEnabled" Value="False" />
</Style>
<Style x:Key="DialpadNumberStyle"
TargetType="TextBlock">
<Setter Property="FontSize"
Value="{ThemeResource TextStyleExtraLargeFontSize}" />
<Setter Property="FontFamily"
Value="{ThemeResource PhoneFontFamilyNormal}" />
<Setter Property="VerticalAlignment"
Value="Bottom" />
<Setter Property="HorizontalAlignment"
Value="Center" />
</Style>
<Style x:Key="DialpadLetterStyle"
TargetType="TextBlock">
<Setter Property="FontSize"
Value="12" />
<Setter Property="FontFamily"
Value="{ThemeResource PhoneFontFamilySemiLight}" />
<Setter Property="FontWeight"
Value="ExtraLight" />
<Setter Property="VerticalAlignment"
Value="Bottom" />
<Setter Property="HorizontalAlignment"
Value="Center" />
<Setter Property="Padding"
Value="0,0,0,0" />
</Style>
<Style x:Key="TextStyle"
TargetType="TextBlock">
<Setter Property="FontSize"
Value="16" />
<Setter Property="FontFamily"
Value="{ThemeResource PhoneFontFamilySemiLight}" />
<Setter Property="FontWeight"
Value="ExtraLight"/>
</Style>
<Style x:Key="DialpadIconStyle"
TargetType="FontIcon">
<Setter Property="FontSize"
Value="12" />
<Setter Property="FontFamily"
Value="{ThemeResource PhoneFontFamilySemiLight}" />
<Setter Property="FontWeight"
Value="ExtraLight" />
<Setter Property="VerticalAlignment"
Value="Bottom" />
<Setter Property="HorizontalAlignment"
Value="Center" />
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="12" />
......
......@@ -15,24 +15,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using Linphone.Model;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace Linphone.Controls
{
/// <summary>
/// Control to display numpad during a call
/// </summary>
public partial class Numpad : UserControl
{
/// <summary>
/// Public constructor
/// </summary>
public Numpad()
{
InitializeComponent();
......
......@@ -7,21 +7,7 @@
xmlns:custom="using:Linphone.Controls"
xmlns:controls="Linphone.Controls"
mc:Ignorable="d">
<UserControl.Resources>
<Style TargetType="TextBlock" x:Key="TimestampStyle">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Opacity" Value="0.5"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Margin" Value="0,0,5,5"/>
</Style>
<Style TargetType="TextBlock" x:Key="MessageStyle">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Margin" Value="7,5,2,2"/>
</Style>
</UserControl.Resources>
<Grid Margin="100,5,5,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
......@@ -34,12 +20,13 @@
Fill="{ThemeResource SystemControlBackgroundAccentBrush}"
Grid.RowSpan="2"/>
<TextBlock
Grid.Row="0"
x:Name="Message"
Style="{StaticResource MessageStyle}"
TextWrapping="Wrap"
TextAlignment="Left"/>
<RichTextBlock
Grid.Row="0"
x:Name="Message"
TextWrapping="Wrap"
IsTextSelectionEnabled="True"
Style="{StaticResource MessageStyle}"
TextAlignment="Left"/>
<Image
Grid.Row="0"
......
......@@ -14,16 +14,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using Linphone.Model;
using Linphone.Views;
using Windows.UI.Xaml.Media;
using Windows.UI;
using Linphone.Controls;
using BelledonneCommunications.Linphone.Native;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml;
......@@ -31,16 +22,10 @@ using Windows.UI.Xaml.Controls;
namespace Linphone.Controls
{
/// <summary>
/// Control to display sent chat messages.
/// </summary>
public partial class OutgoingChatBubble : UserControl
{
private ChatMessage _message;
/// <summary>
/// Chat message associated with this bubble
/// </summary>
public ChatMessage ChatMessage
{
get
......@@ -52,19 +37,7 @@ namespace Linphone.Controls
_message = value;
}
}
/* private SolidColorBrush _darkAccentBrush
{
get
{
Color accent = (Color)Resources["PhoneAccentColor"];
Color darkAccent = Color.FromArgb(accent.A, (byte)(accent.R / 2), (byte)(accent.G / 2), (byte)(accent.B / 2));
return new SolidColorBrush(darkAccent);
}
}*/
/// <summary>
/// Public constructor.
/// </summary>
public OutgoingChatBubble(ChatMessage message)
{
InitializeComponent();
......@@ -85,48 +58,27 @@ namespace Linphone.Controls
else
{
Message.Visibility = Visibility.Visible;
Message.Text = message.Text;
Message.Blocks.Add(Utils.FormatText(message.Text));
//Image.Visibility = Visibility.Collapsed;
//Message.Blocks.Add(TextWithLinks);
}
Timestamp.Text = HumanFriendlyTimeStamp;
//Background.Fill = _darkAccentBrush;
//Path.Fill = _darkAccentBrush;
}
public string HumanFriendlyTimeStamp
{
get
{
DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
long unixTimeStampInTicks = (long)(ChatMessage.Time * TimeSpan.TicksPerSecond);
DateTime date = new DateTime(unixStart.Ticks + unixTimeStampInTicks).ToLocalTime();
return FormatDate(date);
return Utils.FormatDate(ChatMessage.Time);
}
}
private string FormatDate(DateTime date)
{
DateTime now = DateTime.Now;
if (now.Year == date.Year && now.Month == date.Month && now.Day == date.Day)
return String.Format("{0:HH:mm}", date);
else if (now.Year == date.Year)
return String.Format("{0:ddd d MMM, HH:mm}", date);
else
return String.Format("{0:ddd d MMM yyyy, HH:mm}", date);
}
/// <summary>
/// Changes the icon indicating the status of the message (InProgress, Delivered or NotDelivered).
/// </summary>
public void UpdateStatus(ChatMessageState state)
{
//string delivered = "/Assets/AppBar/check.png";
//string notdelivered = "/Assets/AppBar/stop.png";
if (state == ChatMessageState.Delivered)
if (state == ChatMessageState.InProgress)
{
// Status.Source = new BitmapImage(new Uri(delivered, UriKind.RelativeOrAbsolute));
}
......@@ -155,14 +107,7 @@ namespace Linphone.Controls
// MessageBox.Show(result ? AppResources.FileSavingSuccess : AppResources.FileSavingFailure, AppResources.FileSaving, MessageBoxButton.OK);
}
/// <summary>
/// Delegate for delete event.
/// </summary>
public delegate void MessageDeletedEventHandler(object sender, ChatMessage message);
/// <summary>
/// Handler for delete event.
/// </summary>
public event MessageDeletedEventHandler MessageDeleted;
/* private void Image_Tap(object sender, System.Windows.Input.GestureEventArgs e)
......
......@@ -10,7 +10,7 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="40"></ColumnDefinition>
</Grid.ColumnDefinitions>
......@@ -28,6 +28,7 @@
BorderThickness="0"
Style="{StaticResource ButtonStyle}"
Click="SendFile_Click"
Visibility="Collapsed"
Background="Transparent">
<Button.ContentTemplate>
<DataTemplate>
......
......@@ -82,7 +82,7 @@ namespace Linphone.Controls
private void SendFile_Click(object sender, RoutedEventArgs e)
{
SendFileClick(this);
}
private void SendMessage_Click(object sender, RoutedEventArgs e)
......
......@@ -132,8 +132,8 @@
<Compile Include="Controls\TextBoxChatBubble.xaml.cs">
<DependentUpon>TextBoxChatBubble.xaml</DependentUpon>
</Compile>
<Compile Include="Helpers\AlphaKeyGroup.cs" />
<Compile Include="Helpers\ContactItem.cs" />
<Compile Include="Model\AlphaKeyGroup.cs" />
<Compile Include="Model\ContactItem.cs" />
<Compile Include="Model\BaseModel.cs" />
<Compile Include="Model\BoolToAccentBrushConverter.cs" />
<Compile Include="Model\BugCollector.cs" />
......@@ -230,7 +230,6 @@
<Content Include="Assets\Square150x150Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.scale-200.png" />
<Content Include="Assets\StoreLogo.scale-200.png" />
<Content Include="Assets\unknown.png" />
<Content Include="Properties\Default.rd.xml" />
</ItemGroup>
<ItemGroup>
......
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//