private XYMultipleSeriesDataset GetDateDemoDataset()
 {
     XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
     const int nr = 10;
     long value = new Java.Util.Date().Time - 3 * TimeChart.Day;
     Random r = new Random();
     for (int i = 0; i < SERIES_NR; i++)
     {
         TimeSeries series = new TimeSeries("Demo series " + (i + 1));
         for (int k = 0; k < nr; k++)
         {
             series.Add(new Java.Util.Date(value + k * TimeChart.Day / 4), 20 + r.Next() % 100);
         }
         dataset.AddSeries(series);
     }
     return dataset;
 }
    public RaygunEnvironmentMessage()
    {
#if WINRT
      //WindowBoundsHeight = Windows.UI.Xaml.Window.Current.Bounds.Height;
      //WindowBoundsWidth = Windows.UI.Xaml.Window.Current.Bounds.Width;
      PackageVersion = string.Format("{0}.{1}", Package.Current.Id.Version.Major, Package.Current.Id.Version.Minor);
      Cpu = Package.Current.Id.Architecture.ToString();      
      ResolutionScale = DisplayProperties.ResolutionScale.ToString();
      CurrentOrientation = DisplayProperties.CurrentOrientation.ToString();
      Location = Windows.System.UserProfile.GlobalizationPreferences.HomeGeographicRegion;

      DateTime now = DateTime.Now;
      UtcOffset = TimeZoneInfo.Local.GetUtcOffset(now).TotalHours;

      SYSTEM_INFO systemInfo = new SYSTEM_INFO();
      RaygunSystemInfoWrapper.GetNativeSystemInfo(ref systemInfo);
      Architecture = systemInfo.wProcessorArchitecture.ToString();
#elif WINDOWS_PHONE
      Locale = CultureInfo.CurrentCulture.DisplayName;
      OSVersion = Environment.OSVersion.Platform + " " + Environment.OSVersion.Version;
      object deviceName;
      DeviceExtendedProperties.TryGetValue("DeviceName", out deviceName);
      DeviceName = deviceName.ToString();

      WindowBoundsWidth = Application.Current.RootVisual.RenderSize.Width;
      WindowBoundsHeight = Application.Current.RootVisual.RenderSize.Height;

      DateTime now = DateTime.Now;
      UtcOffset = TimeZoneInfo.Local.GetUtcOffset(now).TotalHours;

      PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
      if (frame != null)
      {
        CurrentOrientation = frame.Orientation.ToString();
      }

      //ProcessorCount = Environment.ProcessorCount;
      // TODO: finish other values
#elif ANDROID
      try
      {
        Java.Util.TimeZone tz = Java.Util.TimeZone.Default;
        Java.Util.Date now = new Java.Util.Date();
        UtcOffset = tz.GetOffset(now.Time) / 3600000.0;

        OSVersion = Android.OS.Build.VERSION.Sdk;

        Locale = CultureInfo.CurrentCulture.DisplayName;

        var metrics = Resources.System.DisplayMetrics;
        WindowBoundsWidth = metrics.WidthPixels;
        WindowBoundsHeight = metrics.HeightPixels;

        Context context = RaygunClient.Context;
        if (context != null)
        {
          PackageManager manager = context.PackageManager;
          PackageInfo info = manager.GetPackageInfo(context.PackageName, 0);
          PackageVersion = info.VersionCode + " / " + info.VersionName;

          IWindowManager windowManager = context.GetSystemService(Context.WindowService).JavaCast<IWindowManager>();
          if (windowManager != null)
          {
            Display display = windowManager.DefaultDisplay;
            if (display != null)
            {
              switch (display.Rotation)
              {
                case SurfaceOrientation.Rotation0:
                  CurrentOrientation = "Rotation 0 (Portrait)";
                  break;
                case SurfaceOrientation.Rotation180:
                  CurrentOrientation = "Rotation 180 (Upside down)";
                  break;
                case SurfaceOrientation.Rotation270:
                  CurrentOrientation = "Rotation 270 (Landscape right)";
                  break;
                case SurfaceOrientation.Rotation90:
                  CurrentOrientation = "Rotation 90 (Landscape left)";
                  break;
              }
            }
          }
        }

        DeviceName = RaygunClient.DeviceName;

        Java.Lang.Runtime runtime = Java.Lang.Runtime.GetRuntime();
        TotalPhysicalMemory = (ulong)runtime.TotalMemory();
        AvailablePhysicalMemory = (ulong)runtime.FreeMemory();
        
        ProcessorCount = runtime.AvailableProcessors();
        Architecture = Android.OS.Build.CpuAbi;
        Model = string.Format("{0} / {1} / {2}", Android.OS.Build.Model, Android.OS.Build.Brand, Android.OS.Build.Manufacturer);
      }
      catch (Exception ex)
      {
        System.Diagnostics.Debug.WriteLine(string.Format("Error getting environment info {0}", ex.Message));
      }
#elif IOS
      UtcOffset = NSTimeZone.LocalTimeZone.GetSecondsFromGMT / 3600.0;

      OSVersion = UIDevice.CurrentDevice.SystemName + " " + UIDevice.CurrentDevice.SystemVersion;
      Architecture =  GetStringSysCtl(ArchitecturePropertyName);
      Model = UIDevice.CurrentDevice.Model;
      ProcessorCount = (int)GetIntSysCtl(ProcessiorCountPropertyName);

      Locale = CultureInfo.CurrentCulture.DisplayName;

      UIApplication.SharedApplication.InvokeOnMainThread(() => {
      WindowBoundsWidth = UIScreen.MainScreen.Bounds.Width;
      WindowBoundsHeight = UIScreen.MainScreen.Bounds.Height;
      });

      CurrentOrientation = UIDevice.CurrentDevice.Orientation.ToString();

      TotalPhysicalMemory = GetIntSysCtl(TotalPhysicalMemoryPropertyName);
      AvailablePhysicalMemory = GetIntSysCtl(AvailablePhysicalMemoryPropertyName);

      DeviceName = UIDevice.CurrentDevice.Name;
      PackageVersion = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleVersion").ToString();
#else
      WindowBoundsWidth = SystemInformation.VirtualScreen.Height;
      WindowBoundsHeight = SystemInformation.VirtualScreen.Width;
      ComputerInfo info = new ComputerInfo();
      Locale = CultureInfo.CurrentCulture.DisplayName;

      DateTime now = DateTime.Now;
      UtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(now).TotalHours;

      OSVersion = info.OSVersion;

      if (!RaygunSettings.Settings.MediumTrust)
      {
        try
        {
          Architecture = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
          TotalPhysicalMemory = (ulong)info.TotalPhysicalMemory / 0x100000; // in MB
          AvailablePhysicalMemory = (ulong)info.AvailablePhysicalMemory / 0x100000;
          TotalVirtualMemory = info.TotalVirtualMemory / 0x100000;
          AvailableVirtualMemory = info.AvailableVirtualMemory / 0x100000;
          GetDiskSpace();
          Cpu = GetCpu();
        }
        catch (SecurityException)
        {
          System.Diagnostics.Trace.WriteLine("RaygunClient error: couldn't access environment variables. If you are running in Medium Trust, in web.config in RaygunSettings set mediumtrust=\"true\"");
        }
      }
#endif
    }
        public static RaygunEnvironmentMessage Build()
        {
            RaygunEnvironmentMessage message = new RaygunEnvironmentMessage();

              try
              {
            var metrics = Resources.System.DisplayMetrics;
            message.WindowBoundsWidth = metrics.WidthPixels;
            message.WindowBoundsHeight = metrics.HeightPixels;
              }
              catch (Exception ex)
              {
            System.Diagnostics.Trace.WriteLine(string.Format("Error retrieving screen dimensions: {0}", ex.Message));
              }

              try
              {
            Java.Util.TimeZone tz = Java.Util.TimeZone.Default;
            Java.Util.Date now = new Java.Util.Date();
            message.UtcOffset = tz.GetOffset(now.Time) / 3600000.0;
            message.Locale = CultureInfo.CurrentCulture.DisplayName;
              }
              catch (Exception ex)
              {
            System.Diagnostics.Trace.WriteLine(string.Format("Error retrieving time and locale: {0}", ex.Message));
              }

              try
              {
            Context context = RaygunClient.Context;
            if (context != null)
            {
              IWindowManager windowManager = context.GetSystemService(Context.WindowService).JavaCast<IWindowManager>();
              if (windowManager != null)
              {
            Display display = windowManager.DefaultDisplay;
            if (display != null)
            {
              switch (display.Rotation)
              {
                case SurfaceOrientation.Rotation0:
                  message.CurrentOrientation = "Rotation 0 (Portrait)";
                  break;
                case SurfaceOrientation.Rotation180:
                  message.CurrentOrientation = "Rotation 180 (Upside down)";
                  break;
                case SurfaceOrientation.Rotation270:
                  message.CurrentOrientation = "Rotation 270 (Landscape right)";
                  break;
                case SurfaceOrientation.Rotation90:
                  message.CurrentOrientation = "Rotation 90 (Landscape left)";
                  break;
              }
            }
              }
            }
              }
              catch (Exception ex)
              {
            System.Diagnostics.Trace.WriteLine(string.Format("Error retrieving orientation: {0}", ex.Message));
              }

              try
              {
            Java.Lang.Runtime runtime = Java.Lang.Runtime.GetRuntime();
            message.TotalPhysicalMemory = (ulong)runtime.TotalMemory();
            message.AvailablePhysicalMemory = (ulong)runtime.FreeMemory();
            message.OSVersion = Android.OS.Build.VERSION.Sdk;
            message.ProcessorCount = runtime.AvailableProcessors();
            message.Architecture = Android.OS.Build.CpuAbi;
            message.Model = string.Format("{0} / {1}", Android.OS.Build.Model, Android.OS.Build.Brand);
            message.DeviceManufacturer = Android.OS.Build.Manufacturer;
              }
              catch (Exception ex)
              {
            System.Diagnostics.Trace.WriteLine(string.Format("Error retrieving device info: {0}", ex.Message));
              }

              return message;
        }
        public RaygunEnvironmentMessage()
        {
            try
              {
            Java.Util.TimeZone tz = Java.Util.TimeZone.Default;
            Java.Util.Date now = new Java.Util.Date();
            UtcOffset = tz.GetOffset(now.Time) / 3600000.0;

            OSVersion = Android.OS.Build.VERSION.Sdk;

            Locale = CultureInfo.CurrentCulture.DisplayName;

            var metrics = Resources.System.DisplayMetrics;
            WindowBoundsWidth = metrics.WidthPixels;
            WindowBoundsHeight = metrics.HeightPixels;

            Context context = RaygunClient.Context;
            if (context != null)
            {
              PackageManager manager = context.PackageManager;
              PackageInfo info = manager.GetPackageInfo(context.PackageName, 0);
              PackageVersion = info.VersionCode + " / " + info.VersionName;

              IWindowManager windowManager = context.GetSystemService(Context.WindowService).JavaCast<IWindowManager>();
              if (windowManager != null)
              {
            Display display = windowManager.DefaultDisplay;
            if (display != null)
            {
              switch (display.Rotation)
              {
                case SurfaceOrientation.Rotation0:
                  CurrentOrientation = "Rotation 0 (Portrait)";
                  break;
                case SurfaceOrientation.Rotation180:
                  CurrentOrientation = "Rotation 180 (Upside down)";
                  break;
                case SurfaceOrientation.Rotation270:
                  CurrentOrientation = "Rotation 270 (Landscape right)";
                  break;
                case SurfaceOrientation.Rotation90:
                  CurrentOrientation = "Rotation 90 (Landscape left)";
                  break;
              }
            }
              }
            }

            DeviceName = RaygunClient.DeviceName;

            Java.Lang.Runtime runtime = Java.Lang.Runtime.GetRuntime();
            TotalPhysicalMemory = (ulong)runtime.TotalMemory();
            AvailablePhysicalMemory = (ulong)runtime.FreeMemory();

            ProcessorCount = runtime.AvailableProcessors();
            Architecture = Android.OS.Build.CpuAbi;
            Model = string.Format("{0} / {1} / {2}", Android.OS.Build.Model, Android.OS.Build.Brand, Android.OS.Build.Manufacturer);
              }
              catch (Exception ex)
              {
            System.Diagnostics.Debug.WriteLine(string.Format("Error getting environment info {0}", ex.Message));
              }
        }
Пример #5
0
 public static string ToDeviceDateString (this DateTime self)
 {
     var javaDate = new Java.Util.Date ((long)self.ToUnix ().TotalMilliseconds);
     return DateFormat.GetDateFormat (ServiceContainer.Resolve<Context> ()).Format (javaDate);
 }
 // Load the cached receipts from file and return the decrypted result.
 IList<Receipt> FromCache()
 {
     OuyaFacade.Log("Returning cached receipts");
     IList<Receipt> receipts = null;
     string encryptedReceipts = string.Empty;
     using (var store = IsolatedStorageFile.GetUserStoreForApplication())
     {
         if (store.FileExists(receiptsFileName))
         {
             using (var reader = new StreamReader(store.OpenFile(receiptsFileName, FileMode.Open)))
             {
                 encryptedReceipts = reader.ReadToEnd();
             }
         }
     }
     if (!string.IsNullOrEmpty(encryptedReceipts))
     {
         var decryptedReceipts = CryptoHelper.Decrypt(encryptedReceipts, _gamerUuid);
         var json = new JSONObject(decryptedReceipts);
         var list = json.OptJSONArray("receipts");
         if (list != null)
         {
             receipts = new List<Receipt>(list.Length());
             for (int i = 0; i < list.Length(); ++i)
             {
                 var node = list.GetJSONObject(i);
                 var identifier = node.GetString("identifier");
                 var priceInCents = node.GetInt("priceInCents");
                 var purchaseDate = new Java.Util.Date(node.GetString("purchaseDate"));
                 var generatedDate = new Java.Util.Date(node.GetString("generatedDate"));
                 var gamerUuid = node.GetString("gamerUuid");
                 var uuid = node.GetString("uuid");
                 var receipt = new Receipt(identifier, priceInCents, purchaseDate, generatedDate, gamerUuid, uuid);
                 receipts.Add(receipt);
             }
         }
     }
     return receipts;
 }
Пример #7
0
 // Load the cached receipts from file and return the decrypted result.
 internal static IList<Receipt> FromCache(string gamerUuid)
 {
     OuyaFacade.Log("Returning cached receipts");
     IList<Receipt> receipts = null;
     string encryptedReceipts = string.Empty;
     using (var store = IsolatedStorageFile.GetUserStoreForApplication())
     {
         if (store.FileExists(receiptsFileName))
         {
             using (var reader = new StreamReader(store.OpenFile(receiptsFileName, FileMode.Open)))
             {
                 encryptedReceipts = reader.ReadToEnd();
             }
         }
     }
     if (!string.IsNullOrEmpty(encryptedReceipts))
     {
         var decryptedReceipts = CryptoHelper.Decrypt(encryptedReceipts, gamerUuid);
         var json = new JSONObject(decryptedReceipts);
         var list = json.OptJSONArray("receipts");
         if (list != null)
         {
             receipts = new List<Receipt>(list.Length());
             for (int i = 0; i < list.Length(); ++i)
             {
                 var node = list.GetJSONObject(i);
                 var identifier = node.GetString("identifier");
                 var priceInCents = node.GetInt("priceInCents");
                 var purchaseDate = new Java.Util.Date(node.GetString("purchaseDate"));
                 var generatedDate = new Java.Util.Date(node.GetString("generatedDate"));
                 var gamer = node.GetString("gamerUuid");
                 var uuid = node.GetString("uuid");
                 // Cater for reading old receipts written with pre-1.0.8
                 double localPrice = priceInCents / 100.0;
                 string currencyCode = "USD";
                 try
                 {
                     localPrice = node.GetDouble("localPrice");
                     currencyCode = node.GetString("currencyCode");
                 }
                 catch (JSONException)
                 {
                     OuyaFacade.Log("Older receipt found. Assuming USD price.");
                 }
                 var receipt = new Receipt(identifier, priceInCents, purchaseDate, generatedDate, gamer, uuid, localPrice, currencyCode);
                 receipts.Add(receipt);
             }
         }
     }
     // Return an empty list if nothing was found
     if (receipts == null)
         receipts = new List<Receipt>();
     return receipts;
 }
        public static Task SendMessageTaskAsync(this IBandNotificationManager manager, Java.Util.UUID tileId, string title, string body, DateTime date, MessageFlags flags)
        {
			var javaDate = new Java.Util.Date(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second);
			return manager.SendMessageTaskAsync(tileId, title, body, javaDate, flags);
        }
        private void Calendar_DaySlotLoading(object sender, CalendarDaySlotLoadingEventArgs e)
        {
            // get day
            Java.Util.Date     date = e.Date;
            Java.Util.Calendar cal  = Java.Util.Calendar.GetInstance(Java.Util.Locale.English);
            cal.Time = date;
            int day = cal.Get(Java.Util.CalendarField.DayOfMonth);

            // create day slot layout container
            CalendarDaySlotBase layout = new CalendarDaySlotBase(ApplicationContext);

            layout.SetGravity(GravityFlags.Top);
            layout.SetVerticalGravity(GravityFlags.Top);
            layout.Orientation = Orientation.Vertical;
            layout.SetPadding(5, 5, 5, 5);
            LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.FillParent);
            layout.LayoutParameters = linearLayoutParams;

            // create text element
            TextView tv = new TextView(ApplicationContext);

            //LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
            //vv.LayoutParameters = linearLayoutParams;
            tv.Gravity = GravityFlags.Top;
            tv.Text    = day.ToString();

            if (e.AdjacentDay)
            {
                // format adjacent day text
                tv.SetTextColor(Android.Graphics.Color.DarkGray);
            }

            // add text element to layout
            layout.AddView(tv);


            // add weather image for certain days
            if (day >= 14 && day <= 23)
            {
                ImageView iv = new ImageView(ApplicationContext);
                switch (day % 5)
                {
                case 0: iv.SetImageResource(Resource.Drawable.Cloudy);
                    break;

                case 1: iv.SetImageResource(Resource.Drawable.PartlyCloudy);
                    break;

                case 2: iv.SetImageResource(Resource.Drawable.Rain);
                    break;

                case 3: iv.SetImageResource(Resource.Drawable.Storm);
                    break;

                case 4: iv.SetImageResource(Resource.Drawable.Sun);
                    break;
                }
                layout.AddView(iv);
            }

            // finally, set layout to day slot
            e.DaySlot = layout;
        }
Пример #10
0
 static DateTime JavaDateToDateTime(Java.Util.Date javaDate)
 {
     return(new DateTime(1970, 01, 01, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(javaDate.Time).ToLocalTime());
 }
Пример #11
0
 public void SetExpiryDate(Java.Util.Date date)
 {
     ExpiryDate = date;
 }
 public static Task SendMessageTaskAsync(this IBandNotificationManager manager, Java.Util.UUID tileId, string title, string body, Java.Util.Date date, MessageFlags flags)
 {
     return(manager.SendMessageAsync(tileId, title, body, date, flags).AsTask());
 }
        public static Task SendMessageTaskAsync(this IBandNotificationManager manager, Java.Util.UUID tileId, string title, string body, DateTime date, MessageFlags flags)
        {
            var javaDate = new Java.Util.Date((long)(date.ToUniversalTime() - JavaEpoch).TotalMilliseconds);

            return(manager.SendMessageTaskAsync(tileId, title, body, javaDate, flags));
        }