internal void UpdateGeneralSetting(Settings.GeneralSetting setting)
        {
            if (setting == null)
            {
                //todo:log
                return;
            }


            //todo:VMのプロパティに直に代入すれば良いのでは?
            ShowLineCount = setting.ShowingLineCount;
            _viewModel.NotifyPropertyChanged("LineCountVisible");

            ShowNumberOfLines = setting.ShowingNumberOfLines;
            _viewModel.NotifyPropertyChanged("CanShowNumberOfLines");

            ShowWordCount = setting.ShowingWordCount;
            _viewModel.NotifyPropertyChanged("WordCountVisible");

            TextEditorOptions.ShowEndOfLine = setting.ShowingNewLine;
            TextEditorOptions.ShowSpaces    = setting.ShowingSpace;
            TextEditorOptions.ShowTabs      = setting.ShowingTab;
            _viewModel.NotifyPropertyChanged("TextEditorOptions");

            WordWrap = setting.WrappingText;
            _viewModel.NotifyPropertyChanged("WordWrap");

            FontFamily = setting.MainFontName + ", " + setting.SubFontName;
            _viewModel.NotifyPropertyChanged("FontFamily");

            FontSize = setting.FontSize;
            _viewModel.NotifyPropertyChanged("FontSize");
        }
        private void UpdateGeneralSettingEvent(object sender, Model.Manager.Events.SettingChangedEventArgs args)
        {
            if (args == null)
            {
                //todo:log
                return;
            }

            Settings.GeneralSetting generalSetting = args.GetTargetSetting(typeof(Settings.GeneralSetting)) as Settings.GeneralSetting;
            if (generalSetting == null)
            {
                //todo:log
                return;
            }

            if (_model == null)
            {
                //todo:log
                return;
            }

            _model.UpdateGeneralSetting(generalSetting);
        }
示例#3
0
        private Settings SelectAll()
        {
            if (SettingCache == null)
            {
                SettingCache = new Settings();
            }

            using (var statement = this.conn.Prepare(DML_SETTINGS_READ))
            {
                while (statement.Step() == SQLitePCL.SQLiteResult.ROW)
                {
                    SettingCache.Add(new Setting()
                    {
                        Code  = statement.GetText("CODE"),
                        Value = statement["VALUE"],
                        Type  = statement.GetText("TYPE"),
                        Attr1 = statement["ATTR1"] != null ? statement.GetText("ATTR1") : null,
                        Attr2 = statement["ATTR2"] != null ? statement.GetText("ATTR2") : null,
                    });
                }
            }

            var general   = new Settings.GeneralSetting(SettingCache);
            var playback  = new Settings.PlaybackSetting(SettingCache);
            var subtitle  = new Settings.ClosedCaptionSetting(SettingCache);
            var privacy   = new Settings.PrivacySetting(SettingCache);
            var server    = new Settings.ServerSetting(SettingCache);
            var thumbnail = new Settings.ThumbnailSetting(SettingCache);

            if (SettingCache.Count == 0)
            {
                //최초 상태이면 fal 초기화
                Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Clear();

                //디폴트 값 등록
                //일반
                general.ResetDefaultValue();
                //재생
                playback.ResetDefaultValue();
                //자막
                subtitle.ResetDefaultvalue();
                //개인설정
                privacy.ResetDefaultValue();
                //서버
                server.ResetDefaultValue();
                //썸네일
                thumbnail.ResetDefaultValue();

                try
                {
                    using (var stmt = this.conn.Prepare(TCL_BEGIN)) { stmt.Step(); }
                    using (var custstmt = this.conn.Prepare(DML_SETTINGS_CREATE))
                    {
                        foreach (var setting in SettingCache)
                        {
                            //if (setting.Code == "ForegroundColor")
                            //    System.Diagnostics.Debugger.Break();
                            //System.Diagnostics.Debug.WriteLine(setting.Code + " " + setting.Value + " " + setting.Type + " " + setting.Attr1 + " " + setting.Attr2);
                            custstmt.Bind("@CODE", setting.Code);
                            custstmt.Bind("@VALUE", setting.Value);
                            custstmt.Bind("@TYPE", setting.Type);
                            custstmt.Bind("@ATTR1", setting.Attr1);
                            custstmt.Bind("@ATTR2", setting.Attr2);

                            var result = custstmt.Step();
                            if (result != SQLitePCL.SQLiteResult.DONE)
                            {
                                throw new Exception();
                            }

                            // Resets the statement, to that it can be used again (with different parameters).
                            custstmt.Reset();
                            custstmt.ClearBindings();
                        }
                    }
                    using (var stmt = this.conn.Prepare(TCL_COMMIT)) { stmt.Step(); }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Write("Settings 데이터의 DB 저장이 실패함!!!! : " + ex.Message);
                    using (var stmt = this.conn.Prepare(TCL_ROLLBACK)) { stmt.Step(); }
                }
            }

            return(SettingCache);
        }
示例#4
0
        public Settings SelectAll()
        {
            if (SettingCache == null)
            {
                SettingCache = new Settings();
            }

            using (var statement = this.conn.Prepare(DML_SETTINGS_READ))
            {
                while (statement.Step() == SQLitePCL.SQLiteResult.ROW)
                {
                    SettingCache.Add(new Setting()
                    {
                        Code  = statement.GetText("CODE"),
                        Value = statement["VALUE"],
                        Type  = statement.GetText("TYPE"),
                        Attr1 = statement["ATTR1"] != null ? statement.GetText("ATTR1") : null,
                        Attr2 = statement["ATTR2"] != null ? statement.GetText("ATTR2") : null,
                    });
                }
            }

            var general  = new Settings.GeneralSetting(SettingCache);
            var playback = new Settings.PlaybackSetting(SettingCache);
            var subtitle = new Settings.SubtitleSetting(SettingCache);

            if (SettingCache.Count == 0)
            {
                //최초 상태이면 fal 초기화
                Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Clear();

                //디폴트 값 등록
                //일반
                general.ResetDefaultValue();
                //재생
                playback.ResetDefaultValue();
                //자막
                subtitle.ResetDefaultvalue();

                try
                {
                    using (var stmt = this.conn.Prepare(TCL_BEGIN)) { stmt.Step(); }
                    using (var custstmt = this.conn.Prepare(DML_SETTINGS_CREATE))
                    {
                        foreach (var setting in SettingCache)
                        {
                            custstmt.Bind("@CODE", setting.Code);
                            custstmt.Bind("@VALUE", setting.Value);
                            custstmt.Bind("@TYPE", setting.Type);
                            custstmt.Bind("@ATTR1", setting.Attr1);
                            custstmt.Bind("@ATTR2", setting.Attr2);
                            if (custstmt.Step() != SQLitePCL.SQLiteResult.DONE)
                            {
                                throw new Exception();
                            }

                            // Resets the statement, to that it can be used again (with different parameters).
                            custstmt.Reset();
                            custstmt.ClearBindings();
                        }
                    }
                    using (var stmt = this.conn.Prepare(TCL_COMMIT)) { stmt.Step(); }
                }
                catch (Exception)
                {
                    using (var stmt = this.conn.Prepare(TCL_ROLLBACK)) { stmt.Step(); }
                }
            }

            return(SettingCache);
        }