public MainPage()
        {
            this.InitializeComponent();
            Current          = this;
            SampleTitle.Text = FEATURE_NAME;
            ApplicationDataContainer localSettings = null;

            localSettings = ApplicationData.Current.LocalSettings;

            // 첫 실행시  자동 설정
            if (localSettings == null)
            {
                int[]  resolution         = SettingValue.GetInstance().GetResolution();
                double actualSizeInInches = Double.MaxValue;
                if (DisplayInformation.GetForCurrentView().DiagonalSizeInInches.HasValue)
                {
                    actualSizeInInches = DisplayInformation.GetForCurrentView().DiagonalSizeInInches.Value;
                }
                double d = resolution[0] ^ 2 + resolution[1] ^ 2;
                d = actualSizeInInches / Math.Sqrt(d);
                int[] a = { (int)(d * resolution[0]), (int)(d * resolution[1]) };
                SettingValue.GetInstance().SetScreenSize(a);
            }

            SystemNavigationManagerPreview mgr =
                SystemNavigationManagerPreview.GetForCurrentView();

            mgr.CloseRequested += SystemNavigationManager_CloseRequested;
            Systrayicon();
            //BackBaseTask();
        }
 public static SettingValue GetInstance()
 {
     if (instance == null)
     {
         instance = new SettingValue();
     }
     return(instance);
 }
Beispiel #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SettingValue a = SettingValue.GetInstance();

            int[] sc = { Convert.ToInt32(screensize_x.Text), Convert.ToInt32(screensize_y.Text) };
            a.SetScreenSize(sc);
            ToastHelper.ShowToast("화면크기 적용완료");
        }
        private void ParseGattValue(int index, GattValueChangedEventArgs args)
        {
            string str    = "";
            var    reader = DataReader.FromBuffer(args.CharacteristicValue);

            byte[] input = new byte[args.CharacteristicValue.Capacity];
            reader.ReadBytes(input);
            reader.DetachBuffer();
            str = System.Text.Encoding.UTF8.GetString(input);
            if (str.Contains("\n"))
            {
                string[] splitted = str.Split(stringSeparators, StringSplitOptions.None);

                string toParse = jsonStr[index];
                if (!splitted[0].Equals(""))
                {
                    // "\n"으로 스트링이 시작하면, index 0이 ""이므로 생략.
                    toParse += splitted[0].Substring(0, splitted[0].Length);
                }

                // 초기 시작시 JSON 앞부분을 받지 못하는경우가 있음.
                try
                {
                    if (toParse.Contains("batt"))
                    {
                        string[] batt = toParse.Split(":");
                        SettingValue.GetInstance().SetBattery(index, int.Parse(batt[1]));
                    }
                    else
                    {
                        JsonArray root = JsonValue.Parse(toParse).GetArray();
                        if (root.Count == 4)
                        {
                            List <JsonArray> array;
                            if (index == 0)
                            {
                                array = leftData;
                            }
                            else
                            {
                                array = rightData;
                            }

                            array.Add(root);
                        }
                    }
                }
                catch (Exception e)
                {
                    //Debug.WriteLine("R Parse error" + e.StackTrace);
                }
                jsonStr[index] = splitted[1];
            }
            else
            {
                jsonStr[index] += str;
            }
        }
Beispiel #5
0
        public Scenario1_screensetting()
        {
            this.InitializeComponent();
            Windows.UI.ViewManagement.ApplicationView.PreferredLaunchViewSize      = new Windows.Foundation.Size(500, 500);
            Windows.UI.ViewManagement.ApplicationView.PreferredLaunchWindowingMode = Windows.UI.ViewManagement.ApplicationViewWindowingMode.PreferredLaunchViewSize;

            SettingValue a = SettingValue.GetInstance();

            TextBox_x.Text    = a.GetResolution()[0].ToString();
            TextBox_y.Text    = a.GetResolution()[1].ToString();
            screensize_x.Text = a.GetScreenSize()[0].ToString();
            screensize_y.Text = a.GetScreenSize()[1].ToString();
        }
Beispiel #6
0
        public static Touch GetInstance()
        {
            if (instance == null)
            {
                instance = new Touch();
            }

            instance.w       = SettingValue.GetInstance().GetResolutions()[0];
            instance.h       = SettingValue.GetInstance().GetResolutions()[1];
            instance.screenW = SettingValue.GetInstance().GetScreenSize()[0];
            instance.screenH = SettingValue.GetInstance().GetScreenSize()[1];
            instance.SetSensorsMax();
            return(instance);
        }
Beispiel #7
0
        private async void OnRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
        {
            if (args.Request.Message.ContainsKey("content"))
            {
                object message = null;
                args.Request.Message.TryGetValue("content", out message);
                if (App.IsForeground)
                {
                    await Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(async() =>
                    {
                        MessageDialog dialog = new MessageDialog(message.ToString());
                        await dialog.ShowAsync();
                    }));
                }
                else
                {
                    ToastHelper.ShowToast(message.ToString());
                }
            }

            if (args.Request.Message.ContainsKey("resolutionchaged"))
            {
                object message = null;
                args.Request.Message.TryGetValue("resolutionchaged", out message);
                int a = Convert.ToInt32(message);
                SettingValue.GetInstance().ResolutionChanged(a / 10000, a % 10000);
                System.Diagnostics.Debug.WriteLine("resolutionchaged");

                ToastHelper.ShowToast("해상도 변경 : " + a / 10000 + " X " + a % 10000);
            }

            if (args.Request.Message.ContainsKey("autoSetting"))
            {
                object message = null;
                args.Request.Message.TryGetValue("autoSetting", out message);
                int    a                  = Convert.ToInt32(message);
                int[]  resolution         = SettingValue.GetInstance().ResolutionChanged(a / 10000, a % 10000);
                double actualSizeInInches = Double.MaxValue;
                if (DisplayInformation.GetForCurrentView().DiagonalSizeInInches.HasValue)
                {
                    actualSizeInInches = DisplayInformation.GetForCurrentView().DiagonalSizeInInches.Value;
                }
                double d = resolution[0] ^ 2 + resolution[1] ^ 2;
                d = actualSizeInInches / Math.Sqrt(d);
                int[] size = { (int)(d * resolution[0]), (int)(d * resolution[1]) };
                SettingValue.GetInstance().SetScreenSize(size);

                Scenario3_bluetoothAdvertisement.Current.reSetting();
            }

            if (args.Request.Message.ContainsKey("openSetting"))
            {
                if (App.IsForeground)
                {
                    MainPage.Current.ScenarioControl_Settting();
                }
            }

            if (args.Request.Message.ContainsKey("battery"))
            {
                object message = null;
                args.Request.Message.TryGetValue("battery", out message);
                int a = Convert.ToInt32(message);

                ToastHelper.ShowToast("왼쪽 모듈 배터리    : " + a / 10000 + "%\n오른쪽 모듈 배터리 : " + a % 10000 + "%");
            }

            if (args.Request.Message.ContainsKey("exit"))
            {
                App.Current.Exit();
            }
        }