Exemplo n.º 1
0
 static Settings()
 {
     try
     {
         dict = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings;
     }
     catch (Exception ex) { }
 }
Exemplo n.º 2
0
 private void SaveISS(string in_name, string in_val)
 {
     System.IO.IsolatedStorage.IsolatedStorageSettings iss = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings;
     if (iss.Contains(in_name))
     {
         iss.Remove(in_name);
     }
     iss.Add(in_name, in_val);
     iss.Save();
 }
        /// <summary>
        /// Gets the value for a setting, or a default value if the setting doesn't exist.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sett"></param>
        /// <param name="key"></param>
        /// <param name="val"></param>
        /// <returns></returns>
        public static T GetValueOrDefault <T>(this System.IO.IsolatedStorage.IsolatedStorageSettings sett, string key, T val = default(T))
        {
            T rval = default(T);

            if (sett.TryGetValue <T>(key, out rval))
            {
                return(rval);
            }

            return(val);
        }
Exemplo n.º 4
0
        static Setting()
        {
#if WINDOWS_PHONE
            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }

            _isolatedSettings = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings;
#else
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                return;
            }
#endif
        }
Exemplo n.º 5
0
 public MainPage()
 {
     InitializeComponent();
     a = App.Current as App;
     iss = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings;
     // hocking up all the events for the page
     sun.goToThatPage += new EventHandler(ControlGoToThatPage);
     mon.goToThatPage += new EventHandler(ControlGoToThatPage);
     tue.goToThatPage += new EventHandler(ControlGoToThatPage);
     wed.goToThatPage += new EventHandler(ControlGoToThatPage);
     thu.goToThatPage += new EventHandler(ControlGoToThatPage);
     fri.goToThatPage += new EventHandler(ControlGoToThatPage);
     sat.goToThatPage += new EventHandler(ControlGoToThatPage);
     sun.deleteTimetableElement += new EventHandler(DeleteElementHandler);
     mon.deleteTimetableElement += new EventHandler(DeleteElementHandler);
     tue.deleteTimetableElement += new EventHandler(DeleteElementHandler);
     wed.deleteTimetableElement += new EventHandler(DeleteElementHandler);
     thu.deleteTimetableElement += new EventHandler(DeleteElementHandler);
     fri.deleteTimetableElement += new EventHandler(DeleteElementHandler);
     sat.deleteTimetableElement += new EventHandler(DeleteElementHandler);
     //MessageBox.Show("subject count : "+a.subjects.Count+"\n\n Timetablelist count : "+a.timetable.Count);
     SetupLiveTiles();
 }
        /// <summary>
        /// Sets the value for a setting and saves the settings instance.
        /// </summary>
        /// <param name="sett"></param>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public static void SetValueAndSave(this System.IO.IsolatedStorage.IsolatedStorageSettings sett, string key, object value)
        {
            sett[key] = value;

            sett.Save();
        }
Exemplo n.º 7
0
        public App()
        {
            ONScripterSettings.Initialize();
            UVEngineSettings.Initialize();
            if (UVEngineNative.UVEngineSettings.language == "")
            {
                UVEngine.Resources.UVEngine.Culture = System.Threading.Thread.CurrentThread.CurrentUICulture;
            }
            else
            {
                System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(UVEngineNative.UVEngineSettings.language);
            }
            UnhandledException += Application_UnhandledException;
            InitializeComponent();
            InitializePhoneApplication();
            //InitializeXnaApplication();
            InitializeLanguage();
            GameSession session = XLiveGameManager.CreateSession("GsMmyW5d3a6fr7VbtgRD4SPH");

            session.CreateSessionCompleted += session_CreateSessionCompleted;
            XLiveUIManager.Initialize(this, session);
            session.Open();
            System.IO.IsolatedStorage.IsolatedStorageSettings appSettings = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings;
            if (!appSettings.Contains("showDebug"))
            {
                appSettings.Add("showDebug", 0);
            }
            if ((int)appSettings["showDebug"] == 1)
            {
                Application.Current.Host.Settings.EnableFrameRateCounter = true;
                MemoryDiagnosticsHelper.Start(TimeSpan.FromMilliseconds(100), true);
            }
            PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            Microsoft.Devices.CameraButtons.ShutterKeyPressed
                +=
                    delegate
                {
                if (XLiveGameManager.CurrentSession != null &&
                    XLiveGameManager.CurrentSession.SNSProviders.Count > 0)     // Must exist available provider
                {
                    if (UVEngineSettings.QuickShare)
                    {
                        //App.RootFrame.Navigate(new Uri("/OpenXLive.Silverlight;component/Forms/UpdateStatusPage.xaml", UriKind.Relative));
                        WriteableBitmap bmp;
                        if (landscape)
                        {
                            bmp = new WriteableBitmap((int)App.Current.RootVisual.RenderSize.Height, (int)App.Current.RootVisual.RenderSize.Width);
                        }
                        else
                        {
                            bmp = new WriteableBitmap((int)App.Current.RootVisual.RenderSize.Width, (int)App.Current.RootVisual.RenderSize.Height);
                        }
                        bmp.Render(App.Current.RootVisual, null);
                        bmp.Invalidate();
                        MemoryStream stream = new MemoryStream();
                        //var a = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication().OpenFile("capture.jpg", FileMode.OpenOrCreate);
                        bmp.SaveJpeg(stream, bmp.PixelWidth, bmp.PixelHeight, 0, 100);
                        BitmapImage bi = new BitmapImage();
                        bi.SetSource(stream);
                        OpenXLive.Silverlight.XLiveUIManager.ShowUpdateStatus(bi, "");
                        //capture = stream.ToArray();
                        //OpenXLive.Silverlight.XLiveUIManager.ShowUpdateStatus(new BitmapImage(stream), "");
                    }
                }
                else
                {
                    MessageBox.Show(UVEngine.Resources.UVEngine.openxliveproblem);
                }
                };
            if (UVEngineSettings.ReqPasswd)
            {
                Guide.BeginShowKeyboardInput
                    (Microsoft.Xna.Framework.PlayerIndex.One,
                    UVEngine.Resources.UVEngine.passwdreq,
                    UVEngine.Resources.UVEngine.passwdmes,
                    "",
                    delegate(IAsyncResult result)
                {
                    string text = Guide.EndShowKeyboardInput(result);
                    if (text != UVEngineNative.UVEngineSettings.Passwd)
                    {
                        Application.Current.Terminate();
                    }
                },
                    new object(),
                    true);
            }
            //this.Startup += delegate
            //{
            //    if (UVEngineSettings.ReqPasswd)
            //    {
            //        var passwordInput = new Coding4Fun.Toolkit.Controls.PasswordInputPrompt
            //        {
            //            Title = UVEngine.Resources.UVEngine.passwdreq,
            //            Message = UVEngine.Resources.UVEngine.passwdmes,

            //        };
            //        passwordInput.Completed += new EventHandler<Coding4Fun.Toolkit.Controls.PopUpEventArgs<string, Coding4Fun.Toolkit.Controls.PopUpResult>>(delegate(object sender, Coding4Fun.Toolkit.Controls.PopUpEventArgs<string, Coding4Fun.Toolkit.Controls.PopUpResult> e)
            //        {
            //            if (e.PopUpResult == Coding4Fun.Toolkit.Controls.PopUpResult.Ok)
            //            {
            //                if (e.Result != UVEngineSettings.Passwd)
            //                {
            //                    MessageBox.Show(UVEngine.Resources.UVEngine.wrongpasswd);
            //                    Application.Current.Terminate();
            //                }
            //            }
            //            else
            //            {
            //                Application.Current.Terminate();
            //            }
            //        });
            //        passwordInput.Show();
            //    }
            //};

/*
 *          // 调试时显示图形分析信息。
 *          if (Debugger.IsAttached)
 *          {
 *              // 显示当前帧速率计数器。
 *              Application.Current.Host.Settings.EnableFrameRateCounter = true;
 *
 *              // 显示在每个帧中重绘的应用程序区域。
 *              //Application.Current.Host.Settings.EnableRedrawRegions = true;
 *
 *              // 启用非生产分析可视化模式,
 *              // 该模式显示递交给 GPU 的包含彩色重叠区的页面区域。
 *              //Application.Current.Host.Settings.EnableCacheVisualization = true;
 *
 *              // 通过禁用以下对象阻止在调试过程中关闭屏幕
 *              // 应用程序的空闲检测。
 *              //  注意: 仅在调试模式下使用此设置。禁用用户空闲检测的应用程序在用户不使用电话时将继续运行
 *              // 并且消耗电池电量。
 *              PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
 *          }
 */
            PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
        }
Exemplo n.º 8
0
        public void StoreOAuthUserInfo()
        {
            //TODO: Change this to have ApplicationDataContainer that should have been passed in.

            //ApplicationData.Current.LocalSettings.DeleteContainer("TwitterAPIMash");

            #if NETFX_CORE
            ApplicationDataContainer appLocalData = ApplicationData.Current.LocalSettings.CreateContainer(CommonProperties.TwitterAPI_DataStorage, ApplicationDataCreateDisposition.Always);
            //Save or Update OAuth values in appLocalData if applicable, so won't have to Re-Authorize
            if (appLocalData.Values.ContainsKey("OAuthConsumerKey"))
            {
                appLocalData.Values["OAuthConsumerKey"] = OAuth.OAuthTypes.OAuthConsumerKey;
            }
            else
            {
                appLocalData.Values.Add("OAuthConsumerKey", OAuth.OAuthTypes.OAuthConsumerKey);
            }

            if (appLocalData.Values.ContainsKey("OAuthConsumerSecret"))
            {
                appLocalData.Values["OAuthConsumerSecret"] = OAuth.OAuthTypes.OAuthConsumerSecret;
            }
            else
            {
                appLocalData.Values.Add("OAuthConsumerSecret", OAuth.OAuthTypes.OAuthConsumerSecret);
            }

            if (appLocalData.Values.ContainsKey("OAuthAccessToken"))
            {
                appLocalData.Values["OAuthAccessToken"] = OAuth.OAuthTypes.OAuthAccessTokenKey;
            }
            else
            {
                appLocalData.Values.Add("OAuthAccessToken", OAuth.OAuthTypes.OAuthAccessTokenKey);
            }

            if (appLocalData.Values.ContainsKey("OAuthAccessSecret"))
            {
                appLocalData.Values["OAuthAccessSecret"] = OAuth.OAuthTypes.OAuthAccessTokenSecretKey;
            }
            else
            {
                appLocalData.Values.Add("OAuthAccessSecret", OAuth.OAuthTypes.OAuthAccessTokenSecretKey);
            }

            if (appLocalData.Values.ContainsKey("OAuthVerifier"))
            {
                appLocalData.Values["OAuthVerifier"] = OAuth.OAuthTypes.OAuthVerifierKey;
            }
            else
            {
                appLocalData.Values.Add("OAuthVerifier", OAuth.OAuthTypes.OAuthVerifierKey);
            }

            if (appLocalData.Values.ContainsKey("UserID"))
            {
                appLocalData.Values["UserID"] = TweetAuthConstants.OAuthUserID;
            }
            else
            {
                appLocalData.Values.Add("UserID", TweetAuthConstants.OAuthUserID);
            }

            if (appLocalData.Values.ContainsKey("UserScreenName"))
            {
                appLocalData.Values["UserScreenName"] = TweetAuthConstants.OAuthUserScreenName;
            }
            else
            {
                appLocalData.Values.Add("UserScreenName", TweetAuthConstants.OAuthUserScreenName);
            }
            #else
            System.IO.IsolatedStorage.IsolatedStorageSettings appData = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings;
            if (!appData.Contains(CommonProperties.TwitterAPI_DataStorage))
            {
                appData.Add(CommonProperties.TwitterAPI_DataStorage, new Dictionary <string, string>());
            }

            Dictionary <string, string> appLocalData = appData[CommonProperties.TwitterAPI_DataStorage] as Dictionary <string, string>;

            if (appLocalData.ContainsKey("OAuthConsumerKey"))
            {
                appLocalData["OAuthConsumerKey"] = OAuth.OAuthTypes.OAuthConsumerKey;
            }
            else
            {
                appLocalData.Add("OAuthConsumerKey", OAuth.OAuthTypes.OAuthConsumerKey);
            }

            if (appLocalData.ContainsKey("OAuthConsumerSecret"))
            {
                appLocalData["OAuthConsumerSecret"] = OAuth.OAuthTypes.OAuthConsumerSecret;
            }
            else
            {
                appLocalData.Add("OAuthConsumerSecret", OAuth.OAuthTypes.OAuthConsumerSecret);
            }

            if (appLocalData.ContainsKey("OAuthAccessToken"))
            {
                appLocalData["OAuthAccessToken"] = OAuth.OAuthTypes.OAuthAccessTokenKey;
            }
            else
            {
                appLocalData.Add("OAuthAccessToken", OAuth.OAuthTypes.OAuthAccessTokenKey);
            }

            if (appLocalData.ContainsKey("OAuthAccessSecret"))
            {
                appLocalData["OAuthAccessSecret"] = OAuth.OAuthTypes.OAuthAccessTokenSecretKey;
            }
            else
            {
                appLocalData.Add("OAuthAccessSecret", OAuth.OAuthTypes.OAuthAccessTokenSecretKey);
            }

            if (appLocalData.ContainsKey("OAuthVerifier"))
            {
                appLocalData["OAuthVerifier"] = OAuth.OAuthTypes.OAuthVerifierKey;
            }
            else
            {
                appLocalData.Add("OAuthVerifier", OAuth.OAuthTypes.OAuthVerifierKey);
            }

            if (appLocalData.ContainsKey("UserID"))
            {
                appLocalData["UserID"] = TweetAuthConstants.OAuthUserID;
            }
            else
            {
                appLocalData.Add("UserID", TweetAuthConstants.OAuthUserID);
            }

            if (appLocalData.ContainsKey("UserScreenName"))
            {
                appLocalData["UserScreenName"] = TweetAuthConstants.OAuthUserScreenName;
            }
            else
            {
                appLocalData.Add("UserScreenName", TweetAuthConstants.OAuthUserScreenName);
            }

            appData.Save();
            #endif
        }