// Constructor
        public MainPage()
        {
            InitializeComponent();

            txtDeviceManufacturer.Text = DeviceExtendedProperties.GetValue("DeviceManufacturer").ToString();
            txtDeviceName.Text         = DeviceExtendedProperties.GetValue("DeviceName").ToString();
        }
Esempio n. 2
0
        public static double GetMemory()
        {
            long applicationCurrentMemoryUsage = (long)DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage");
            var  currentMemoryUsageInMB        = Convert.ToInt32(applicationCurrentMemoryUsage) / (1024 * 1024.0);

            return(currentMemoryUsageInMB);
        }
        internal static Dictionary <string, object> ComputeLegacyAppState()
        {
            // Used by CrashReport and HandledException report.
            // Getting lots of stuff here. Some things like "DeviceId" require manifest-level authorization so skipping
            // those for now, see http://msdn.microsoft.com/en-us/library/ff769509%28v=vs.92%29.aspx#BKMK_Capabilities

            return(new Dictionary <string, object> {
                { "app_version", Crittercism.AppVersion },
                // RemainingChargePercent returns an integer in [0,100]
#if WINDOWS_PHONE
                { "battery_level", Windows.Phone.Devices.Power.Battery.GetDefault().RemainingChargePercent / 100.0 },
                { "carrier", DeviceNetworkInformation.CellularMobileOperator },
                { "device_total_ram_bytes", DeviceExtendedProperties.GetValue("DeviceTotalMemory") },
                { "memory_usage", DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage") },
                { "memory_usage_peak", DeviceExtendedProperties.GetValue("ApplicationPeakMemoryUsage") },
                { "on_cellular_data", DeviceNetworkInformation.IsCellularDataEnabled },
                { "on_wifi", DeviceNetworkInformation.IsWiFiEnabled },
                { "orientation", DisplayProperties.NativeOrientation.ToString() },
#endif
                { "disk_space_free", StorageHelper.AvailableFreeSpace() },
                // skipping "name" for device name as it requires manifest approval
                { "locale", CultureInfo.CurrentCulture.Name },
                // all counters below in bytes
                { "reported_at", TimeUtils.GMTDateString(DateTime.UtcNow) }
            });
        }
Esempio n. 4
0
        public static string GetManufactor()
        {
            string manufacturer = DeviceExtendedProperties.GetValue("DeviceManufacturer").ToString();

            manufacturer = manufacturer.Replace(" ", "-");
            return(manufacturer);
        }
Esempio n. 5
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            var askforReview = (bool)IsolatedStorageSettings.ApplicationSettings["askforreview"];

            if (askforReview)
            {
                //make sure we only ask once!
                IsolatedStorageSettings.ApplicationSettings["askforreview"] = false;
                var returnvalue = MessageBox.Show(AppResources.TextID20, AppResources.TextID21, MessageBoxButton.OKCancel);
                if (returnvalue == MessageBoxResult.OK)
                {
                    var marketplaceReviewTask = new MarketplaceReviewTask();
                    marketplaceReviewTask.Show();
                }
            }

#if DEBUG_AGENT
            DispatcherTimer timer = new DispatcherTimer();
            timer.Tick += (ss, ee) =>
            {
                const string current      = "ApplicationCurrentMemoryUsage";
                var          currentBytes = ((long)DeviceExtendedProperties.GetValue(current)) / 1024.0 / 1024.0;
                System.Diagnostics.Debug.WriteLine(String.Format("Memory  = {0,5:F} MB / {1,5:F} MB\n", currentBytes, DeviceStatus.ApplicationMemoryUsageLimit / 1024 / 1024));
            };
            timer.Interval = new TimeSpan(0, 0, 0, 1, 0);
            timer.Start();
#endif
        }
Esempio n. 6
0
        public static string GetDeviceName()
        {
            string deviceName = DeviceExtendedProperties.GetValue("DeviceName").ToString();

            deviceName = deviceName.Replace(" ", "-");
            return(deviceName);
        }
Esempio n. 7
0
        private async void AttemptSave()
        {
            if (Processing)
            {
                return;
            }
            Processing = true;

            GC.Collect();

            var lowMemory = false;

            try
            {
                var result = (long)DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit");

                lowMemory = result / 1024 / 1024 < 300;
            }
            catch (ArgumentOutOfRangeException)
            {
            }

            IBuffer buffer;

            Model.OriginalImage.Position = 0;

            using (var source = new StreamImageSource(Model.OriginalImage))
                using (var segmenter = new InteractiveForegroundSegmenter(source))
                    using (var annotationsSource = new BitmapImageSource(Model.AnnotationsBitmap))
                    {
                        segmenter.Quality           = lowMemory ? 0.5 : 1;
                        segmenter.AnnotationsSource = annotationsSource;

                        var foregroundColor = Model.ForegroundBrush.Color;
                        var backgroundColor = Model.BackgroundBrush.Color;

                        segmenter.ForegroundColor = Windows.UI.Color.FromArgb(foregroundColor.A, foregroundColor.R, foregroundColor.G, foregroundColor.B);
                        segmenter.BackgroundColor = Windows.UI.Color.FromArgb(backgroundColor.A, backgroundColor.R, backgroundColor.G, backgroundColor.B);

                        using (var effect = new LensBlurEffect(source, new LensBlurPredefinedKernel(Shape, (uint)SizeSlider.Value)))
                            using (var renderer = new JpegRenderer(effect))
                            {
                                effect.KernelMap = segmenter;

                                buffer = await renderer.RenderAsync();
                            }
                    }

            using (var library = new MediaLibrary())
                using (var stream = buffer.AsStream())
                {
                    library.SavePicture("lensblur_" + DateTime.Now.Ticks, stream);

                    Model.Saved = true;

                    AdaptButtonsToState();
                }

            Processing = false;
        }
Esempio n. 8
0
        //get device id
        public static string getDeviceId()
        {
            string strDeviceUniqueID = "";

            try
            {
                byte[] byteArray = DeviceExtendedProperties.GetValue("DeviceUniqueId") as byte[];
                string strTemp   = "";

                foreach (byte b in byteArray)
                {
                    strTemp = b.ToString();
                    if (1 == strTemp.Length)
                    {
                        strTemp = "00" + strTemp;
                    }
                    else if (2 == strTemp.Length)
                    {
                        strTemp = "0" + strTemp;
                    }
                    strDeviceUniqueID += strTemp;
                }
            }
            catch (Exception e)
            {
                DebugTool.Log(e);
            }
            return(strDeviceUniqueID);
        }
Esempio n. 9
0
        public static void BeginRecording()
        {
            // start a timer to report memory conditions every 3 seconds
            //
            _timer = new Timer(state =>
            {
                string c = "unassigned";
                try
                {
                    //
                }
                catch (ArgumentOutOfRangeException ar)
                {
                    var c1 = ar.Message;
                }
                catch
                {
                    c = "unassigned";
                }


                string report = "";
                //report += Environment.NewLine +
                //    "Current: " + (DeviceStatus.ApplicationCurrentMemoryUsage / 1000000).ToString() + "MB\n" +
                //    "Peak: " + (DeviceStatus.ApplicationPeakMemoryUsage / 1000000).ToString() + "MB\n" +
                //    "Memory Limit: " + (DeviceStatus.ApplicationMemoryUsageLimit / 1000000).ToString() + "MB\n\n" +
                //    "Device Total Memory: " + (DeviceStatus.DeviceTotalMemory / 1000000).ToString() + "MB\n" +
                //    "Working Limit: " + Convert.ToInt32((Convert.ToDouble(DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit")) / 1000000)).ToString() + "MB";

                double current = 0;
                double rate    = 0;
                lock (lockObj)
                {
                    current = DeviceStatus.ApplicationCurrentMemoryUsage / 1000000;
                    rate    = 0;
                    if (_last != 0)
                    {
                        rate = ((current - _last) / current) * 100;
                    }

                    _last = current;
                }


                report += Environment.NewLine +
                          "Current: " + current.ToString() + "MB\n" +
                          "Increased: " + rate.ToString() + "%\n" +
                          "Peak: " + (DeviceStatus.ApplicationPeakMemoryUsage / 1000000).ToString() + "MB\n" +
                          "Memory Limit: " + (DeviceStatus.ApplicationMemoryUsageLimit / 1000000).ToString() + "MB\n" +
                          "Working Limit: " + Convert.ToInt32((Convert.ToDouble(DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit")) / 1000000)).ToString() + "MB";

                Deployment.Current.Dispatcher.BeginInvoke(delegate
                {
                    Debug.WriteLine(report);
                });
            },
                               null,
                               TimeSpan.FromSeconds(5),
                               TimeSpan.FromSeconds(5));
        }
Esempio n. 10
0
            public static void BeginRecording()
            {
                // before we start recording we can clean up the previous session.
                // e.g. Get a logging file from IsoStore and upload to the server

                // start a timer to report memory conditions every 2 seconds
                timer = new Timer(state =>
                {
                    // every 2 seconds do something
                    string report =
                        DateTime.Now.ToLongTimeString() + " memory conditions: " +
                        Environment.NewLine +
                        "\tApplicationCurrentMemoryUsage: " +
                        DeviceStatus.ApplicationCurrentMemoryUsage +
                        Environment.NewLine +
                        "\tApplicationPeakMemoryUsage: " +
                        DeviceStatus.ApplicationPeakMemoryUsage +
                        Environment.NewLine +
                        "\tApplicationMemoryUsageLimit: " +
                        DeviceStatus.ApplicationMemoryUsageLimit +
                        Environment.NewLine +
                        "\tDeviceTotalMemory: " + DeviceStatus.DeviceTotalMemory + Environment.NewLine +
                        "\tApplicationWorkingSetLimit: " +
                        DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit") +
                        Environment.NewLine;

                    // write to IsoStore or debug conolse
                    Debug.WriteLine(report);
                },
                                  null,
                                  TimeSpan.FromSeconds(2),
                                  TimeSpan.FromSeconds(2));
            }
Esempio n. 11
0
        public static bool IsLowMemoryDevice()
        {
#if WINDOWS_PHONE
            try
            {
                var result = (long)DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit");

                if (result < 94371840L)
                {
                    return(true);
                }

                return(false);
            }

            catch (ArgumentOutOfRangeException)
            {
                // The device does not support querying for this value. This occurs
                // on Windows Phone OS 7.1 and older phones without OS updates.

                return(true);
            }
#else
            return(false);
#endif
        }
Esempio n. 12
0
        private void GetDeviceId()
        {
            var deviceArrayID = (Byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId");

            deviceID = Convert.ToBase64String(deviceArrayID);
            Logger.Show(deviceID);
        }
Esempio n. 13
0
        public string GetDeviceUniqueId()
        {
            byte[] bytes = (byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId");
            string hex   = BitConverter.ToString(bytes);

            return(hex.Replace("-", "").ToLower());
        }
Esempio n. 14
0
        public static void DACPlaying(DACPlayInfo playInfo, PPTVData.Entity.ChannelDetailInfo channelInfo, Version clientVersion)
        {
            string content = "Action=0&A=" + playInfo.castType.ToString() + "&B=1&C=6&D=" + GetUserId() + "&E=";

            content  += (clientVersion == null?"":clientVersion.ToString());
            content  += "&F=" + channelInfo.TypeID.ToString();
            content  += "&G=" + channelInfo.VID.ToString();
            content  += "&H=" + channelInfo.Title;
            content  += "&I=" + playInfo.playTime.ToString("0");
            content  += "&J=" + playInfo.mp4Name;
            content  += "&K=" + playInfo.programSource.ToString();
            content  += "&L=" + playInfo.prepareTime.ToString("0");
            content  += "&M=" + playInfo.bufferTime.ToString("0");
            content  += "&N=" + playInfo.allBufferCount.ToString();
            content  += "&O=" + playInfo.dragCount.ToString();
            content  += "&P=" + playInfo.dragBufferTime.ToString("0");
            content  += "&Q=" + playInfo.playBufferCount.ToString();
            content  += "&R=" + playInfo.connType.ToString();
            content  += "&S=" + playInfo.isPlaySucceeded.ToString();
            content  += "&T=";
            content  += "&U=";
            content  += "&V=" + playInfo.averageDownSpeed.ToString();
            content  += "&W=" + playInfo.stopReason.ToString();
            content  += "&Y1=0";
            content  += "&Y2=" + DeviceExtendedProperties.GetValue("DeviceName").ToString();
            content  += "&Y3=" + System.Environment.OSVersion.Version.ToString();
            _instance = new DACFactory();
            _instance.DACSend(content);
        }
Esempio n. 15
0
        //get client data
        public ClientData getClientData()
        {
            ClientData clientdata = new ClientData();

            clientdata.platform   = "windows phone";
            clientdata.os_version = Utility.getOsVersion();
            clientdata.language   = CultureInfo.CurrentCulture.DisplayName;
            clientdata.resolution = UMSApi.device_resolution;
            clientdata.deviceid   = Utility.getDeviceId();
            clientdata.devicename = DeviceExtendedProperties.GetValue("DeviceName").ToString();
            clientdata.version    = Utility.getApplicationVersion();
            clientdata.appkey     = key;
            clientdata.time       = Utility.getTime();
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

            if (settings["autolocation"].ToString().Equals("1"))
            {
                double[] location = Utility.GetLocationProperty();
                clientdata.latitude  = location[0].ToString();
                clientdata.longitude = location[1].ToString();
            }

            clientdata.network        = Utility.GetNetStates();
            clientdata.defaultbrowser = "";


            return(clientdata);
        }
Esempio n. 16
0
        public DeviceInfo()
        {
            this.Manufacturer    = DeviceStatus.DeviceManufacturer;
            this.Model           = DeviceStatus.DeviceName;
            this.OperatingSystem = Env.OSVersion.ToString();

            var deviceIdBytes = (byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId");

            this.DeviceId = Convert.ToBase64String(deviceIdBytes);

            this.IsRearCameraAvailable  = PhotoCamera.IsCameraTypeSupported(CameraType.Primary);
            this.IsFrontCameraAvailable = PhotoCamera.IsCameraTypeSupported(CameraType.FrontFacing);
            this.IsSimulator            = (DevEnv.DeviceType == DeviceType.Emulator);

            switch (GetScaleFactor())
            {
            case 150:
                this.ScreenWidth  = 720;
                this.ScreenHeight = 1280;
                break;

            case 160:
                this.ScreenWidth  = 768;
                this.ScreenHeight = 1280;
                break;

            case 100:
            default:
                this.ScreenWidth  = 480;
                this.ScreenHeight = 800;
                break;
            }
        }
Esempio n. 17
0
        public DeviceInfo()
        {
            this.deviceId = new Lazy <string>(() => {
                var deviceIdBytes = (byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId");
                return(Convert.ToBase64String(deviceIdBytes));
            });
            switch (GetScaleFactor())
            {
            case 150:
                this.ScreenWidth  = 720;
                this.ScreenHeight = 1280;
                break;

            case 160:
                this.ScreenWidth  = 768;
                this.ScreenHeight = 1280;
                break;

            case 100:
            default:
                this.ScreenWidth  = 480;
                this.ScreenHeight = 800;
                break;
            }
        }
Esempio n. 18
0
 void MainPage_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         tinh_select    = IsolatedStorageSettings.ApplicationSettings["tinh"].ToString();
         huyen_select   = IsolatedStorageSettings.ApplicationSettings["huyen"].ToString();
         tinhid_select  = IsolatedStorageSettings.ApplicationSettings["tinhid"].ToString();
         huyenid_select = IsolatedStorageSettings.ApplicationSettings["huyenid"].ToString();
     }
     catch (Exception ee2)
     {
         tinh_select    = "Can Tho";
         huyen_select   = "Toan tinh";
         tinhid_select  = "cantho";
         huyenid_select = "toantinh";
     }
     if (NetworkInterface.GetIsNetworkAvailable() == true)
     {
         byte[] myDeviceID       = (byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId");
         string DeviceIDAsString = Convert.ToBase64String(myDeviceID);
         log("WP.lichcupdien_v2", DeviceIDAsString);
         getpara();
         get_dmtinh();
     }
     else
     {
         MessageBox.Show("Vui lòng kết nối mạng và thử lại");
         App.Current.Terminate();
     }
 }
Esempio n. 19
0
        public string GetManufacturer()
        {
#if TEST_WINPHONE || WINDOWS_PHONE
            return((string)DeviceExtendedProperties.GetValue("DeviceManufacturer"));
#else
            return("Microsoft");
#endif
        }
Esempio n. 20
0
        public static string GetDeviceFullName()
        {
#if WINDOWS_PHONE
            return((string)DeviceExtendedProperties.GetValue("DeviceName"));
#else
            return("TestWinRT");
#endif
        }
Esempio n. 21
0
        public string GetModel()
        {
#if TEST_WINPHONE || WINDOWS_PHONE
            return((string)DeviceExtendedProperties.GetValue("DeviceName"));
#else
            return(null);
#endif
        }
Esempio n. 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PhoneMemoryViewModel"/> class.
 /// </summary>
 /// <param name="navigationService">
 /// The navigation service.
 /// </param>
 public PhoneMemoryViewModel(INavigationService navigationService)
     : base(navigationService)
 {
     this.DeviceTotalMemory =
         FormatKBytesString((long)DeviceExtendedProperties.GetValue("DeviceTotalMemory"));
     this.ApplicationCurrentMemoryUsage =
         FormatKBytesString((long)DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage"));
 }
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        async protected override void OnInvoke(ScheduledTask task)
        {
            Logger.Log("Agent", "- - - - - - - - - - - - -");
            Logger.Log("Agent", "Agent invoked -> " + task.Name);

            this.contactBindingManager = await ContactBindings.GetAppContactBindingManagerAsync();

            // Use the name of the task to differentiate between the ExtensilityTaskAgent
            // and the ScheduledTaskAgent
            if (task.Name == "ExtensibilityTaskAgent")
            {
                List <Task> inprogressOperations = new List <Task>();

                OperationQueue operationQueue = await SocialManager.GetOperationQueueAsync();

                ISocialOperation socialOperation = await operationQueue.GetNextOperationAsync();

                while (null != socialOperation)
                {
                    Logger.Log("Agent", "Dequeued an operation of type " + socialOperation.Type.ToString());

                    try
                    {
                        switch (socialOperation.Type)
                        {
                        case SocialOperationType.DownloadRichConnectData:
                            await ProcessOperationAsync(socialOperation as DownloadRichConnectDataOperation);

                            break;

                        default:
                            // This should never happen
                            HandleUnknownOperation(socialOperation);
                            break;
                        }

                        // The agent can only use up to 20 MB
                        // Logging the memory usage information for debugging purposes
                        Logger.Log("Agent", string.Format("Completed operation {0}, memusage: {1}kb/{2}kb",
                                                          socialOperation.ToString(),
                                                          (int)((long)DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage")) / 1024,
                                                          (int)((long)DeviceExtendedProperties.GetValue("ApplicationPeakMemoryUsage")) / 1024));


                        // This can block for up to 1 minute. Don't expect to run instantly every time.
                        socialOperation = await operationQueue.GetNextOperationAsync();
                    }
                    catch (Exception e)
                    {
                        Helpers.HandleException(e);
                    }
                }

                Logger.Log("Agent", "No more operations in the queue");
            }

            NotifyComplete();
        }
Esempio n. 24
0
        /// <summary>
        /// Gets the peak memory usage, in bytes. Returns zero in non-debug mode
        /// </summary>
        /// <returns>Peak memory usage</returns>
        public static long GetPeakMemoryUsage()
        {
#if DEBUG
            // don't use DeviceExtendedProperties for release builds (requires a capability)
            return((long)DeviceExtendedProperties.GetValue("ApplicationPeakMemoryUsage"));
#else
            return(0);
#endif
        }
Esempio n. 25
0
        public MainPage()
        {
            InitializeComponent();
            _deviceId =
                Convert.ToBase64String(DeviceExtendedProperties.GetValue("DeviceUniqueId") as byte[] ??
                                       Guid.NewGuid().ToByteArray());

            this.Loaded += new RoutedEventHandler(MainPage_Loaded);
        }
        /// <summary>
        /// Gets the current memory usage, in bytes. Returns zero in non-debug mode
        /// </summary>
        /// <returns>Current usage</returns>
        public static long GetCurrentMemoryUsage()
        {
//#if DEBUG
            // don't use DeviceExtendedProperties for release builds (requires a capability)
            return((long)DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage"));
//#else
//      return 0;
//#endif
        }
Esempio n. 27
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            byte[] id = (byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId");
            Player = Convert.ToBase64String(id);
            var SRB = new ServiceReferenceBalda.ServiceBaldaClient();
         //  SRB.RegistrationCompleted += new EventHandler<ServiceReferenceBalda.RegistrationCompletedEventArgs>(CallRegistration);
        //    SRB.RegistrationAsync(Player);
        }
Esempio n. 28
0
 public static string GetDeviceType()
 {
     try
     {
         return(DeviceExtendedProperties.GetValue("DeviceName").ToString());
     }
     catch
     {
         return(string.Empty);
     }
 }
Esempio n. 29
0
 public static string GetDeviceManufacturer()
 {
     try
     {
         return(DeviceExtendedProperties.GetValue("DeviceManufacturer").ToString());
     }
     catch
     {
         return(string.Empty);
     }
 }
Esempio n. 30
0
        public static string GetUniqueId()
        {
            byte[]        byteArray = DeviceExtendedProperties.GetValue("DeviceUniqueId") as byte[];
            StringBuilder sb        = new StringBuilder();

            foreach (byte b in byteArray)
            {
                sb.Append(b.ToString("X2"));
            }
            return(sb.ToString());
        }