Commit 02ee5e58 authored by Sylvain Berfini's avatar Sylvain Berfini

Added option to scale down sent images

parent 52ec746a
......@@ -1208,6 +1208,7 @@ namespace Linphone.Model
#region Constants settings names
private const string VibrateOnIncomingMessageKeyName = "VibrateOnIncomingMessage";
private const string ScaleDownSentPicturesKeyName = "ScaleDownSentPictures";
#endregion
#region Implementation of the ISettingsManager interface
......@@ -1223,8 +1224,13 @@ namespace Linphone.Model
value = ((bool)_settings[VibrateOnIncomingMessageKeyName]).ToString();
else
value = true.ToString();
dict[VibrateOnIncomingMessageKeyName] = value;
if (_settings.Contains(ScaleDownSentPicturesKeyName))
value = ((bool)_settings[ScaleDownSentPicturesKeyName]).ToString();
else
value = true.ToString();
dict[ScaleDownSentPicturesKeyName] = value;
}
/// <summary>
......@@ -1241,6 +1247,15 @@ namespace Linphone.Model
_settings.Add(VibrateOnIncomingMessageKeyName, value);
_settings.Save();
}
if (ValueChanged(ScaleDownSentPicturesKeyName))
{
bool value = Convert.ToBoolean(GetNew(ScaleDownSentPicturesKeyName));
if (_settings.Contains(ScaleDownSentPicturesKeyName))
_settings[ScaleDownSentPicturesKeyName] = value;
else
_settings.Add(ScaleDownSentPicturesKeyName, value);
_settings.Save();
}
}
#endregion
......@@ -1259,6 +1274,17 @@ namespace Linphone.Model
Set(VibrateOnIncomingMessageKeyName, value.ToString());
}
}
public bool? ScaleDownSentPictures
{
get
{
return Convert.ToBoolean(Get(ScaleDownSentPicturesKeyName));
}
set
{
Set(ScaleDownSentPicturesKeyName, value.ToString());
}
}
#endregion
}
}
......@@ -795,6 +795,15 @@ namespace Linphone.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Scale down sent pictures.
/// </summary>
public static string ResizeSetting {
get {
return ResourceManager.GetString("ResizeSetting", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to LeftToRight.
/// </summary>
......
......@@ -503,4 +503,7 @@ http://www.linphone.org/m/help
<data name="LinphoneLogin" xml:space="preserve">
<value>Use linphone.org account</value>
</data>
<data name="ResizeSetting" xml:space="preserve">
<value>Scale down sent pictures</value>
</data>
</root>
\ No newline at end of file
......@@ -90,6 +90,10 @@
x:Name="vibrator"
Header="{Binding Path=LocalizedResources.VibratorSetting, Source={StaticResource LocalizedStrings}}">
</toolkit:ToggleSwitch>
<toolkit:ToggleSwitch
x:Name="resizeDown"
Header="{Binding Path=LocalizedResources.ResizeSetting, Source={StaticResource LocalizedStrings}}">
</toolkit:ToggleSwitch>
</StackPanel>
</phone:PivotItem>
</phone:Pivot>
......
......@@ -31,6 +31,7 @@ namespace Linphone.Views
rfc2833.IsChecked = _callSettings.SendDTFMsRFC2833;
sipInfo.IsChecked = _callSettings.SendDTFMsSIPInfo;
vibrator.IsChecked = _chatSettings.VibrateOnIncomingMessage;
resizeDown.IsChecked = _chatSettings.ScaleDownSentPictures;
List<string> tunnelModes = new List<string>
{
......@@ -84,6 +85,7 @@ namespace Linphone.Views
_networkSettings.Save();
_chatSettings.VibrateOnIncomingMessage = vibrator.IsChecked;
_chatSettings.ScaleDownSentPictures = resizeDown.IsChecked;
_chatSettings.Save();
NavigationService.GoBack();
......
......@@ -397,6 +397,29 @@ namespace Linphone.Views
BitmapImage image = new BitmapImage();
image.SetSource(e.ChosenPhoto);
ChatSettingsManager chatMgr = new ChatSettingsManager();
chatMgr.Load();
if ((bool)chatMgr.ScaleDownSentPictures)
{
// Resize down the image
WriteableBitmap bm = new WriteableBitmap(image);
MemoryStream ms = new MemoryStream();
int w = image.PixelWidth;
int h = image.PixelHeight;
if (w > h && w > 500)
{
h = (500 * h) / w;
w = 500;
}
else if (h > w && h > 500)
{
w = (500 * w) / h;
h = 500;
}
bm.SaveJpeg(ms, w, h, 0, 100);
image.SetSource(ms);
}
try
{
ProgressPopup.Visibility = Visibility.Visible;
......
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