Pārlūkot izejas kodu

Replaced TrackBars with Sliders

Enabled DoubleBuffering for Track to reduce flickering
Implemented Undo/Redo
tags/Undo-History^2
DragonSkills99 pirms 5 gadiem
vecāks
revīzija
1e56c19ca2

+ 136
- 61
Funscripta/Form1.Designer.cs Parādīt failu

@@ -37,11 +37,18 @@
this.saveFile = new System.Windows.Forms.ToolStripMenuItem();
this.saveFileAs = new System.Windows.Forms.ToolStripMenuItem();
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.undo = new System.Windows.Forms.ToolStripMenuItem();
this.redo = new System.Windows.Forms.ToolStripMenuItem();
this.redoAlt = new System.Windows.Forms.ToolStripMenuItem();
this.mediaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.playPause = new System.Windows.Forms.ToolStripMenuItem();
this.forward = new System.Windows.Forms.ToolStripMenuItem();
this.backward = new System.Windows.Forms.ToolStripMenuItem();
this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.unpackManagerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.videoPanel = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.frames = new System.Windows.Forms.ToolStripStatusLabel();
this.framesPerSecond = new System.Windows.Forms.ToolStripStatusLabel();
@@ -54,18 +61,14 @@
this.removeNode = new System.Windows.Forms.ToolStripDropDownButton();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.position = new System.Windows.Forms.TrackBar();
this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.unpackManagerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.trackBar1 = new System.Windows.Forms.TrackBar();
this.label1 = new System.Windows.Forms.Label();
this.zoom = new Funscripta.Slider();
this.position = new Funscripta.Slider();
this.track1 = new Funscripta.Track();
this.menuStrip1.SuspendLayout();
this.videoPanel.SuspendLayout();
this.statusStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.position)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
@@ -73,6 +76,7 @@
this.menuStrip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(55)))), ((int)(((byte)(55)))));
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.editToolStripMenuItem,
this.mediaToolStripMenuItem,
this.viewToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
@@ -150,6 +154,48 @@
this.newToolStripMenuItem.Text = "New";
this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
//
// editToolStripMenuItem
//
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.undo,
this.redo,
this.redoAlt});
this.editToolStripMenuItem.ForeColor = System.Drawing.Color.White;
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
this.editToolStripMenuItem.Text = "Edit";
//
// undo
//
this.undo.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(55)))), ((int)(((byte)(55)))));
this.undo.ForeColor = System.Drawing.Color.White;
this.undo.Name = "undo";
this.undo.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z)));
this.undo.Size = new System.Drawing.Size(174, 22);
this.undo.Text = "Undo";
this.undo.Click += new System.EventHandler(this.undo_Click);
//
// redo
//
this.redo.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(55)))), ((int)(((byte)(55)))));
this.redo.ForeColor = System.Drawing.Color.White;
this.redo.Name = "redo";
this.redo.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y)));
this.redo.Size = new System.Drawing.Size(174, 22);
this.redo.Text = "Redo";
this.redo.Click += new System.EventHandler(this.redo_Click);
//
// redoAlt
//
this.redoAlt.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(55)))), ((int)(((byte)(55)))));
this.redoAlt.ForeColor = System.Drawing.Color.White;
this.redoAlt.Name = "redoAlt";
this.redoAlt.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.Z)));
this.redoAlt.Size = new System.Drawing.Size(174, 22);
this.redoAlt.Text = "Redo";
this.redoAlt.Click += new System.EventHandler(this.redo_Click);
//
// mediaToolStripMenuItem
//
this.mediaToolStripMenuItem.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(55)))), ((int)(((byte)(55)))));
@@ -192,6 +238,25 @@
this.backward.Text = "Backward";
this.backward.Click += new System.EventHandler(this.backward_Click);
//
// viewToolStripMenuItem
//
this.viewToolStripMenuItem.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(55)))), ((int)(((byte)(55)))));
this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.unpackManagerToolStripMenuItem});
this.viewToolStripMenuItem.ForeColor = System.Drawing.Color.White;
this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
this.viewToolStripMenuItem.Text = "View";
//
// unpackManagerToolStripMenuItem
//
this.unpackManagerToolStripMenuItem.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(55)))), ((int)(((byte)(55)))));
this.unpackManagerToolStripMenuItem.ForeColor = System.Drawing.Color.White;
this.unpackManagerToolStripMenuItem.Name = "unpackManagerToolStripMenuItem";
this.unpackManagerToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
this.unpackManagerToolStripMenuItem.Text = "Unpack-Manager";
this.unpackManagerToolStripMenuItem.Click += new System.EventHandler(this.unpackManagerToolStripMenuItem_Click);
//
// videoPanel
//
this.videoPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@@ -205,6 +270,15 @@
this.videoPanel.Size = new System.Drawing.Size(725, 408);
this.videoPanel.TabIndex = 1;
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(725, 408);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// statusStrip1
//
this.statusStrip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(55)))), ((int)(((byte)(55)))));
@@ -263,7 +337,6 @@
// framesPerStep
//
this.framesPerStep.BackColor = System.Drawing.Color.White;
this.framesPerStep.Font = new System.Drawing.Font("Segoe UI", 9F);
this.framesPerStep.Name = "framesPerStep";
this.framesPerStep.Size = new System.Drawing.Size(100, 23);
this.framesPerStep.Text = "1";
@@ -305,59 +378,57 @@
//
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label1.Location = new System.Drawing.Point(743, 27);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(45, 21);
this.label1.TabIndex = 7;
this.label1.Text = "Zoom";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// zoom
//
this.zoom.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.zoom.BarColor = System.Drawing.Color.White;
this.zoom.BarSelectedColor = System.Drawing.Color.DarkCyan;
this.zoom.Location = new System.Drawing.Point(743, 51);
this.zoom.Maximum = 500F;
this.zoom.Minimum = 100F;
this.zoom.Name = "zoom";
this.zoom.Orientation = System.Windows.Forms.Orientation.Vertical;
this.zoom.PullerColor = System.Drawing.Color.Cyan;
this.zoom.PullerHoverColor = System.Drawing.Color.DarkCyan;
this.zoom.PullerOuterColor = System.Drawing.Color.DarkCyan;
this.zoom.PullerSize = new System.Drawing.Size(10, 10);
this.zoom.Size = new System.Drawing.Size(45, 384);
this.zoom.Step = 1F;
this.zoom.TabIndex = 6;
this.zoom.Value = 100F;
this.zoom.ValueChanged += new Funscripta.Slider.ValueChangedDelegate(this.zoom_ValueChanged);
//
// position
//
this.position.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.position.BarColor = System.Drawing.Color.White;
this.position.BarSelectedColor = System.Drawing.Color.DarkCyan;
this.position.Location = new System.Drawing.Point(12, 441);
this.position.Maximum = 100;
this.position.Maximum = 100F;
this.position.Minimum = 0F;
this.position.Name = "position";
this.position.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.position.PullerColor = System.Drawing.Color.Cyan;
this.position.PullerHoverColor = System.Drawing.Color.DarkCyan;
this.position.PullerOuterColor = System.Drawing.Color.DarkCyan;
this.position.PullerSize = new System.Drawing.Size(10, 10);
this.position.Size = new System.Drawing.Size(776, 45);
this.position.TabIndex = 4;
this.position.Scroll += new System.EventHandler(this.position_Scroll);
this.position.ValueChanged += new System.EventHandler(this.position_ValueChanged);
//
// viewToolStripMenuItem
//
this.viewToolStripMenuItem.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(55)))), ((int)(((byte)(55)))));
this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.unpackManagerToolStripMenuItem});
this.viewToolStripMenuItem.ForeColor = System.Drawing.Color.White;
this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
this.viewToolStripMenuItem.Text = "View";
//
// unpackManagerToolStripMenuItem
//
this.unpackManagerToolStripMenuItem.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(55)))), ((int)(((byte)(55)))));
this.unpackManagerToolStripMenuItem.ForeColor = System.Drawing.Color.White;
this.unpackManagerToolStripMenuItem.Name = "unpackManagerToolStripMenuItem";
this.unpackManagerToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
this.unpackManagerToolStripMenuItem.Text = "Unpack-Manager";
this.unpackManagerToolStripMenuItem.Click += new System.EventHandler(this.unpackManagerToolStripMenuItem_Click);
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(725, 408);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// trackBar1
//
this.trackBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.trackBar1.Location = new System.Drawing.Point(743, 27);
this.trackBar1.Maximum = 500;
this.trackBar1.Minimum = 100;
this.trackBar1.Name = "trackBar1";
this.trackBar1.Orientation = System.Windows.Forms.Orientation.Vertical;
this.trackBar1.Size = new System.Drawing.Size(45, 408);
this.trackBar1.TabIndex = 1;
this.trackBar1.Value = 500;
this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);
this.position.Step = 1F;
this.position.TabIndex = 5;
this.position.Value = 0F;
this.position.ValueChanged += new Funscripta.Slider.ValueChangedDelegate(this.slider1_ValueChanged);
//
// track1
//
@@ -378,7 +449,8 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(55)))), ((int)(((byte)(55)))));
this.ClientSize = new System.Drawing.Size(800, 563);
this.Controls.Add(this.trackBar1);
this.Controls.Add(this.label1);
this.Controls.Add(this.zoom);
this.Controls.Add(this.position);
this.Controls.Add(this.track1);
this.Controls.Add(this.statusStrip1);
@@ -394,11 +466,9 @@
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.videoPanel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.position)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();

@@ -431,11 +501,16 @@
private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;
private System.Windows.Forms.ToolStripDropDownButton removeNode;
private System.Windows.Forms.ToolStripDropDownButton toolStripDropDownButton1;
private System.Windows.Forms.TrackBar position;
private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem unpackManagerToolStripMenuItem;
private System.Windows.Forms.TrackBar trackBar1;
private System.Windows.Forms.PictureBox pictureBox1;
private Slider position;
private Slider zoom;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem undo;
private System.Windows.Forms.ToolStripMenuItem redo;
private System.Windows.Forms.ToolStripMenuItem redoAlt;
}
}


+ 34
- 27
Funscripta/Form1.cs Parādīt failu

@@ -283,31 +283,6 @@ namespace Funscripta
if ( Directory.Exists( RawName ) ) Directory.Delete( RawName, true );
}

private void position_ValueChanged( object sender, EventArgs e )
{
}

private Task ScrollDelay;

private void position_Scroll( object sender, EventArgs e )
{
var val = position.Value;
ScrollDelay = new Task( () => {
System.Threading.Thread.Sleep( 100 );
if ( position.MayInvoke( () => position.Value ) != val ) return;
this.MayInvoke( PositionChanged );
} );
ScrollDelay.Start();
}



private void PositionChanged()
{
track1.FunScript.AddAction( ( long ) track1.CurrentTimestamp, position.Value );
track1.Refresh();
}

private void removeNode_Click( object sender, EventArgs e )
{
track1.FunScript.RemoveAction( ( long ) track1.CurrentTimestamp );
@@ -324,14 +299,46 @@ namespace Funscripta
( new Unpack_Manager() ).Show();
}

private void trackBar1_Scroll( object sender, EventArgs e )
private void slider1_ValueChanged( float frame, Slider.Action sender )
{
if ( sender == Slider.Action.Mouse )
{
track1.FunScript.AddAction( ( long ) track1.CurrentTimestamp, ( int ) frame );
track1.Refresh();
}
}

private void zoom_ValueChanged( float frame, Slider.Action sender )
{
var val = trackBar1.Maximum - trackBar1.Value + trackBar1.Minimum;
if ( sender == Slider.Action.Mouse ) return;
var val = zoom.Value;
var mod = val / 100D;
pictureBox1.Width = ( int ) ( videoPanel.Width * mod );
pictureBox1.Height = ( int ) ( videoPanel.Height * mod );
videoPanel.HorizontalScroll.Enabled = mod > 1D;
videoPanel.VerticalScroll.Enabled = mod > 1D;
}

private void undo_Click( object sender, EventArgs e )
{
track1.FunScript.Undo();
track1.Refresh();
}

private void redo_Click( object sender, EventArgs e )
{
track1.FunScript.Redo();
track1.Refresh();
}

protected override void OnSizeChanged( EventArgs e )
{
base.OnSizeChanged( e );
}
protected override void OnClientSizeChanged( EventArgs e )
{
zoom_ValueChanged( zoom.Value, Slider.Action.Script );
base.OnClientSizeChanged( e );
}
}
}

+ 93
- 5
Funscripta/FunScript.cs Parādīt failu

@@ -12,6 +12,27 @@ namespace Funscripta
{
public class FunScript
{
[JsonIgnore]
public static int HistoryLimit { get; set; } = 100;

public class HistoryEntry
{
public enum HistoryAction
{
Create, Update, Delete
}

public HistoryAction Action { get; set; }
public long Timestamp { get; set; }
public int? PositionBefore { get; set; }
public int? PositionAfter { get; set; }
}

[JsonIgnore]
public List<HistoryEntry> History { get; set; } = new List<HistoryEntry>();
[JsonIgnore]
public List<HistoryEntry> UndoHistory { get; set; } = new List<HistoryEntry>();

[JsonProperty( "version" )]
public string Version { get; set; } = "1.0";
[JsonProperty( "actions" )]
@@ -21,7 +42,10 @@ namespace Funscripta
[JsonProperty( "range" )]
public int Range { get; set; } = 100;


[JsonIgnore]
public bool CanUndo => History.Count > 0;
[JsonIgnore]
public bool CanRedo => UndoHistory.Count > 0;

internal FunScript()
{
@@ -52,23 +76,87 @@ namespace Funscripta
public void AddAction( long timestamp, int position )
{
var a = Find( timestamp );
if ( a.Timestamp == timestamp )
if ( a.Timestamp == timestamp && a.Position != position )
{
if ( timestamp < 0 && Find( timestamp - 1 ).Position == position ) RemoveAction( timestamp );
else a.Position = position;
HistoryAdd( HistoryEntry.HistoryAction.Update, a.Timestamp, a.Position, position );
a.Position = position;
}
else if ( a.Position == position ) return;
else
{
var _a = Actions.Find( a );
Actions.AddAfter( _a, new Action( timestamp, position ) );
HistoryAdd( HistoryEntry.HistoryAction.Create, timestamp, null, position );
}
}

public void RemoveAction( long timestamp )
{
var a = Find( timestamp );
if ( a.Timestamp != 0 ) Actions.Remove( Actions.Find( a ) );
if ( a.Timestamp != 0 )
{
Actions.Remove( Actions.Find( a ) );
HistoryAdd( HistoryEntry.HistoryAction.Delete, a.Timestamp, a.Position, null );
}
}

private void HistoryAdd( HistoryEntry.HistoryAction action, long timestamp, int? posBefore, int? posAfter )
{
History.Add( new HistoryEntry()
{
Action = action,
Timestamp = timestamp,
PositionBefore = posBefore,
PositionAfter = posAfter
}
);
if ( History.Count > HistoryLimit ) History.RemoveAt( 0 );
UndoHistory.Clear();
}

private void UndoHistoryAdd( HistoryEntry historyEntry )
{
UndoHistory.Add( historyEntry );
}

public void Undo()
{
if ( !CanUndo ) return;
var e = History.Last();
History.Remove( e );
switch( e.Action )
{
case HistoryEntry.HistoryAction.Create:
Actions.Remove( Find( e.Timestamp ) );
break;
case HistoryEntry.HistoryAction.Update:
Find( e.Timestamp ).Position = e.PositionBefore.Value;
break;
case HistoryEntry.HistoryAction.Delete:
Actions.AddAfter( Actions.Find( Find( e.Timestamp ) ), new Action( e.Timestamp, e.PositionBefore.Value ) );
break;
}
UndoHistoryAdd( e );
}

public void Redo()
{
if ( !CanRedo ) return;
var e = UndoHistory.Last();
UndoHistory.Remove( e );
switch ( e.Action )
{
case HistoryEntry.HistoryAction.Create:
Actions.AddAfter( Actions.Find( Find( e.Timestamp ) ), new Action( e.Timestamp, e.PositionAfter.Value ) );
break;
case HistoryEntry.HistoryAction.Update:
Find( e.Timestamp ).Position = e.PositionAfter.Value;
break;
case HistoryEntry.HistoryAction.Delete:
Actions.Remove( Find( e.Timestamp ) );
break;
}
History.Add( e );
}

public static FunScript LoadFile( string file )

+ 32
- 5
Funscripta/Funscripta.csproj Parādīt failu

@@ -14,20 +14,24 @@
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<IsWebBootstrapper>true</IsWebBootstrapper>
<PublishUrl>ftp://dragonskills99.de/var/www/html/scripts.dragonskills99.de/projects/funscripta/</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<InstallFrom>Web</InstallFrom>
<UpdateEnabled>true</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<InstallUrl>http://scripts.dragonskills99.de/projects/funscripta/</InstallUrl>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -52,6 +56,18 @@
<PropertyGroup>
<ApplicationIcon>vibrator.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>7B7B2051F5DE01D2D0D5776D44253BCD191CE8D5</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>Funscripta_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="Accord, Version=3.8.2.0, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7, processorArchitecture=MSIL">
<HintPath>..\packages\Accord.3.8.2-alpha\lib\net462\Accord.dll</HintPath>
@@ -92,8 +108,15 @@
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="FunScript.cs" />
<Compile Include="LineCapPen.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Slider.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Slider.Designer.cs">
<DependentUpon>Slider.cs</DependentUpon>
</Compile>
<Compile Include="Track.cs">
<SubType>UserControl</SubType>
</Compile>
@@ -118,12 +141,16 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="Slider.resx">
<DependentUpon>Slider.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Track.resx">
<DependentUpon>Track.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Unpack-Manager.resx">
<DependentUpon>Unpack-Manager.cs</DependentUpon>
</EmbeddedResource>
<None Include="Funscripta_TemporaryKey.pfx" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>

+ 34
- 0
Funscripta/LineCapPen.cs Parādīt failu

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace System.Drawing
{
class LineCapPen
{
public static Pen Create( Color color, LineCap cap )
{
Pen pen = new Pen( color )
{
EndCap = cap,
StartCap = cap
};
pen.SetLineCap( cap, cap, DashCap.Flat );
return pen;
}
public static Pen Create( Color color, float barWidth, LineCap cap )
{
Pen pen = new Pen( color, barWidth )
{
EndCap = cap,
StartCap = cap
};
pen.SetLineCap( cap, cap, DashCap.Flat );
return pen;
}
}
}

+ 46
- 0
Funscripta/Slider.Designer.cs Parādīt failu

@@ -0,0 +1,46 @@
namespace Funscripta
{
partial class Slider

{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose( bool disposing )
{
if ( disposing && ( components != null ) )
{
components.Dispose();
}
base.Dispose( disposing );
}

#region Component Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// Track
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "Track";
this.Size = new System.Drawing.Size(588, 46);
this.ResumeLayout(false);

}

#endregion
}
}

+ 301
- 0
Funscripta/Slider.cs Parādīt failu

@@ -0,0 +1,301 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace Funscripta
{
public partial class Slider : UserControl
{
protected class _Puller : UserControl
{
private Slider Root { get; set; }
public bool Moving { get; set; } = false;

public _Puller( Size size, Slider parent )
{
Size = size;
Root = parent;
DoubleBuffered = true;
}

protected override void OnPaintBackground( PaintEventArgs e )
{
var g = e.Graphics;
g.FillRectangle( new SolidBrush( Root.BackColor ), ClientRectangle );
}

protected override void OnPaint( PaintEventArgs e )
{
var g = e.Graphics;
g.FillEllipse( new SolidBrush( Hovering || Moving ? Root.PullerHoverColor : Root.PullerColor ), ClientRectangle );
g.DrawEllipse( new Pen( Root.PullerOuterColor ), ClientRectangle );
}

public bool Hovering => ClientRectangle.Contains( PointToClient( Control.MousePosition ) );

protected override void OnMouseEnter( EventArgs e )
{
Refresh();
base.OnMouseEnter( e );
}
protected override void OnMouseDown( MouseEventArgs e )
{
if ( e.Button == MouseButtons.Left && Hovering ) Moving = true;
base.OnMouseDown( e );
}

protected override void OnMouseUp( MouseEventArgs e )
{
if ( e.Button == MouseButtons.Left && Moving ) Moving = false;
base.OnMouseUp( e );
Root.Slider_MouseClick( this, new MouseEventArgs( e.Button, e.Clicks, e.X + Location.X, e.Y + Location.Y, e.Delta ) );
}

protected override void OnMouseLeave( EventArgs e )
{
Refresh();
base.OnMouseLeave( e );
}

protected override void OnMouseMove( MouseEventArgs e )
{
base.OnMouseMove( e );
Root.Slider_MouseClick( this, new MouseEventArgs( e.Button, e.Clicks, e.X + Location.X, e.Y + Location.Y, e.Delta ) );
}
}

public enum Action
{
Script, Mouse
}

public delegate void ValueChangedDelegate( float frame, Action sender );
public event ValueChangedDelegate ValueChanged;

private float _max = 100;
private float _min = 0;
private float _value = 0;
private float _step = 1;
private Color _pullerColor = Color.Cyan;
private Color _pullerHoverColor = Color.DarkCyan;
private Color _pullerOuterColor = Color.DarkCyan;
private Color _barColor = Color.White;
private Color _barSelectedColor = Color.DarkCyan;
private Orientation _orientation = Orientation.Horizontal;

[Browsable( true )]
public float Maximum
{
get => _max;
set
{
if ( value <= Minimum ) value = Minimum + 1;
if ( Value > value ) Value = value;
_max = value;
}
}
[Browsable( true )]
public float Minimum
{
get => _min;
set
{
if ( value >= Maximum ) value = Maximum - 1;
if ( Value < value ) Value = value;
_min = value;
}
}
[Browsable( true )]
public float Value
{
get => _value;
set
{
value = value - ( value % Step );
if ( value > Maximum ) value = Maximum;
if ( value < Minimum ) value = Minimum;
_value = value;
ValueChanged( value, Action.Script );
}
}
private float DecimalPercentage {
get => ( Value - Minimum ) / ( Maximum - Minimum );
set => Value = ( ( Maximum - Minimum ) * value ) + Minimum;
}

[Browsable( true )]
public float Step
{
get => _step;
set
{
if ( value <= 0 ) value = 1;
if ( value > Maximum - Minimum ) value = Maximum - Minimum;
_step = value;
}
}
[Browsable( true )]
public Color PullerColor
{
get => _pullerColor;
set
{
_pullerColor = value;
Puller.Refresh();
}
}
[Browsable( true )]
public Color PullerHoverColor
{
get => _pullerHoverColor;
set
{
_pullerHoverColor = value;
Puller.Refresh();
}
}
[Browsable( true )]
public Color PullerOuterColor
{
get => _pullerOuterColor;
set
{
_pullerOuterColor = value;
Puller.Refresh();
}
}
[Browsable( true )]
public Color BarColor
{
get => _barColor;
set
{
_barColor = value;
Refresh();
}
}
[Browsable( true )]
public Color BarSelectedColor
{
get => _barSelectedColor;
set
{
_barSelectedColor = value;
Refresh();
}
}
[Browsable(true)]
public Orientation Orientation
{
get => _orientation;
set
{
_orientation = value;
Refresh();
}
}

private _Puller Puller { get; set; }
[Browsable( true )]
public Size PullerSize { get => Puller.Size; set => Puller.Size = value; }

public Slider()
{
Puller = new _Puller( new Size( 10, 10 ), this );
Controls.Add( Puller );
InitializeComponent();
ValueChanged += ( l, s ) => { };
MouseClick += Slider_MouseClick;
DoubleBuffered = true;
}

protected void Slider_MouseClick( object sender, MouseEventArgs e )
{
if ( e.Button == MouseButtons.Left )
{
Select();
switch( Orientation )
{
default:
case Orientation.Horizontal:
var pullerX = Puller.Size.Width;
var pullerXHalf = pullerX / 2;
var width = Width - pullerX;
var x = e.Location.X;
if ( x < pullerXHalf ) x = pullerXHalf;
else if ( x > ( width + pullerXHalf ) ) x = width + pullerXHalf;
x -= pullerXHalf;

DecimalPercentage = x / ( float ) width;
break;
case Orientation.Vertical:
var pullerY = Puller.Size.Height;
var pullerYHalf = pullerY / 2;
var height = Height - pullerY;
var y = e.Location.Y;
if ( y < pullerYHalf ) x = pullerYHalf;
else if ( y > ( height + pullerYHalf ) ) y = height + pullerYHalf;
y -= pullerYHalf;

DecimalPercentage = y / ( float ) height;
break;
}
if ( !Puller.Moving ) ValueChanged( Value, Action.Mouse );
Refresh();
}
}

protected override void OnPaintBackground( PaintEventArgs e )
{
var g = e.Graphics;
g.FillRectangle( new SolidBrush( BackColor ), ClientRectangle );
}

protected override void OnPaint( PaintEventArgs e )
{
var g = e.Graphics;
int pullerX = Puller.Size.Width, pullerY = Puller.Size.Height;
int barWidth, barLocation, pullerXHalf, pullerYHalf;

switch ( Orientation )
{

default:
case Orientation.Horizontal:
barWidth = pullerY / 3;
barLocation = Height / 2 - barWidth / 2;
pullerXHalf = pullerX / 2;

g.DrawLine( LineCapPen.Create( BarColor, barWidth, LineCap.Round ), pullerXHalf, barLocation, Width - pullerXHalf, barLocation );
g.DrawLine( LineCapPen.Create( BarSelectedColor, barWidth, LineCap.Round ), pullerXHalf, barLocation, ( Width - pullerXHalf ) * DecimalPercentage, barLocation );

Puller.Location = new Point( ( int ) ( ( Width - pullerX ) * DecimalPercentage ), barLocation - pullerXHalf );
break;
case Orientation.Vertical:
barWidth = pullerX / 3;
barLocation = Width / 2 - barWidth / 2;
pullerYHalf = pullerY / 2;

g.DrawLine( LineCapPen.Create( BarColor, barWidth, LineCap.Round ), barLocation, pullerYHalf, barLocation, Height - pullerYHalf );
g.DrawLine( LineCapPen.Create( BarSelectedColor, barWidth, LineCap.Round ), barLocation, pullerYHalf, barLocation, ( Height - pullerYHalf ) * DecimalPercentage );

Puller.Location = new Point( barLocation - pullerYHalf, ( int ) ( ( Height - pullerY ) * DecimalPercentage ) );
break;
}

}

protected override void OnClientSizeChanged( EventArgs e )
{
Invalidate();
base.OnClientSizeChanged( e );
}
}
}

+ 120
- 0
Funscripta/Slider.resx Parādīt failu

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

+ 1
- 0
Funscripta/Track.cs Parādīt failu

@@ -63,6 +63,7 @@ namespace Funscripta
{
InitializeComponent();
FrameChanged += ( l, s ) => { };
DoubleBuffered = true;
}

protected override void OnPaintBackground( PaintEventArgs e )

Notiek ielāde…
Atcelt
Saglabāt