Ejemplo n.º 1
0
        protected override void OnNavigatedTo( NavigationEventArgs e )
        {
            base.OnNavigatedTo( e );
            Logger.Log( ID, string.Format( "OnNavigatedTo: {0}", e.SourcePageType.Name ), LogType.INFO );

            InitTemplate( CurrentSet = e.Parameter as ThemeSet );
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // get a syntax
            SyntaxSet ss     = SyntaxSet.LoadDefaults();
            Syntax    syntax = ss.FindByExtension("cs"); // syntax for C#

            // get a theme
            ThemeSet ts    = ThemeSet.LoadDefaults();
            Theme    theme = ts["InspiredGitHub"]; // github syntax highlighting theme

            // highlight source code to html
            string sourceCode = @"using ColorfulCode;

namespace HelloWorld {
    class Program {
        static Main(string[] args) {
            Console.WriteLine(""Hello World"");
        }
    }
}
";
            string html       = syntax.HighlightToHtml(sourceCode, theme);

            Console.WriteLine(html);
        }
Ejemplo n.º 3
0
        private void SetThemeBlocks(ThemeSet ColorSet)
        {
            List <ThemeTextBlock> ThemeBlocks = new List <ThemeTextBlock>();

            Type TypeInfo = typeof(ThemeSet);

            // Major Color Schemes
            PutThemeBlocks(
                ThemeBlocks
                , new string[] { "ColorMajor", "ColorMinor", "RelColorMajorBackground", "SubtleColor" }
                , new string[] { "BgColorMajor", "BgColorMinor" }
                , ColorSet
                );

            // Major Text Schemes
            PutThemeBlocks(
                ThemeBlocks
                , new string[] { "RelColorMajor" }
                , new string[] { "ColorMajor", "ColorMinor" }
                , ColorSet
                );

            // Shades Major Schemes
            PutThemeBlocks(
                ThemeBlocks
                , new string[] { "RelColorMajorBackground" }
                , new string[] { "ColorMajor", "ColorMinor", "RibbonColorHorz", "RibbonColorVert" }
                , ColorSet
                );

            ThemeView.ItemsSource  = ThemeBlocks;
            ThemeView.SelectedItem = ThemeBlocks;
            ViewShades(ThemeBlocks[0]);
        }
Ejemplo n.º 4
0
        public ThemeControl(ThemeSet theme)
        {
            Theme = theme;
            InitializeComponent();

            ThemeName.Text = theme.ThemeName;
            ThemeText.Text = theme.ThemeText;
        }
Ejemplo n.º 5
0
        public SimpleTheme(ThemeSet theme, string AuthorName)
        {
            InitializeComponent();
            Theme = theme;

            ThemeName.Text = Theme.ThemeName;
            Author.Text   += " " + AuthorName;
        }
Ejemplo n.º 6
0
        public Redactor(ThemeSet theme)
        {
            Theme = theme;
            InitializeComponent();

            ThemeName.Text = Theme.ThemeName;
            ThemeText.Text = Theme.ThemeText;
        }
Ejemplo n.º 7
0
 private void InitTemplate( ThemeSet ColorSet )
 {
     List<ColorItem> Items = new List<ColorItem>();
     foreach( KeyValuePair<string, string> s in ThemeSet.ParamMap )
     {
         Items.Add( new ColorItem( s.Value, ColorSet.ColorDefs[ s.Key ] ) );
     }
     ColorList.ItemsSource = Items;
 }
Ejemplo n.º 8
0
        private void InitTemplate(ThemeSet ColorSet)
        {
            List <ColorItem> Items = new List <ColorItem>();

            foreach (KeyValuePair <string, string> s in ThemeSet.ParamMap)
            {
                Items.Add(new ColorItem(s.Value, ColorSet.ColorDefs[s.Key]));
            }
            ColorList.ItemsSource = Items;
        }
Ejemplo n.º 9
0
        private void ThemeContextMenu(object sender, RightTappedRoutedEventArgs e)
        {
            StackPanel ThemeItem = sender as StackPanel;

            if (ThemeItem == null)
            {
                return;
            }

            FlyoutBase.ShowAttachedFlyout(ThemeItem);
            FlyoutBase ThemeContext = FlyoutBase.GetAttachedFlyout(ThemeItem);

            SelectedTheme = ThemeItem.DataContext as ThemeSet;
        }
Ejemplo n.º 10
0
        public SingleTheme(ThemeSet theme)
        {
            InitializeComponent();
            Theme = theme;

            using (ForumContainer container = new ForumContainer())
            {
                var account = container.AccountSet.SingleOrDefault(x => x.AccountId == Theme.AuthorId);
                ThemeAuthor.Text      = "Автор: " + account.Name.TrimEnd();
                ThemeAuthor.Text     += "\n" + Theme.CreateDate;
                CommentoryCount.Text += "  " + container.CommentorySet.Where(x => x.ThemeId == Theme.ThemeId).ToList().Count;
            }
            ThemeName.Text      = Theme.ThemeName;
            ThemeStartText.Text = Theme.ThemeText;
        }
Ejemplo n.º 11
0
        private async void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            // Save the selected set since in time this will be unselected and cause problem
            ThemeSet ThisSet = Presets.SelectedItem as ThemeSet;

            if (ThisSet == null)
            {
                return;
            }

            if (!await MainSettings.Instance.ConfirmRestart("Appearance_Theme"))
            {
                return;
            }

            ThisSet.Apply();
        }
Ejemplo n.º 12
0
        public InteractiveThemeControl(ThemeSet theme)
        {
            EventHandlerTransform handlerTransform = new EventHandlerTransform(Theme, this);

            handlerTransform.LoadAllLinks();

            InitializeComponent();
            Theme = theme;

            ThemeText.Text = Theme.ThemeText;
            int v1 = ThemeText.Text.IndexOf('<');
            int v2 = ThemeText.Text.IndexOf('>');

            ThemeText.LinkArea = new LinkArea(v1, v2);

            handlerTransform.SetLinkLabel(ThemeText);
            ThemeText.LinkClicked += handlerTransform.GetParametrByName(Theme.ThemeText.Substring(++v1, ++v2));
        }
Ejemplo n.º 13
0
        private void SetupThemes()
        {
            ResourceDictionary[] darkTheme  = new ResourceDictionary[1];
            ResourceDictionary[] lightTheme = new ResourceDictionary[1];

            // Dark
            darkTheme[0] = ResourceHandler.GetThemeResourceDictionary(GetAssemblyName(), ResourceHandler.THEME_DARK);
            ThemeSet darkSet = ThemeSet.CreateThemeSet(darkTheme);

            ResourceHandler.ThemeSets.Add(ResourceHandler.THEME_DARK, darkSet);

            // Light
            lightTheme[0] = ResourceHandler.GetThemeResourceDictionary(GetAssemblyName(), ResourceHandler.THEME_LIGHT);
            ThemeSet lightSet = ThemeSet.CreateThemeSet(lightTheme);

            ResourceHandler.ThemeSets.Add(ResourceHandler.THEME_LIGHT, lightSet);

            ThemeManager.TurnOnThemeTracker();
        }
Ejemplo n.º 14
0
        private void SendOnDatebaseButton_Click(object sender, EventArgs e)
        {
            if (ThemeName.Text == string.Empty)
            {
                MessageBox.Show("Имя темы не может быть пустым.");
                return;
            }

            if (ThemeText.Text.Length < 25)
            {
                MessageBox.Show("Текст темы не может быть менее, чем 25 символов.");
                return;
            }

            if (Author.AccountType == 0)
            {
                if (Author.Reputation < 25 || Author.Reputation == 0)
                {
                    MessageBox.Show("Вы не можете отправлять заявки на темы. Вам не хватает репутации.");
                    return;
                }
            }

            using (ForumContainer container = new ForumContainer()) {
                ThemeSet newTheme = new ThemeSet()
                {
                    AuthorId    = Author.AccountId,
                    ThemeName   = ThemeName.Text,
                    ThemeText   = ThemeText.Text,
                    ThemePoints = 0,
                    CreateDate  = DateTime.Now,
                    Visible     = false
                };

                container.ThemeSet.Add(newTheme);
                container.SaveChanges();

                MessageBox.Show("Тема была успешно отправлена на редакцию");
            }
        }
Ejemplo n.º 15
0
        private void ThemeContextMenu( object sender, RightTappedRoutedEventArgs e )
        {
            StackPanel ThemeItem = sender as StackPanel;
            if ( ThemeItem == null ) return;

            FlyoutBase.ShowAttachedFlyout( ThemeItem );
            FlyoutBase ThemeContext = FlyoutBase.GetAttachedFlyout( ThemeItem );

            SelectedTheme = ThemeItem.DataContext as ThemeSet;
        }
Ejemplo n.º 16
0
        public ThemePreviewButton(ThemeSet themeSet, ThemeColorPanel themeColorPanel)
        {
            this.ThemeSet = themeSet;

            var theme = themeSet.Theme;

            var primaryAccentColor = theme.PrimaryAccentColor;

            this.Padding         = 8;
            this.BackgroundColor = theme.BackgroundColor;
            this.Cursor          = Cursors.Hand;

            secondaryBackground = new GuiWidget()
            {
                HAnchor         = HAnchor.Absolute | HAnchor.Left,
                VAnchor         = VAnchor.Stretch,
                Margin          = new BorderDouble(0),
                Width           = 20 * GuiWidget.DeviceScale,
                BackgroundColor = theme.MinimalShade,
            };
            this.AddChild(secondaryBackground);

            accentColor = new GuiWidget()
            {
                HAnchor         = HAnchor.Stretch,
                VAnchor         = VAnchor.Absolute | VAnchor.Top,
                Height          = 6 * GuiWidget.DeviceScale,
                Margin          = new BorderDouble(left: 25),
                BackgroundColor = primaryAccentColor,
            };
            this.AddChild(accentColor);

            icon1 = new GuiWidget()
            {
                HAnchor         = HAnchor.Absolute | HAnchor.Left,
                VAnchor         = VAnchor.Absolute | VAnchor.Top,
                Height          = 8 * GuiWidget.DeviceScale,
                Width           = 8 * GuiWidget.DeviceScale,
                Margin          = new BorderDouble(left: 6, top: 6),
                BackgroundColor = primaryAccentColor,
            };
            this.AddChild(icon1);

            icon2 = new GuiWidget()
            {
                HAnchor         = HAnchor.Absolute | HAnchor.Left,
                VAnchor         = VAnchor.Absolute | VAnchor.Top,
                Height          = 8 * GuiWidget.DeviceScale,
                Width           = 8 * GuiWidget.DeviceScale,
                Margin          = new BorderDouble(left: 6, top: 20),
                BackgroundColor = primaryAccentColor,
            };
            this.AddChild(icon2);

            icon3 = new GuiWidget()
            {
                HAnchor         = HAnchor.Absolute | HAnchor.Left,
                VAnchor         = VAnchor.Absolute | VAnchor.Top,
                Height          = 8 * GuiWidget.DeviceScale,
                Width           = 8 * GuiWidget.DeviceScale,
                Margin          = new BorderDouble(left: 6, top: 34),
                BackgroundColor = primaryAccentColor,
            };
            this.AddChild(icon3);

            tertiaryBackground = new GuiWidget()
            {
                HAnchor         = HAnchor.Stretch,
                VAnchor         = VAnchor.Absolute | VAnchor.Top,
                Height          = 37 * GuiWidget.DeviceScale,
                Margin          = new BorderDouble(left: 25, top: 12),
                BackgroundColor = theme.SlightShade,
            };
            this.AddChild(tertiaryBackground);

            var overlay = new GuiWidget
            {
                VAnchor = VAnchor.Stretch,
                HAnchor = HAnchor.Stretch,
                Cursor  = Cursors.Hand
            };

            overlay.Click += (s, e) =>
            {
                // Activate the theme
                themeColorPanel.SetThemeColor(this.ThemeSet, primaryAccentColor, this.Mode);

                // Disable further theme clicks until reload completes
                themeColorPanel.Enabled = false;
            };

            this.AddChild(overlay);
        }
Ejemplo n.º 17
0
 private void PutThemeBlocks(List <ThemeTextBlock> Blocks, string[] FGs, string[] BGs, ThemeSet ColorSet)
 {
     foreach (string FG in FGs)
     {
         foreach (string BG in BGs)
         {
             Blocks.Add(new ThemeTextBlock(FG, BG, ColorSet));
         }
     }
 }
Ejemplo n.º 18
0
        private void SetThemeBlocks( ThemeSet ColorSet )
        {
            List<ThemeTextBlock> ThemeBlocks = new List<ThemeTextBlock>();

            Type TypeInfo = typeof( ThemeSet );

            // Major Color Schemes
            PutThemeBlocks(
                ThemeBlocks
                , new string[] {
                    "APPEARENCE_THEME_MAJOR_COLOR"
                    , "APPEARENCE_THEME_MINOR_COLOR"
                    , "APPEARENCE_THEME_TEXT_COLOR_RELATIVE_TO_BACKGROUND"
                    , "APPEARENCE_THEME_SUBTLE_TEXT_COLOR"
                }
                , new string[]
                {
                    "APPEARENCE_THEME_MAJOR_BACKGROUND_COLOR"
                    , "APPEARENCE_THEME_MINOR_BACKGROUND_COLOR"
                }
                , ColorSet
            );

            // Major Text Schemes
            PutThemeBlocks(
                ThemeBlocks
                , new string[] {
                    "APPEARENCE_THEME_TEXT_COLOR_RELATIVE_TO_MAJOR"
                }
                , new string[]
                {
                    "APPEARENCE_THEME_MAJOR_COLOR"
                    , "APPEARENCE_THEME_MINOR_COLOR"
                }
                , ColorSet
            );

            // Shades Major Schemes
            PutThemeBlocks(
                ThemeBlocks
                , new string[] {
                    "APPEARENCE_THEME_TEXT_COLOR_RELATIVE_TO_MAJOR"
                }
                , new string[]
                {
                    "APPEARENCE_THEME_MAJOR_COLOR"
                    , "APPEARENCE_THEME_MINOR_COLOR"
                    , "APPEARENCE_THEME_HORIZONTAL_RIBBON_COLOR"
                    , "APPEARENCE_THEME_VERTICAL_RIBBON_COLOR"
                }
                , ColorSet
            );

            ThemeView.ItemsSource = ThemeBlocks;
            ThemeView.SelectedItem = ThemeBlocks;
            ViewShades( ThemeBlocks[ 0 ] );
        }
Ejemplo n.º 19
0
        private Task MigrateSettings()
        {
            return(Task.Run(() =>
            {
                ThemeSet ThSet = GSystem.ThemeManager.DefaultDark();
                ThSet.GreyShades();

                GRConfig.ContentReader.BackgroundColor = Color.FromArgb(255, 20, 20, 20);
                GRConfig.ContentReader.FontColor = Color.FromArgb(255, 45, 77, 59);
                GRConfig.ContentReader.TapBrushColor = Color.FromArgb(255, 138, 41, 0);
                GRConfig.ContentReader.BgColorNav = Color.FromArgb(255, 50, 50, 50);
                GRConfig.ContentReader.BgColorAssist = Color.FromArgb(23, 0, 0, 0);
                ThSet.Apply();

                Dictionary <string, Action <object> > LegacyConf = new Dictionary <string, Action <object> >
                {
                    ["ContentReader_Autobookmark"] = x => GRConfig.ContentReader.AutoBookmark = ( bool )x,
                    ["ContentReader_UseInertia"] = x => GRConfig.ContentReader.UseInertia = ( bool )x,
                    ["Appearance_ContentReader_FontSize"] = x => GRConfig.ContentReader.FontSize = ( double )x,
                    ["Appearance_ContentReader_LeftContext"] = x => GRConfig.ContentReader.LeftContext = ( bool )x,
                    ["Appearance_ContentReader_EmbedIllus"] = x => GRConfig.ContentReader.EmbedIllus = ( bool )x,
                    ["Appearance_ContentReader_LineHeight"] = x => GRConfig.ContentReader.LineHeight = ( double )x,
                    ["Appearance_ContentReader_ParagraphSpacing"] = x => GRConfig.ContentReader.ParagraphSpacing = 2 * ( double )x,
                    ["Appearance_ContentReader_BlockHeight"] = x => GRConfig.ContentReader.BlockHeight = ( double )x,
                    ["Appearance_ContentReader_FontColor"] = x => GRConfig.ContentReader.FontColor = GetColorFromByte(x),
                    ["Appearance_ContentReader_Clock_Arc_Hand_Color"] = x => GRConfig.ContentReader.Clock.ARColor = GetColorFromByte(x),
                    ["Appearance_ContentReader_Clock_Hour_Hand_Color"] = x => GRConfig.ContentReader.Clock.HHColor = GetColorFromByte(x),
                    ["Appearance_ContentReader_Clock_Hour_Hand_Color"] = x => GRConfig.ContentReader.Clock.HHColor = GetColorFromByte(x),
                    ["Appearance_ContentReader_Clock_Minute_Hand_Color"] = x => GRConfig.ContentReader.Clock.MHColor = GetColorFromByte(x),
                    ["Appearance_ContentReader_Clock_Scales_Color"] = x => GRConfig.ContentReader.Clock.SColor = GetColorFromByte(x),
                    ["Appearance_ContentReader_EpStepper_DateColor"] = x => GRConfig.ContentReader.EpStepper.DColor = GetColorFromByte(x),
                    ["Appearance_ContentReader_EpStepper_StepperColor"] = x => GRConfig.ContentReader.EpStepper.SColor = GetColorFromByte(x),
                    ["Appearance_ContentReader_EpStepper_Background"] = x => GRConfig.ContentReader.EpStepper.BackgroundColor = GetColorFromByte(x),
                    ["Appearance_ContentReader_AssistBg"] = x => GRConfig.ContentReader.BgColorAssist = GetColorFromByte(x),
                    ["Appearance_ContentReader_NavBg"] = x => GRConfig.ContentReader.BgColorNav = GetColorFromByte(x),
                    ["Appearance_ContentReader_FontWeight"] = x => GRConfig.ContentReader.FontWeight = new Windows.UI.Text.FontWeight()
                    {
                        Weight = ( ushort )x
                    },
                    ["Appearance_ContentReader_Background"] = x => GRConfig.ContentReader.BackgroundColor = GetColorFromByte(x),
                    ["Appearance_ContentReader_ScrollBar"] = x => GRConfig.ContentReader.ScrollBarColor = GetColorFromByte(x),
                    ["Appearance_ContentReader_EnableReadingAnchor"] = x => GRConfig.ContentReader.ReadingAnchor = ( bool )x,
                    ["Appearance_ContentReader_EnableDoubleTap"] = x => GRConfig.ContentReader.DoubleTap = ( bool )x,
                    ["Appearance_ContentReader_TapBrushColor"] = x => GRConfig.ContentReader.TapBrushColor = GetColorFromByte(x),

                    ["Appearance_Theme_Text_Color_Relative_To_Background"] = x => GRConfig.Theme.RelColorMajorBackground = GetColorFromByte(x),
                    ["Appearance_Theme_Text_Color_Relative_To_Major"] = x => GRConfig.Theme.RelColorMajor = GetColorFromByte(x),
                    ["Appearance_Theme_Subtle_Text_Color"] = x => GRConfig.Theme.SubtleColor = GetColorFromByte(x),
                    ["Appearance_Theme_Major_Background_Color"] = x => GRConfig.Theme.BgColorMajor = GetColorFromByte(x),
                    ["Appearance_Theme_Minor_Background_Color"] = x => GRConfig.Theme.BgColorMinor = GetColorFromByte(x),
                    ["Appearance_Theme_Major_Color"] = x => GRConfig.Theme.ColorMajor = GetColorFromByte(x),
                    ["Appearance_Theme_Minor_Color"] = x => GRConfig.Theme.ColorMinor = GetColorFromByte(x),
                    ["Appearance_Theme_Horizontal_Ribbon_Color"] = x => GRConfig.Theme.RibbonColorHorz = GetColorFromByte(x),
                    ["Appearance_Theme_Vertical_Ribbon_Color"] = x => GRConfig.Theme.RibbonColorVert = GetColorFromByte(x),
                    ["Appearance_Theme_Shades_10"] = x => GRConfig.Theme.Shades10 = GetColorFromByte(x),
                    ["Appearance_Theme_Shades_20"] = x => GRConfig.Theme.Shades20 = GetColorFromByte(x),
                    ["Appearance_Theme_Shades_30"] = x => GRConfig.Theme.Shades30 = GetColorFromByte(x),
                    ["Appearance_Theme_Shades_40"] = x => GRConfig.Theme.Shades40 = GetColorFromByte(x),
                    ["Appearance_Theme_Shades_50"] = x => GRConfig.Theme.Shades50 = GetColorFromByte(x),
                    ["Appearance_Theme_Shades_60"] = x => GRConfig.Theme.Shades60 = GetColorFromByte(x),
                    ["Appearance_Theme_Shades_70"] = x => GRConfig.Theme.Shades70 = GetColorFromByte(x),
                    ["Appearance_Theme_Shades_80"] = x => GRConfig.Theme.Shades80 = GetColorFromByte(x),
                    ["Appearance_Theme_Shades_90"] = x => GRConfig.Theme.Shades90 = GetColorFromByte(x),
                    ["Appearence_Theme_Relative_Shades_Color"] = x => GRConfig.Theme.RelColorShades = GetColorFromByte(x),

                    ["Enable_OneDrive"] = x => GRConfig.System.EnableOneDrive = ( bool )x,
                    ["Misc_Text_Patch_Syntax"] = x => GRConfig.System.PatchSyntax = ( bool )x,
                    ["Misc_Chunk_Single_Volume"] = x => GRConfig.System.ChunkSingleVol = ( bool )x
                };

                foreach (KeyValuePair <string, Action <object> > Conf in LegacyConf)
                {
                    if (Settings.TryGetValue(Conf.Key, out object value))
                    {
                        Conf.Value(value);
                        Settings.Remove(Conf.Key);
                    }
                }
            }));
        }
Ejemplo n.º 20
0
 public EditColors(ThemeSet ThemeColors)
     : this()
 {
     InitTemplate(CurrentSet = ThemeColors);
 }
Ejemplo n.º 21
0
 private void PutThemeBlocks( List<ThemeTextBlock> Blocks, string[] FGs, string[] BGs, ThemeSet ColorSet )
 {
     foreach ( string FG in FGs )
     {
         foreach ( string BG in BGs )
         {
             Blocks.Add( new ThemeTextBlock( FG, BG, ColorSet ) );
         }
     }
 }
Ejemplo n.º 22
0
 public EventHandlerTransform(ThemeSet set, InteractiveThemeControl control)
 {
     Theme   = set;
     Control = control;
 }
Ejemplo n.º 23
0
		private void PanelTheme_Load(object sender, System.EventArgs e)
		{
			PanelThemeSaveP.Visible = IsEdit;
			if (!Page.IsPostBack)
			{
				Query q = new Query();
				q.OrderBy = new OrderBy(Theme.Columns.Order);
				ThemeSet ts = new ThemeSet(q);

				ThemesRadioButtonList.DataTextField = "RadioButtonText";
				ThemesRadioButtonList.DataValueField = "K";
				ThemesRadioButtonList.DataSource = ts;
				ThemesRadioButtonList.DataBind();

				if (IsEdit)
				{
					if (CurrentGroup.ThemeK == 0)
						ThemesRadioButtonList.SelectedValue = "18";
					else
						ThemesRadioButtonList.SelectedValue = CurrentGroup.ThemeK.ToString();
				}
				if (IsEdit && CurrentGroup.BrandK > 0)
				{
					foreach (ListItem li in ThemesRadioButtonList.Items)
					{
						if (!li.Value.Equals("1"))
							li.Attributes["disabled"] = "true";
					}
				}
			}
		}