Skip to content
Browse files

Changed view message item template to auto count height of messabe block

  • Loading branch information...
1 parent 1deb843 commit 28ef75026d4a4cd81f66ab79f645a66cd336e875 @coolAdmin coolAdmin committed Mar 18, 2012
View
5 Som v Prahe Mobile Client.sln
@@ -5,6 +5,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Som v Prahe.sk", "SvP Mobil
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvP Mobile Client Scheduler", "SvP Mobile Client Scheduler\SvP Mobile Client Scheduler.csproj", "{07715240-D511-410B-9E9A-AD070874D344}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{626C581E-AA40-4ABE-9800-12205DCC0CDA}"
+ ProjectSection(SolutionItems) = preProject
+ LICENSE = LICENSE
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
View
9 SvP Mobile Client/AppResources.Designer.cs
@@ -356,5 +356,14 @@ public class AppResources {
return ResourceManager.GetString("UnknownException", resourceCulture);
}
}
+
+ /// <summary>
+ /// Looks up a localized string similar to Users.
+ /// </summary>
+ public static string Users {
+ get {
+ return ResourceManager.GetString("Users", resourceCulture);
+ }
+ }
}
}
View
3 SvP Mobile Client/AppResources.cs-CZ.resx
@@ -218,4 +218,7 @@
<data name="PleaseDeleteYourNicknameFromTo" xml:space="preserve">
<value>Prosim, odtran svoj nick z adresatov.</value>
</data>
+ <data name="Users" xml:space="preserve">
+ <value>Užívatelia</value>
+ </data>
</root>
View
3 SvP Mobile Client/AppResources.resx
@@ -218,4 +218,7 @@
<data name="PleaseDeleteYourNicknameFromTo" xml:space="preserve">
<value>Please delete your nickname from To field</value>
</data>
+ <data name="Users" xml:space="preserve">
+ <value>Users</value>
+ </data>
</root>
View
37 SvP Mobile Client/Drupal/drupal.cs
@@ -10,6 +10,7 @@
using System.Windows.Shapes;
using CookComputing.XmlRpc;
using System.Reflection;
+using System.Collections.Generic;
namespace SvP_Mobile_Client
{
@@ -121,6 +122,42 @@ public Cookie GetSessionCookie(string name, string value)
#endif
public class DrupalProxy : XmlRpcClientProtocol
{
+ [XmlRpcBegin("svp.usercount")]
+ public IAsyncResult BeginSvPUserCount(bool dummy, AsyncCallback acb)
+ {
+ return this.BeginInvoke(MethodBase.GetCurrentMethod(), new object[] { dummy }, acb, null);
+ }
+ [XmlRpcEnd]
+ public XmlRpcStruct EndSvPUserCount(IAsyncResult iasr)
+ {
+ XmlRpcStruct ret = (XmlRpcStruct)this.EndInvoke(iasr);
+ return ret;
+ }
+
+ [XmlRpcBegin("svp.userindex")]
+ public IAsyncResult BeginSvPUserIndex(AsyncCallback acb)
+ {
+ return this.BeginInvoke(MethodBase.GetCurrentMethod(), new object[] { }, acb, null);
+ }
+ [XmlRpcEnd]
+ public XmlRpcStruct[] EndSvPUserIndex(IAsyncResult iasr)
+ {
+ XmlRpcStruct[] ret = (XmlRpcStruct[])this.EndInvoke(iasr);
+ return ret;
+ }
+
+ [XmlRpcBegin("user.index")]
+ public IAsyncResult BeginUserIndex(int page, string fields, object parameters, int pagesize, AsyncCallback acb)
+ {
+ return this.BeginInvoke(MethodBase.GetCurrentMethod(), new object[] { page, fields, parameters, pagesize }, acb, null);
+ }
+ [XmlRpcEnd]
+ public XmlRpcStruct[] EndUserIndex(IAsyncResult iasr)
+ {
+ XmlRpcStruct[] ret = (XmlRpcStruct[])this.EndInvoke(iasr);
+ return ret;
+ }
+
[XmlRpcBegin("user.login")]
public IAsyncResult BeginUserLogin(string username, string password, AsyncCallback acb)
{
View
4 SvP Mobile Client/Som v Prahe.sk.csproj
@@ -24,6 +24,8 @@
<SilverlightAppEntry>SvP_Mobile_Client.App</SilverlightAppEntry>
<ValidateXaml>true</ValidateXaml>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
+ <Utf8Output>true</Utf8Output>
+ <ExpressionBlendVersion>4.0.30816.0</ExpressionBlendVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -50,6 +52,7 @@
<Reference Include="CookComputing.XmlRpcPhone">
<HintPath>..\..\..\external_libraries\xml-rpc.net.3.0.0-dev\CookComputing.XmlRpcPhone.dll</HintPath>
</Reference>
+ <Reference Include="Microsoft.Expression.Drawing" />
<Reference Include="Microsoft.Phone" />
<Reference Include="Microsoft.Phone.Controls, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Phone.Interop" />
@@ -173,6 +176,7 @@
<Resource Include="Images\icon_62_62.png" />
<Resource Include="Images\icon_200_200.png" />
<Resource Include="Images\icon_text_320.png" />
+ <None Include="LICENSE" />
<Content Include="SplashScreenImag.jpg" />
</ItemGroup>
<ItemGroup>
View
17 SvP Mobile Client/svpPanorama.xaml
@@ -82,6 +82,23 @@
</ScrollViewer>
</Grid>
</controls:PanoramaItem>
+
+ <controls:PanoramaItem>
+ <controls:PanoramaItem.Header>
+ <StackPanel Orientation="Horizontal" Margin="10,0,0,0">
+ <TextBlock Name="labelUsers" FontSize="60" Text="{Binding Path=LocalizedResources.Users, Source={StaticResource LocalizedStrings}}" />
+ </StackPanel>
+ </controls:PanoramaItem.Header>
+ <Grid>
+ <ScrollViewer>
+ <TextBlock Name="txtUsers" TextWrapping="Wrap">
+ Still in progress...
+ </TextBlock>
+ </ScrollViewer>
+ <Button Content="Button" Height="72" HorizontalAlignment="Left" Margin="128.606,249.118,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="cmdGetUsers" />
+ <Button Content="Button" Height="72" HorizontalAlignment="Left" Margin="172.891,377.689,0,0" Name="button2" VerticalAlignment="Top" Width="160" Click="button2_Click" />
+ </Grid>
+ </controls:PanoramaItem>
</controls:Panorama>
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
View
56 SvP Mobile Client/svpPanorama.xaml.cs
@@ -39,6 +39,8 @@ public partial class svpPanorama : PhoneApplicationPage
string culture = "en-US";
CultureInfo newCulture = null;
+ int users = 0;
+
public svpPanorama()
{
InitializeComponent();
@@ -258,6 +260,33 @@ public void PrivatemsgGet()
});
}
+ /// <summary>
+ /// Get Users
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void cmdGetUsers(object sender, RoutedEventArgs e)
+ {
+
+ DrupalConnection.GetInstance().GetProxy().BeginSvPUserCount(true, asr =>
+ {
+ Dispatcher.BeginInvoke(delegate()
+ {
+ try
+ {
+ var getThreadResponse = DrupalConnection.GetInstance().GetProxy().EndSvPUserCount(asr);
+ this.txtUsers.Text = ((XmlRpcStruct)getThreadResponse)["count"].ToString();
+ users = int.Parse(((XmlRpcStruct)getThreadResponse)["count"].ToString());
+ }
+ catch (Exception ex)
+ {
+ this.txtUsers.Text = ex.Message;
+ }
+ });
+ }
+ );
+ }
+
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBox myList = (ListBox)sender;
@@ -341,6 +370,33 @@ private void ReloadStrings()
labelEvents.Text = AppResources.Events;
labelBlogs.Text = AppResources.Blogs;
labelMessagesTitle.Text = AppResources.Messages;
+ labelUsers.Text = AppResources.Users;
+ }
+
+ private void button2_Click(object sender, RoutedEventArgs e)
+ {
+ DrupalConnection.GetInstance().GetProxy().BeginSvPUserIndex(asr =>
+ {
+ Dispatcher.BeginInvoke(delegate()
+ {
+ this.txtUsers.Text = "";
+ try
+ {
+ var getThreadResponse = DrupalConnection.GetInstance().GetProxy().EndSvPUserIndex(asr);
+ foreach (XmlRpcStruct item in ((XmlRpcStruct[])getThreadResponse))
+ {
+ this.txtUsers.Text = this.txtUsers.Text + item["name"] + "\r\n";
+ }
+ this.txtUsers.Text = "DONEEEEEEEEE\r\n" + this.txtUsers.Text;
+ }
+ catch (Exception ex)
+ {
+ this.txtUsers.Text = ex.Message;
+ }
+ });
+ }
+ );
+
}
}
View
63 SvP Mobile Client/viewMessage.xaml
@@ -1,44 +1,69 @@
-<phone:PhoneApplicationPage
- x:Class="SvP_Mobile_Client.viewMessage"
+<phone:PhoneApplicationPage
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- FontFamily="{StaticResource PhoneFontFamilyNormal}"
- FontSize="{StaticResource PhoneFontSizeNormal}"
- Foreground="{StaticResource PhoneForegroundBrush}"
+ xmlns:edc="clr-namespace:Microsoft.Expression.Controls;assembly=Microsoft.Expression.Drawing" xmlns:es="clr-namespace:Microsoft.Expression.Shapes;assembly=Microsoft.Expression.Drawing"
+ xmlns:local="clr-namespace:SvP_Mobile_Client"
+ x:Class="SvP_Mobile_Client.viewMessage"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="728" d:DesignWidth="480"
shell:SystemTray.IsVisible="False" Loaded="PhoneApplicationPage_Loaded">
+
+ <phone:PhoneApplicationPage.Resources>
+ <local:PrivatemsgListboxBlock x:Key="PrivatemsgListboxBlockDataSource" d:IsDataSource="True"/>
+ </phone:PhoneApplicationPage.Resources>
+ <phone:PhoneApplicationPage.FontFamily>
+ <StaticResource ResourceKey="PhoneFontFamilyNormal"/>
+ </phone:PhoneApplicationPage.FontFamily>
+ <phone:PhoneApplicationPage.FontSize>
+ <StaticResource ResourceKey="PhoneFontSizeNormal"/>
+ </phone:PhoneApplicationPage.FontSize>
+ <phone:PhoneApplicationPage.Foreground>
+ <StaticResource ResourceKey="PhoneForegroundBrush"/>
+ </phone:PhoneApplicationPage.Foreground>
+
+ <phone:PhoneApplicationPage.ApplicationBar>
+ <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
+ <shell:ApplicationBarIconButton IconUri="/Images/dark_theme/appbar.respond.rest.png" Text="reply" Click="btnReply"/>
+ </shell:ApplicationBar>
+ </phone:PhoneApplicationPage.ApplicationBar>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
- <ProgressBar Name="progress1" Visibility="Collapsed" IsIndeterminate="True" Margin="20,6,10,0" Height="14" VerticalAlignment="Top"></ProgressBar>
+ <ProgressBar x:Name="progress1" Visibility="Collapsed" IsIndeterminate="True" Margin="20,6,10,0" Height="14" VerticalAlignment="Top"/>
<StackPanel x:Name="TitlePanel" Margin="20,20,10,0" Grid.RowSpan="1" Grid.Row="0">
- <TextBlock Name="subject" Text="Subject:" FontSize="40"/>
- <TextBlock Name="participants" Text="{Binding Path=LocalizedResources.Participants, Source={StaticResource LocalizedStrings}}" TextTrimming="WordEllipsis" FontSize="18"/>
+ <TextBlock x:Name="subject" Text="Subject:" FontSize="40"/>
+ <TextBlock x:Name="participants" Text="{Binding LocalizedResources.Participants, Source={StaticResource LocalizedStrings}}" TextTrimming="WordEllipsis" FontSize="18"/>
</StackPanel>
<ScrollViewer>
- <ListBox Name="lstBody" Margin="0,0,10,0" Height="617" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="450">
+ <ListBox x:Name="lstBody" Margin="0,0,10,0" Height="617" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="450">
<ListBox.ItemTemplate>
<DataTemplate>
- <Grid Margin="15,8,0,0">
- <Rectangle Height="{Binding CalculateHeightRectangle}" Width="420" Stroke="Black" VerticalAlignment="Top" Fill="{StaticResource PhoneAccentBrush}" />
- <TextBlock Height="24" Width="368" Margin="16,4,16,0" Text="{Binding From}" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" FontWeight="Bold" />
- <TextBlock Height="{Binding CalculateHeightBody}" Width="368" Margin="16,30,16,0" Text="{Binding Message}" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="18" />
+ <Grid Margin="15,4,0,27" Width="420">
+ <Grid.Background>
+ <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
+ </Grid.Background>
+ <Path Data="M94.418007,3.1655526 L124.90263,20.463373 L29.525221,38.033195 z" HorizontalAlignment="Right" Height="34.868" Margin="0,0,3.686,-28.889" RenderTransformOrigin="0.5,0.5" Stretch="Fill" StrokeThickness="0" UseLayoutRounding="False" VerticalAlignment="Bottom" Width="95.377" d:LayoutOverrides="VerticalAlignment">
+ <Path.Fill>
+ <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
+ </Path.Fill>
+ <Path.RenderTransform>
+ <CompositeTransform Rotation="28.25" TranslateX="7.4675009352531987" TranslateY="-8.7405661357952056"/>
+ </Path.RenderTransform>
+ <Path.Stroke>
+ <SolidColorBrush Color="{StaticResource PhoneBackgroundColor}"/>
+ </Path.Stroke>
+ </Path>
+ <TextBlock Margin="20,8,20,0" TextWrapping="Wrap" FontSize="16" FontWeight="Bold" Height="24" VerticalAlignment="Top" d:LayoutOverrides="VerticalAlignment" Text="{Binding From}" />
+ <TextBlock Margin="20,32,20,8" TextWrapping="Wrap" FontSize="18" Height="Auto" Text="{Binding Message}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
</Grid>
-
- <phone:PhoneApplicationPage.ApplicationBar>
- <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
- <shell:ApplicationBarIconButton IconUri="/Images/dark_theme/appbar.respond.rest.png" Text="reply" Click="btnReply"/>
- </shell:ApplicationBar>
- </phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>
View
27 SvP Mobile Client/viewMessage.xaml.cs
@@ -82,7 +82,6 @@ private void GetThread(int threadid, int offset = 0)
msgBlock.From = ((XmlRpcStruct)item["author"])["name"].ToString() + " " + utility.UnixTimeToDateTime(item["timestamp"].ToString());
msgBlock.Message = StripEndTagsRegex(item["body"].ToString());
msgBlock.Message = StripStartTagsRegex(msgBlock.Message);
- msgBlock.Calculate();
this.lstBody.Items.Add(msgBlock);
}
@@ -159,31 +158,5 @@ public class PrivatemsgListboxBlock
public double CalculateHeightBody { get; set; }
public double CalculateHeightRectangle { get; set; }
- private TextBlock txtCalculateHeight = new TextBlock();
-
- public void Calculate()
- {
- this.CalculateHeightBody = this.CalculateHeightBodyMethod();
- this.CalculateHeightRectangle = this.CalculateHeightRectangleMethod();
- }
-
-
- private double CalculateHeightBodyMethod()
- {
- this.txtCalculateHeight.Width = 368;
- this.txtCalculateHeight.TextWrapping = TextWrapping.Wrap;
- this.txtCalculateHeight.FontSize = 18;
- this.txtCalculateHeight.Text = this.Message;
- return this.txtCalculateHeight.ActualHeight + 10;
- }
-
-
- private double CalculateHeightRectangleMethod()
- {
- double a;
- a = this.CalculateHeightBodyMethod();
- a = a + 45;
- return a;
- }
}
}

0 comments on commit 28ef750

Please sign in to comment.
Something went wrong with that request. Please try again.