コード例 #1
0
ファイル: ExpressionEngine.cs プロジェクト: Egaros/lib
 private ExpressionEngine()
 {
     _engine.RegisterMethod <Color, double, Color>("Tint", (color, amount) => ColorFunctions.Tint(color.ToRgbColor(), amount, ColorFunctionUnits.Relative).ToXamlColor());
     _engine.RegisterMethod <Color, double, Color>("Shade", (color, amount) => ColorFunctions.Shade(color.ToRgbColor(), amount, ColorFunctionUnits.Relative).ToXamlColor());
     _engine.RegisterMethod <Color, double, Color>("Lighten", (color, amount) => ColorFunctions.Lighten(color.ToRgbColor(), amount, ColorFunctionUnits.Relative).ToXamlColor());
     _engine.RegisterMethod <Color, double, Color>("Darken", (color, amount) => ColorFunctions.Darken(color.ToRgbColor(), amount, ColorFunctionUnits.Relative).ToXamlColor());
 }
コード例 #2
0
ファイル: frmInvestimentos.cs プロジェクト: nfrick/MoneyBin2
        private static void PopulateBarChart(IEnumerable <Patrimonio> data, Chart chart)
        {
            chart.Visible = false;
            chart.Series.Clear();

            var data1 = data.ToArray();

            if (!data1.Any())
            {
                return;
            }

            var total = data1.Sum(d => d.Valor);

            if (total == 0)
            {
                return;
            }

            chart.Visible        = true;
            chart.Titles[0].Text = $"Total: {total:N2}";
            foreach (var d in data1.Where(d => d.Valor > 0))
            {
                var serie = chart.Series.Add(d.Item);
                serie.ChartType = SeriesChartType.StackedColumn100;
                serie.Font      = new Font("Segoe UI", 7);
                serie.Label     = $"{d.Valor / total:P0}";
                serie.Points.AddY((double)d.Valor);
                //chart.ApplyPaletteColors();
                serie.LabelForeColor = ColorFunctions.ContrastColor(serie.Color);
            }
            chart.ApplyPaletteColors();
        }
コード例 #3
0
        private void _currentAlbumImage_DownloadCompleted(object sender, EventArgs e)
        {
            this.CurrentAlbumImage = _currentAlbumImage;
            var color = ColorFunctions.GetImageColor(_currentAlbumImage);

            this.BackgroundColor = new SolidColorBrush(color);
            _eventAggregator.GetEvent <SwitchBackgroudColorEvent>().Publish(color);
        }
コード例 #4
0
 public ActionResult GetColor(DAL.Entities.Color color)
 {
     try
     {
         return(Json(ColorFunctions.Get(color)));
     }
     catch (Exception ex)
     {
         return(Json("Error occurred. Error details: " + ex.Message));
     }
 }
コード例 #5
0
 private void RadWindowsTheme_Click(object sender, RoutedEventArgs e)
 {
     ClrCustomColor.IsEnabled       = false;
     Group.SelectedBackgroundOption = BackgroundOption.WindowsTheme;
     if (ColorFunctions.getThemeMode())
     {
         Group.BackgroundColor = Color.FromRgb(230, 230, 230).ToString();
     }
     else
     {
         Group.BackgroundColor = Color.FromRgb(30, 30, 30).ToString();
     }
 }
コード例 #6
0
ファイル: Converters.cs プロジェクト: soulhez/DouBanFM_WPF
 /// <summary>
 /// 由窗口背景转换为进度条前景
 /// </summary>
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (value is SolidColorBrush)
     {
         SolidColorBrush brush = new SolidColorBrush(ColorFunctions.ReviseBrighter(new HslColor(((SolidColorBrush)value).Color), ColorFunctions.ProgressBarReviseParameter).ToRgb());
         brush.Opacity = ((SolidColorBrush)value).Opacity;
         if (brush.CanFreeze)
         {
             brush.Freeze();
         }
         return(brush);
     }
     return(value);
 }
コード例 #7
0
        private void CurrentAccentButton_Click(object sender, RoutedEventArgs e)
        {
            var f = Path.GetTempFileName();

            DrawFilledRectangle(1024, 1024, new SolidBrush(System.Drawing.Color.Transparent)).Save(f, ImageFormat.Png);

            _mainWindow.SelectedFile = f;

            var c = ColorFunctions.GetImmersiveColor(ImmersiveColors.ImmersiveStartBackground);

            Reset(FillImageColor(c));


            SolidColorPicker.SelectedColor = c.ToMediaColor();
        }
コード例 #8
0
ファイル: frmGrafico.cs プロジェクト: nfrick/MoneyBin2
 private void invertBackgroundToolStripMenuItem_Click(object sender, EventArgs e)
 {
     foreach (var axis in chart.ChartAreas[0].Axes)
     {
         axis.LineColor            = ColorFunctions.InvertColor(axis.LineColor);
         axis.MajorGrid.LineColor  = ColorFunctions.InvertColor(axis.LineColor);
         axis.MinorGrid.LineColor  = ColorFunctions.InvertColor(axis.LineColor);
         axis.LabelStyle.ForeColor = ColorFunctions.InvertColor(axis.LabelStyle.ForeColor);
     }
     foreach (var legend in chart.Legends)
     {
         legend.ForeColor = ColorFunctions.InvertColor(legend.ForeColor);
     }
     chart.BackColor = ColorFunctions.InvertColor(chart.BackColor);
 }
コード例 #9
0
ファイル: frmInvestimentos.cs プロジェクト: nfrick/MoneyBin2
        private void BindDataSourceAndPopulatePieChart(IEnumerable <Patrimonio> data,
                                                       string fonte)
        {
            var dgv   = fonte == "Ações" ? dgvResumoAcoes : dgvResumoFundos;
            var chart = fonte == "Ações" ? chartResumoAcoes : chartResumoFundos;
            var label = fonte == "Ações" ? labelResumoAcoes : labelResumoFundos;

            var data1 = data.ToArray();

            dgv.Visible = chart.Visible = label.Visible = false;
            chart.Series.Clear();

            if (!data1.Any())
            {
                return;
            }

            var total = data1.Sum(d => d.Valor);

            if (total == 0 && !_chkShowAll.Checked)
            {
                return;
            }

            dgv.Visible = label.Visible = true;
            if (total == 0)
            {
                return;
            }
            chart.Visible        = true;
            chart.Titles[0].Text = $"{fonte}: {total:N2}";
            var serie = chart.Series.Add("AAA");

            serie.ChartType = SeriesChartType.Pie;
            serie.Font      = new Font("Segoe UI", 7);
            foreach (var d in data1.Where(d => d.Valor > 0))
            {
                var dp = serie.Points.Add((double)d.Valor);
                dp.LegendText     = d.Item;
                dp.AxisLabel      = $"{d.Valor / total:P0}";
                dp.LabelForeColor = ColorFunctions.ContrastColor(dp.Color);
            }
            chart.ApplyPaletteColors();
        }
コード例 #10
0
        public ActionResult CreateUpdateColor(DAL.Entities.Color color)
        {
            try
            {
                if (color.ColorId != null)
                {
                    ColorFunctions.Update(color);
                }
                else
                {
                    ColorFunctions.Create(color);
                }

                return(Json("Success"));
            }
            catch (Exception ex)
            {
                return(Json("Error occurred. Error details: " + ex.Message));
            }
        }
コード例 #11
0
        public MainWindow()
        {
            InitializeComponent();
            Debug.WriteLine("[User Picture]: " + Helpers.GetUserTilePath(null));
            Settings.Init(Config.SettingsFilePath, new DesEncrpytion("W10Logon", "W10Logon"));

            var currentLang = CultureInfo.CurrentCulture.ToString().ToLower().Replace("-", "_");

            if (!LanguageLibrary.Language.GetLangNames().ContainsValue(currentLang))
            {
                currentLang = "en_us";
            }

            Debug.WriteLine(currentLang);

            //default all strings to en-us
            LanguageLibrary.Language.Init();
            LanguageLibrary.Language.Set(Settings.Default.Get("language", currentLang));

            Debug.WriteLine((string)LanguageLibrary.Language.Default.title_error);

            if (!Settings.Default.Get("eula", false))
            {
                var dlg =
                    WpfMessageBox.Show(
                        LanguageLibrary.Language.Default.EULA,
                        LanguageLibrary.Language.Default.title_eula, MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (dlg == MessageBoxResult.No)
                {
                    Close();
                }
            }

            if (Helpers.IsBackgroundDisabled())
            {
                WpfMessageBox.Show(LanguageLibrary.Language.Default.background_disabled,
                                   LanguageLibrary.Language.Default.title_bg_disabled, MessageBoxButton.OK, MessageBoxImage.Information);
            }

            Debug.WriteLine(
                $"[AccentColor]: {ColorFunctions.GetImmersiveColor(ImmersiveColors.ImmersiveStartBackground)}");

            Title += $" - {AssemblyInfo.Version}";

            Settings.Default.Set("eula", true);
            Settings.Default.Save();

            Debug.WriteLine("[EULA Test] {0}", Settings.Default.Get <bool>("eula"));

            ApplicationSettingsFlyout.Content = new SettingsMenuControl(this);

            SettingFlyout.Content = new BgEditorControl(this);
            SettingFlyout.IsOpen  = true;

            AboutFlyout.Content = new AboutControl(this);

            HelperLib.TakeOwnership(Config.LogonFolder);
            HelperLib.TakeOwnership(Config.PriFileLocation);

            if (!File.Exists(Config.BakPriFileLocation))
            {
                Debug.WriteLine("[Warning]: Could not find Windows.UI.Logon.pri.bak file. Creating new.");
                File.Copy(Config.PriFileLocation, Config.BakPriFileLocation);
            }

            HelperLib.TakeOwnership(Config.BakPriFileLocation);

            File.Copy(Config.BakPriFileLocation, _tempPriFile, true);

            if (File.Exists(Config.CurrentImageLocation))
            {
                var temp = Path.GetTempFileName();
                File.Copy(Config.CurrentImageLocation, temp, true);

                Settings.Default.Set("current.img", File.ReadAllBytes(temp));
                Settings.Default.Save();

                File.Delete(Config.CurrentImageLocation);
            }

            Loaded += (o, i) =>
            {
                SettingFlyout.Position = Settings.Default.Get("flyout", Position.Right);
                GlyphsViewer.ToolTip   = Settings.Default.Get("filename", "No File");
            };

            if (Settings.Default.Exist("current.img"))
            {
                var temp = Path.GetTempFileName();

                File.WriteAllBytes(temp, Settings.Default.Get <byte[]>("current.img"));

                WallpaperViewer.Source = new BitmapImage(new Uri(temp));
            }

            EditBackgroundLabel.Text         = LanguageLibrary.Language.Default.main_top_edit;
            LockWindowsLabel.Text            = LanguageLibrary.Language.Default.main_top_lock;
            AboutButton.Content              = LanguageLibrary.Language.Default.main_top_about;
            SettingFlyout.Header             = LanguageLibrary.Language.Default.flyout_edit_title;
            AboutFlyout.Header               = LanguageLibrary.Language.Default.flyout_about_title;
            ApplicationSettingsFlyout.Header = LanguageLibrary.Language.Default.flyout_settings_title;
            settingsName.Text = LanguageLibrary.Language.Default.flyout_settings_title;

#if !DEBUG
            UsernameFeild.Text = Environment.UserName;
#endif
            UserDisplayPicture.Source =
                Image.FromFile(Helpers.GetUserTilePath(null))
                .ResizeImage(new Size(300, 300))
                .ToBitmapSource();
        }
コード例 #12
0
        public ActionResult DeleteColor(DAL.Entities.Color color)
        {
            ColorFunctions.Delete(color);

            return(RedirectToAction("Colors", "ProductOptions"));
        }
コード例 #13
0
 private void RadWindowsAccentColor_Click(object sender, RoutedEventArgs e)
 {
     ClrCustomColor.IsEnabled       = false;
     Group.SelectedBackgroundOption = BackgroundOption.WindowsAccentColor;
     Group.BackgroundColor          = ColorFunctions.GetThemeColor().ToString();
 }
コード例 #14
0
        public static Color GetFillColorTagValue(OverlayStatusUpdate info, YurFillColors tag)
        {
            Color value = Color.gray;

            switch (tag)
            {
            case YurFillColors.Default:
                value = ColorFunctions.GetDefaultColor();
                break;

            case YurFillColors.SquatCountLevel:
                value = ColorFunctions.GetSquatColor(info.SquatCount);
                break;

            case YurFillColors.TodaySquatCountLevel:
                value = ColorFunctions.GetSquatColor(info.TodaySquatCount);
                break;

            case YurFillColors.EstOrHeartRateLevel:
                value = ColorFunctions.GetDayLevelColor((int)info.CalculationMetrics.ActivityLevel);
                break;

            case YurFillColors.WorkoutTimeLevel:
                value = ColorFunctions.GetWorkoutTimeColor(info.SecondsInWorkout);
                break;

            case YurFillColors.TodayTimeLevel:
                value = ColorFunctions.GetTodayTimeColor(info.SecondsToday);
                break;

            case YurFillColors.BurnRateLevel:
                value = ColorFunctions.GetDayLevelColor((int)info.CalculationMetrics.ActivityLevel);
                break;

            case YurFillColors.TodayCaloriesLevel:
                value = ColorFunctions.GetTodayCalsColor(info.TodayCalories);
                break;

            case YurFillColors.UserRank:
                Color colorToReturn;
                if (ColorUtility.TryParseHtmlString(info.RankCurrentColor, out colorToReturn))
                {
                    value = colorToReturn;
                }
                else
                {
                    value = ColorFunctions.GetDefaultColor();
                }
                break;

            case YurFillColors.UserRankContrast:
                value = ColorFunctions.GetReadableForeColor(info.RankCurrentColor);
                break;

            case YurFillColors.WorkoutCaloriesLevel:
                //TODO: what should this be?
                value = ColorFunctions.GetTodayCalsColor(info.CurrentCalories);
                break;

            default:
                //unknown
                value = ColorFunctions.GetDefaultColor();
                break;
            }
            return(value);
        }