diff --git a/libmsstyle/Animation.cs b/libmsstyle/Animation.cs index 8690cc4..7a92056 100644 --- a/libmsstyle/Animation.cs +++ b/libmsstyle/Animation.cs @@ -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; } @@ -24,9 +23,9 @@ public class Animation public int TuningLevel { get; set; } public float Perspective { get; set; } private List _transforms = new List(); + [Description("The list of animations to play at the same time.")] public List Transforms { get { return _transforms; } } public PropertyHeader Header; - public Animation(byte[] data, ref int start, PropertyHeader header) { this.Header = header; @@ -61,13 +60,14 @@ public Animation(byte[] data, ref int start, PropertyHeader header) /// Header of the animations class /// Animation part /// Animation state - 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) @@ -77,7 +77,7 @@ 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; @@ -85,9 +85,12 @@ public void Write(BinaryWriter bw) { total_size += item.StructureSize + GetPaddingForSize(item.StructureSize); } - Header.sizeInBytes = total_size; + } + public void Write(BinaryWriter bw) + { + CalculateTotalSize(); bw.Write(Header.Serialize()); WriteData(bw); } @@ -143,4 +146,4 @@ public AnimationStates(string name, Dictionary states) AnimationStateDict = states; } } -} \ No newline at end of file +} diff --git a/libmsstyle/StyleProperty.cs b/libmsstyle/StyleProperty.cs index 64196b9..207e5f4 100644 --- a/libmsstyle/StyleProperty.cs +++ b/libmsstyle/StyleProperty.cs @@ -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. diff --git a/libmsstyle/TimingFunction.cs b/libmsstyle/TimingFunction.cs index 7a455ee..b119f86 100644 --- a/libmsstyle/TimingFunction.cs +++ b/libmsstyle/TimingFunction.cs @@ -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; @@ -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) @@ -44,7 +48,6 @@ public void Write(BinaryWriter bw) bw.Write(Header.Serialize()); WriteData(bw); } - public void WriteData(BinaryWriter w) { w.Write((int)Type); @@ -54,7 +57,6 @@ public void WriteData(BinaryWriter w) } w.Write(0); //Write padding } - public override string ToString() { return "Timing function"; diff --git a/libmsstyle/Transform.cs b/libmsstyle/Transform.cs index 455c94c..02fcc16 100644 --- a/libmsstyle/Transform.cs +++ b/libmsstyle/Transform.cs @@ -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))] @@ -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); diff --git a/libmsstyle/VisualStyle.cs b/libmsstyle/VisualStyle.cs index 9403ca8..9a65ad1 100644 --- a/libmsstyle/VisualStyle.cs +++ b/libmsstyle/VisualStyle.cs @@ -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); diff --git a/msstyleEditorSharp/Dialogs/ClassView.cs b/msstyleEditorSharp/Dialogs/ClassView.cs index ece6206..f15a0d6 100644 --- a/msstyleEditorSharp/Dialogs/ClassView.cs +++ b/msstyleEditorSharp/Dialogs/ClassView.cs @@ -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 predicate) { diff --git a/msstyleEditorSharp/Dialogs/MainWindow.cs b/msstyleEditorSharp/Dialogs/MainWindow.cs index 8df0c34..294f710 100644 --- a/msstyleEditorSharp/Dialogs/MainWindow.cs +++ b/msstyleEditorSharp/Dialogs/MainWindow.cs @@ -470,7 +470,7 @@ private void OnTreeItemSelected(object sender, TreeViewEventArgs e) if (func != null) { m_selectedTimingFunction = func; - m_propertyView.SetTimingFunction(func); + m_propertyView.SetTimingFunction(m_style, func); return; } @@ -478,7 +478,7 @@ private void OnTreeItemSelected(object sender, TreeViewEventArgs e) if (animation != null) { m_selectedAnimation = animation; - m_propertyView.SetAnimation(animation); + m_propertyView.SetAnimation(m_style, animation); return; } @@ -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); } } @@ -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); } } diff --git a/msstyleEditorSharp/Dialogs/NewDialog.Designer.cs b/msstyleEditorSharp/Dialogs/NewDialog.Designer.cs new file mode 100644 index 0000000..9875705 --- /dev/null +++ b/msstyleEditorSharp/Dialogs/NewDialog.Designer.cs @@ -0,0 +1,112 @@ +namespace msstyleEditor.Dialogs +{ + partial class NewDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.txtPartId = new System.Windows.Forms.TextBox(); + this.txtStateId = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.btnCreate = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // txtPartId + // + this.txtPartId.Location = new System.Drawing.Point(107, 13); + this.txtPartId.Name = "txtPartId"; + this.txtPartId.Size = new System.Drawing.Size(191, 33); + this.txtPartId.TabIndex = 0; + // + // txtStateId + // + this.txtStateId.Location = new System.Drawing.Point(107, 58); + this.txtStateId.Name = "txtStateId"; + this.txtStateId.Size = new System.Drawing.Size(188, 33); + this.txtStateId.TabIndex = 1; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(13, 13); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(74, 28); + this.label1.TabIndex = 2; + this.label1.Text = "Part ID:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(13, 58); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(84, 28); + this.label2.TabIndex = 3; + this.label2.Text = "State ID:"; + // + // btnCreate + // + this.btnCreate.Font = new System.Drawing.Font("Segoe UI", 8.142858F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnCreate.Location = new System.Drawing.Point(189, 106); + this.btnCreate.Name = "btnCreate"; + this.btnCreate.Size = new System.Drawing.Size(109, 45); + this.btnCreate.TabIndex = 4; + this.btnCreate.Text = "Create"; + this.btnCreate.UseVisualStyleBackColor = true; + this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click); + // + // NewAnimationDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.ClientSize = new System.Drawing.Size(316, 163); + this.Controls.Add(this.btnCreate); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.txtStateId); + this.Controls.Add(this.txtPartId); + this.Font = new System.Drawing.Font("Segoe UI", 8.142858F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "NewAnimationDialog"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Add new animation"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox txtPartId; + private System.Windows.Forms.TextBox txtStateId; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button btnCreate; + } +} \ No newline at end of file diff --git a/msstyleEditorSharp/Dialogs/NewDialog.cs b/msstyleEditorSharp/Dialogs/NewDialog.cs new file mode 100644 index 0000000..4f5c5ba --- /dev/null +++ b/msstyleEditorSharp/Dialogs/NewDialog.cs @@ -0,0 +1,76 @@ +using libmsstyle; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace msstyleEditor.Dialogs +{ + public partial class NewDialog : Form + { + public int PartID { get; private set; } + public int StateID { get; private set; } + private bool HasState { get; set; } + public NewDialog() + { + InitializeComponent(); + } + + private void btnCreate_Click(object sender, EventArgs e) + { + if (!int.TryParse(txtPartId.Text, out int PartID)) + { + MessageBox.Show("Part ID must be a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + this.PartID = PartID; + + if (!int.TryParse(txtStateId.Text, out int StateID) && HasState) + { + MessageBox.Show("State ID must be a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + this.StateID = StateID; + + DialogResult = DialogResult.OK; + } + + public Animation ShowDialogAnimation(PropertyHeader header) + { + Text = "New animation"; + HasState = true; + txtStateId.Enabled = true; + if (base.ShowDialog() == DialogResult.OK) + { + return new Animation(header, PartID, StateID); + } + else + { + return null; + } + } + + public TimingFunction ShowDialogTimingFunction(PropertyHeader header) + { + Text = "New timing function"; + HasState = false; + txtStateId.Enabled = false; + label2.Enabled = false; + if (base.ShowDialog() == DialogResult.OK) + { + return new TimingFunction(header, PartID); + } + else + { + return null; + } + } + } +} diff --git a/msstyleEditorSharp/Dialogs/NewDialog.resx b/msstyleEditorSharp/Dialogs/NewDialog.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/msstyleEditorSharp/Dialogs/NewDialog.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/msstyleEditorSharp/Dialogs/PropertyView.cs b/msstyleEditorSharp/Dialogs/PropertyView.cs index dc4657f..b340ae5 100644 --- a/msstyleEditorSharp/Dialogs/PropertyView.cs +++ b/msstyleEditorSharp/Dialogs/PropertyView.cs @@ -2,6 +2,7 @@ using msstyleEditor.PropView; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Windows.Forms; namespace msstyleEditor.Dialogs @@ -15,19 +16,24 @@ public partial class PropertyViewWindow : ToolWindow private StyleState m_state; private StyleProperty m_prop; + private AnimationTypeDescriptor m_SelectedAnimation; + private Animation m_SelectedAnimationPart; + private PropertyViewMode m_viewMode; - public delegate void PropertyChangedHandler(StyleProperty prop); + public delegate void PropertyChangedHandler(object prop); public event PropertyChangedHandler OnPropertyAdded; public event PropertyChangedHandler OnPropertyRemoved; + public PropertyViewWindow() { InitializeComponent(); } - public void SetAnimation(AnimationTypeDescriptor anim) + public void SetAnimation(VisualStyle style, AnimationTypeDescriptor anim) { + m_style = style; m_viewMode = PropertyViewMode.AnimationMode; newPropertyToolStripMenuItem.Enabled = false; deleteToolStripMenuItem.Enabled = false; @@ -35,8 +41,9 @@ public void SetAnimation(AnimationTypeDescriptor anim) propertyView.SelectedObject = anim; } - public void SetTimingFunction(TimingFunction timing) + public void SetTimingFunction(VisualStyle style, TimingFunction timing) { + m_style = style; m_viewMode = PropertyViewMode.TimingFunction; newPropertyToolStripMenuItem.Enabled = false; deleteToolStripMenuItem.Enabled = false; @@ -76,7 +83,53 @@ private void OnPropertyAdd(object sender, EventArgs e) { if (m_class.ClassName == "animations") { + var dlg2 = new NewDialog(); + //typeid is the same for all animations + var anim = dlg2.ShowDialogAnimation(new PropertyHeader((int)IDENTIFIER.ANIMATION, m_style.Animations[0].Header.typeID) { classID = m_class.ClassId}); + if (anim != null) + { + //check if there are any animations with same part id. it is important that all animations are sorted correctly + int idx = 0; + int latest_idx = -1; + foreach (var item in m_style.Animations) + { + if(item.Header.partID == anim.Header.partID) + { + latest_idx = idx; + } + idx++; + } + + if (latest_idx == -1) + { + m_style.Animations.Add(anim); + } + else + { + m_style.Animations.Insert(latest_idx + 1, anim); + } + + if (OnPropertyAdded != null) + { + OnPropertyAdded(anim); + } + propertyView.Refresh(); + } + return; + } + else if (m_class.ClassName == "timingfunction") + { + var dlg2 = new NewDialog(); + var timingfunc = dlg2.ShowDialogTimingFunction(new PropertyHeader((int)IDENTIFIER.TIMINGFUNCTION, m_style.TimingFunctions[0].Header.typeID) { classID = m_class.ClassId }); + if(timingfunc != null) + m_style.TimingFunctions.Add(timingfunc); + if (OnPropertyAdded != null) + { + OnPropertyAdded(timingfunc); + } + propertyView.Refresh(); + return; } } if(m_style == null @@ -110,67 +163,127 @@ private void OnPropertyAdd(object sender, EventArgs e) private void OnPropertyRemove(object sender, EventArgs e) { - if (m_viewMode != PropertyViewMode.ClassMode) - return; - if (m_state == null || - m_prop == null) + if (m_viewMode == PropertyViewMode.ClassMode) { - return; - } + if (m_state == null || m_prop == null) + { + return; + } - m_state.Properties.Remove(m_prop); - if (OnPropertyRemoved != null) + m_state.Properties.Remove(m_prop); + if (OnPropertyRemoved != null) + { + OnPropertyRemoved(m_prop); + } + propertyView.Refresh(); + } + else if (m_viewMode == PropertyViewMode.TimingFunction) { - OnPropertyRemoved(m_prop); + var func = (TimingFunction)propertyView.SelectedObject; + if(func != null) + { + m_style.TimingFunctions.Remove(func); + if (OnPropertyRemoved != null) + { + OnPropertyRemoved(m_prop); + } + propertyView.Refresh(); + } + } + else if (m_viewMode == PropertyViewMode.AnimationMode) + { + var anim = (AnimationTypeDescriptor)propertyView.SelectedObject; + if(anim != null && m_SelectedAnimationPart == null) + { + //remove all animations + foreach (var item in anim.Animations) + { + m_style.Animations.Remove(item); + } + } + if (m_SelectedAnimationPart != null) + { + m_style.Animations.Remove(m_SelectedAnimationPart); + } + + if (OnPropertyRemoved != null) + { + if (m_prop != null) + OnPropertyRemoved(m_prop); + else if (m_SelectedAnimationPart != null) + OnPropertyRemoved(m_SelectedAnimationPart); + } + propertyView.Refresh(); } - propertyView.Refresh(); } private void OnPropertySelected(object sender, SelectedGridItemChangedEventArgs e) { - if (m_viewMode != PropertyViewMode.ClassMode) - return; - const int CTX_ADD = 0; - const int CTX_REM = 1; + if (m_viewMode == PropertyViewMode.ClassMode) + { + const int CTX_ADD = 0; + const int CTX_REM = 1; - bool haveSelection = e.NewSelection != null; - propViewContextMenu.Items[CTX_ADD].Enabled = haveSelection; - propViewContextMenu.Items[CTX_REM].Enabled = haveSelection; - if (!haveSelection) - return; + bool haveSelection = e.NewSelection != null; + propViewContextMenu.Items[CTX_ADD].Enabled = haveSelection; + propViewContextMenu.Items[CTX_REM].Enabled = haveSelection; + if (!haveSelection) + return; - var propDesc = e.NewSelection.PropertyDescriptor as StylePropertyDescriptor; - if (propDesc != null) - { - propViewContextMenu.Items[CTX_ADD].Text = "Add Property to [" + propDesc.Category + "]"; - propViewContextMenu.Items[CTX_REM].Text = "Remove " + propDesc.Name; + var propDesc = e.NewSelection.PropertyDescriptor as StylePropertyDescriptor; + if (propDesc != null) + { + propViewContextMenu.Items[CTX_ADD].Text = "Add Property to [" + propDesc.Category + "]"; + propViewContextMenu.Items[CTX_REM].Text = "Remove " + propDesc.Name; - m_state = propDesc.StyleState; - m_prop = propDesc.StyleProperty; - return; - } + m_state = propDesc.StyleState; + m_prop = propDesc.StyleProperty; + return; + } - var dummyDesc = e.NewSelection.PropertyDescriptor as PlaceHolderPropertyDescriptor; - if (dummyDesc != null) - { - propViewContextMenu.Items[CTX_ADD].Enabled = true; - propViewContextMenu.Items[CTX_ADD].Text = "Add Property to [" + dummyDesc.Category + "]"; - propViewContextMenu.Items[CTX_REM].Enabled = false; - propViewContextMenu.Items[CTX_REM].Text = "Remove"; - m_state = dummyDesc.StyleState; - return; - } + var dummyDesc = e.NewSelection.PropertyDescriptor as PlaceHolderPropertyDescriptor; + if (dummyDesc != null) + { + propViewContextMenu.Items[CTX_ADD].Enabled = true; + propViewContextMenu.Items[CTX_ADD].Text = "Add Property to [" + dummyDesc.Category + "]"; + propViewContextMenu.Items[CTX_REM].Enabled = false; + propViewContextMenu.Items[CTX_REM].Text = "Remove"; + m_state = dummyDesc.StyleState; + return; + } - if (e.NewSelection.GridItemType == GridItemType.Category) - { - OnPropertySelected(sender, new SelectedGridItemChangedEventArgs(null, e.NewSelection.GridItems[0])); // select child - return; - } + if (e.NewSelection.GridItemType == GridItemType.Category) + { + OnPropertySelected(sender, new SelectedGridItemChangedEventArgs(null, e.NewSelection.GridItems[0])); // select child + return; + } - if (e.NewSelection.GridItemType == GridItemType.Property) + if (e.NewSelection.GridItemType == GridItemType.Property) + { + OnPropertySelected(sender, new SelectedGridItemChangedEventArgs(null, e.NewSelection.Parent)); // select parent + return; + } + } + else if (m_viewMode == PropertyViewMode.AnimationMode) { - OnPropertySelected(sender, new SelectedGridItemChangedEventArgs(null, e.NewSelection.Parent)); // select parent - return; + if (e.NewSelection == null) + return; + + var prop = e.NewSelection.PropertyDescriptor as AnimationPropertyDescriptior; + if(prop != null) + { + Debug.WriteLine("selected property descriptor"); + } + + if (e.NewSelection.GridItemType == GridItemType.Category) + { + m_SelectedAnimationPart = (e.NewSelection.GridItems[0].PropertyDescriptor as AnimationPropertyDescriptior).m_animation; + } + + if (e.NewSelection.GridItemType == GridItemType.Property) + { + Debug.WriteLine("selected prop " + e.NewSelection.Parent.Label); + } } } } diff --git a/msstyleEditorSharp/PropView/AnimationWrapper.cs b/msstyleEditorSharp/PropView/AnimationWrapper.cs deleted file mode 100644 index 7175713..0000000 --- a/msstyleEditorSharp/PropView/AnimationWrapper.cs +++ /dev/null @@ -1,123 +0,0 @@ -using libmsstyle; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace msstyleEditor.PropView -{ /// - /// This class is needed to avoid the depencency of System.Windows.Forms in libmsstyle at the animation flags enum - /// - public class AnimationWrapper - { - private Animation m_animation; - [Editor(typeof(EnumFlagUIEditor), typeof(System.Drawing.Design.UITypeEditor))] - [Description("The animation flags to use")] - public AnimationFlags AnimationFlags - { - get - { - return m_animation.AnimationFlags; - } - set - { - m_animation.AnimationFlags = value; - } - } - - public int StaggerDelay - { - get - { - return m_animation.StaggerDelay; - } - set - { - m_animation.StaggerDelay = value; - } - } - - public int StaggerDelayCap - { - get - { - return m_animation.StaggerDelayCap; - } - set - { - m_animation.StaggerDelayCap = value; - } - } - - public float StaggerDelayFactor - { - get - { - return m_animation.StaggerDelayFactor; - } - set - { - m_animation.StaggerDelayFactor = value; - } - } - - public int ZOrder - { - get - { - return m_animation.ZOrder; - } - set - { - m_animation.ZOrder = value; - } - } - [Description("The background part ID. Used if AnimationFlags.HasBackground is set")] - public int BackgroundPartID - { - get - { - return m_animation.BackgroundPartID; - } - set - { - m_animation.BackgroundPartID = value; - } - } - - public int TuningLevel - { - get - { - return m_animation.TuningLevel; - } - set - { - m_animation.TuningLevel = value; - } - } - - public float Perspective - { - get - { - return m_animation.Perspective; - } - set - { - m_animation.Perspective = value; - } - } - - [Description("The list of transforms. Can be zero.")] - public List Transforms { get { return m_animation.Transforms; } } - - public AnimationWrapper(Animation wrapper) - { - this.m_animation = wrapper; - } - } -} diff --git a/msstyleEditorSharp/PropView/TypeDescriptors.cs b/msstyleEditorSharp/PropView/TypeDescriptors.cs index d61a2d6..0aae9c7 100644 --- a/msstyleEditorSharp/PropView/TypeDescriptors.cs +++ b/msstyleEditorSharp/PropView/TypeDescriptors.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Drawing.Design; using System.Text; namespace msstyleEditor.PropView @@ -396,7 +397,7 @@ public class AnimationPropertyDescriptior : PropertyDescriptor public override Type PropertyType => m_fi.PropertyType; private System.Reflection.PropertyInfo m_fi; - private Animation m_animation; + public Animation m_animation; private string m_category; public override string Category => m_category; @@ -423,6 +424,21 @@ public AnimationPropertyDescriptior(System.Reflection.PropertyInfo fi, Animation { this.m_category = "State " + animation.Header.stateID; } + List newAtribs = new List(); + if (fi.Name == "AnimationFlags") + { + newAtribs.Add(new EditorAttribute(typeof(EnumFlagUIEditor), typeof(UITypeEditor))); + } + //add description + var desc = fi.GetCustomAttributes(false); + foreach (var item in desc) + { + if(item is DescriptionAttribute) + { + newAtribs.Add(item as DescriptionAttribute); + } + } + this.AttributeArray = newAtribs.ToArray(); } public override bool CanResetValue(object component) diff --git a/msstyleEditorSharp/msstyleEditorSharp.csproj b/msstyleEditorSharp/msstyleEditorSharp.csproj index b0234fe..0b1109d 100644 --- a/msstyleEditorSharp/msstyleEditorSharp.csproj +++ b/msstyleEditorSharp/msstyleEditorSharp.csproj @@ -134,6 +134,12 @@ LicenseDialog.cs + + Form + + + NewDialog.cs + Form @@ -167,7 +173,6 @@ True Resources.resx - Component @@ -219,6 +224,9 @@ MainWindow.cs Designer + + NewDialog.cs + PropertyView.cs