예제 #1
0
    // the user clicked the image panel, so do display an open file dialog to select a new image..
    private void pnImage_Click(object sender, EventArgs e)
    {
        if (listThemeImages.SelectedItem == null)
        {
            return;
        }

        if (fdOpenImage.ShowDialog() == DialogResult.OK)
        {
            var item = (ImageStringProperty)listThemeImages.SelectedItem;
            item.Image = Image.FromFile(fdOpenImage.FileName);

            if (item.Image.Width >= pnImage.Width || item.Image.Height >= pnImage.Height)
            {
                pnImage.BackgroundImageLayout = ImageLayout.Zoom;
            }
            else
            {
                pnImage.BackgroundImageLayout = ImageLayout.Center;
            }

            var property = ThemeSettings.GetType().GetProperty(item.Name);
            property?.SetValue(ThemeSettings, item.Image);

            pnImage.BackgroundImage = item.Image;

            FormMain.ThemeMainForm(ThemeSettings);
        }
    }
예제 #2
0
    /// <summary>
    /// Lists the theme colors and images to the GUI.
    /// </summary>
    private void ListThemeData()
    {
        listThemeColors.Items.Clear();
        listThemeImages.Items.Clear();

        var properties = ThemeSettings.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);

        foreach (var propertyInfo in properties)
        {
            if (propertyInfo.PropertyType == typeof(Color))
            {
                listThemeColors.Items.Add(new ColorStringProperty
                {
                    Color = (Color)propertyInfo.GetValue(ThemeSettings), Name = propertyInfo.Name
                });
            }

            if (propertyInfo.PropertyType == typeof(Image))
            {
                listThemeImages.Items.Add(new ImageStringProperty
                {
                    Image = (Image)propertyInfo.GetValue(ThemeSettings), Name = propertyInfo.Name
                });
            }
        }
    }
예제 #3
0
    // the color selection has changed, set the color to a possibly selected item..
    private void colorWheel_ColorChanged(object sender, EventArgs e)
    {
        if (SuspendColorChange || listThemeColors.SelectedItem == null)
        {
            return;
        }

        colorEditor.Color        = colorWheel.Color;
        pnColorDisplay.BackColor = colorWheel.Color;

        var item = (ColorStringProperty)listThemeColors.SelectedItem;

        item.Color = colorWheel.Color;

        var property = ThemeSettings.GetType().GetProperty(item.Name);

        property?.SetValue(ThemeSettings, item.Color);

        FormMain.ThemeMainForm(ThemeSettings);
    }