Skip to content

Commit

Permalink
-Fix bid bug
Browse files Browse the repository at this point in the history
-Fix speed issue
-Still not refresh after post
  • Loading branch information
Wait committed Jul 18, 2014
1 parent 03e2a1f commit 1ab1f0d
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 52 deletions.
Binary file modified Quyd/Quyd.v12.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion Quyd/Quyd/Controls/ControlFeed.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public partial class ControlFeed : UserControl
public ControlFeed()
{
InitializeComponent();
}
}
}
}
2 changes: 1 addition & 1 deletion Quyd/Quyd/Controls/ControlItemDetail.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Quyd.Controls
{
public partial class ControlItemDetail : UserControl
{
private Item item;
public Item item;
private int value;

public ControlItemDetail()
Expand Down
11 changes: 8 additions & 3 deletions Quyd/Quyd/Controls/ControlPost.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
namespace Quyd.Controls
{
public partial class ControlPost : UserControl
{
{
public PivotPage1 parent;
Post post;
Store store;
public int num;

public void setValue(Post post, Store store)
{
Expand All @@ -30,13 +32,14 @@ public ControlPost()
InitializeComponent();
}

public void setItems(ItemList itemList)
public async void setItems(Post post)
{
ItemList itemList = await post.getUserItem();
StackItem.Children.Clear();
foreach (Item item in itemList)
{
var controlItem = new Quyd.Controls.ControlItem();
controlItem.icon.Source = new BitmapImage(new Uri("/Resources/Images/"+item.Name+".jpg", UriKind.Relative));//new BitmapImage(new Uri(@"/Resources/Images/"+item.Name+".png", UriKind.Absolute));
controlItem.icon.Source = new BitmapImage(new Uri(item.Icon, UriKind.Absolute));
controlItem.quantity.Text = (item as Quantifiable).Quantity.ToString();
StackItem.Children.Add(controlItem);
}
Expand All @@ -50,6 +53,8 @@ private async void BtnBid_Click(object sender, RoutedEventArgs e)
await bid.saveAsync();
Notification notification = new Notification();
//await notification.sendAsync(post.PostBy, false, post, notificationType.bid, false);

parent.bidEvent(num, post);
}
}
}
6 changes: 6 additions & 0 deletions Quyd/Quyd/LoginPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ private async void loginFace_Click(object sender, RoutedEventArgs e)
user["name"] = fbData.Name;
user["facebookId"] = fbData.Id;

dynamic parameters = new System.Dynamic.ExpandoObject();
parameters.access_token = ParseFacebookUtils.AccessToken;
parameters.fields = "email";
dynamic result = await fb.GetTaskAsync("me", parameters);
user["email"] = result.email;

await user.SaveAsync();

NavigationService.Navigate(new Uri("/PivotPage1.xaml", UriKind.Relative));
Expand Down
6 changes: 3 additions & 3 deletions Quyd/Quyd/Models/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task loadUserPostAsync(ParseUser user)
{
var query = from post in ParseObject.GetQuery("Post").Include("postBy")
where post.Get<ParseUser>("postBy") == user
orderby post.CreatedAt ascending
orderby post.CreatedAt descending
select post;
try
{
Expand All @@ -52,7 +52,7 @@ public async Task loadStorePostAsync(Store store)
{
var query = from bid in ParseObject.GetQuery("Bid").Include("post").Include("post.postBy")
where bid.Get<ParseObject>("bidStore") == store.Object
orderby bid.CreatedAt ascending
orderby bid.CreatedAt descending
select bid;
try
{
Expand Down Expand Up @@ -80,7 +80,7 @@ public async Task loadFeedAsync(ParseUser user)
{
var query = from post in ParseObject.GetQuery("Post").Include("postBy")
where post.Get<ParseUser>("postBy") != user
orderby post.CreatedAt ascending
orderby post.CreatedAt descending
select post;
try
{
Expand Down
18 changes: 15 additions & 3 deletions Quyd/Quyd/PagePost.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,29 @@ private async void Button_Click(object sender, RoutedEventArgs e)
await post.saveAsync();
int i = 0;
ItemList itemList = await post.getUserItem();
foreach (var item in (itemList))
List<Item> saveList = new List<Item>();
foreach (UIElement controlItemDetail in StackItem.Children)
{
int q = Convert.ToInt32((StackItem.Children.ElementAt<UIElement>(i) as Quyd.Controls.ControlItemDetail).BoxValue.Text);
int q = Convert.ToInt32((controlItemDetail as Quyd.Controls.ControlItemDetail).BoxValue.Text);
if (q > 0)
{
Item item = itemList.itemList.ElementAt(i);
(item as PostItem).Quantity = q;
i++;
(item as PostItem).Post = post;
await (item as PostItem).saveAsync();
saveList.Add(item);
}
}

foreach (var item in (saveList))
{
await (item as PostItem).saveAsync();
}

if(saveList.Count<Item>() == 0)
{
await post.Object.DeleteAsync();
}

NavigationService.GoBack();
}
Expand Down
2 changes: 1 addition & 1 deletion Quyd/Quyd/PivotPage1.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded">

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="#FFE65101">
Expand Down
69 changes: 39 additions & 30 deletions Quyd/Quyd/PivotPage1.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ public async void loadComponentAsync()
fb.AccessToken = ParseFacebookUtils.AccessToken;
dynamic me = await fb.GetTaskAsync("me");
UserProfile.usernameBox.Text = ParseUser.CurrentUser.Get<string>("name");
UserDetail.BoxMail.Text = me.email;
UserDetail.BoxMail.Text = ParseUser.CurrentUser.Email;
UserDetail.BoxFacebook.NavigateUri = new Uri(me.link, UriKind.Absolute);
UserDetail.BoxFacebook.TargetName = "_blank";
dynamic photo = await fb.GetTaskAsync("me/picture?redirect=false");
string facebookId = ParseUser.CurrentUser.Get<string>("facebookId");
UserProfile.profilePictureBox.Source = new BitmapImage(new Uri("http://graph.facebook.com/" + facebookId + "/picture", UriKind.Absolute));

await reloadAll();
Init();
}

public async Task reloadAll()
public async void Init()
{
Store store = new Store();
try
Expand All @@ -69,19 +69,13 @@ public async Task reloadAll()
await store.saveAsync();
}

await reloadUserPage();
await reloadFeedPage(store);
await reloadStorePage(store);
reloadUserPage();
reloadFeedPage(store);
reloadStorePage(store);
}

public async Task reloadUserPage()
public async void reloadUserPage()
{
var fb = new Facebook.FacebookClient();
fb.AccessToken = ParseFacebookUtils.AccessToken;
var me = await fb.GetTaskAsync("me");

var fbData = new Facebook.Client.GraphUser(me);

PostList posts = new PostList();

await posts.loadUserPostAsync(ParseUser.CurrentUser);
Expand All @@ -95,23 +89,21 @@ public async Task reloadUserPage()
UserLoad.Text = "ไม่มีข้อมูล";
}

Store store = new Store();

await store.loadAsync(ParseUser.CurrentUser);

foreach (var post in posts.posts)
{
var controlPost = new Quyd.Controls.ControlPost();
controlPost.locationBox.Text = "Bangkok , Thailand";
controlPost.setItems(await post.getUserItem());
controlPost.setItems(post);
controlPost.timeBox.Text = post.CreateAt.ToString();
controlPost.BtnBid.Visibility = (await post.isBidable(ParseUser.CurrentUser))?Visibility.Visible:Visibility.Collapsed;
controlPost.BtnBid.Visibility = Visibility.Collapsed;
UserPosts.Children.Add(controlPost);
}
}

public async Task reloadFeedPage(Store store)
public async void reloadFeedPage(Store store)
{
FeedList.Children.Clear();

PostList posts = new PostList();

await posts.loadFeedAsync(ParseUser.CurrentUser);
Expand All @@ -124,23 +116,25 @@ public async Task reloadFeedPage(Store store)
{
FeedLoad.Text = "ไม่มีข้อมูล";
}

int i = 0;
foreach (var post in posts.posts)
{
var controlFeed = new Quyd.Controls.ControlFeed();
controlFeed.controlUserProfile.usernameBox.Text = post.PostBy.Get<string>("name");
string facebookId = post.PostBy.Get<string>("facebookId");
controlFeed.controlUserProfile.profilePictureBox.Source = new BitmapImage(new Uri("http://graph.facebook.com/" + facebookId + "/picture", UriKind.Absolute));
controlFeed.controlPost.locationBox.Text = "Bangkok , Thailand";
controlFeed.controlPost.BtnBid.Visibility = (await post.isBidable(ParseUser.CurrentUser)) ? Visibility.Visible : Visibility.Collapsed;
controlFeed.controlPost.setItems(await post.getUserItem());
controlFeed.controlPost.BtnBid.Visibility = Visibility.Visible;
controlFeed.controlPost.setItems(post);
controlFeed.controlPost.setValue(post, store);
controlFeed.controlPost.timeBox.Text = post.CreateAt.ToString();
controlFeed.controlPost.parent = this;
controlFeed.controlPost.num = i++;
FeedList.Children.Add(controlFeed);
}
}

public async Task reloadStorePage(Store store)
public async void reloadStorePage(Store store)
{
ItemList itemList = await store.getStoreItemsAsync();
if (itemList.Size > 0)
Expand All @@ -159,7 +153,7 @@ public async Task reloadStorePage(Store store)
controlItemDetail.BoxInfo.Text = item.Description;
controlItemDetail.BoxValue.Text = (item as Priceable).Price.ToString();
controlItemDetail.ImageIcon.Source = new BitmapImage(new Uri("/Resources/Images/" + item.Name + ".jpg", UriKind.Relative));

StackItemDetail.Children.Add(controlItemDetail);
}

Expand All @@ -182,21 +176,36 @@ public async Task reloadStorePage(Store store)
string facebookId = post.PostBy.Get<string>("facebookId");
controlFeed.controlUserProfile.profilePictureBox.Source = new BitmapImage(new Uri("http://graph.facebook.com/" + facebookId + "/picture", UriKind.Absolute));
controlFeed.controlPost.locationBox.Text = "Bangkok , Thailand";
controlFeed.controlPost.setItems(await post.getUserItem());
controlFeed.controlPost.setItems(post);
controlFeed.controlPost.timeBox.Text = post.CreateAt.ToString();
controlFeed.controlPost.BtnBid.Visibility = (await post.isBidable(ParseUser.CurrentUser)) ? Visibility.Visible : Visibility.Collapsed;
controlFeed.controlPost.BtnBid.Visibility = Visibility.Collapsed;
StackPost.Children.Add(controlFeed);
}
}

public void bidEvent(int num, Post post)
{
FeedList.Children.RemoveAt(num);

var controlFeed = new Quyd.Controls.ControlFeed();
controlFeed.controlUserProfile.usernameBox.Text = post.PostBy.Get<string>("name");
string facebookId = post.PostBy.Get<string>("facebookId");
controlFeed.controlUserProfile.profilePictureBox.Source = new BitmapImage(new Uri("http://graph.facebook.com/" + facebookId + "/picture", UriKind.Absolute));
controlFeed.controlPost.locationBox.Text = "Bangkok , Thailand";
controlFeed.controlPost.setItems(post);
controlFeed.controlPost.timeBox.Text = post.CreateAt.ToString();
controlFeed.controlPost.BtnBid.Visibility = Visibility.Collapsed;
StackPost.Children.Add(controlFeed);
}

private void Button_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/PagePost.xaml", UriKind.Relative));
}

protected void Page_InitComplete(object sender, EventArgs e)
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
reloadAll();
}
reloadUserPage();
}
}
}
7 changes: 0 additions & 7 deletions Quyd/Quyd/Quyd.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,11 @@
<Content Include="Assets\ApplicationIcon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\Images\HDPE.jpg" />
<Content Include="Resources\Images\LDPE.jpg" />
<Content Include="Resources\Images\Logo.jpg" />
<Content Include="Resources\Images\Logo_160.png" />
<Content Include="Resources\Images\Logo_340.png" />
<Content Include="Resources\Images\Logo_lanscape.png" />
<Content Include="Resources\Images\Logo_low.png" />
<Content Include="Resources\Images\Other.jpg" />
<Content Include="Resources\Images\PETE.jpg" />
<Content Include="Resources\Images\PP.jpg" />
<Content Include="Resources\Images\PS.jpg" />
<Content Include="Resources\Images\V.jpg" />
<Content Include="Resources\login_background.jpg" />
<Content Include="Assets\Tiles\FlipCycleTileLarge.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
6 changes: 3 additions & 3 deletions Quyd/Quyd/Quyd.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<CurrentDeployCmdId>256</CurrentDeployCmdId>
<CurrentDeployID>30F105C9-681E-420b-A277-7C086EAD8A4E</CurrentDeployID>
<CurrentDeployID>5E7661DF-D928-40ff-B747-A4B1957194F9</CurrentDeployID>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<CurrentDeployCmdId>256</CurrentDeployCmdId>
<CurrentDeployID>30F105C9-681E-420b-A277-7C086EAD8A4E</CurrentDeployID>
<CurrentDeployID>5E7661DF-D928-40ff-B747-A4B1957194F9</CurrentDeployID>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{C089C8C0-30E0-4E22-80C0-CE093F111A43}">
<SilverlightMobileCSProjectFlavor>
<FullDeploy>False</FullDeploy>
<FullDeploy>True</FullDeploy>
<DebuggerType>Managed</DebuggerType>
<DebuggerAgentType>Managed</DebuggerAgentType>
<Tombstone>False</Tombstone>
Expand Down

0 comments on commit 1ab1f0d

Please sign in to comment.