Merge pull request #97 from flokuep/develop
Fixes #96 - Also added message if server is not running.
This commit is contained in:
commit
722a3279d5
5 files changed
+73
-11
No files matched your search
@@ -203,9 +203,9 @@ namespace ServerLib
|
||||
_Init(port, encrypted);
|
||||
}
|
||||
|
||||
public static string GetLocalAddress()
|
||||
public string GetBaseAddress()
|
||||
{
|
||||
return Dns.GetHostName();
|
||||
return _BaseAddress.AbsoluteUri;
|
||||
|
||||
/*IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
|
||||
foreach (IPAddress ip in ips)
|
||||
@@ -216,6 +216,11 @@ namespace ServerLib
|
||||
return "";*/
|
||||
}
|
||||
|
||||
public bool IsRunning()
|
||||
{
|
||||
return _Host.State == CommunicationState.Opened;
|
||||
}
|
||||
|
||||
#region server control
|
||||
|
||||
private void _Init(int port, bool encrypted)
|
||||
|
||||
@@ -216,4 +216,5 @@
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_BOTTOMRIGHT">Bottom right</string>
|
||||
<string name="TR_SCREENPVOLUMECONTROL_VOLUME">Volume</string>
|
||||
<string name="TR_SCREENPSERVERQR_ADDRESS">Server address</string>
|
||||
<string name="TR_SCREENPSERVERQR_NOTRUNNING">Server is not running. Please check config.xml!</string>
|
||||
</resources>
|
||||
@@ -131,6 +131,36 @@
|
||||
<!-- <Space>: Reflection Space-->
|
||||
<!-- <Height>: Reflection Height-->
|
||||
</TextServerAddress>
|
||||
<TextServerNotRunning>
|
||||
<!--<X>, <Y>: Text position-->
|
||||
<X>640</X>
|
||||
<Y>265</Y>
|
||||
<!--<Z>: Text position-->
|
||||
<Z>-2,00</Z>
|
||||
<!--<H>: Text height-->
|
||||
<H>45</H>
|
||||
<!--<MaxW>: Maximum text width (if exists)-->
|
||||
<MaxW>600</MaxW>
|
||||
<!--<Color>: Text color from ColorScheme (high priority)-->
|
||||
<!--or <R>, <G>, <B>, <A> (lower priority)-->
|
||||
<Color>StaticColor</Color>
|
||||
<!--<SColor>: Selected Text color from ColorScheme (high priority)-->
|
||||
<!--or <SR>, <SG>, <SB>, <SA> (lower priority)-->
|
||||
<SColor>TextSColor</SColor>
|
||||
<!--<Align>: Text align horizontal: Left, Center, Right-->
|
||||
<Align>Center</Align>
|
||||
<!--<ResizeAlign>: Text align vertical (on downsizing): Top, Center, Bottom-->
|
||||
<HAlign>Center</HAlign>
|
||||
<!--<Style>: Text style: Normal, Italic, Bold, BoldItalic-->
|
||||
<Style>Bold</Style>
|
||||
<!--<Font>: Text font name-->
|
||||
<Font>Outline</Font>
|
||||
<!--<Text>: Nothing or translation tag-->
|
||||
<Text>TR_SCREENPSERVERQR_NOTRUNNING</Text>
|
||||
<!--<Reflection> If exists:-->
|
||||
<!-- <Space>: Reflection Space-->
|
||||
<!-- <Height>: Reflection Height-->
|
||||
</TextServerNotRunning>
|
||||
<Text1>
|
||||
<!--<X>, <Y>: Text position-->
|
||||
<X>640</X>
|
||||
|
||||
@@ -88,6 +88,19 @@ namespace Vocaluxe.Base.Server
|
||||
//_Discover.Stop();
|
||||
}
|
||||
|
||||
public static string GetServerAddress()
|
||||
{
|
||||
return _Server == null ? "" : _Server.GetBaseAddress();
|
||||
}
|
||||
|
||||
public static bool IsServerRunning()
|
||||
{
|
||||
if (_Server == null)
|
||||
return false;
|
||||
|
||||
return _Server.IsRunning();
|
||||
}
|
||||
|
||||
private static bool _SendKeyEvent(string key)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
using ServerLib;
|
||||
using Vocaluxe.Base;
|
||||
using Vocaluxe.Base.Server;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Draw;
|
||||
@@ -45,25 +46,37 @@ namespace Vocaluxe.Screens
|
||||
private const string _StaticQRWindowsPhone = "StaticQRWindowsPhone";
|
||||
|
||||
private const string _TextServerAddress = "TextServerAddress";
|
||||
private const string _TextServerNotRunning = "TextServerNotRunning";
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeStatics = new string[] { _StaticQRServer, _StaticQRAndroid, _StaticQRSymbian, _StaticQRWebOS, _StaticQRWindowsPhone };
|
||||
_ThemeTexts = new string[] { _TextServerAddress };
|
||||
_ThemeTexts = new string[] { _TextServerAddress, _TextServerNotRunning };
|
||||
}
|
||||
|
||||
public override void LoadTheme(string xmlPath)
|
||||
{
|
||||
base.LoadTheme(xmlPath);
|
||||
_GenerateQRs();
|
||||
_Statics[_StaticQRServer].Texture = _QRServerAddress;
|
||||
_Statics[_StaticQRAndroid].Texture = _QRAndroidLink;
|
||||
_Statics[_StaticQRSymbian].Texture = _QRSymbianLink;
|
||||
_Statics[_StaticQRWebOS].Texture = _QRWebOSLink;
|
||||
_Statics[_StaticQRWindowsPhone].Texture = _QRWindowsPhoneLink;
|
||||
_Texts[_TextServerAddress].Text = CServer.GetLocalAddress() + ":" + CConfig.ServerPort;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
if (_QRServerAddress == null)
|
||||
{
|
||||
_GenerateQRs();
|
||||
_Statics[_StaticQRServer].Texture = _QRServerAddress;
|
||||
_Statics[_StaticQRAndroid].Texture = _QRAndroidLink;
|
||||
_Statics[_StaticQRSymbian].Texture = _QRSymbianLink;
|
||||
_Statics[_StaticQRWebOS].Texture = _QRWebOSLink;
|
||||
_Statics[_StaticQRWindowsPhone].Texture = _QRWindowsPhoneLink;
|
||||
_Texts[_TextServerAddress].Text = CVocaluxeServer.GetServerAddress();
|
||||
}
|
||||
_Texts[_TextServerAddress].Visible = CVocaluxeServer.IsServerRunning();
|
||||
_Statics[_StaticQRServer].Visible = CVocaluxeServer.IsServerRunning();
|
||||
_Texts[_TextServerNotRunning].Visible = !CVocaluxeServer.IsServerRunning();
|
||||
}
|
||||
|
||||
public override bool HandleMouse(SMouseEvent mouseEvent)
|
||||
@@ -94,7 +107,7 @@ namespace Vocaluxe.Screens
|
||||
QRCodeGenerator qr = new QRCodeGenerator();
|
||||
|
||||
//ServerAddress
|
||||
QRCodeGenerator.QRCode qrcode = qr.CreateQrCode(CServer.GetLocalAddress() + ":" + CConfig.ServerPort, QRCodeGenerator.ECCLevel.H);
|
||||
QRCodeGenerator.QRCode qrcode = qr.CreateQrCode(CVocaluxeServer.GetServerAddress(), QRCodeGenerator.ECCLevel.H);
|
||||
_QRServerAddress = CDraw.AddTexture(qrcode.GetGraphic(20));
|
||||
|
||||
//Android
|
||||
|
||||
Reference in new issue
Block a user