Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions libmsstyle/Animation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ public class Animation
public int SizeInBytes;
public int PropertiesIndex;
public int TransformsIndex;

public AnimationFlags AnimationFlags { get; set; }
public int TransformCount { get; set; }
private int TransformCount;
public int StaggerDelay { get; set; }
public int StaggerDelayCap { get; set; }
public float StaggerDelayFactor { get; set; }
Expand All @@ -24,9 +23,9 @@ public class Animation
public int TuningLevel { get; set; }
public float Perspective { get; set; }
private List<Transform> _transforms = new List<Transform>();
[Description("The list of animations to play at the same time.")]
public List<Transform> Transforms { get { return _transforms; } }
public PropertyHeader Header;

public Animation(byte[] data, ref int start, PropertyHeader header)
{
this.Header = header;
Expand Down Expand Up @@ -61,13 +60,14 @@ public Animation(byte[] data, ref int start, PropertyHeader header)
/// <param name="animationsHeader">Header of the animations class</param>
/// <param name="part">Animation part</param>
/// <param name="state">Animation state</param>
public Animation(PropertyHeader animationsHeader, int part, int state)
public Animation(PropertyHeader header, int part, int state)
{
PropertiesIndex = 16;
TransformsIndex = 56;
Header = new PropertyHeader(20000, animationsHeader.typeID);
Header = header;
Header.stateID = state;
Header.partID = part;
CalculateTotalSize();
}

int GetPaddingForSize(int size)
Expand All @@ -77,17 +77,20 @@ int GetPaddingForSize(int size)
return ((size + 39) & -8) - sizeOfRecordHeader - size;
}

public void Write(BinaryWriter bw)
private void CalculateTotalSize()
{
// Update the total size
int total_size = 56;
foreach (var item in Transforms)
{
total_size += item.StructureSize + GetPaddingForSize(item.StructureSize);
}

Header.sizeInBytes = total_size;
}

public void Write(BinaryWriter bw)
{
CalculateTotalSize();
bw.Write(Header.Serialize());
WriteData(bw);
}
Expand Down Expand Up @@ -143,4 +146,4 @@ public AnimationStates(string name, Dictionary<int, string> states)
AnimationStateDict = states;
}
}
}
}
7 changes: 5 additions & 2 deletions libmsstyle/StyleProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,11 @@ public bool IsValid()
classID > 500) // guessing here to be stateless
return false;

// Basic range check
if (typeID < (int)IDENTIFIER.ENUM || typeID >= (int)IDENTIFIER.COLORSCHEMES)
if (nameID == 20000) //Animation
return true;

// Basic range check
if (typeID < (int)IDENTIFIER.ENUM || typeID >= (int)IDENTIFIER.COLORSCHEMES)
return false;

// Some color and font props use an type id as name id.
Expand Down
10 changes: 6 additions & 4 deletions libmsstyle/TimingFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class TimingFunction
public CubicBezierTimingFunction CubicBezier { get; set; }

public PropertyHeader Header;

public TimingFunction(byte[] data, int start, PropertyHeader header)
{
this.Header = header;
Expand All @@ -33,7 +32,12 @@ public TimingFunction(byte[] data, int start, PropertyHeader header)
throw new Exception("Unknown timing function type: " + Type);
}
}

public TimingFunction(PropertyHeader header, int partid)
{
CubicBezier = new CubicBezierTimingFunction();
Header = header;
Header.partID = partid;
}
public void Write(BinaryWriter bw)
{
if (Type == TimingFunctionType.Undefined)
Expand All @@ -44,7 +48,6 @@ public void Write(BinaryWriter bw)
bw.Write(Header.Serialize());
WriteData(bw);
}

public void WriteData(BinaryWriter w)
{
w.Write((int)Type);
Expand All @@ -54,7 +57,6 @@ public void WriteData(BinaryWriter w)
}
w.Write(0); //Write padding
}

public override string ToString()
{
return "Timing function";
Expand Down
3 changes: 1 addition & 2 deletions libmsstyle/Transform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Transform
public int DurationTime { get; set; }
public TransformFlag Flags { get; set; }
[TypeConverter(typeof(ExpandableObjectConverter))]

[Description("3D animation. No longer working in Windows 10+")]
public Transform3D Transform3DStructure { get; set; }
[TypeConverter(typeof(ExpandableObjectConverter))]

Expand Down Expand Up @@ -58,7 +58,6 @@ public Transform()
Transform2DStructure = new Transform2D();
TransformOpacity = new TransformOpacity();
}

public Transform(byte[] data, ref int start)
{
Type = (TransformType)BitConverter.ToInt32(data, start + 0);
Expand Down
2 changes: 1 addition & 1 deletion libmsstyle/VisualStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private bool SaveAMap(IntPtr moduleHandle, IntPtr updateHandle)

MemoryStream ms = new MemoryStream();
BinaryWriter bw = new BinaryWriter(ms);

m_timingFunctions.OrderBy(t => t.Header.partID);
foreach (var item in m_timingFunctions)
{
item.Write(bw);
Expand Down
7 changes: 7 additions & 0 deletions msstyleEditorSharp/Dialogs/ClassView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ public void SetVisualStyle(VisualStyle style)
}
classView.EndUpdate();
}
public void Refresh()
{
classView.BeginUpdate();
classView.Nodes.Clear();
classView.EndUpdate();

SetVisualStyle(m_style);
}
bool m_endReached = false;
public TreeNode FindNextNode(bool includeSelectedNode, Predicate<TreeNode> predicate)
{
Expand Down
45 changes: 35 additions & 10 deletions msstyleEditorSharp/Dialogs/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,15 +470,15 @@ private void OnTreeItemSelected(object sender, TreeViewEventArgs e)
if (func != null)
{
m_selectedTimingFunction = func;
m_propertyView.SetTimingFunction(func);
m_propertyView.SetTimingFunction(m_style, func);
return;
}

AnimationTypeDescriptor animation = e.Node.Tag as AnimationTypeDescriptor;
if (animation != null)
{
m_selectedAnimation = animation;
m_propertyView.SetAnimation(animation);
m_propertyView.SetAnimation(m_style, animation);
return;
}

Expand Down Expand Up @@ -748,12 +748,29 @@ private void OnPropertyAdd(object sender, EventArgs e)
m_propertyView.ShowPropertyAddDialog();
}

private void OnPropertyAdded(StyleProperty prop)
private void OnPropertyAdded(object prop)
{
// refresh gui to account for new image property
if (prop.IsImageProperty())
if (prop is StyleProperty styleProp)
{
DisplayPart(m_selection.Class, m_selection.Part);
// refresh gui to account for new image property
if (styleProp.IsImageProperty())
{
DisplayPart(m_selection.Class, m_selection.Part);
}
}

if (prop is Animation animation)
{
m_selectedAnimation = new AnimationTypeDescriptor(animation);
m_classView.Refresh();
m_propertyView.SetStylePart(null, null, null);
}

if (prop is TimingFunction timingFunc)
{
m_selectedTimingFunction = timingFunc;
m_classView.Refresh();
m_propertyView.SetStylePart(null, null, null);
}
}

Expand All @@ -762,12 +779,20 @@ private void OnPropertyRemove(object sender, EventArgs e)
m_propertyView.RemoveSelectedProperty();
}

private void OnPropertyRemoved(StyleProperty prop)
private void OnPropertyRemoved(object prop)
{
// refresh gui to account for removed image property
if (prop.IsImageProperty())
if(prop is StyleProperty styleProp)
{
// refresh gui to account for removed image property
if (styleProp.IsImageProperty())
{
DisplayPart(m_selection.Class, m_selection.Part);
}
}
else if (prop is Animation || prop is TimingFunction)
{
DisplayPart(m_selection.Class, m_selection.Part);
m_classView.Refresh();
m_propertyView.SetStylePart(null, null, null);
}
}

Expand Down
112 changes: 112 additions & 0 deletions msstyleEditorSharp/Dialogs/NewDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading