|
using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
using System.Windows.Controls;
namespace LightSwitchApplication
{
public partial class PostsListDetail
{
partial void MessagesEditSelected_Execute()
{
this.OpenModalWindow("Messages_SelectedItem");
}
#region SaveResponse_Execute
partial void SaveResponse_Execute()
{
this.CloseModalWindow("Message_Response");
this.Save();
}
#endregion
#region RespondToMessage_Execute()
partial void RespondToMessage_Execute()
{
// Create a new Message
Message_Response = new Message();
//Set the Post
Message_Response.Post = Posts.SelectedItem;
// Set Email defaults
Message_Response.MessageBy = this.Application.User.Name;
// these values are from the currently selected Message
Message_Response.NameFrom = Messages.SelectedItem.NameTo;
Message_Response.EmailFrom = Messages.SelectedItem.EmailTo;
Message_Response.NameTo = Messages.SelectedItem.NameFrom;
Message_Response.EmailTo = Messages.SelectedItem.EmailFrom;
this.OpenModalWindow("Message_Response");
// Wire up an event to detect when the Modal window is closed
this.FindControl("Message_Response").ControlAvailable +=
new EventHandler<ControlAvailableEventArgs>(PostsListDetail_ControlAvailable);
}
#endregion
#region PostsListDetail_ControlAvailable
void PostsListDetail_ControlAvailable(object sender, ControlAvailableEventArgs e)
{
ChildWindow window = (ChildWindow)e.Control;
window.Closed += new EventHandler(Message_Response_Closed);
}
#endregion
#region Message_Response_Closed
void Message_Response_Closed(object sender, EventArgs e)
{
ChildWindow window = (ChildWindow)sender;
if (!(window.DialogResult.HasValue))
{
// Remove unsaved records
foreach (Message message in this.DataWorkspace.ApplicationData.Details.GetChanges()
.AddedEntities.OfType<Message>())
{
message.Details.DiscardChanges();
}
}
}
#endregion
#region RespondToMessage_CanExecute
partial void RespondToMessage_CanExecute(ref bool result)
{
// Must have a Message Selected
result = (Messages.SelectedItem != null);
}
#endregion
#region MessagesEditSelected_CanExecute
partial void MessagesEditSelected_CanExecute(ref bool result)
{
// Must have a Message Selected
result = (Messages.SelectedItem != null);
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.