1) One of the first things you should notice is your XAML Source View.
[You must be registered and logged in to see this image.]This is how you will be designing the Graphical User Interface of your Application.
It won't be too hard if your wanting to make something basic.
2) Just like C#/VB/.net applications, theirs a toolbar for you to add controls to your APP. Add a button to your APP.
[You must be registered and logged in to see this image.]3) Click on the button. You will see the properties for it popup on the rightside of Visual Studio. Navigate to "Common" tab and change the 'Content' to "Connect and attach".
[You must be registered and logged in to see this image.]Also, change the button name to ConnectButton, this is so XAML has a name for this control.
[You must be registered and logged in to see this image.](If it doesn't show up, right click in solution explorer and click "Properties")
[You must be registered and logged in to see this image.]3.1) Add a toggleswitch and name it "VSATtoggle". Also change the header to "VSAT".
3.2) Add a textbox and name it "ipaddresstextbox", and put the Content as your PS3IP or blank.
*Note: you can change the tooltip and placeholder text.
[You must be registered and logged in to see this image.]4) Double click on your Connect & Attach button (or right click>"View Code"). C#!
Look familiar.
5) Time to code!
*Put this as all your imports for the current C# classview*
- Code:
-
using System;
using System.Text;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.Popups;
using System.Runtime.InteropServices;
using Windows.System;
Put the following code inside your button:
- Code:
-
try
{
var dialog1 = new MessageDialog("Connect IP: " + ipaddresstextbox.Text + "?" + Environment.NewLine + "CEX ONLY!", "Connect to PS3");
dialog1.Commands.Add(new UICommand("CEX", new UICommandInvokedHandler(CommandHandler)));
dialog1.Commands.Add(new UICommand("DEX", new UICommandInvokedHandler(CommandHandler)));
dialog1.Commands.Add(new UICommand("Cancel", new UICommandInvokedHandler(CommandHandler)));
dialog1.DefaultCommandIndex = 3;
dialog1.CancelCommandIndex = 1;
attachbutton.IsEnabled = true;
await dialog1.ShowAsync();
}
catch
{
var Mesg = new MessageDialog("Failure Connecting!", "Error!");
await Mesg.ShowAsync();
}
You should get an error "The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.", add 'async' to your button like so:
- Code:
-
private async void Button_Click(object sender, RoutedEventArgs e)//...ETC
//(Inbetween 'private' & 'void' of your button, put "async").
6) Add these constructors somewhere in your code (Within the form boundaries).
- Code:
-
public PS3Lib.CCAPI CEX = new PS3Lib.CCAPI();
public PS3Lib.Extension EXT = new PS3Lib.Extension();
public PS3Lib.PS3API ps3api = new PS3Lib.PS3API(PS3Lib.SelectAPI.ControlConsole);
private void CommandHandler(IUICommand command)//added async
{
var commandLabel = command.Label;
switch (commandLabel)
{
case "CEX":
if (Convert.ToBoolean(CEX.ConnectTarget(ipaddresstextbox.Text)))
{
CEX.RingBuzzer(PS3Lib.CCAPI.BuzzerMode.Single);
CEX.Notify(PS3Lib.CCAPI.NotifyIcon.FRIEND, "Connected!");
MessageDialog CEXConnect = new MessageDialog("SUCCESS!", "Connected to CEX!");
// await CEXConnect.ShowAsync(); <- This doesn't work. Try to find a way around this.
}
else
{
MessageDialog CEXConnect = new MessageDialog("Error!", "Failure Connecting to CEX!");
// await CEXConnect.ShowAsync(); <- This doesn't work. Try to find a way around this.
}
break;
case "DEX":
//Nothing
break;
case "Cancel":
//Nothing
break;
}
}
7) Add "async" to your switch just like the button & add this code to your switch:
async:
- Code:
-
private async void ToggleSwitch_Toggled(object sender, RoutedEventArgs e)
- Code:
-
ToggleSwitch toggleswitch = sender as ToggleSwitch;
if (toggleswitch.IsOn == true)
{
MessageDialog MyMessage = new MessageDialog("Activated", "VSAT");
//MessageDialog MyMessage = new MessageDialog(Description text, TITLE TEXT);
byte[] buffer = new byte[4];
buffer[0] = 0x60;
xmain.CEX.SetMemory(0x33c60, buffer);
await MyMessage.ShowAsync();
}
else
{
MessageDialog MyMessage = new MessageDialog("Deactivated", "VSAT");
xmain.CEX.SetMemory(0x33c60, new byte[] { 0x40, 0x81, 0, 0x44 });
await MyMessage.ShowAsync();
}
Run your APP *and look keep an eye on the debugger for any errors!*
[You must be registered and logged in to see this image.]9) Put your PS3 Ipaddress in, Click connect and attach. *You should hear your PS3 beep, and show a notification
9.1) Click on the switch, and see if it turned VSAT on!
10) That's it!