Skip to content

Commit

Permalink
Finish wiring the options window, creation and modifying of themes. A…
Browse files Browse the repository at this point in the history
…dded script to output themes at compilation
  • Loading branch information
jotatsu committed Aug 4, 2017
1 parent 6f25a72 commit 376f22c
Show file tree
Hide file tree
Showing 12 changed files with 382 additions and 53 deletions.
19 changes: 19 additions & 0 deletions Tools/copy_themes.ps1
@@ -0,0 +1,19 @@
param (
[string]
[Parameter(Mandatory=$true)]
$SolutionDir,

[string]
[Parameter(Mandatory=$true)]
$TargetDir
)

Write-Output "===== Beginning $($PSCmdlet.MyInvocation.MyCommand) ====="
Write-Output "Copying THEMES folder to output"

$sourceFiles = [io.path]::combine($SolutionDir , 'mRemoteV1\Resources\Themes' )
$DestinationDir = [io.path]::combine($TargetDir , 'Themes')

robocopy $sourceFiles $DestinationDir *.vstheme /s

Write-Output ""
1 change: 1 addition & 0 deletions Tools/postbuild_mremotev1.ps1
Expand Up @@ -39,6 +39,7 @@ Format-Table -AutoSize -Wrap -InputObject @{


& "$PSScriptRoot\copy_puttyng.ps1" -SolutionDir $SolutionDir -TargetDir $TargetDir
& "$PSScriptRoot\copy_themes.ps1" -SolutionDir $SolutionDir -TargetDir $TargetDir
& "$PSScriptRoot\move_help_files.ps1" -TargetDir $TargetDir
& "$PSScriptRoot\set_LargeAddressAware.ps1" -TargetDir $TargetDir -TargetFileName $TargetFileName
& "$PSScriptRoot\verify_LargeAddressAware.ps1" -TargetDir $TargetDir -TargetFileName $TargetFileName
Expand Down
4 changes: 2 additions & 2 deletions mRemoteV1/Resources/Themes/darcula.vstheme
Expand Up @@ -9044,7 +9044,7 @@
<Foreground Type="CT_INVALID" Source="00000000" />
</Color>
<Color Name="compiler error">
<Background Type="CT_INVALID" Source="00000000" />
<Background Type="CT_INVALID" Source="FFFF5555" />
<Foreground Type="CT_RAW" Source="FFBC3F3C" />
</Color>
<Color Name="syntax error">
Expand All @@ -9060,7 +9060,7 @@
<Foreground Type="CT_RAW" Source="FFFFFFFF" />
</Color>
<Color Name="compiler warning">
<Background Type="CT_INVALID" Source="00000000" />
<Background Type="CT_INVALID" Source="FFFFB86C" />
<Foreground Type="CT_RAW" Source="FF867F27" />
</Color>
<Color Name="Code Snippet Field">
Expand Down
2 changes: 1 addition & 1 deletion mRemoteV1/Resources/Themes/vs2015blue.vstheme
Expand Up @@ -571,7 +571,7 @@
</Color>
<Color Name="Dialog">
<Background Type="CT_RAW" Source="FFD6DBE9" />
<Foreground Type="CT_SYSCOLOR" Source="00000008" />
<Foreground Type="CT_SYSCOLOR" Source="FF1E1E1E" />
</Color>
<Color Name="DialogBorder">
<Background Type="CT_SYSCOLOR" Source="0000000F" />
Expand Down
64 changes: 63 additions & 1 deletion mRemoteV1/Themes/ExtendedColorPalette.cs
Expand Up @@ -6,6 +6,39 @@

namespace mRemoteNG.Themes
{
public class PseudoKeyColor
{
private string key;
private Color value;
public PseudoKeyColor(string _key, Color _value)
{
key = _key;
value = _value;
}
public String Key
{
get
{
return key;
}
set
{
key = value;
}
}
public Color Value
{
get
{
return value;
}
set
{
this.value = value;
}
}
}

public class ExtendedColorPalette
{
#region Private Variables
Expand Down Expand Up @@ -54,11 +87,40 @@ public Color getColor(String colorKey)
return retColor;

}
public void addColor(String colorKey,Color inColor)
public void addColor(string colorKey,Color inColor)
{
_extendedColors.Add(colorKey, inColor);
}

public void replaceColor(string colorKey, Color inColor)
{
_extendedColors[colorKey]= inColor;
}

public Dictionary<String, Color> DefaultColorPalette
{
get
{
return _default;
}
set
{
_default = value;
}
}


public Dictionary<String, Color> ExtColorPalette
{
get
{
return _extendedColors;
}
set
{
_extendedColors = value;
}
}
}
}

Expand Down
Expand Up @@ -15,15 +15,15 @@
namespace mRemoteNG.Themes
{
//Class to extract the rest of the required theme colors for MremoteNG from the vstheme file
public class MremoteNGPaletteLoader
public class MremoteNGPaletteManipulator
{
private XmlDocument _xml;
private ExtendedColorPalette _defaultPalette;



//warning, defaultpalette should always contain all the values, because when is loaded there is no default palette (parameter is null
public MremoteNGPaletteLoader(byte[] file, ExtendedColorPalette defaultPalette = null )
public MremoteNGPaletteManipulator(byte[] file, ExtendedColorPalette defaultPalette = null )
{
_xml = new XmlDocument();
_xml.LoadXml(new StreamReader(new MemoryStream(file)).ReadToEnd());
Expand Down Expand Up @@ -52,7 +52,31 @@ public ExtendedColorPalette getColors()
}

return newPalette;
}


public byte[] mergePalette(ExtendedColorPalette colorPalette)
{
ResourceSet resourceSet = mRemoteNG.ColorMapTheme.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);

foreach (DictionaryEntry entry in resourceSet)
{
string colorName = entry.Key.ToString();
String xmlQueryPath = (String)entry.Value;
XmlNodeList colorNodeList = _xml.DocumentElement.FirstChild.SelectNodes(xmlQueryPath);
if(colorNodeList.Count > 0)
{
Color paletteColor = colorPalette.getColor(colorName);
colorNodeList[0].Value = string.Format("FF{0:X2}{1:X2}{2:X2}", paletteColor.R, paletteColor.G, paletteColor.B);
}

}
MemoryStream ms = new MemoryStream();
_xml.Save(ms);
byte[] bytes = ms.ToArray();

return bytes;
}

}
}
41 changes: 38 additions & 3 deletions mRemoteV1/Themes/ThemeInfo.cs
Expand Up @@ -2,19 +2,24 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using WeifenLuo.WinFormsUI.Docking;


namespace mRemoteNG.Themes
{
public class ThemeInfo


public class ThemeInfo : ICloneable
{
#region Private Variables
private string _name;
private ThemeBase _theme;
private String _URI;
private VisualStudioToolStripExtender.VsVersion _version;
private ExtendedColorPalette _extendedPalette;
private bool _isThemeBase;
private bool _isExtendable;

#endregion

Expand All @@ -26,21 +31,33 @@ public ThemeInfo(string themeName, ThemeBase inTheme, String inURI, VisualStudio
_URI = inURI;
_version = inVersion;
_extendedPalette = inExtendedPalette;
_isThemeBase = false;
_isExtendable = false;
}

public ThemeInfo(string themeName, ThemeBase inTheme, String inURI, VisualStudioToolStripExtender.VsVersion inVersion)
{
_name = themeName;
_theme = inTheme;
_URI = inURI;
_version = inVersion;
_version = inVersion;
_isThemeBase = false;
_isExtendable = false;
}
#endregion

#region Public Methods
public object Clone()
{
return MemberwiseClone();
ThemeInfo clonedObj;
ExtendedColorPalette extPalette = new ExtendedColorPalette();
extPalette.ExtColorPalette = _extendedPalette.ExtColorPalette.ToDictionary(entry => entry.Key,entry => entry.Value);
extPalette.DefaultColorPalette = _extendedPalette.DefaultColorPalette;
clonedObj = new ThemeInfo(_name, _theme, _URI, _version, extPalette);
clonedObj.IsExtendable = _isExtendable;
clonedObj.IsThemeBase = _isThemeBase;

return clonedObj;
}

#endregion
Expand Down Expand Up @@ -112,6 +129,24 @@ public ExtendedColorPalette ExtendedPalette
_extendedPalette = value;
}
}

public bool IsThemeBase
{
get { return _isThemeBase; }
set
{
_isThemeBase = value;
}
}

public bool IsExtendable
{
get { return _isExtendable; }
set
{
_isExtendable = value;
}
}
#endregion
}
}
48 changes: 43 additions & 5 deletions mRemoteV1/Themes/ThemeManager.cs
Expand Up @@ -106,19 +106,56 @@ public List<ThemeInfo> LoadThemes()

}

}

}
return themes.Values.OfType<ThemeInfo>().ToList();
}

public ThemeInfo addTheme(ThemeInfo baseTheme, string newThemeName)
{
if (!themes.Contains(newThemeName))
{
ThemeInfo modifiedTheme = (ThemeInfo)baseTheme.Clone();
modifiedTheme.Name = newThemeName;
modifiedTheme.IsExtendable = true;
modifiedTheme.IsThemeBase = false;
ThemeSerializer.SaveToXmlFile(modifiedTheme,baseTheme);
themes.Add(newThemeName,modifiedTheme);
return modifiedTheme;
}
return null;
}

public void deleteTheme(ThemeInfo themeToDelete)
{
if (themes.Contains(themeToDelete.Name))
{
if(ActiveTheme == themeToDelete)
ActiveTheme = DefaultTheme;
themes.Remove(themeToDelete.Name);
ThemeSerializer.DeleteFile(themeToDelete);
}
}

return themes.Values.OfType<ThemeInfo>().ToList();
public void updateTheme(ThemeInfo themeToUpdate)
{
ThemeSerializer.UpdateThemeXMLValues(themeToUpdate);
}

public void refreshUI()
{
NotifyThemeChanged(this, new PropertyChangedEventArgs(""));
}


private void SaveTheme(ThemeInfo theme)
public bool isThemeNameOk(string name)
{
if (themes.Contains(name))
return false;
char[] badChars = Path.GetInvalidFileNameChars();
if (name.IndexOfAny(badChars) != -1)
return false;
return true;
}


#endregion

Expand Down Expand Up @@ -153,6 +190,7 @@ public bool ThemingActive
{
_themeActive = value;
Settings.Default.ThemingActive = value;
NotifyThemeChanged(this, new PropertyChangedEventArgs(""));
}
}

Expand Down

0 comments on commit 376f22c

Please sign in to comment.