Commit 95f91b36 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Reworked Dialer, using WP style

parent 0a56af8b
No preview for this file type
......@@ -11,17 +11,35 @@
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="100" d:DesignWidth="480">
<Grid x:Name="LayoutRoot" VerticalAlignment="Center">
<Grid x:Name="LayoutRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- This is a hack needed to be able to edit the text box
without displaying the focused state of the box -->
<toolkit:PhoneTextBox
Grid.Column="0"
x:Name="behindAddress"
FontSize="35"
IsReadOnly="True"
BorderThickness="0"
Foreground="White"
Background="Transparent"
Hint="{Binding Path=LocalizedResources.AddressHint, Source={StaticResource LocalizedStrings}}"/>
<toolkit:PhoneTextBox
Grid.Column="0"
x:Name="address"
Text="{Binding Text}"
FontSize="35"
Margin="0, 0, 95, 0"
Text="{Binding Text}"
TextChanged="address_TextChanged_1"
AcceptsReturn="False"
BorderThickness="0"
Hint="{Binding Path=LocalizedResources.AddressHint, Source={StaticResource LocalizedStrings}}"/>
Opacity="0"/>
<Button ClickMode="Press" Click="backspace_Click_1">
<Button ClickMode="Press" Click="backspace_Click_1" Grid.Column="1">
<Button.Template>
<ControlTemplate>
<Image
......@@ -37,6 +55,5 @@
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</UserControl>
\ No newline at end of file
......@@ -57,5 +57,11 @@ namespace Linphone.Controls
Image image = (sender as Image);
image.Source = new BitmapImage(new Uri("/Assets/backspace_default.png", UriKind.RelativeOrAbsolute));
}
// This is needed for the textbox hack, see comment in .xaml file
private void address_TextChanged_1(object sender, TextChangedEventArgs e)
{
behindAddress.Text = address.Text;
}
}
}
<UserControl x:Class="Linphone.Controls.Digit"
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:controls="clr-namespace:Linphone.Controls"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480">
<Grid x:Name="LayoutRoot" Background="Transparent">
<Button x:Name="digit" Click="digit_Click_1" ClickMode="Press">
<Button.Template>
<ControlTemplate>
<Image Stretch="UniformToFill" Source="{Binding DefaultImage}"
ManipulationStarted="Image_ManipulationStarted_1"
ManipulationCompleted="Image_ManipulationCompleted_1"/>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</UserControl>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media.Imaging;
using System.Windows.Input;
namespace Linphone.Controls
{
/// <summary>
/// Custom control to represent a Digit in the numpad.
/// </summary>
public partial class Digit : UserControl
{
/// <summary>
/// Dependency property for the idle image.
/// </summary>
public static readonly DependencyProperty DefaultImageProperty = DependencyProperty.Register("DefaultImage", typeof(String), typeof(Digit), new PropertyMetadata(""));
/// <summary>
/// Dependency property for the pressed image.
/// </summary>
public static readonly DependencyProperty OverImageProperty = DependencyProperty.Register("OverImage", typeof(String), typeof(Digit), new PropertyMetadata(""));
/// <summary>
/// Dependency property for the numpad host.
/// </summary>
public static readonly DependencyProperty NumpadProperty = DependencyProperty.Register("Numpad", typeof(Numpad), typeof(Digit), new PropertyMetadata(null));
/// <summary>
/// Idle image for the digit.
/// </summary>
public String DefaultImage
{
get { return (String)GetValue(DefaultImageProperty); }
set { SetValue(DefaultImageProperty, value); }
}
/// <summary>
/// Image to display when the digit is pressed.
/// </summary>
public String OverImage
{
get { return (String)GetValue(OverImageProperty); }
set { SetValue(OverImageProperty, value); }
}
/// <summary>
/// Numpad in which the digit is displayed.
/// </summary>
public Numpad Numpad
{
get { return (Numpad)GetValue(NumpadProperty); }
set { SetValue(NumpadProperty, value); }
}
/// <summary>
/// Public constructor.
/// </summary>
public Digit()
{
InitializeComponent();
this.DataContext = this;
}
private void Image_ManipulationStarted_1(object sender, ManipulationStartedEventArgs e)
{
Image image = (sender as Image);
image.Source = new BitmapImage(new Uri(OverImage, UriKind.RelativeOrAbsolute));
}
private void Image_ManipulationCompleted_1(object sender, ManipulationCompletedEventArgs e)
{
Image image = (sender as Image);
image.Source = new BitmapImage(new Uri(DefaultImage, UriKind.RelativeOrAbsolute));
}
private void digit_Click_1(object sender, RoutedEventArgs e)
{
Numpad.digit_Click_1(this, e);
}
}
}
<UserControl x:Class="Linphone.Controls.Numpad"
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:controls="clr-namespace:Linphone.Controls"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Margin="-20, 10, -20, 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<controls:Digit Grid.Column="0" x:Name="one" Tag="1"
DefaultImage="/Assets/Numpad/numpad_one_default.png"
OverImage="/Assets/Numpad/numpad_one_over.png">
</controls:Digit>
<controls:Digit Grid.Column="1" x:Name="two" Tag="2"
DefaultImage="/Assets/Numpad/numpad_two_default.png"
OverImage="/Assets/Numpad/numpad_two_over.png">
</controls:Digit>
<controls:Digit Grid.Column="2" x:Name="three" Tag="3"
DefaultImage="/Assets/Numpad/numpad_three_default.png"
OverImage="/Assets/Numpad/numpad_three_over.png">
</controls:Digit>
</Grid>
<Grid Grid.Row="1" Margin="-20, 10, -20, 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<controls:Digit Grid.Column="0" x:Name="four" Tag="4"
DefaultImage="/Assets/Numpad/numpad_four_default.png"
OverImage="/Assets/Numpad/numpad_four_over.png">
</controls:Digit>
<controls:Digit Grid.Column="1" x:Name="five" Tag="5"
DefaultImage="/Assets/Numpad/numpad_five_default.png"
OverImage="/Assets/Numpad/numpad_five_over.png">
</controls:Digit>
<controls:Digit Grid.Column="2" x:Name="six" Tag="6"
DefaultImage="/Assets/Numpad/numpad_six_default.png"
OverImage="/Assets/Numpad/numpad_six_over.png">
</controls:Digit>
</Grid>
<Grid Grid.Row="2" Margin="-20, 10, -20, 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<controls:Digit Grid.Column="0" x:Name="seven" Tag="7"
DefaultImage="/Assets/Numpad/numpad_seven_default.png"
OverImage="/Assets/Numpad/numpad_seven_over.png">
</controls:Digit>
<controls:Digit Grid.Column="1" x:Name="eight" Tag="8"
DefaultImage="/Assets/Numpad/numpad_eight_default.png"
OverImage="/Assets/Numpad/numpad_eight_over.png">
</controls:Digit>
<controls:Digit Grid.Column="2" x:Name="nine" Tag="9"
DefaultImage="/Assets/Numpad/numpad_nine_default.png"
OverImage="/Assets/Numpad/numpad_nine_over.png">
</controls:Digit>
</Grid>
<Grid Grid.Row="3" Margin="-20, 10, -20, 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<controls:Digit Grid.Column="0" x:Name="star" Tag="*"
DefaultImage="/Assets/Numpad/numpad_star_default.png"
OverImage="/Assets/Numpad/numpad_star_over.png">
</controls:Digit>
<controls:Digit Grid.Column="1" x:Name="zero" Tag="0" Hold="zero_Hold_1"
DefaultImage="/Assets/Numpad/numpad_zero_default.png"
OverImage="/Assets/Numpad/numpad_zero_over.png">
</controls:Digit>
<controls:Digit Grid.Column="2" x:Name="sharp" Tag="#"
DefaultImage="/Assets/Numpad/numpad_sharp_default.png"
OverImage="/Assets/Numpad/numpad_sharp_over.png">
</controls:Digit>
</Grid>
</Grid>
</UserControl>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Threading;
using System.Windows.Media.Imaging;
using System.Windows.Input;
namespace Linphone.Controls
{
/// <summary>
/// Custom control to represent a numpad (composed of Digits and an AddressBox).
/// </summary>
public partial class Numpad : UserControl
{
/// <summary>
/// Dependency property for the AddressBox.
/// </summary>
public static readonly DependencyProperty AddressProperty = DependencyProperty.Register("Address", typeof(AddressBox), typeof(Numpad), new PropertyMetadata(new AddressBox()));
/// <summary>
/// AddressBox (custom control) in which to append the clicked digits.
/// </summary>
public AddressBox Address
{
get { return (AddressBox)GetValue(AddressProperty); }
set { SetValue(AddressProperty, value); }
}
/// <summary>
/// Public constructor.
/// </summary>
public Numpad()
{
InitializeComponent();
this.DataContext = this;
initNumpadForDigits();
}
private void initNumpadForDigits()
{
one.Numpad = this;
two.Numpad = this;
three.Numpad = this;
four.Numpad = this;
five.Numpad = this;
six.Numpad = this;
seven.Numpad = this;
eight.Numpad = this;
nine.Numpad = this;
zero.Numpad = this;
star.Numpad = this;
sharp.Numpad = this;
}
/// <summary>
/// Event triggered when a Digit is pressed and released.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void digit_Click_1(object sender, RoutedEventArgs e)
{
Digit button = (sender as Digit);
String character = (button.Tag as String);
Address.Text += character;
}
private void zero_Hold_1(object sender, System.Windows.Input.GestureEventArgs e)
{
if (Address.Text.Length > 0)
Address.Text = Address.Text.Substring(0, Address.Text.Length - 1); ;
Address.Text += "+";
}
}
}
......@@ -102,12 +102,6 @@
<Compile Include="Controls\ContactAction.xaml.cs">
<DependentUpon>ContactAction.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\Digit.xaml.cs">
<DependentUpon>Digit.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\Numpad.xaml.cs">
<DependentUpon>Numpad.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\TwoStateButton.xaml.cs">
<DependentUpon>TwoStateButton.xaml</DependentUpon>
</Compile>
......@@ -278,14 +272,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\Digit.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\Numpad.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\TwoStateButton.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......
......@@ -32,19 +32,201 @@
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<controls:AddressBox
x:Name="sipAddress"
x:Name="addressBox"
Grid.Row="0"
BorderThickness="0"
FontSize="40"/>
<controls:Numpad x:Name="numpad" Grid.Row="1"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button
Grid.Row="0"
Grid.Column="0"
BorderThickness="0"
Margin="-10"
Click="Numpad_Click_1"
ClickMode="Press"
Tag="1"
Background="{StaticResource PhoneChromeBrush}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="1" FontSize="50"/>
</StackPanel>
</Button>
<Button
Grid.Row="0"
Grid.Column="1"
BorderThickness="0"
Margin="-10"
Click="Numpad_Click_1"
ClickMode="Press"
Tag="2"
Background="{StaticResource PhoneChromeBrush}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="2" FontSize="50"/>
</StackPanel>
</Button>
<Button
Grid.Row="0"
Grid.Column="2"
BorderThickness="0"
Margin="-10"
Click="Numpad_Click_1"
ClickMode="Press"
Tag="3"
Background="{StaticResource PhoneChromeBrush}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="3" FontSize="50"/>
</StackPanel>
</Button>
<Button
Grid.Row="1"
Grid.Column="0"
BorderThickness="0"
Margin="-10"
Click="Numpad_Click_1"
ClickMode="Press"
Tag="4"
Background="{StaticResource PhoneChromeBrush}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="4" FontSize="50"/>
</StackPanel>
</Button>
<Button
Grid.Row="1"
Grid.Column="1"
BorderThickness="0"
Margin="-10"
Click="Numpad_Click_1"
ClickMode="Press"
Tag="5"
Background="{StaticResource PhoneChromeBrush}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="5" FontSize="50"/>
</StackPanel>
</Button>
<Button
Grid.Row="1"
Grid.Column="2"
BorderThickness="0"
Margin="-10"
Click="Numpad_Click_1"
ClickMode="Press"
Tag="6"
Background="{StaticResource PhoneChromeBrush}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="6" FontSize="50"/>
</StackPanel>
</Button>
<Button
Grid.Row="2"
Grid.Column="0"
BorderThickness="0"
Margin="-10"
Click="Numpad_Click_1"
ClickMode="Press"
Tag="7"
Background="{StaticResource PhoneChromeBrush}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="7" FontSize="50"/>
</StackPanel>
</Button>
<Button
Grid.Row="2"
Grid.Column="1"
BorderThickness="0"
Margin="-10"
Click="Numpad_Click_1"
ClickMode="Press"
Tag="8"
Background="{StaticResource PhoneChromeBrush}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="8" FontSize="50"/>
</StackPanel>
</Button>
<Button
Grid.Row="2"
Grid.Column="2"
BorderThickness="0"
Margin="-10"
Click="Numpad_Click_1"
ClickMode="Press"
Tag="9"
Background="{StaticResource PhoneChromeBrush}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="9" FontSize="50"/>
</StackPanel>
</Button>
<Button
Grid.Row="3"
Grid.Column="0"
BorderThickness="0"
Margin="-10"
Click="Numpad_Click_1"
ClickMode="Press"
Tag="*"
Background="{StaticResource PhoneChromeBrush}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="*" FontSize="50"/>
</StackPanel>
</Button>
<Button
Grid.Row="3"
Grid.Column="1"
BorderThickness="0"
Margin="-10"
Click="Numpad_Click_1"
Hold="zero_Hold_1"
ClickMode="Press"
Tag="0"
Background="{StaticResource PhoneChromeBrush}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="0" FontSize="50"/>
</StackPanel>
</Button>
<Button
Grid.Row="3"
Grid.Column="2"
BorderThickness="0"
Margin="-10"
Click="Numpad_Click_1"
ClickMode="Press"
Tag="#"
Background="{StaticResource PhoneChromeBrush}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="#" FontSize="50"/>
</StackPanel>
</Button>
</Grid>
<Grid Grid.Row="2">
<Grid Grid.Row="2" Margin="0,20,0,20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
......
......@@ -27,7 +27,6 @@ namespace Linphone
public Dialer()
{
InitializeComponent();
numpad.Address = sipAddress;
BuildLocalizedApplicationBar();
ContactManager contactManager = ContactManager.Instance; //Force creation and init of ContactManager
......@@ -50,7 +49,7 @@ namespace Linphone
if (NavigationContext.QueryString.ContainsKey("sip") && e.NavigationMode != NavigationMode.Back)
{
String sipAddressToCall = NavigationContext.QueryString["sip"];
sipAddress.Text = sipAddressToCall;
addressBox.Text = sipAddressToCall;
NewOutgoingCall(sipAddressToCall);
}
}
......@@ -60,13 +59,29 @@ namespace Linphone
if (address != null && address.Length > 0)
{
NavigationService.Navigate(new Uri("/Views/InCall.xaml?sip=" + address, UriKind.RelativeOrAbsolute));
LinphoneManager.Instance.NewOutgoingCall(numpad.Address.Text);
LinphoneManager.Instance.NewOutgoingCall(addressBox.Text);
}
}
private void call_Click_1(object sender, EventArgs e)
{
NewOutgoingCall(numpad.Address.Text);
NewOutgoingCall(addressBox.Text);
}
private void Numpad_Click_1(object sender, RoutedEventArgs e)
{
Button button = sender as Button;
String tag = button.Tag as String;
LinphoneManager.Instance.LinphoneCore.PlayDTMF(Convert.ToChar(tag), 500);
addressBox.Text += tag;
}
private void zero_Hold_1(object sender, System.Windows.Input.GestureEventArgs e)
{
if (addressBox.Text.Length > 0)
addressBox.Text = addressBox.Text.Substring(0, addressBox.Text.Length - 1); ;
addressBox.Text += "+";
}
private void history_Click_1(object sender, EventArgs e)
......
In order to compile Linphone, you need:
* A computer with Windows 8 (Pro if you want to use the emulator)
* Visual Studio 11 (2012)
* The Windows Phone 8 SDK
The documentation is directly included in the code using Intellisense,
but a .xml file with the C++ API documentation is also generated at the
compilation as Linphone.Core.xml.
To import the solution, open the Linphone.sln file at the root of the project.
The solution is composed of four projects:
* Agents: contains the background agents for the VoIP application
* Core: contains the C++ API wrapper for Linphone Core
* CoreProxyStub: contains only generated files allowing
the Linphone project to make calls to the C++ API
/!\ Do not touch anything in this project!
* Linphone: the interface project
To compile and run it, attach a windows phone 8 device or choose an emulator
and run the build/install (using F5 or the green triangle). The app will start
automatically once built.
/!\ Please check the Linphone project in the solution is set as startup project.
(The startup project is in bold in the project list)
If not, right click on Linphone project and choose the menu "Set as StartUp project".
02-15-2012:
* C++ API stubbed
* Interface almost finished, some API calls are included
* Background process and agents running depending on the interface status
* Incoming call using push notification
(button is available in setting page to send one to itself)
* Interface designed to be launched on a phone running a Dark theme (for now), Ligth
theme not yet supported.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment