├── Chatters
├── chat.png
├── LICENSE.TXT
├── WPFChatter
│ ├── chat.png
│ ├── App.config
│ ├── app.xaml
│ ├── SignInControl.xaml
│ ├── WPFChatter.csproj
│ ├── SignInControl.xaml.cs
│ ├── ChatService.cs
│ ├── ClassDiagram1.cd
│ ├── ChatControl.xaml
│ ├── Window1.xaml
│ ├── ChatControl.xaml.cs
│ └── Proxy_Singleton.cs
├── ChatService
│ ├── HOW TO CREATE CLIENT PROXY.txt
│ ├── App.config
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── ClassDiagram1.cd
│ └── ChatService.csproj
├── Common
│ ├── ClassDiagram1.cd
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Common.csproj
│ └── Person.cs
└── Chatters.sln
├── ChatSolution
├── Client
│ ├── Images
│ │ ├── About.jpg
│ │ ├── Login.jpg
│ │ ├── Image1.jpg
│ │ ├── Feedback.jpg
│ │ └── Registration.jpg
│ ├── Properties
│ │ ├── Settings.settings
│ │ ├── Settings.Designer.cs
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── Service References
│ │ └── Chat
│ │ │ ├── Client.Chat.User.datasource
│ │ │ ├── Client.Chat.Message.datasource
│ │ │ ├── Client.Chat.PersonalRoom.datasource
│ │ │ ├── configuration.svcinfo
│ │ │ ├── Reference.svcmap
│ │ │ ├── service1.xsd
│ │ │ ├── Chat_Library.xsd
│ │ │ └── service.xsd
│ ├── App.config
│ ├── Registration.xaml.cs
│ ├── AboutWin.xaml.cs
│ ├── AboutWin.xaml
│ ├── Login.xaml
│ ├── Feedback.xaml
│ ├── Login.xaml.cs
│ ├── Feedback.xaml.cs
│ ├── Registration.xaml
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ └── Client.csproj
├── Chat_Library
│ ├── packages.config
│ ├── MessagePM.cs
│ ├── Messages.cs
│ ├── Messages.edmx.diagram
│ ├── Messages.Designer.cs
│ ├── Message.cs
│ ├── User.cs
│ ├── Messages.Context.cs
│ ├── IChatable.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── App.config
│ ├── Chatable.cs
│ ├── Chat_Library.csproj
│ └── Messages.edmx
├── TEST
│ ├── Service References
│ │ └── ServiceReference1
│ │ │ ├── TEST.ServiceReference1.Message.datasource
│ │ │ ├── Chat_Library.xsd
│ │ │ ├── service.xsd
│ │ │ ├── configuration.svcinfo
│ │ │ ├── Reference.svcmap
│ │ │ ├── service1.xsd
│ │ │ ├── service.wsdl
│ │ │ └── Reference.cs
│ ├── App.config
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── TEST.csproj
└── ChatSolution.sln
├── README.md
├── LICENSE
├── .gitattributes
└── .gitignore
/Chatters/chat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/narekye/Chat_WCF_WPF/HEAD/Chatters/chat.png
--------------------------------------------------------------------------------
/Chatters/LICENSE.TXT:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/narekye/Chat_WCF_WPF/HEAD/Chatters/LICENSE.TXT
--------------------------------------------------------------------------------
/Chatters/WPFChatter/chat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/narekye/Chat_WCF_WPF/HEAD/Chatters/WPFChatter/chat.png
--------------------------------------------------------------------------------
/ChatSolution/Client/Images/About.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/narekye/Chat_WCF_WPF/HEAD/ChatSolution/Client/Images/About.jpg
--------------------------------------------------------------------------------
/ChatSolution/Client/Images/Login.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/narekye/Chat_WCF_WPF/HEAD/ChatSolution/Client/Images/Login.jpg
--------------------------------------------------------------------------------
/ChatSolution/Client/Images/Image1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/narekye/Chat_WCF_WPF/HEAD/ChatSolution/Client/Images/Image1.jpg
--------------------------------------------------------------------------------
/ChatSolution/Client/Images/Feedback.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/narekye/Chat_WCF_WPF/HEAD/ChatSolution/Client/Images/Feedback.jpg
--------------------------------------------------------------------------------
/ChatSolution/Client/Images/Registration.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/narekye/Chat_WCF_WPF/HEAD/ChatSolution/Client/Images/Registration.jpg
--------------------------------------------------------------------------------
/ChatSolution/Chat_Library/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Chatters/ChatService/HOW TO CREATE CLIENT PROXY.txt:
--------------------------------------------------------------------------------
1 | svcutil ChatService.exe
2 | svcutil *.wsdl *.xsd /language:C# /out:MyProxy.cs /config:app.config
3 |
4 |
5 | FOR ASYNCH
6 |
7 | svcutil *.wsdl *.xsd /a /language:C# /out:MyProxy.cs /config:app.config
--------------------------------------------------------------------------------
/ChatSolution/Client/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ChatSolution/Chat_Library/MessagePM.cs:
--------------------------------------------------------------------------------
1 | namespace Chat_Library
2 | {
3 | using System.Collections.Generic;
4 | public class PersonalRoom
5 | {
6 | public List Messages { get; set; }
7 | public List Users { get; set; }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | These distributed applications are built on a learning experience. I wanted to share the code to learn more and let others learn too, so if you got problems, errors, ideas, please let me know. If you liked it, please Star. Thanks.
2 |
3 |
4 | 
5 |
6 |
--------------------------------------------------------------------------------
/ChatSolution/Client/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ChatSolution/Client/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace Client
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Chatters/Common/ClassDiagram1.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Person.cs
8 | AAAAAAAAAAAAAAAAJAAAAAQAgAAEAAAABAAAAAAAAAA=
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/ChatSolution/Chat_Library/Messages.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Service References/Chat/Client.Chat.User.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | Client.Chat.User, Service References.Chat.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Service References/Chat/Client.Chat.Message.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | Client.Chat.Message, Service References.Chat.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/Chatters/WPFChatter/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Service References/Chat/Client.Chat.PersonalRoom.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | Client.Chat.PersonalRoom, Service References.Chat.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/ChatSolution/TEST/Service References/ServiceReference1/TEST.ServiceReference1.Message.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | TEST.ServiceReference1.Message, Service References.ServiceReference1.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/Chatters/WPFChatter/app.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ChatSolution/Client/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/ChatSolution/TEST/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/ChatSolution/Chat_Library/Messages.edmx.diagram:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/ChatSolution/Chat_Library/Messages.Designer.cs:
--------------------------------------------------------------------------------
1 | // T4 code generation is enabled for model 'C:\Users\Narek-PC\Source\Repos\Chat_WCF_WPF\ChatSolution\Chat_Library\Messages.edmx'.
2 | // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer
3 | // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model
4 | // is open in the designer.
5 |
6 | // If no context and entity classes have been generated, it may be because you created an empty model but
7 | // have not yet chosen which version of Entity Framework to use. To generate a context class and entity
8 | // classes for your model, open the model in the designer, right-click on the designer surface, and
9 | // select 'Update Model from Database...', 'Generate Database from Model...', or 'Add Code Generation
10 | // Item...'.
--------------------------------------------------------------------------------
/ChatSolution/Chat_Library/Message.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Chat_Library
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class Message
16 | {
17 | public int MessageId { get; set; }
18 | public string MessageSender { get; set; }
19 | public string MessageContent { get; set; }
20 | public string MessageTIme { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ChatSolution/Chat_Library/User.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Chat_Library
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 |
15 | public partial class User
16 | {
17 | public int UserId { get; set; }
18 | public string UserName { get; set; }
19 | public string NickName { get; set; }
20 | public string UserPassword { get; set; }
21 | public string Email { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ChatSolution/TEST/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using TEST.ServiceReference1;
7 |
8 | namespace TEST
9 | {
10 | class Program
11 | {
12 | static void Main(string[] args)
13 | {
14 | ServiceReference1.Message mes = new Message()
15 | {
16 | MessageContent = "Hello... !!",
17 | MessageSender = "Narek"
18 | };
19 | ServiceReference1.ChatableClient client = new ChatableClient();
20 | // client.Send(mes);
21 | var list = client.GetMessages();
22 | foreach (Message message in list)
23 | {
24 | Console.WriteLine(message.MessageSender);
25 | }
26 |
27 | Console.Read();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ChatSolution/TEST/Service References/ServiceReference1/Chat_Library.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Chatters/ChatService/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Narek Yegoryan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/ChatSolution/Chat_Library/Messages.Context.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated from a template.
4 | //
5 | // Manual changes to this file may cause unexpected behavior in your application.
6 | // Manual changes to this file will be overwritten if the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace Chat_Library
11 | {
12 | using System;
13 | using System.Data.Entity;
14 | using System.Data.Entity.Infrastructure;
15 |
16 | public partial class MessagesContext_ : DbContext
17 | {
18 | public MessagesContext_()
19 | : base("name=MessagesContext_")
20 | {
21 | }
22 |
23 | protected override void OnModelCreating(DbModelBuilder modelBuilder)
24 | {
25 | throw new UnintentionalCodeFirstException();
26 | }
27 |
28 | public virtual DbSet Messages { get; set; }
29 | public virtual DbSet Users { get; set; }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Client.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ChatSolution/TEST/Service References/ServiceReference1/service.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Registration.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Client
2 | {
3 | using System.Windows;
4 | using Chat;
5 |
6 | public partial class Registration
7 | {
8 | public Registration()
9 | {
10 | InitializeComponent();
11 | }
12 |
13 | private async void Register_Click(object sender, RoutedEventArgs e)
14 | {
15 | if ((Username.Text == null || Username.Text.Length < 3) && (Password.Text == null || Password.Text.Length < 6) && Nickname == null )
16 | {
17 | MessageBox.Show("Input correctly Credential \nPassword must by more than 6 symbol !!!");
18 | }
19 | User user = new User
20 | {
21 | NickName = Nickname.Text,
22 | UserName = Username.Text,
23 | Email = Email.Text,
24 | UserPassword = Password.Text
25 | };
26 |
27 | MainWindow._proxy.SendMail(user);
28 | if (await MainWindow._proxy.RegisterAsync(user))
29 | {
30 | MessageBox.Show("User successfully registered...");
31 | Close();
32 | return;
33 | }
34 | MessageBox.Show("User with the same nickname was founded, try another nickname...");
35 | Close();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Chatters/ChatService/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.ServiceModel;
5 | using System.Configuration;
6 |
7 | namespace Chatters
8 | {
9 | #region ChatService
10 | ///
11 | /// This class creates the initial ChatService which
12 | /// is used by all the connected chat clients. The app.config is used to creat the
13 | /// service bindings
14 | ///
15 | class Program
16 | {
17 | ///
18 | /// Main access point, creates the initial ChatService which
19 | /// is used by all the connected chat clients. The app.config is used to creat the
20 | /// service bindings
21 | ///
22 | /// The command line args
23 | static void Main(string[] args)
24 | {
25 | Uri uri = new Uri(ConfigurationManager.AppSettings["addr"]);
26 | ServiceHost host = new ServiceHost(typeof(Chatters.ChatService), uri);
27 | host.Open();
28 | Console.WriteLine("Chat service listen on endpoint {0}", uri.ToString());
29 | Console.WriteLine("Press ENTER to stop chat service...");
30 | Console.ReadLine();
31 | host.Abort();
32 | host.Close();
33 | }
34 | }
35 | #endregion
36 | }
37 |
--------------------------------------------------------------------------------
/ChatSolution/Chat_Library/IChatable.cs:
--------------------------------------------------------------------------------
1 | namespace Chat_Library
2 | {
3 | using System.Collections.Generic;
4 | using System.ServiceModel;
5 | using System.Threading.Tasks;
6 |
7 | [ServiceContract]
8 | public interface IChatable
9 | {
10 | [OperationContract]
11 | void Send(Message message);
12 | [OperationContract]
13 | Task> GetMessages();
14 | [OperationContract]
15 | Task LoginAsync(User user);
16 | [OperationContract]
17 | Task RegisterAsync(User user);
18 | [OperationContract]
19 | void SendMail(User user);
20 | [OperationContract]
21 | List GetAllUsersAsync();
22 | [OperationContract]
23 | Task> GetAllUsersAsyncFromDb();
24 | [OperationContract]
25 | void RemoveFromList(User users);
26 | // added for PM
27 |
28 | #region PM
29 |
30 |
31 |
32 | [OperationContract]
33 | bool EnterExsitingRoom(User first, User second);
34 | [OperationContract]
35 | List GetAllRooms();
36 | [OperationContract]
37 | int CreateRoom(User first);
38 | [OperationContract]
39 | void SendToRoom(int roomindex, Message message);
40 | [OperationContract]
41 | List GetRoomMessages(int index);
42 | [OperationContract]
43 | int GetIndex(User us);
44 | #endregion
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Chatters/Common/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Person")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Person")]
13 | [assembly: AssemblyCopyright("Copyright © 2007")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("113a7596-ad50-4afa-a5d7-154a2791b3ab")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Service References/Chat/configuration.svcinfo:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Chatters/ChatService/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Chat service")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("NikeSoft")]
12 | [assembly: AssemblyProduct("Chat service")]
13 | [assembly: AssemblyCopyright("Copyright © Nikola Paljetak 2006")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("502fde73-5223-43e7-9426-67df9d5451a1")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/ChatSolution/TEST/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("TEST")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TEST")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("c9cfb7fc-96cf-45b3-a7d4-1e66487d0be2")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ChatSolution/Chat_Library/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Chat_Library")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Chat_Library")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("4ed206c8-dab3-4723-a17b-677a47f19922")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ChatSolution/TEST/Service References/ServiceReference1/configuration.svcinfo:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ChatSolution/Client/AboutWin.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Shapes;
15 |
16 | namespace Client
17 | {
18 | ///
19 | /// Interaction logic for AboutWin.xaml
20 | ///
21 | public partial class AboutWin : Window
22 | {
23 | public AboutWin()
24 | {
25 | InitializeComponent();
26 | }
27 | private void NarGithub_Click(object sender, RoutedEventArgs e)
28 | {
29 | Process.Start("https://github.com/narekye");
30 | }
31 |
32 | private void VanGithub_Click(object sender, RoutedEventArgs e)
33 | {
34 | Process.Start("https://github.com/vanhakobyan");
35 |
36 | }
37 |
38 | private void NarFB_Click(object sender, RoutedEventArgs e)
39 | {
40 | Process.Start("https://www.facebook.com/yegoryan.narek");
41 | }
42 |
43 |
44 |
45 | private void VanFB_Click(object sender, RoutedEventArgs e)
46 | {
47 | Process.Start("https://www.facebook.com/VANHAKOBYAN");
48 | }
49 |
50 | private void MainBrowser_Loaded(object sender, RoutedEventArgs e)
51 | {
52 | MainBrowser.Navigate("https://github.com/narekye/Chat_WCF_WPF");
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/ChatSolution/Client/AboutWin.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Login.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/ChatSolution/ChatSolution.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chat_Library", "Chat_Library\Chat_Library.csproj", "{4ED206C8-DAB3-4723-A17B-677A47F19922}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{5EF1D52A-2BBA-4A1C-99C3-7E94A05413A2}"
9 | ProjectSection(ProjectDependencies) = postProject
10 | {4ED206C8-DAB3-4723-A17B-677A47F19922} = {4ED206C8-DAB3-4723-A17B-677A47F19922}
11 | EndProjectSection
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Any CPU = Debug|Any CPU
16 | Release|Any CPU = Release|Any CPU
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {4ED206C8-DAB3-4723-A17B-677A47F19922}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {4ED206C8-DAB3-4723-A17B-677A47F19922}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {4ED206C8-DAB3-4723-A17B-677A47F19922}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {4ED206C8-DAB3-4723-A17B-677A47F19922}.Release|Any CPU.Build.0 = Release|Any CPU
23 | {5EF1D52A-2BBA-4A1C-99C3-7E94A05413A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {5EF1D52A-2BBA-4A1C-99C3-7E94A05413A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {5EF1D52A-2BBA-4A1C-99C3-7E94A05413A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {5EF1D52A-2BBA-4A1C-99C3-7E94A05413A2}.Release|Any CPU.Build.0 = Release|Any CPU
27 | EndGlobalSection
28 | GlobalSection(SolutionProperties) = preSolution
29 | HideSolutionNode = FALSE
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Feedback.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Login.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Client
2 | {
3 | using System;
4 | using System.Windows;
5 | using Chat;
6 | using System.Windows.Input;
7 |
8 | public partial class Login
9 | {
10 | private static User user;
11 | private static ChatableClient chat = MainWindow._proxy;
12 | public Login()
13 | {
14 | InitializeComponent();
15 | }
16 |
17 | private async void button_Click(object sender, RoutedEventArgs e)
18 | {
19 | if ((Login_.Text == null || Login_.Text == string.Empty)
20 | && (Password.Password == null || Password.Password == string.Empty)
21 | || (Password.Password.Length <= 6 && Password.Password.Length >= 15))
22 | {
23 | MessageBox.Show("Please correctly enter the Login or password..");
24 | }
25 | user = new User()
26 | {
27 | NickName = Login_.Text,
28 | UserPassword = Password.Password
29 | };
30 | if (await chat.LoginAsync(user))
31 | {
32 | MainWindow.user = user;
33 | MessageBox.Show("Logged in as: " + user.NickName);
34 | Close();
35 | return;
36 | }
37 | MessageBox.Show("UserName or password incorrect.../nPlease correctly enter !!!");
38 | Close();
39 | }
40 |
41 | private void Password_KeyDown(object sender, KeyEventArgs e)
42 | {
43 | if (e.Key == Key.Enter)
44 | {
45 | button_Click(null, null);
46 | }
47 | }
48 |
49 | private async void ComboBox(object sender, EventArgs e)
50 | {
51 | Login_.Items.Clear();
52 | var list = await chat.GetAllUsersAsyncFromDbAsync();
53 | foreach (User user1 in list)
54 | {
55 | Login_.Items.Add(user1.NickName);
56 | }
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Chatters/ChatService/ClassDiagram1.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | ChatService.cs
8 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAACAACA=
9 |
10 |
11 |
12 |
13 |
14 | ChatService.cs
15 | EARgABAAAAAABAhAAAAEABQgAQEAAAAAAAAAEACAAAA=
16 |
17 |
18 |
19 |
20 | ChatService.cs
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | Program.cs
30 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAA=
31 |
32 |
33 |
34 |
35 |
36 | ChatService.cs
37 | AAAAAAAAAAAABAgAAAAAABAAAAEAAAAAAAAAAAAAAAA=
38 |
39 |
40 |
41 |
42 |
43 | ChatService.cs
44 | AABAAAAAAAAAAAAAAAAAAAAAAAAQAAAQAgAAAAAAAAA=
45 |
46 |
47 |
48 |
49 |
50 | ChatService.cs
51 | AABAAAAAAAAAAAAAAAAAAAAAAAAQAAAQAgAAAAAAAAA=
52 |
53 |
54 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Service References/Chat/Reference.svcmap:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | false
5 | true
6 | true
7 |
8 | false
9 | false
10 | false
11 |
12 |
13 | true
14 | Auto
15 | true
16 | true
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Chatters/Chatters.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27004.2010
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{ADFF1AB8-CBE5-4575-90CB-04E1D40C210E}"
7 | ProjectSection(SolutionItems) = preProject
8 | ChatService\HOW TO CREATE CLIENT PROXY.txt = ChatService\HOW TO CREATE CLIENT PROXY.txt
9 | TODO.txt = TODO.txt
10 | EndProjectSection
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChatService", "ChatService\ChatService.csproj", "{DD577760-8113-409A-B2B8-DE6F8C267F69}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{37999231-F81C-4638-974E-66D2D736D19C}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFChatter", "WPFChatter\WPFChatter.csproj", "{9AFE07B2-EBD3-4385-A533-CB58EDAF64EB}"
17 | EndProject
18 | Global
19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
20 | Debug|Any CPU = Debug|Any CPU
21 | Release|Any CPU = Release|Any CPU
22 | EndGlobalSection
23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
24 | {DD577760-8113-409A-B2B8-DE6F8C267F69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {DD577760-8113-409A-B2B8-DE6F8C267F69}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {DD577760-8113-409A-B2B8-DE6F8C267F69}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {DD577760-8113-409A-B2B8-DE6F8C267F69}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {37999231-F81C-4638-974E-66D2D736D19C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {37999231-F81C-4638-974E-66D2D736D19C}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {37999231-F81C-4638-974E-66D2D736D19C}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {37999231-F81C-4638-974E-66D2D736D19C}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {9AFE07B2-EBD3-4385-A533-CB58EDAF64EB}.Debug|Any CPU.ActiveCfg = Debug|x86
33 | {9AFE07B2-EBD3-4385-A533-CB58EDAF64EB}.Release|Any CPU.ActiveCfg = Debug|x86
34 | {9AFE07B2-EBD3-4385-A533-CB58EDAF64EB}.Release|Any CPU.Build.0 = Debug|x86
35 | EndGlobalSection
36 | GlobalSection(SolutionProperties) = preSolution
37 | HideSolutionNode = FALSE
38 | EndGlobalSection
39 | GlobalSection(ExtensibilityGlobals) = postSolution
40 | SolutionGuid = {C8BF33FE-B6B7-40FF-94AA-CD19F9434E2A}
41 | EndGlobalSection
42 | EndGlobal
43 |
--------------------------------------------------------------------------------
/ChatSolution/TEST/Service References/ServiceReference1/Reference.svcmap:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | false
5 | true
6 | true
7 |
8 | false
9 | false
10 | false
11 |
12 |
13 | true
14 | Auto
15 | true
16 | true
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Feedback.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Client
2 | {
3 | using System;
4 | using System.Net;
5 | using System.Net.Mail;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Input;
9 |
10 | public partial class Feedback
11 | {
12 | public Feedback()
13 | {
14 | InitializeComponent();
15 | }
16 |
17 | private async void SendFeedback_Click(object sender, RoutedEventArgs e)
18 | {
19 | if ((Email.Text == null || !Email.Text.Contains("@") && Password.Password.Length < 6 && Text.Text == null))
20 | {
21 | MessageBox.Show("Please input correct credential !!!");
22 | }
23 | await Task.Run(() =>
24 | {
25 | string text = Text.Text;
26 | string smtpAddress = "smtp.gmail.com";
27 | string emailFrom = Email.Text;
28 | string password = Password.Password;
29 | string emailTo = "chatablenarvan@gmail.com";
30 | string subject = "FeedBack";
31 | string body = text;
32 | MailMessage mail = new MailMessage();
33 | mail.From = new MailAddress(emailFrom);
34 | mail.To.Add(emailTo);
35 | mail.Subject = subject;
36 | mail.Body = body;
37 | mail.IsBodyHtml = true;
38 | using (SmtpClient smtp = new SmtpClient(smtpAddress, 587))
39 | {
40 | smtp.Credentials = new NetworkCredential(emailFrom, password);
41 | smtp.EnableSsl = true;
42 | try
43 | {
44 | smtp.SendAsync(mail, new object());
45 | MessageBox.Show("Your FeedBack Successfully Sent\n \t Thank You");
46 | }
47 | catch (Exception)
48 | {
49 | MessageBox.Show("Input Correct Gmail and/or Password");
50 | }
51 | }
52 | });
53 | }
54 | private async void Send_KeyDown(object sender, KeyEventArgs e)
55 | {
56 | await Task.Run(() =>
57 | {
58 | if (e.Key == Key.Enter)
59 | {
60 | SendFeedback_Click(null, null);
61 | }
62 | });
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Registration.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("Client")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("Client")]
15 | [assembly: AssemblyCopyright("Copyright © 2017")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Service References/Chat/service1.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/ChatSolution/TEST/Service References/ServiceReference1/service1.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Service References/Chat/Chat_Library.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/Chatters/Common/Common.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Debug
4 | AnyCPU
5 | 8.0.50727
6 | 2.0
7 | {37999231-F81C-4638-974E-66D2D736D19C}
8 | Library
9 | Properties
10 | Person
11 | Person
12 |
13 |
14 | v2.0
15 |
16 |
17 |
18 |
19 | 2.0
20 |
21 |
22 | true
23 | full
24 | false
25 | bin\Debug\
26 | DEBUG;TRACE
27 | prompt
28 | 4
29 |
30 |
31 | pdbonly
32 | true
33 | bin\Release\
34 | TRACE
35 | prompt
36 | 4
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
60 |
--------------------------------------------------------------------------------
/ChatSolution/Client/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Client.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Client.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Chatters/ChatService/ChatService.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Debug
4 | AnyCPU
5 | 8.0.50727
6 | 2.0
7 | {DD577760-8113-409A-B2B8-DE6F8C267F69}
8 | Exe
9 | Properties
10 | ChatService
11 | ChatService
12 |
13 |
14 | v2.0
15 |
16 |
17 |
18 |
19 | 2.0
20 |
21 |
22 | true
23 | full
24 | false
25 | bin\Debug\
26 | DEBUG;TRACE
27 | prompt
28 | 4
29 |
30 |
31 | pdbonly
32 | true
33 | bin\Release\
34 | TRACE
35 | prompt
36 | 4
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | {37999231-F81C-4638-974E-66D2D736D19C}
60 | Common
61 |
62 |
63 |
64 |
71 |
--------------------------------------------------------------------------------
/Chatters/Common/Person.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.ServiceModel;
5 | using System.Runtime.Serialization;
6 | using System.ComponentModel;
7 |
8 | namespace Common
9 | {
10 | #region Person class
11 | ///
12 | /// This class represnts a single chat user that can participate in this chat application
13 | /// This class implements INotifyPropertyChanged to support one-way and two-way
14 | /// WPF bindings (such that the UI element updates when the source has been changed
15 | /// dynamically)
16 | /// [DataContract] specifies that the type defines or implements a data contract
17 | /// and is serializable by a serializer, such as the DataContractSerializer
18 | ///
19 | [DataContract]
20 | public class Person : INotifyPropertyChanged
21 | {
22 | #region Instance Fields
23 | private string imageURL;
24 | private string name;
25 | public event PropertyChangedEventHandler PropertyChanged;
26 | #endregion
27 | #region Ctors
28 | ///
29 | /// Blank constructor
30 | ///
31 | public Person()
32 | {
33 | }
34 |
35 | ///
36 | /// Assign constructor
37 | ///
38 | /// Image url to allow a picture to be created for this chatter
39 | /// The name to use for this chatter
40 | public Person(string imageURL, string name)
41 | {
42 | this.imageURL = imageURL;
43 | this.name = name;
44 | }
45 | #endregion
46 | #region Public Properties
47 | ///
48 | /// The chatters image url
49 | ///
50 | [DataMember]
51 | public string ImageURL
52 | {
53 | get { return imageURL; }
54 | set
55 | {
56 | imageURL = value;
57 | // Call OnPropertyChanged whenever the property is updated
58 | OnPropertyChanged("ImageURL");
59 | }
60 | }
61 |
62 | ///
63 | /// The chatters Name
64 | ///
65 | [DataMember]
66 | public string Name
67 | {
68 | get { return name; }
69 | set
70 | {
71 | name = value;
72 | // Call OnPropertyChanged whenever the property is updated
73 | OnPropertyChanged("Name");
74 | }
75 | }
76 | #endregion
77 | #region OnPropertyChanged (for correct well behaved databinding)
78 | ///
79 | /// Notifies the parent bindings (if any) that a property
80 | /// value changed and that the binding needs updating
81 | ///
82 | /// The property which changed
83 | protected void OnPropertyChanged(string propValue)
84 | {
85 | PropertyChangedEventHandler handler = PropertyChanged;
86 | if (handler != null)
87 | {
88 | handler(this, new PropertyChangedEventArgs(propValue));
89 | }
90 | }
91 | #endregion
92 | }
93 | #endregion
94 | }
95 |
--------------------------------------------------------------------------------
/ChatSolution/Client/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Client
2 | {
3 | using System;
4 | using System.Windows;
5 | using Chat;
6 |
7 | public partial class MainWindow
8 | {
9 | public static User user;
10 | public static ChatableClient _proxy = new ChatableClient();
11 | public MainWindow()
12 | {
13 | InitializeComponent();
14 | }
15 |
16 | private void Send_Message(object sender, RoutedEventArgs e)
17 | {
18 | if (ReferenceEquals(user, null))
19 | {
20 | MessageBox.Show("You must logged in at first...");
21 | return;
22 | }
23 | Message msg = new Message()
24 | {
25 | MessageSender = user.NickName,
26 | MessageContent = message.Text
27 | };
28 | _proxy.Send(msg);
29 | Refresh_Block(null, null);
30 | }
31 | private async void Refresh_Block(object sender, EventArgs e)
32 | {
33 | if (ReferenceEquals(user, null))
34 | {
35 | SignOUT.IsEnabled = false;
36 | signin.IsEnabled = true;
37 | reg.IsEnabled = true;
38 | Label.Text = "";
39 | return;
40 | }
41 | else Label.Text = "Logged in as: " + user.NickName;
42 | {
43 | signin.IsEnabled = false;
44 | SignOUT.IsEnabled = true;
45 | reg.IsEnabled = false;
46 | }
47 | res.Text = "";
48 | var list = await _proxy.GetMessagesAsync();
49 | Dispatcher.Invoke(() =>
50 | {
51 | foreach (Message message1 in list)
52 | {
53 | res.Text += message1.MessageSender + " : " + "\t" + message1.MessageContent + "\n";
54 | }
55 | RefreshUsers();
56 | });
57 | Label.Text = "Logged in as: " + user.NickName;
58 | message.Text = "Type Your Message Here: ";
59 | }
60 |
61 | private void Reg_of_Show(object sender, RoutedEventArgs e) => new Registration().Show();
62 | private void Sign_of_Show(object sender, RoutedEventArgs e)
63 | {
64 | new Login().Show();
65 | if (!ReferenceEquals(user, null))
66 | {
67 | SignOUT.IsEnabled = true;
68 | }
69 | }
70 |
71 | private void Out_of_Show(object sender, RoutedEventArgs e)
72 | {
73 | _proxy.RemoveFromList(user);
74 | user = null;
75 | listBox.Items.Clear();
76 | res.Text = "";
77 | MessageBox.Show("You have successfully signed out...");
78 | Label.Text = "";
79 | }
80 | #region BTNCLICKS
81 |
82 | private void RefreshUsers()
83 | {
84 | listBox.Items.Clear();
85 | foreach (User us in _proxy.GetAllUsersAsync())
86 | {
87 | listBox.Items.Add(": " + us.UserName + "\t" + us.NickName);
88 | }
89 | }
90 | private void Feed_Click(object sender, RoutedEventArgs e) => new Feedback().Show();
91 |
92 | private void About_Click(object sender, RoutedEventArgs e) => new AboutWin().Show();
93 | #endregion
94 | }
95 | }
--------------------------------------------------------------------------------
/Chatters/WPFChatter/SignInControl.xaml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/ChatSolution/TEST/Service References/ServiceReference1/service.wsdl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/Chatters/WPFChatter/WPFChatter.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WPFChatter
5 | WPFChat
6 | winexe
7 | Debug
8 | False
9 | bin\$(Configuration)\
10 | 8.0.50727
11 | 2.0
12 | {9AFE07B2-EBD3-4385-A533-CB58EDAF64EB}
13 | v3.0
14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 |
16 |
17 |
18 |
19 | 2.0
20 |
21 |
22 |
23 |
24 |
25 | False
26 | ..\..\..\..\..\Program Files\Microsoft Visual Studio 8\Common7\IDE\Cider\PresentationDesignDeveloper.DLL
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | MSBuild:Compile
41 | Designer
42 |
43 |
44 | ChatControl.xaml
45 |
46 |
47 |
48 |
49 |
50 | MSBuild:Compile
51 | Designer
52 |
53 |
54 |
55 | MSBuild:Compile
56 | Designer
57 |
58 |
59 | MSBuild:Compile
60 | Designer
61 |
62 |
63 | MSBuild:Compile
64 | Designer
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | Code
73 | SignInControl.xaml
74 |
75 |
76 | Code
77 | Window1.xaml
78 |
79 |
80 |
81 |
82 | {37999231-F81C-4638-974E-66D2D736D19C}
83 | Common
84 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/ChatSolution/Chat_Library/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
46 |
47 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/ChatSolution/TEST/TEST.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {C9CFB7FC-96CF-45B3-A7D4-1E66487D0BE2}
8 | Exe
9 | Properties
10 | TEST
11 | TEST
12 | v4.5.2
13 | 512
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | True
52 | True
53 | Reference.svcmap
54 |
55 |
56 |
57 |
58 |
59 | Designer
60 |
61 |
62 |
63 | Designer
64 |
65 |
66 | Designer
67 |
68 |
69 | Reference.svcmap
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 | WCF Proxy Generator
87 | Reference.cs
88 |
89 |
90 |
91 |
98 |
--------------------------------------------------------------------------------
/ChatSolution/Chat_Library/Chatable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Chat_Library
4 | {
5 | using System.Windows;
6 | using System.Collections.Generic;
7 | using System.Data.Entity;
8 | using System.Linq;
9 | using System.Threading.Tasks;
10 |
11 | public class Chatable : IChatable
12 | {
13 | private readonly MessagesContext_ _db = new MessagesContext_();
14 | private static List connectedUsers = new List();
15 | // for PM
16 | private static List _room = new List();
17 |
18 |
19 |
20 | public void Send(Message message)
21 | {
22 | _db.Messages.Add(message);
23 | _db.SaveChanges();
24 | }
25 | public async Task> GetMessages()
26 | {
27 | return await _db.Messages.ToListAsync();
28 | }
29 | public async Task LoginAsync(User user)
30 | {
31 | User list = await (from d in _db.Users
32 | where d.NickName == user.NickName && d.UserPassword == user.UserPassword
33 | select d).FirstOrDefaultAsync();
34 | connectedUsers.Add(list);
35 | return !ReferenceEquals(list, null);
36 | }
37 | public async Task RegisterAsync(User user)
38 | {
39 | User member = await (from u in _db.Users
40 | where u.NickName == user.NickName
41 | select u).FirstOrDefaultAsync();
42 | if (ReferenceEquals(member, null))
43 | {
44 | _db.Users.Add(user);
45 | await _db.SaveChangesAsync();
46 | return true;
47 | }
48 | return false;
49 | }
50 | public void SendMail(User user)
51 | {
52 |
53 | }
54 |
55 | public List GetAllUsersAsync()
56 | {
57 | return connectedUsers;
58 | }
59 |
60 | public async Task> GetAllUsersAsyncFromDb()
61 | {
62 | return await _db.Users.ToListAsync();
63 | }
64 |
65 | public void RemoveFromList(User user)
66 | {
67 | var us = connectedUsers.FindLast(p => p.NickName == user.NickName);
68 | connectedUsers.Remove(us);
69 | }
70 | // TODO: PM messaging methods not completed
71 | public int CreateRoom(User first)
72 | {
73 | List list = new List(2)
74 | {
75 | first
76 |
77 | };
78 | _room.Add(new PersonalRoom()
79 | {
80 | Users = list,
81 | Messages = new List()
82 | });
83 | return _room.Count - 1;
84 | }
85 |
86 | public void SendToRoom(int roomindex, Message message)
87 | {
88 | _room[roomindex].Messages.Add(message);
89 | }
90 |
91 | public List GetRoomMessages(int index)
92 | {
93 | return _room[index].Messages;
94 | }
95 |
96 | public List GetAllRooms()
97 | {
98 | return _room;
99 | }
100 |
101 | public bool EnterExsitingRoom(User sender, User enter)
102 | {
103 | PersonalRoom current = new PersonalRoom();
104 | foreach (PersonalRoom personalRoom in _room)
105 | {
106 | if (personalRoom.Users.Contains(sender))
107 | {
108 | current = personalRoom;
109 | break;
110 | }
111 | current = null;
112 | }
113 | if (ReferenceEquals(current, null))
114 | return false;
115 |
116 |
117 | current.Users.Add(enter);
118 | return true;
119 | }
120 |
121 | public int GetIndex(User us)
122 | {
123 | for (int i = 0; i < _room.Count; i++)
124 | {
125 | if (_room[i].Users.Contains(us))
126 | {
127 | return i;
128 | }
129 | }
130 | return 0;
131 | }
132 |
133 | public bool InviteToChat(User sender)
134 | {
135 | CreateRoom(sender);
136 | return true;
137 | }
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/Chatters/WPFChatter/SignInControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Imaging;
11 | using System.Windows.Navigation;
12 | using System.Windows.Shapes;
13 |
14 | using Common;
15 |
16 | namespace WPFChatter
17 | {
18 | #region ChatControl class
19 | ///
20 | /// This class represents a signin control, which is used to create a new
21 | /// chatter. The user is expected to pick a name and an image. When they
22 | /// have done this a new chatter
23 | /// is created
24 | ///
25 | /// This provides the logic for the user control, whilst the SignInControl.xaml
26 | /// provides the WPF UI design.
27 | ///
28 | public partial class SignInControl : System.Windows.Controls.UserControl
29 | {
30 | #region Instance Fields
31 | string photoPath;
32 | Person currentPerson;
33 | #endregion
34 | #region Routed Events
35 |
36 | ///
37 | /// AddButtonClickEvent event, occurs when the user clicks the add button
38 | ///
39 | public static readonly RoutedEvent AddButtonClickEvent = EventManager.RegisterRoutedEvent(
40 | "AddButtonClick", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(SignInControl));
41 |
42 | ///
43 | /// Expose the AddButtonClick to external sources
44 | ///
45 | public event RoutedEventHandler AddButtonClick
46 | {
47 | add { AddHandler(AddButtonClickEvent, value); }
48 | remove { RemoveHandler(AddButtonClickEvent, value); }
49 | }
50 |
51 | #endregion
52 | #region Constructor
53 | ///
54 | /// Blank constructor
55 | ///
56 | public SignInControl()
57 | {
58 | InitializeComponent();
59 | }
60 | #endregion
61 | #region Public Properties
62 | ///
63 | /// The current chatter
64 | ///
65 | public Person CurrentPerson
66 | {
67 | get { return currentPerson; }
68 | set { currentPerson = value; }
69 | }
70 | #endregion
71 | #region Private Methods
72 | ///
73 | /// If there is a chatter name and image provided
74 | /// the currentPerson property is set to be a new
75 | /// chatter and the
76 | /// AddButtonClickEvent is raised which is used by the
77 | /// parent window
78 | ///
79 | /// AddButton
80 | /// The event args
81 | private void AddButton_Click(object sender, RoutedEventArgs e)
82 | {
83 | if (!string.IsNullOrEmpty(txtName.Text) &&
84 | !string.IsNullOrEmpty(photoPath))
85 | {
86 | currentPerson = new Person(photoPath, txtName.Text);
87 | RaiseEvent(new RoutedEventArgs(AddButtonClickEvent));
88 | }
89 | else
90 | {
91 | MessageBox.Show("You need to pick a screen name and image", "Error",
92 | MessageBoxButton.OK, MessageBoxImage.Error);
93 | }
94 | }
95 |
96 | private void CloseButton_Click(object sender, RoutedEventArgs e)
97 | {
98 | Application.Current.Shutdown(0);
99 | }
100 |
101 | ///
102 | /// Handles Drop Event for Avatar photo.
103 | ///
104 | private void Photo_Drop(object sender, DragEventArgs e)
105 | {
106 | string[] fileNames = e.Data.GetData(DataFormats.FileDrop, true) as string[];
107 |
108 | if (fileNames.Length > 0)
109 | {
110 | photoPath = fileNames[0];
111 | photoSrc.Source = new BitmapImage(new Uri(photoPath));
112 | }
113 |
114 | // Mark the event as handled, so the control's native Drop handler is not called.
115 | e.Handled = true;
116 | }
117 |
118 | #endregion
119 | }
120 | #endregion
121 | }
--------------------------------------------------------------------------------
/Chatters/WPFChatter/ChatService.cs:
--------------------------------------------------------------------------------
1 |
2 | using Common;
3 |
4 | ///
5 | /// This class was auto generated by the svcutil.exe utility.
6 | /// The www.codeprject.com article will explain how this class
7 | /// was generated, for those readers that just need to know.
8 | /// Basically, anyone like me.
9 | ///
10 | #region IChat interface
11 | [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
12 | [System.ServiceModel.ServiceContractAttribute(CallbackContract = typeof(IChatCallback), SessionMode = System.ServiceModel.SessionMode.Required)]
13 | public interface IChat
14 | {
15 |
16 | [System.ServiceModel.OperationContractAttribute(AsyncPattern = true, Action = "http://tempuri.org/IChat/Join", ReplyAction = "http://tempuri.org/IChat/JoinResponse")]
17 | System.IAsyncResult BeginJoin(Person name, System.AsyncCallback callback, object asyncState);
18 |
19 | Person[] EndJoin(System.IAsyncResult result);
20 |
21 | [System.ServiceModel.OperationContractAttribute(IsOneWay = true, IsInitiating = false, Action = "http://tempuri.org/IChat/Leave")]
22 | void Leave();
23 |
24 | [System.ServiceModel.OperationContractAttribute(IsOneWay = true, IsInitiating = false, Action = "http://tempuri.org/IChat/Say")]
25 | void Say(string msg);
26 |
27 | [System.ServiceModel.OperationContractAttribute(IsOneWay = true, IsInitiating = false, Action = "http://tempuri.org/IChat/Whisper")]
28 | void Whisper(string to, string msg);
29 | }
30 | #endregion
31 | #region IChatCallback interface
32 | [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
33 | public interface IChatCallback
34 | {
35 |
36 | [System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://tempuri.org/IChat/Receive")]
37 | void Receive(Person sender, string message);
38 |
39 | [System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://tempuri.org/IChat/ReceiveWhisper")]
40 | void ReceiveWhisper(Person sender, string message);
41 |
42 | [System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://tempuri.org/IChat/UserEnter")]
43 | void UserEnter(Person person);
44 |
45 | [System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://tempuri.org/IChat/UserLeave")]
46 | void UserLeave(Person person);
47 | }
48 | #endregion
49 | #region IChatChannel interface
50 | [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
51 | public interface IChatChannel : IChat, System.ServiceModel.IClientChannel
52 | {
53 | }
54 | #endregion
55 | #region ChatProxy class
56 | [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
57 | public partial class ChatProxy : System.ServiceModel.DuplexClientBase, IChat
58 | {
59 |
60 | public ChatProxy(System.ServiceModel.InstanceContext callbackInstance)
61 | :
62 | base(callbackInstance)
63 | {
64 | }
65 |
66 | public ChatProxy(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName)
67 | :
68 | base(callbackInstance, endpointConfigurationName)
69 | {
70 | }
71 |
72 | public ChatProxy(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, string remoteAddress)
73 | :
74 | base(callbackInstance, endpointConfigurationName, remoteAddress)
75 | {
76 | }
77 |
78 | public ChatProxy(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
79 | :
80 | base(callbackInstance, endpointConfigurationName, remoteAddress)
81 | {
82 | }
83 |
84 | public ChatProxy(System.ServiceModel.InstanceContext callbackInstance, System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress)
85 | :
86 | base(callbackInstance, binding, remoteAddress)
87 | {
88 | }
89 |
90 | public System.IAsyncResult BeginJoin(Person name, System.AsyncCallback callback, object asyncState)
91 | {
92 | return base.Channel.BeginJoin(name, callback, asyncState);
93 | }
94 |
95 | public Person[] EndJoin(System.IAsyncResult result)
96 | {
97 | return base.Channel.EndJoin(result);
98 | }
99 |
100 | public void Leave()
101 | {
102 | base.Channel.Leave();
103 | }
104 |
105 | public void Say(string msg)
106 | {
107 | base.Channel.Say(msg);
108 | }
109 |
110 | public void Whisper(string to, string msg)
111 | {
112 | base.Channel.Whisper(to, msg);
113 | }
114 | }
115 | #endregion
116 |
117 |
--------------------------------------------------------------------------------
/Chatters/WPFChatter/ClassDiagram1.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | ChatControl.xaml.cs
8 | EQBAIAAIgAAABQAAAQQEAgAAAAAAgAAQAAAAAAEAAEA=
9 |
10 |
11 |
12 |
13 |
14 | Proxy_Singleton.cs
15 | AAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
16 |
17 |
18 |
19 |
20 |
21 | Proxy_Singleton.cs
22 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAACAACA=
23 |
24 |
25 |
26 |
27 |
28 | Proxy_Singleton.cs
29 | AABABkAAAgAEAggAAAgAAoAABQAUAgAQAgAAAQAAAAA=
30 |
31 |
32 |
33 |
34 | Proxy_Singleton.cs
35 |
36 |
37 |
38 |
39 | Proxy_Singleton.cs
40 |
41 |
42 |
43 |
44 | Proxy_Singleton.cs
45 |
46 |
47 |
48 |
49 | Proxy_Singleton.cs
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | SignInControl.xaml.cs
59 | AAAAABAAAEAABAAAAAQEACAACAAAACAAAAAAAAAAAAA=
60 |
61 |
62 |
63 |
64 |
65 | Window1.xaml.cs
66 | AQBAAABAAAAACAAEAEQAAgAAAAAQECCQAgGAAAAAAEA=
67 |
68 |
69 |
70 |
71 | Window1.xaml.cs
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | ChatService.cs
80 | AAAAAAAAABAABAAAAAAAABAAAAEAAQAAAAAAAAAAAAA=
81 |
82 |
83 |
84 |
85 |
86 |
87 | ChatService.cs
88 | AAAAAAAAABAABAAAAAAAABAAAAEAAQAAAAAAAAAAAAA=
89 |
90 |
91 |
92 |
93 |
94 | ChatService.cs
95 | AABAAAAAAAAAAAAAAAAAAAAAAAAQAAAQAgAAAAAAAAA=
96 |
97 |
98 |
99 |
100 |
101 | ChatService.cs
102 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
103 |
104 |
105 |
106 |
107 |
108 | Proxy_Singleton.cs
109 | AABAAAAAAAAAAAAAAAAAAAAAAAAQAAAQAgAAAAAAAAA=
110 |
111 |
112 |
--------------------------------------------------------------------------------
/Chatters/WPFChatter/ChatControl.xaml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 | *.VC.VC.opendb
85 |
86 | # Visual Studio profiler
87 | *.psess
88 | *.vsp
89 | *.vspx
90 | *.sap
91 |
92 | # TFS 2012 Local Workspace
93 | $tf/
94 |
95 | # Guidance Automation Toolkit
96 | *.gpState
97 |
98 | # ReSharper is a .NET coding add-in
99 | _ReSharper*/
100 | *.[Rr]e[Ss]harper
101 | *.DotSettings.user
102 |
103 | # JustCode is a .NET coding add-in
104 | .JustCode
105 |
106 | # TeamCity is a build add-in
107 | _TeamCity*
108 |
109 | # DotCover is a Code Coverage Tool
110 | *.dotCover
111 |
112 | # NCrunch
113 | _NCrunch_*
114 | .*crunch*.local.xml
115 | nCrunchTemp_*
116 |
117 | # MightyMoose
118 | *.mm.*
119 | AutoTest.Net/
120 |
121 | # Web workbench (sass)
122 | .sass-cache/
123 |
124 | # Installshield output folder
125 | [Ee]xpress/
126 |
127 | # DocProject is a documentation generator add-in
128 | DocProject/buildhelp/
129 | DocProject/Help/*.HxT
130 | DocProject/Help/*.HxC
131 | DocProject/Help/*.hhc
132 | DocProject/Help/*.hhk
133 | DocProject/Help/*.hhp
134 | DocProject/Help/Html2
135 | DocProject/Help/html
136 |
137 | # Click-Once directory
138 | publish/
139 |
140 | # Publish Web Output
141 | *.[Pp]ublish.xml
142 | *.azurePubxml
143 | # TODO: Comment the next line if you want to checkin your web deploy settings
144 | # but database connection strings (with potential passwords) will be unencrypted
145 | *.pubxml
146 | *.publishproj
147 |
148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
149 | # checkin your Azure Web App publish settings, but sensitive information contained
150 | # in these scripts will be unencrypted
151 | PublishScripts/
152 |
153 | # NuGet Packages
154 | *.nupkg
155 | # The packages folder can be ignored because of Package Restore
156 | **/packages/*
157 | # except build/, which is used as an MSBuild target.
158 | !**/packages/build/
159 | # Uncomment if necessary however generally it will be regenerated when needed
160 | #!**/packages/repositories.config
161 | # NuGet v3's project.json files produces more ignoreable files
162 | *.nuget.props
163 | *.nuget.targets
164 |
165 | # Microsoft Azure Build Output
166 | csx/
167 | *.build.csdef
168 |
169 | # Microsoft Azure Emulator
170 | ecf/
171 | rcf/
172 |
173 | # Windows Store app package directories and files
174 | AppPackages/
175 | BundleArtifacts/
176 | Package.StoreAssociation.xml
177 | _pkginfo.txt
178 |
179 | # Visual Studio cache files
180 | # files ending in .cache can be ignored
181 | *.[Cc]ache
182 | # but keep track of directories ending in .cache
183 | !*.[Cc]ache/
184 |
185 | # Others
186 | ClientBin/
187 | ~$*
188 | *~
189 | *.dbmdl
190 | *.dbproj.schemaview
191 | *.pfx
192 | *.publishsettings
193 | node_modules/
194 | orleans.codegen.cs
195 |
196 | # Since there are multiple workflows, uncomment next line to ignore bower_components
197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
198 | #bower_components/
199 |
200 | # RIA/Silverlight projects
201 | Generated_Code/
202 |
203 | # Backup & report files from converting an old project file
204 | # to a newer Visual Studio version. Backup files are not needed,
205 | # because we have git ;-)
206 | _UpgradeReport_Files/
207 | Backup*/
208 | UpgradeLog*.XML
209 | UpgradeLog*.htm
210 |
211 | # SQL Server files
212 | *.mdf
213 | *.ldf
214 |
215 | # Business Intelligence projects
216 | *.rdl.data
217 | *.bim.layout
218 | *.bim_*.settings
219 |
220 | # Microsoft Fakes
221 | FakesAssemblies/
222 |
223 | # GhostDoc plugin setting file
224 | *.GhostDoc.xml
225 |
226 | # Node.js Tools for Visual Studio
227 | .ntvs_analysis.dat
228 |
229 | # Visual Studio 6 build log
230 | *.plg
231 |
232 | # Visual Studio 6 workspace options file
233 | *.opt
234 |
235 | # Visual Studio LightSwitch build output
236 | **/*.HTMLClient/GeneratedArtifacts
237 | **/*.DesktopClient/GeneratedArtifacts
238 | **/*.DesktopClient/ModelManifest.xml
239 | **/*.Server/GeneratedArtifacts
240 | **/*.Server/ModelManifest.xml
241 | _Pvt_Extensions
242 |
243 | # Paket dependency manager
244 | .paket/paket.exe
245 | paket-files/
246 |
247 | # FAKE - F# Make
248 | .fake/
249 |
250 | # JetBrains Rider
251 | .idea/
252 | *.sln.iml
253 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/ChatSolution/Chat_Library/Chat_Library.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | 8.0.50727
8 | 2.0
9 | {4ED206C8-DAB3-4723-A17B-677A47F19922}
10 | Library
11 | Properties
12 | Chat_Library
13 | Chat_Library
14 | {3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | /client:"WcfTestClient.exe"
16 | v4.5.2
17 | True
18 | True
19 |
20 |
21 | true
22 | full
23 | false
24 | bin\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 | ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll
40 | True
41 |
42 |
43 | ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll
44 | True
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | Messages.tt
61 |
62 |
63 | True
64 | True
65 | Messages.Context.tt
66 |
67 |
68 | True
69 | True
70 | Messages.tt
71 |
72 |
73 | True
74 | True
75 | Messages.edmx
76 |
77 |
78 |
79 |
80 |
81 | Messages.tt
82 |
83 |
84 |
85 |
86 |
87 | EntityModelCodeGenerator
88 | Messages.Designer.cs
89 |
90 |
91 | Messages.edmx
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | TextTemplatingFileGenerator
101 | Messages.edmx
102 | Messages.Context.cs
103 |
104 |
105 | TextTemplatingFileGenerator
106 | Messages.edmx
107 | Messages.cs
108 |
109 |
110 |
111 |
112 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
113 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio
114 | $(VSToolsPath)\WCF
115 |
116 |
117 |
118 |
119 |
120 |
121 | True
122 |
123 |
124 |
125 |
126 |
133 |
--------------------------------------------------------------------------------
/ChatSolution/Chat_Library/Messages.edmx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/ChatSolution/TEST/Service References/ServiceReference1/Reference.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace TEST.ServiceReference1 {
12 | using System.Runtime.Serialization;
13 | using System;
14 |
15 |
16 | [System.Diagnostics.DebuggerStepThroughAttribute()]
17 | [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
18 | [System.Runtime.Serialization.DataContractAttribute(Name="Message", Namespace="http://schemas.datacontract.org/2004/07/Chat_Library")]
19 | [System.SerializableAttribute()]
20 | public partial class Message : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
21 |
22 | [System.NonSerializedAttribute()]
23 | private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
24 |
25 | [System.Runtime.Serialization.OptionalFieldAttribute()]
26 | private string MessageContentField;
27 |
28 | [System.Runtime.Serialization.OptionalFieldAttribute()]
29 | private int MessageIdField;
30 |
31 | [System.Runtime.Serialization.OptionalFieldAttribute()]
32 | private string MessageSenderField;
33 |
34 | [global::System.ComponentModel.BrowsableAttribute(false)]
35 | public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
36 | get {
37 | return this.extensionDataField;
38 | }
39 | set {
40 | this.extensionDataField = value;
41 | }
42 | }
43 |
44 | [System.Runtime.Serialization.DataMemberAttribute()]
45 | public string MessageContent {
46 | get {
47 | return this.MessageContentField;
48 | }
49 | set {
50 | if ((object.ReferenceEquals(this.MessageContentField, value) != true)) {
51 | this.MessageContentField = value;
52 | this.RaisePropertyChanged("MessageContent");
53 | }
54 | }
55 | }
56 |
57 | [System.Runtime.Serialization.DataMemberAttribute()]
58 | public int MessageId {
59 | get {
60 | return this.MessageIdField;
61 | }
62 | set {
63 | if ((this.MessageIdField.Equals(value) != true)) {
64 | this.MessageIdField = value;
65 | this.RaisePropertyChanged("MessageId");
66 | }
67 | }
68 | }
69 |
70 | [System.Runtime.Serialization.DataMemberAttribute()]
71 | public string MessageSender {
72 | get {
73 | return this.MessageSenderField;
74 | }
75 | set {
76 | if ((object.ReferenceEquals(this.MessageSenderField, value) != true)) {
77 | this.MessageSenderField = value;
78 | this.RaisePropertyChanged("MessageSender");
79 | }
80 | }
81 | }
82 |
83 | public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
84 |
85 | protected void RaisePropertyChanged(string propertyName) {
86 | System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
87 | if ((propertyChanged != null)) {
88 | propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
89 | }
90 | }
91 | }
92 |
93 | [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
94 | [System.ServiceModel.ServiceContractAttribute(ConfigurationName="ServiceReference1.IChatable")]
95 | public interface IChatable {
96 |
97 | [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IChatable/Send", ReplyAction="http://tempuri.org/IChatable/SendResponse")]
98 | void Send(TEST.ServiceReference1.Message message);
99 |
100 | [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IChatable/Send", ReplyAction="http://tempuri.org/IChatable/SendResponse")]
101 | System.Threading.Tasks.Task SendAsync(TEST.ServiceReference1.Message message);
102 |
103 | [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IChatable/GetMessages", ReplyAction="http://tempuri.org/IChatable/GetMessagesResponse")]
104 | TEST.ServiceReference1.Message[] GetMessages();
105 |
106 | [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IChatable/GetMessages", ReplyAction="http://tempuri.org/IChatable/GetMessagesResponse")]
107 | System.Threading.Tasks.Task GetMessagesAsync();
108 | }
109 |
110 | [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
111 | public interface IChatableChannel : TEST.ServiceReference1.IChatable, System.ServiceModel.IClientChannel {
112 | }
113 |
114 | [System.Diagnostics.DebuggerStepThroughAttribute()]
115 | [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
116 | public partial class ChatableClient : System.ServiceModel.ClientBase, TEST.ServiceReference1.IChatable {
117 |
118 | public ChatableClient() {
119 | }
120 |
121 | public ChatableClient(string endpointConfigurationName) :
122 | base(endpointConfigurationName) {
123 | }
124 |
125 | public ChatableClient(string endpointConfigurationName, string remoteAddress) :
126 | base(endpointConfigurationName, remoteAddress) {
127 | }
128 |
129 | public ChatableClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
130 | base(endpointConfigurationName, remoteAddress) {
131 | }
132 |
133 | public ChatableClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
134 | base(binding, remoteAddress) {
135 | }
136 |
137 | public void Send(TEST.ServiceReference1.Message message) {
138 | base.Channel.Send(message);
139 | }
140 |
141 | public System.Threading.Tasks.Task SendAsync(TEST.ServiceReference1.Message message) {
142 | return base.Channel.SendAsync(message);
143 | }
144 |
145 | public TEST.ServiceReference1.Message[] GetMessages() {
146 | return base.Channel.GetMessages();
147 | }
148 |
149 | public System.Threading.Tasks.Task GetMessagesAsync() {
150 | return base.Channel.GetMessagesAsync();
151 | }
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Service References/Chat/service.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
--------------------------------------------------------------------------------
/ChatSolution/Client/Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {5EF1D52A-2BBA-4A1C-99C3-7E94A05413A2}
8 | WinExe
9 | Properties
10 | Client
11 | Client
12 | v4.5.2
13 | 512
14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 4
16 | true
17 |
18 |
19 | AnyCPU
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 |
28 |
29 | AnyCPU
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | 4.0
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | MSBuild:Compile
58 | Designer
59 |
60 |
61 | AboutWin.xaml
62 |
63 |
64 | Feedback.xaml
65 |
66 |
67 | Login.xaml
68 |
69 |
70 | Registration.xaml
71 |
72 |
73 | True
74 | True
75 | Reference.svcmap
76 |
77 |
78 | Designer
79 | MSBuild:Compile
80 |
81 |
82 | Designer
83 | MSBuild:Compile
84 |
85 |
86 | Designer
87 | MSBuild:Compile
88 |
89 |
90 | MSBuild:Compile
91 | Designer
92 |
93 |
94 | App.xaml
95 | Code
96 |
97 |
98 | MainWindow.xaml
99 | Code
100 |
101 |
102 | Designer
103 | MSBuild:Compile
104 |
105 |
106 |
107 |
108 | Code
109 |
110 |
111 | True
112 | True
113 | Resources.resx
114 |
115 |
116 | True
117 | Settings.settings
118 | True
119 |
120 |
121 | ResXFileCodeGenerator
122 | Resources.Designer.cs
123 |
124 |
125 | SettingsSingleFileGenerator
126 | Settings.Designer.cs
127 |
128 |
129 |
130 | Designer
131 |
132 |
133 | Reference.svcmap
134 |
135 |
136 | Reference.svcmap
137 |
138 |
139 | Reference.svcmap
140 |
141 |
142 |
143 | Designer
144 |
145 |
146 | Designer
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 | WCF Proxy Generator
167 | Reference.cs
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
193 |
--------------------------------------------------------------------------------
/Chatters/WPFChatter/Window1.xaml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
144 |
145 |
146 |
147 |
148 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
--------------------------------------------------------------------------------
/Chatters/WPFChatter/ChatControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Imaging;
11 | using System.Windows.Media.Animation;
12 | using System.Windows.Shapes;
13 | using System.Runtime.InteropServices;
14 | using System.Windows.Threading; //for WPF Dispatcher
15 |
16 | using Common;
17 |
18 | namespace WPFChatter
19 | {
20 | #region ChatControl class
21 | ///
22 | /// This class represents a chat control, which may be used to chat with fellow
23 | /// chatters. There are buttons for Say/Whisper/Close and a text box for entering
24 | /// new chat messages, and also a larger textbox for displaying incoming chat
25 | /// messages to this chatter
26 | ///
27 | /// This provides the logic for the user control, whilst the ChatControl.xaml
28 | /// provides the WPF UI design.
29 | ///
30 | public partial class ChatControl
31 | {
32 |
33 | #region Instance Fields
34 | Person currentPerson;
35 | Person otherPerson;
36 | private Proxy_Singleton ProxySingleton = Proxy_Singleton.GetInstance();
37 | #endregion
38 | #region Routed Events
39 |
40 | ///
41 | /// CloseClickEvent event, occurs when the user clicks the close button
42 | ///
43 | public static readonly RoutedEvent CloseClickEvent = EventManager.RegisterRoutedEvent(
44 | "CloseClickEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ChatControl));
45 |
46 | ///
47 | /// Expose the CloseClickEvent to external sources
48 | ///
49 | public event RoutedEventHandler CloseClick
50 | {
51 | add { AddHandler(CloseClickEvent, value); }
52 | remove { RemoveHandler(CloseClickEvent, value); }
53 | }
54 |
55 | #endregion
56 | #region Ctor
57 | ///
58 | /// Wires up the UI Element events
59 | ///
60 | public ChatControl()
61 | {
62 | this.InitializeComponent();
63 | this.lblExit.MouseDown += new System.Windows.Input.MouseButtonEventHandler(lblExit_MouseDown);
64 | this.btnSay.Click += new RoutedEventHandler(btnSay_Click);
65 | this.btnWhisper.Click += new RoutedEventHandler(btnWhisper_Click);
66 |
67 | }
68 | #endregion
69 | #region Public Methods/Properties
70 | ///
71 | /// When called will append the text input parameter to
72 | /// the text of incoming messages
73 | ///
74 | /// The text to append
75 | public void AppendText(string text)
76 | {
77 | this.txtMessages.AppendText(text);
78 | }
79 |
80 | ///
81 | /// Gets/Sets the current chatter
82 | /// which ensures that the current chatter's image (Avatar) and name
83 | /// can be shown
84 | ///
85 | public Person CurrentPerson
86 | {
87 | get { return currentPerson; }
88 | set
89 | {
90 | currentPerson = value;
91 | if (currentPerson != null)
92 | {
93 | this.imgMine.Source = new BitmapImage(new Uri(currentPerson.ImageURL));
94 | this.lblCurrPersonName.Content = currentPerson.Name;
95 | }
96 | }
97 | }
98 |
99 | ///
100 | /// Gets/Sets the other chatter
101 | /// which ensures that the other chatter's image (Avatar) and name
102 | /// can be shown
103 | ///
104 | public Person OtherPerson
105 | {
106 | get { return otherPerson; }
107 | set
108 | {
109 | otherPerson = value;
110 | if (otherPerson != null)
111 | {
112 | this.imgOther.Source = new BitmapImage(new Uri(otherPerson.ImageURL));
113 | this.lblOtherPersonName.Content = otherPerson.Name;
114 | }
115 | }
116 | }
117 |
118 | ///
119 | /// This method is called when ever the
120 | /// Proxy ProxyCallBackEvent is raised, in response to an incoming message
121 | /// When this method is called it will examine the events
122 | /// ProxyCallBackEventArgs to see what type of message is being recieved,
123 | /// and will then call the correspoding method.
124 | /// UserEnter/UserLeave are not dealt with
125 | /// as they are not relevant to this control. They are dealt with by
126 | /// the main WPF window
127 | ///
128 | /// the sender, which is not used
129 | /// The ChatEventArgs
130 | public void ProxySingleton_ProxyCallBackEvent(object sender, ProxyCallBackEventArgs e)
131 | {
132 | switch (e.callbackType)
133 | {
134 | case CallBackType.Receive:
135 | Receive(e.person.Name, e.message);
136 | break;
137 | case CallBackType.ReceiveWhisper:
138 | ReceiveWhisper(e.person.Name, e.message);
139 | break;
140 | case CallBackType.UserEnter:
141 | break;
142 | case CallBackType.UserLeave:
143 | break;
144 |
145 | }
146 | }
147 |
148 | ///
149 | /// Appends the incoming Receive message
150 | /// using the AppendText() method.
151 | ///
152 | /// the senders chat name
153 | /// the send message
154 | public void Receive(string senderName, string message)
155 | {
156 | AppendText(senderName + ": " + message + Environment.NewLine);
157 | }
158 |
159 | public void ReceiveWhisper(string senderName, string message)
160 | {
161 | AppendText(senderName + " whisper: " + message + Environment.NewLine);
162 | }
163 | #endregion
164 | #region Private Methods
165 |
166 | ///
167 | /// The Whisper button has been clicked, so conduct a
168 | /// private message send between the currentPerson and
169 | /// the otherPerson.
170 | /// Calls the SayAndClear() method passing True for the
171 | /// "pvt" input parameter
172 | ///
173 | /// btnWhisper
174 | /// The event args
175 | private void btnWhisper_Click(object sender, RoutedEventArgs e)
176 | {
177 | if (txtMessage.Text == "")
178 | return;
179 |
180 | Person to = otherPerson;
181 | if (to != null)
182 | {
183 | string receiverName = to.Name;
184 | AppendText("Whisper to " + receiverName + ": " + txtMessage.Text + Environment.NewLine);
185 | SayAndClear(receiverName, txtMessage.Text, true);
186 | txtMessage.Focus();
187 | }
188 | }
189 |
190 | ///
191 | /// The Say button has been clicked, so conduct a
192 | /// non private message between the currentPerson and
193 | /// the all other chatters.
194 | /// Calls the SayAndClear() method with a blank "to" parameter
195 | ///
196 | /// btnSay
197 | /// The event args
198 | private void btnSay_Click(object sender, RoutedEventArgs e)
199 | {
200 | SayAndClear("", txtMessage.Text, false);
201 | txtMessage.Focus();
202 | }
203 |
204 | ///
205 | /// Raises the CloseClickEvent and the
206 | /// CloseClickEvent is raised which is used by the
207 | /// parent window
208 | ///
209 | /// lblExit
210 | /// The event args
211 | private void lblExit_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
212 | {
213 | RaiseEvent(new RoutedEventArgs(CloseClickEvent));
214 | }
215 |
216 | ///
217 | /// Simply calls the
218 | /// Proxy.SayAndClear() method passing it these
219 | /// input parameters
220 | ///
221 | /// The chatter name to send messager to
222 | /// The message to send
223 | /// True means its a private 1 to 1 message
224 | private void SayAndClear(string to, string msg, bool pvt)
225 | {
226 | if (msg != "")
227 | {
228 | try
229 | {
230 | ProxySingleton.SayAndClear(to, msg, pvt);
231 | txtMessage.Text = "";
232 | }
233 | catch
234 | {
235 | AbortProxyAndUpdateUI();
236 | AppendText("Disconnected at " + DateTime.Now.ToString() + Environment.NewLine);
237 | Error("Error: Connection to chat server lost!");
238 | }
239 | }
240 | }
241 |
242 | ///
243 | /// Shows an error message and calls the
244 | /// Proxy.AbortProxy() method
245 | ///
246 | private void AbortProxyAndUpdateUI()
247 | {
248 | ProxySingleton.AbortProxy();
249 | MessageBox.Show("An error occurred, Disconnecting");
250 | }
251 |
252 | ///
253 | /// Shows an error message and calls the
254 | /// Proxy.ExitChatSession() method
255 | ///
256 | /// The error message to display
257 | private void Error(string errMessage)
258 | {
259 | ProxySingleton.ExitChatSession();
260 | MessageBox.Show(errMessage, "Connection error", MessageBoxButton.OK, MessageBoxImage.Error);
261 |
262 | }
263 | #endregion
264 | }
265 | #endregion
266 | }
--------------------------------------------------------------------------------
/Chatters/WPFChatter/Proxy_Singleton.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Text;
6 | using System.Runtime.InteropServices;
7 | using System.ServiceModel;
8 | using System.Windows; // For MessageBox
9 |
10 | using Common;
11 |
12 | namespace WPFChatter
13 | {
14 | #region Public enums/event args
15 | ///
16 | /// A simple enumeration for dealing with the chat message types
17 | ///
18 | public enum CallBackType { Receive, ReceiveWhisper, UserEnter, UserLeave };
19 |
20 | ///
21 | /// Proxy event args
22 | ///
23 | public class ProxyEventArgs : EventArgs
24 | {
25 | ///
26 | /// Current list of Chatters
27 | ///
28 | public Person[] list;
29 | }
30 |
31 | ///
32 | /// Proxy callback event args
33 | ///
34 | public class ProxyCallBackEventArgs : EventArgs
35 | {
36 | ///
37 | /// Callback type CallBackType
38 | ///
39 | public CallBackType callbackType;
40 | ///
41 | /// The incoming message
42 | ///
43 | public string message="";
44 | ///
45 | /// The Chatters who created the
46 | /// message
47 | ///
48 | public Person person=null;
49 |
50 | }
51 | #endregion
52 | #region Proxy_Singleton class
53 | ///
54 | /// Provides a thread safe singleton which deals with
55 | /// interacting with the ChatService
56 | /// This class implements IChatCallback as such
57 | /// implementation details are found here for the expected IChatCallback
58 | /// interface methods
59 | /// This class also provides 2 events for subscribers to hook to, namely
60 | /// OnProxyCallBackEvent / OnProxyEvent.
61 | ///
62 | public sealed class Proxy_Singleton : IChatCallback
63 | {
64 | #region Instance Fields
65 | private static Proxy_Singleton singleton = null;
66 | private static readonly object singletonLock = new object();
67 | private ChatProxy proxy;
68 | private Person myPerson;
69 | private delegate void HandleDelegate(Person[] list);
70 | private delegate void HandleErrorDelegate();
71 | //main proxy event
72 | public delegate void ProxyEventHandler(object sender, ProxyEventArgs e);
73 | public event ProxyEventHandler ProxyEvent;
74 | //callback proxy event
75 | public delegate void ProxyCallBackEventHandler(object sender, ProxyCallBackEventArgs e);
76 | public event ProxyCallBackEventHandler ProxyCallBackEvent;
77 | #endregion
78 | #region Ctor
79 | ///
80 | /// Blank constructor
81 | ///
82 | private Proxy_Singleton()
83 | {
84 |
85 | }
86 | #endregion
87 | #region Public Methods
88 | #region IChatCallback implementation
89 |
90 | ///
91 | /// Recieve a message from a fellow chatter, so call the
92 | /// internal Receive() method passing it these input parameters
93 | /// and the CallBackType.Receive
94 | /// type
95 | ///
96 | /// The current chatter
97 | /// The message
98 | public void Receive(Person sender, string message)
99 | {
100 | Receive(sender, message, CallBackType.Receive);
101 | }
102 |
103 | ///
104 | /// Recieve a message from a fellow chatter, so call the
105 | /// internal Receive() method passing it these input parameters
106 | /// and the CallBackType.ReceiveWhisper
107 | /// type
108 | ///
109 | /// The current chatter
110 | /// The message
111 | public void ReceiveWhisper(Person sender, string message)
112 | {
113 | Receive(sender, message, CallBackType.ReceiveWhisper);
114 | }
115 |
116 | ///
117 | /// Calls by either the Receive() or ReceiveWhisper() IChatCallback
118 | /// method implementations, and simply raises the OnProxyCallBackEvent() event
119 | /// to any subscribers
120 | ///
121 | /// The current chatter
122 | /// The message
123 | /// Could be CallBackType.Receive or
124 | /// CallBackType.ReceiveWhisper
125 | private void Receive(Person sender, string message, CallBackType callbackType)
126 | {
127 | ProxyCallBackEventArgs e = new ProxyCallBackEventArgs();
128 | e.message = message;
129 | e.callbackType = callbackType;
130 | e.person = sender;
131 | OnProxyCallBackEvent(e);
132 | }
133 |
134 | ///
135 | /// New chatter entered chat room, so call the
136 | /// internal UserEnterLeave() method passing it the input parameters
137 | /// and the CallBackType.UserEnter
138 | /// type
139 | ///
140 | /// The current chatter
141 | /// The message
142 | public void UserEnter(Person person)
143 | {
144 | UserEnterLeave(person, CallBackType.UserEnter);
145 | }
146 |
147 | ///
148 | /// An existing chatter left chat room, so call the
149 | /// internal UserEnterLeave() method passing it the input parameters
150 | /// and the CallBackType.UserLeave
151 | /// type
152 | ///
153 | /// The current chatter
154 | /// The message
155 | public void UserLeave(Person person)
156 | {
157 | UserEnterLeave(person, CallBackType.UserLeave);
158 | }
159 |
160 | ///
161 | /// Calls by either the UserEnter() or UserLeave() IChatCallback
162 | /// method implementations, and simply raises the OnProxyCallBackEvent() event
163 | /// to any subscribers
164 | ///
165 | /// The current chatter
166 | /// The message
167 | /// Could be CallBackType.UserEnter or
168 | /// CallBackType.UserLeave
169 | private void UserEnterLeave(Person person, CallBackType callbackType)
170 | {
171 | ProxyCallBackEventArgs e = new ProxyCallBackEventArgs();
172 | e.person = person;
173 | e.callbackType = callbackType;
174 | OnProxyCallBackEvent(e);
175 | }
176 | #endregion
177 | ///
178 | /// Begins an asynchronous join operation on the underlying ChatProxy
179 | /// which will call the OnEndJoin() method on completion
180 | ///
181 | /// The chatter to try and join with
182 | public void Connect(Person p)
183 | {
184 | InstanceContext site = new InstanceContext(this);
185 | proxy = new ChatProxy(site);
186 | IAsyncResult iar = proxy.BeginJoin(p, new AsyncCallback(OnEndJoin), null);
187 | }
188 |
189 | ///
190 | /// Is called as a callback from the asynchronous call, so simply get the
191 | /// list of Chatters that will
192 | /// be yielded as part of the Asynch Join call
193 | ///
194 | /// The asnch result
195 | private void OnEndJoin(IAsyncResult iar)
196 | {
197 | try
198 | {
199 | Person[] list = proxy.EndJoin(iar);
200 | HandleEndJoin(list);
201 | }
202 | catch (Exception e)
203 | {
204 | MessageBox.Show(e.Message, "Error",
205 | MessageBoxButton.OK, MessageBoxImage.Error);
206 | }
207 | }
208 |
209 | ///
210 | /// If the input list is not empty, then call the
211 | /// OnProxyEvent() event, to raise the event for subscribers
212 | ///
213 | /// The list of Chatters
214 | private void HandleEndJoin(Person[] list)
215 | {
216 |
217 | if (list == null)
218 | {
219 | MessageBox.Show("Error: List is empty", "Error",
220 | MessageBoxButton.OK, MessageBoxImage.Error);
221 | ExitChatSession();
222 | }
223 | else
224 | {
225 | ProxyEventArgs e = new ProxyEventArgs();
226 | e.list = list;
227 | OnProxyEvent(e);
228 | }
229 | }
230 |
231 | ///
232 | /// Raises the event for connected subscribers
233 | ///
234 | /// ProxyCallBackEventArgs event args
235 | protected void OnProxyCallBackEvent(ProxyCallBackEventArgs e)
236 | {
237 | if (ProxyCallBackEvent != null)
238 | {
239 | // Invokes the delegates.
240 | ProxyCallBackEvent(this, e);
241 | }
242 | }
243 |
244 | ///
245 | /// Raises the event for connected subscribers
246 | ///
247 | /// ProxyEventArgs event args
248 | protected void OnProxyEvent(ProxyEventArgs e)
249 | {
250 | if (ProxyEvent != null)
251 | {
252 | // Invokes the delegates.
253 | ProxyEvent(this, e);
254 | }
255 | }
256 |
257 | ///
258 | /// Returns a singleton Proxy_Singleton
259 | ///
260 | /// a singleton Proxy_Singleton
261 | public static Proxy_Singleton GetInstance()
262 | {
263 | //critical section, which ensures the singleton
264 | //is thread safe
265 | lock (singletonLock)
266 | {
267 | if (singleton == null)
268 | {
269 | singleton = new Proxy_Singleton();
270 | }
271 | return singleton;
272 | }
273 | }
274 |
275 | ///
276 | /// Will either call the Whisper/Say ChatProxy methods
277 | /// passing in the required parameters.
278 | ///
279 | /// The chatters name who the message
280 | /// is for
281 | /// The message
282 | /// If true will call the ChatProxy.Whisper()
283 | /// method, otherwise will call the ChatProxy.Say() method
284 | public void SayAndClear(string to, string msg, bool pvt)
285 | {
286 | if (!pvt)
287 | proxy.Say(msg);
288 | else
289 | proxy.Whisper(to, msg);
290 | }
291 |
292 | ///
293 | /// First calls the ChatProxy.Leave (ClientBase<IChat>.Leave())
294 | /// method, and finally calls the AbortProxy() method
295 | ///
296 | public void ExitChatSession()
297 | {
298 | try
299 | {
300 | proxy.Leave();
301 | }
302 | catch { }
303 | finally
304 | {
305 | AbortProxy();
306 | }
307 | }
308 |
309 | ///
310 | /// Calls the ChatProxy.Abort (ClientBase<IChat>.Abort()) and also
311 | /// the ChatProxy.Close (ClientBase<IChat>.Close()) methods
312 | ///
313 | public void AbortProxy()
314 | {
315 | if (proxy != null)
316 | {
317 | proxy.Abort();
318 | proxy.Close();
319 | proxy = null;
320 | }
321 | }
322 | #endregion
323 | }
324 | #endregion
325 | }
326 |
--------------------------------------------------------------------------------