private void SetTemplate() { ReaderContext = new ReaderView(); ContentGrid.DataContext = ReaderContext; ContextGrid.DataContext = new ESContext(); RBgContext = new BgContext(GRConfig.ContentReader.BgContext); ContentBg.DataContext = RBgContext; RBgContext.ApplyBackgrounds(); if (Paragraph.Translator == null) { Paragraph.Translator = new libtranslate.Translator(); } StringResources stx = StringResources.Load("Settings"); ExpContent = new Paragraph[] { new Paragraph(stx.Text("Appearance_ContentReader_Exp1")) , new Paragraph(stx.Text("Appearance_ContentReader_Exp2")) , new Paragraph(stx.Text("Appearance_ContentReader_Exp3")) , new Paragraph(stx.Text("Appearance_ContentReader_Exp4")) }; XTitleStepper.Text = YTitleStepper.Text = stx.Text("Appearance_ContentReader_Exp2"); ColorList.ItemsSource = new ColorItem[] { new ColorItem( stx.Text("Appearance_ContentReader_Background") , GRConfig.ContentReader.BackgroundColor ) { BindAction = (c) => { GRConfig.ContentReader.BackgroundColor = c; UpdateExampleFc(); } } , new ColorItem( stx.Text("Appearance_ContentReader_ScrollBar") , GRConfig.ContentReader.ScrollBarColor ) { BindAction = (c) => { GRConfig.ContentReader.ScrollBarColor = c; UpdateScrollBar(); } } , new ColorItem( stx.Text("Appearance_ContentReader_FontColor") , GRConfig.ContentReader.FontColor ) { BindAction = (c) => { GRConfig.ContentReader.FontColor = c; } } , new ColorItem( stx.Text("Appearance_ContentReader_TapBrushColor") , GRConfig.ContentReader.TapBrushColor ) { BindAction = (c) => { GRConfig.ContentReader.TapBrushColor = c; } } , new ColorItem( stx.Text("Appearance_ContentReader_NavBg") , GRConfig.ContentReader.BgColorNav ) { BindAction = (c) => { GRConfig.ContentReader.BgColorNav = c; } } , new ColorItem( stx.Text("Appearance_ContentReader_AssistHelper") , GRConfig.ContentReader.BgColorAssist ) { BindAction = (c) => { GRConfig.ContentReader.BgColorAssist = c; } } }; ClockColorList.ItemsSource = new ColorItem[] { new ColorItem( stx.Text("Appearance_ContentReader_Clock_ARColor") , GRConfig.ContentReader.Clock.ARColor ) { BindAction = (c) => { GRConfig.ContentReader.Clock.ARColor = c; } } , new ColorItem( stx.Text("Appearance_ContentReader_Clock_HHColor") , GRConfig.ContentReader.Clock.HHColor ) { BindAction = (c) => { GRConfig.ContentReader.Clock.HHColor = c; } } , new ColorItem( stx.Text("Appearance_ContentReader_Clock_MHColor") , GRConfig.ContentReader.Clock.MHColor ) { BindAction = (c) => { GRConfig.ContentReader.Clock.MHColor = c; } } , new ColorItem( stx.Text("Appearance_ContentReader_Clock_SColor") , GRConfig.ContentReader.Clock.SColor ) { BindAction = (c) => { GRConfig.ContentReader.Clock.SColor = c; } } , new ColorItem( stx.Text("Appearance_ContentReader_EStepper_DColor") , GRConfig.ContentReader.EpStepper.DColor ) { BindAction = (c) => { GRConfig.ContentReader.EpStepper.DColor = c; } } , new ColorItem( stx.Text("Appearance_ContentReader_EStepper_SColor") , GRConfig.ContentReader.EpStepper.SColor ) { BindAction = (c) => { GRConfig.ContentReader.EpStepper.SColor = c; } } , new ColorItem( stx.Text("Appearance_ContentReader_Background") , GRConfig.ContentReader.EpStepper.BackgroundColor ) { BindAction = (c) => { GRConfig.ContentReader.EpStepper.BackgroundColor = c; } } }; BatteryReport Report = Battery.AggregateBattery.GetReport(); if (Report.RemainingCapacityInMilliwattHours != null) { YClock.Progress = XClock.Progress = ( float )Report.RemainingCapacityInMilliwattHours / ( float )Report.FullChargeCapacityInMilliwattHours; } SSliders[FontSizeInput.Name] = FontSizeSlider; SSliders[BlockHeightInput.Name] = BlockHeightSlider; SSliders[LineSpacingInput.Name] = LineSpacingSlider; SSliders[ParaSpacingInput.Name] = ParaSpacingSlider; FontSizeSlider.Value = GRConfig.ContentReader.FontSize; LineSpacingSlider.Value = GRConfig.ContentReader.LineHeight; ParaSpacingSlider.Value = 2 * GRConfig.ContentReader.ParagraphSpacing; FontSizeInput.Text = FontSizeSlider.Value.ToString(); LineSpacingInput.Text = LineSpacingSlider.Value.ToString(); ParaSpacingInput.Text = ParaSpacingSlider.Value.ToString(); double BlockHeight = GRConfig.ContentReader.BlockHeight; if (0 < BlockHeight) { BlockHeightSlider.Value = BlockHeight; } FontWeight FWeight = GRConfig.ContentReader.FontWeight; // Set font weights Dictionary <string, FontWeight> ForReflection = new Dictionary <string, FontWeight>() { { "Thin", FontWeights.Thin } , { "ExtraLight", FontWeights.ExtraLight } , { "Light", FontWeights.Light } , { "SemiLight", FontWeights.SemiLight } , { "Normal", FontWeights.Normal } , { "Medium", FontWeights.Medium } , { "SemiBold", FontWeights.SemiBold } , { "Bold", FontWeights.Bold } , { "ExtraBold", FontWeights.ExtraBold } , { "Black", FontWeights.Black } , { "ExtraBlack", FontWeights.ExtraBlack } }; Logger.Log(ID, "Default FontWeight is " + FWeight.Weight); List <PInfoWrapper> PIW = new List <PInfoWrapper>(); foreach (KeyValuePair <string, FontWeight> K in ForReflection) { PInfoWrapper PWrapper = new PInfoWrapper(K.Key, K.Value); PIW.Add(PWrapper); } FontWeightCB.ItemsSource = PIW; FontWeightCB.SelectedItem = PIW.First(x => x.Weight.Weight == FWeight.Weight); YClock.Time = XClock.Time = DateTime.Now; XDayofWeek.Text = YDayofWeek.Text = YClock.Time.ToString("dddd"); XDayofMonth.Text = YDayofMonth.Text = YClock.Time.Day.ToString(); XMonth.Text = YMonth.Text = YClock.Time.ToString("MMMM"); SetLayoutAware(); UpdateExampleLs(); UpdateExamplePs(); UpdateExampleFc(); UpdateExampleFs(); UpdateExampleBh(); for (int i = 0; i < 3; i++) { var j = ContentGrid.Dispatcher.RunIdleAsync((x) => { UpdateExampleFs(); UpdateExampleBh(); }); } }
private void InitTemplate() { ReaderContext = new ReaderView(); ContentGrid.DataContext = ReaderContext; ContextGrid.DataContext = new ESContext(); RBgContext = ReaderContext.Settings.GetBgContext(); ContentBg.DataContext = RBgContext; RBgContext.ApplyBackgrounds(); StringResources stx = new StringResources( "Settings" ); ExpContent = new Paragraph[] { new Paragraph( stx.Text( "Appearance_ContentReader_Exp1") ) , new Paragraph( stx.Text( "Appearance_ContentReader_Exp2") ) , new Paragraph( stx.Text( "Appearance_ContentReader_Exp3") ) , new Paragraph( stx.Text( "Appearance_ContentReader_Exp4") ) }; XTitleStepper.Text = YTitleStepper.Text = stx.Text( "Appearance_ContentReader_Exp2" ); ColorList.ItemsSource = new ColorItem[] { new ColorItem( stx.Text( "Appearance_ContentReader_Background" ) , Properties.APPEARANCE_CONTENTREADER_BACKGROUND ) { BindAction = ( c ) => { Properties.APPEARANCE_CONTENTREADER_BACKGROUND = c; UpdateExampleFc(); } } , new ColorItem( stx.Text( "Appearance_ContentReader_FontColor" ) , Properties.APPEARANCE_CONTENTREADER_FONTCOLOR ) { BindAction = ( c ) => { Properties.APPEARANCE_CONTENTREADER_FONTCOLOR = c; } } , new ColorItem( stx.Text( "Appearance_ContentReader_TapBrushColor" ) , Properties.APPEARANCE_CONTENTREADER_TAPBRUSHCOLOR ) { BindAction = ( c ) => { Properties.APPEARANCE_CONTENTREADER_TAPBRUSHCOLOR = c; } } , new ColorItem( stx.Text( "Appearance_ContentReader_NavBg" ) , Properties.APPEARANCE_CONTENTREADER_NAVBG ) { BindAction = ( c ) => { Properties.APPEARANCE_CONTENTREADER_NAVBG = c; } } , new ColorItem( stx.Text( "Appearance_ContentReader_AssistHelper" ) , Properties.APPEARANCE_CONTENTREADER_ASSISTBG ) { BindAction = ( c ) => { Properties.APPEARANCE_CONTENTREADER_ASSISTBG = c; } } }; ClockColorList.ItemsSource = new ColorItem[] { new ColorItem( stx.Text( "Appearance_ContentReader_Clock_ARColor" ) , Properties.APPEARANCE_CONTENTREADER_CLOCK_ARCOLOR ) { BindAction = ( c ) => { Properties.APPEARANCE_CONTENTREADER_CLOCK_ARCOLOR = c; } } , new ColorItem( stx.Text( "Appearance_ContentReader_Clock_HHColor" ) , Properties.APPEARANCE_CONTENTREADER_CLOCK_HHCOLOR ) { BindAction = ( c ) => { Properties.APPEARANCE_CONTENTREADER_CLOCK_HHCOLOR = c; } } , new ColorItem( stx.Text( "Appearance_ContentReader_Clock_MHColor" ) , Properties.APPEARANCE_CONTENTREADER_CLOCK_MHCOLOR ) { BindAction = ( c ) => { Properties.APPEARANCE_CONTENTREADER_CLOCK_MHCOLOR = c; } } , new ColorItem( stx.Text( "Appearance_ContentReader_Clock_SColor" ) , Properties.APPEARANCE_CONTENTREADER_CLOCK_SCOLOR ) { BindAction = ( c ) => { Properties.APPEARANCE_CONTENTREADER_CLOCK_SCOLOR = c; } } , new ColorItem( stx.Text( "Appearance_ContentReader_EStepper_DColor" ) , Properties.APPEARANCE_CONTENTREADER_ES_DCOLOR ) { BindAction = ( c ) => { Properties.APPEARANCE_CONTENTREADER_ES_DCOLOR = c; } } , new ColorItem( stx.Text( "Appearance_ContentReader_EStepper_SColor" ) , Properties.APPEARANCE_CONTENTREADER_ES_SCOLOR ) { BindAction = ( c ) => { Properties.APPEARANCE_CONTENTREADER_ES_SCOLOR = c; } } , new ColorItem( stx.Text( "Appearance_ContentReader_Background" ) , Properties.APPEARANCE_CONTENTREADER_ES_BG ) { BindAction = ( c ) => { Properties.APPEARANCE_CONTENTREADER_ES_BG = c; } } }; BatteryReport Report = Battery.AggregateBattery.GetReport(); if ( Report.RemainingCapacityInMilliwattHours != null ) { YClock.Progress = XClock.Progress = ( float ) Report.RemainingCapacityInMilliwattHours / ( float ) Report.FullChargeCapacityInMilliwattHours; } FontSizeSlider.Value = Properties.APPEARANCE_CONTENTREADER_FONTSIZE; LineSpacingSlider.Value = Properties.APPEARANCE_CONTENTREADER_LINEHEIGHT; ParagraphSpacingSlider.Value = 2 * Properties.APPEARANCE_CONTENTREADER_PARAGRAPHSPACING; FontWeight FWeight = Properties.APPEARANCE_CONTENTREADER_FONTWEIGHT; // Set font weights Dictionary<string, FontWeight> ForReflection = new Dictionary<string, FontWeight>() { { "Thin", FontWeights.Thin } , { "ExtraLight", FontWeights.ExtraLight } , { "Light", FontWeights.Light } , { "SemiLight", FontWeights.SemiLight } , { "Normal", FontWeights.Normal } , { "Medium", FontWeights.Medium } , { "SemiBold", FontWeights.SemiBold } , { "Bold", FontWeights.Bold } , { "ExtraBold", FontWeights.ExtraBold } , { "Black", FontWeights.Black } , { "ExtraBlack", FontWeights.ExtraBlack } }; Logger.Log( ID, "Default FontWeight is " + FWeight.Weight ); List<PInfoWrapper> PIW = new List<PInfoWrapper>(); foreach ( KeyValuePair<string, FontWeight> K in ForReflection ) { PInfoWrapper PWrapper = new PInfoWrapper( K.Key, K.Value ); PIW.Add( PWrapper ); } FontWeightCB.ItemsSource = PIW; FontWeightCB.SelectedItem = PIW.First( x => x.Weight.Weight == FWeight.Weight ); YClock.Time = XClock.Time = DateTime.Now; XDayofWeek.Text = YDayofWeek.Text = YClock.Time.ToString( "dddd" ); XDayofMonth.Text = YDayofMonth.Text = YClock.Time.Day.ToString(); XMonth.Text = YMonth.Text = YClock.Time.ToString( "MMMM" ); SetLayoutAware(); UpdateExampleLs(); UpdateExamplePs(); UpdateExampleFc(); UpdateExampleFs(); for ( int i = 0; i < 3; i++ ) { var j = ContentGrid.Dispatcher.RunIdleAsync( ( x ) => UpdateExampleFs() ); } }