#region Windows-Store
//------------------<
region: Windows-Store >------------------
private StoreContext _Store_context = null;
private StoreAppLicense appLicense = null;
private String _Store_SkuStoreId = null;
private StoreLicense _Store_addOnLicense_0 = null;
private bool _Store_IsPaid = false;
private bool _Store_IsTestperiod = true;
private DateTime _Store_DateStart_TestPeriod = Convert.ToDateTime(null);
private int _Store_Testrange_in_Days = 30;
private async void init_Store()
{
//-------------<
init_Store()-------------
//< get variables >
await check_Store_IsPaid();
if (_Store_IsPaid == false)
{
await check_init_Store_Testperiod();
}
//</ get variables >
//< set Controls >
if (_Store_IsPaid == true )
{
btnStore.Visibility = Visibility.Collapsed;
}
else
{
if (_Store_IsTestperiod==true
)
{
//*IsTestperiod: everything works
}
else
{
//< Testperiod is over >
btnStore.Visibility = Visibility.Visible;
btnOptions.IsEnabled = false;
btnControllers.IsEnabled
= false;
//</ Testperiod is over >
}
}
//</ set Controls >
//-------------</
init_Store()-------------
}
public async Task<bool> check_init_Store_Testperiod()
{
//-------------<
check_init_Store_Testperiod()-------------
//----< get Start_Testperiod >----
try
{
//< Get Setting >
var varDateStart_TestPeriod = ApplicationData.Current.LocalSettings.Values["DateStart_TestPeriod"];
//</ Get Setting >
if (varDateStart_TestPeriod is null)
{
//< init testperiod >
_Store_DateStart_TestPeriod = DateTime.Now;
//< Save Setting >
ApplicationData.Current.LocalSettings.Values["DateStart_TestPeriod"] =
_Store_DateStart_TestPeriod.ToString();
//</ Save Setting >
//</ init testperiod >
}
else
{
//< convert setting >
_Store_DateStart_TestPeriod = Convert.ToDateTime(varDateStart_TestPeriod);
//</ convert setting >
}
}
catch (Exception ex)
{
//< error >
MessageDialog dialog = new MessageDialog( ex.Message , "Information: Check Store
TestPeriod");
await dialog.ShowAsync();
return false;
//</ error >
}
//----</ get Start_Testperiod
>----
//----< check in TestPeriod >----
if(_Store_DateStart_TestPeriod.AddDays(_Store_Testrange_in_Days)>DateTime.Now )
{ _Store_IsTestperiod = true; }
else
{ _Store_IsTestperiod = false ; }
//----</ check in TestPeriod >----
//< output >
return _Store_IsTestperiod;
//</ output >
//-------------</
check_init_Store_Testperiod()-------------
}
public async Task<bool> check_Store_IsPaid()
{
//-------------<
check_Store_IsPaid()-------------
//< check ok >
if(_Store_IsPaid ==true)
{
return true;
}
//</ check ok >
//----< get Setting: Store_IsPaid
>----
try
{
//< Get Setting >
var varStore_IsPaid = ApplicationData.Current.LocalSettings.Values["Store_IsPaid"];
//</ Get Setting >
if (varStore_IsPaid is null)
{
//< init testperiod >
_Store_IsPaid = false;
//< Save Setting >
ApplicationData.Current.LocalSettings.Values["Store_IsPaid"] = _Store_IsPaid ;
//</ Save Setting >
//</ init testperiod >
}
else
{
//< convert setting >
_Store_IsPaid = Convert.ToBoolean(varStore_IsPaid);
//</ convert setting >
}
}
catch (Exception ex)
{
//< error >
MessageDialog dialog = new MessageDialog(ex.Message, "Information: Check Store Addon
is Paid");
await dialog.ShowAsync();
return false;
//</ error >
}
//----</ get Setting: Store_IsPaid
>----
//< output >
return _Store_IsPaid;
//</ output >
//-------------</
check_Store_IsPaid()-------------
}
public async Task<bool> get_Store_IsPaid()
{
//-------------<
get_Store_LicenseInfo()-------------
if (_Store_context == null)
{
_Store_context = StoreContext.GetDefault(); //UWP App
}
//< get Store Data >
appLicense = await _Store_context.GetAppLicenseAsync();
//</ get Store Data >
if (appLicense == null)
{
return false;
}
else
{
//--< show License Infos >--
_Store_SkuStoreId=
appLicense.SkuStoreId;
if (appLicense.AddOnLicenses.Count>0)
{
foreach (KeyValuePair<string, StoreLicense> item in appLicense.AddOnLicenses)
{
_Store_addOnLicense_0
= item.Value;
//--< check first AddOn
>--
if(_Store_addOnLicense_0.IsActive==true)
{
_Store_IsPaid = true;
return true;
}
break;
//--</ check first AddOn
>--
}
}
//* nothing found is false
return false ;
//--</ show License Infos >--
}
//-------------</
get_Store_LicenseInfo()-------------
}
public async Task<bool> get_Store_AddOn_License_0()
{
//-------------<
get_Store_AddOn_License_0()-------------
if (_Store_context == null)
{
_Store_context = StoreContext.GetDefault(); //UWP App
}
//< get Store Data >
appLicense = await _Store_context.GetAppLicenseAsync();
//</ get Store Data >
if (appLicense == null)
{
return false;
}
else
{
//--< show License Infos >--
if (appLicense.AddOnLicenses.Count > 0)
{
foreach (KeyValuePair<string, StoreLicense> item in appLicense.AddOnLicenses)
{
_Store_addOnLicense_0
= item.Value;
return true;
//--</ check first AddOn
>--
}
}
//* nothing found is false
return false;
//--</ show License Infos >--
}
//-------------</
get_Store_AddOn_License_0()-------------
}
#endregion /Windows-Store
|