appscape fixes + video player

This commit is contained in:
Michael 2017-04-25 11:48:44 -04:00
parent d22957d2ab
commit cd29d582d9
6 changed files with 486 additions and 30 deletions

View file

@ -0,0 +1,168 @@
namespace ShiftOS.WinForms.Applications
{
partial class VideoPlayer
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VideoPlayer));
this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
this.flcontrols = new System.Windows.Forms.FlowLayoutPanel();
this.btnplay = new System.Windows.Forms.Button();
this.pgplaytime = new ShiftOS.WinForms.Controls.ShiftedProgressBar();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.addSongToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.wpaudio = new AxWMPLib.AxWindowsMediaPlayer();
this.toolStripContainer1.ContentPanel.SuspendLayout();
this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
this.toolStripContainer1.SuspendLayout();
this.flcontrols.SuspendLayout();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.wpaudio)).BeginInit();
this.SuspendLayout();
//
// toolStripContainer1
//
//
// toolStripContainer1.ContentPanel
//
this.toolStripContainer1.ContentPanel.Controls.Add(this.wpaudio);
this.toolStripContainer1.ContentPanel.Controls.Add(this.flcontrols);
this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(805, 402);
this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer1.LeftToolStripPanelVisible = false;
this.toolStripContainer1.Location = new System.Drawing.Point(0, 0);
this.toolStripContainer1.Name = "toolStripContainer1";
this.toolStripContainer1.RightToolStripPanelVisible = false;
this.toolStripContainer1.Size = new System.Drawing.Size(805, 426);
this.toolStripContainer1.TabIndex = 3;
this.toolStripContainer1.Text = "toolStripContainer1";
//
// toolStripContainer1.TopToolStripPanel
//
this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.menuStrip1);
//
// flcontrols
//
this.flcontrols.AutoSize = true;
this.flcontrols.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flcontrols.Controls.Add(this.btnplay);
this.flcontrols.Controls.Add(this.pgplaytime);
this.flcontrols.Dock = System.Windows.Forms.DockStyle.Bottom;
this.flcontrols.Location = new System.Drawing.Point(0, 373);
this.flcontrols.Name = "flcontrols";
this.flcontrols.Size = new System.Drawing.Size(805, 29);
this.flcontrols.TabIndex = 0;
//
// btnplay
//
this.btnplay.AutoSize = true;
this.btnplay.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnplay.Location = new System.Drawing.Point(3, 3);
this.btnplay.Name = "btnplay";
this.btnplay.Size = new System.Drawing.Size(37, 23);
this.btnplay.TabIndex = 0;
this.btnplay.Text = "Play";
this.btnplay.UseVisualStyleBackColor = true;
this.btnplay.Click += new System.EventHandler(this.btnplay_Click);
//
// pgplaytime
//
this.pgplaytime.BlockSize = 5;
this.pgplaytime.Location = new System.Drawing.Point(46, 3);
this.pgplaytime.Maximum = 100;
this.pgplaytime.Name = "pgplaytime";
this.pgplaytime.Size = new System.Drawing.Size(749, 23);
this.pgplaytime.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
this.pgplaytime.TabIndex = 1;
this.pgplaytime.Tag = "keepbg";
this.pgplaytime.Text = "shiftedProgressBar1";
this.pgplaytime.Value = 0;
this.pgplaytime.MouseDown += new System.Windows.Forms.MouseEventHandler(this.startScrub);
this.pgplaytime.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pgplaytime_MouseMove);
this.pgplaytime.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pgplaytime_MouseUp);
//
// menuStrip1
//
this.menuStrip1.Dock = System.Windows.Forms.DockStyle.None;
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addSongToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(805, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// addSongToolStripMenuItem
//
this.addSongToolStripMenuItem.Name = "addSongToolStripMenuItem";
this.addSongToolStripMenuItem.Size = new System.Drawing.Size(81, 20);
this.addSongToolStripMenuItem.Text = "Open Video";
this.addSongToolStripMenuItem.Click += new System.EventHandler(this.addSongToolStripMenuItem_Click);
//
// wpaudio
//
this.wpaudio.Dock = System.Windows.Forms.DockStyle.Fill;
this.wpaudio.Enabled = true;
this.wpaudio.Location = new System.Drawing.Point(0, 0);
this.wpaudio.Name = "wpaudio";
this.wpaudio.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("wpaudio.OcxState")));
this.wpaudio.Size = new System.Drawing.Size(805, 373);
this.wpaudio.TabIndex = 2;
this.wpaudio.Visible = false;
//
// VideoPlayer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.toolStripContainer1);
this.Name = "VideoPlayer";
this.Size = new System.Drawing.Size(805, 426);
this.toolStripContainer1.ContentPanel.ResumeLayout(false);
this.toolStripContainer1.ContentPanel.PerformLayout();
this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false);
this.toolStripContainer1.TopToolStripPanel.PerformLayout();
this.toolStripContainer1.ResumeLayout(false);
this.toolStripContainer1.PerformLayout();
this.flcontrols.ResumeLayout(false);
this.flcontrols.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.wpaudio)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ToolStripContainer toolStripContainer1;
private System.Windows.Forms.FlowLayoutPanel flcontrols;
private System.Windows.Forms.Button btnplay;
private Controls.ShiftedProgressBar pgplaytime;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem addSongToolStripMenuItem;
private AxWMPLib.AxWindowsMediaPlayer wpaudio;
}
}

View file

@ -0,0 +1,132 @@
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 ShiftOS.Engine;
using System.IO;
namespace ShiftOS.WinForms.Applications
{
[AppscapeEntry("Video Player", "Play .mp4 files or .wmv files as videos inside ShiftOS! Perfect for a shifted movie night.", 1524, 1000, "file_skimmer", "Entertainment")]
[DefaultTitle("Video Player")]
[Launcher("Video Player", false, null, "Entertainment")]
[WinOpen("video_player")]
public partial class VideoPlayer : UserControl, IShiftOSWindow
{
public VideoPlayer()
{
InitializeComponent();
}
public void OnLoad()
{
tmr.Interval = 50;
tmr.Tick += (o, a) =>
{
try
{
double end = wpaudio.currentMedia.duration;
double pos = wpaudio.Ctlcontrols.currentPosition;
pgplaytime.Maximum = (int)end;
pgplaytime.Value = (int)pos;
}
catch { }
};
tmr.Start();
}
public void OnSkinLoad()
{
wpaudio.uiMode = "none";
wpaudio.Show();
pgplaytime.Width = flcontrols.Width - btnplay.Width - 25;
wpaudio.enableContextMenu = false;
}
public bool OnUnload()
{
if(!string.IsNullOrWhiteSpace(filePath))
if (File.Exists(filePath))
File.Delete(filePath);
tmr.Stop();
return true;
}
public void OnUpgrade()
{
}
Timer tmr = new Timer();
string filePath = null;
private void addSongToolStripMenuItem_Click(object sender, EventArgs e)
{
FileSkimmerBackend.GetFile(new[] { ".mp4", ".wmv" }, FileOpenerStyle.Open, (result) =>
{
var finf = ShiftOS.Objects.ShiftFS.Utils.GetFileInfo(result);
File.WriteAllBytes(finf.Name, ShiftOS.Objects.ShiftFS.Utils.ReadAllBytes(result));
filePath = finf.Name;
wpaudio.URL = filePath;
wpaudio.Ctlcontrols.play();
btnplay.Text = "Pause";
});
}
private void btnplay_Click(object sender, EventArgs e)
{
if(wpaudio.playState == WMPLib.WMPPlayState.wmppsPlaying)
{
wpaudio.Ctlcontrols.pause();
btnplay.Text = "Play";
}
else if(wpaudio.playState == WMPLib.WMPPlayState.wmppsPaused)
{
wpaudio.Ctlcontrols.play();
btnplay.Text = "Pause";
}
}
bool scrubbing = false;
private void startScrub(object sender, MouseEventArgs e)
{
scrubbing = true;
}
static public double linear(double x, double x0, double x1, double y0, double y1)
{
if ((x1 - x0) == 0)
{
return (y0 + y1) / 2;
}
return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
}
private void pgplaytime_MouseMove(object sender, MouseEventArgs e)
{
if (wpaudio.playState == WMPLib.WMPPlayState.wmppsPlaying || wpaudio.playState == WMPLib.WMPPlayState.wmppsPaused)
try
{
if (scrubbing)
{
double end = wpaudio.currentMedia.duration;
double result = linear(e.X, 0, pgplaytime.Width, 0, end);
wpaudio.Ctlcontrols.currentPosition = result;
}
}
catch { }
}
private void pgplaytime_MouseUp(object sender, MouseEventArgs e)
{
scrubbing = false;
}
}
}

View file

@ -0,0 +1,134 @@
<?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>
<data name="wpaudio.OcxState" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAtwAAAAIB
AAAAAQAAAAAAAAAAAAAAAKIAAAAAAwAACAAAAAAABQAAAAAAAADwPwMAAAAAAAUAAAAAAAAAAAAIAAIA
AAAAAAMAAQAAAAsA//8DAAAAAAALAP//CAACAAAAAAADADIAAAALAAAACAAKAAAAbgBvAG4AZQAAAAsA
AAALAAAACwD//wsA//8LAAAACAACAAAAAAAIAAIAAAAAAAgAAgAAAAAACAACAAAAAAALAAAAelIAAK4w
AAAL
</value>
</data>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -244,6 +244,12 @@
<Compile Include="Applications\UpdateManager.Designer.cs">
<DependentUpon>UpdateManager.cs</DependentUpon>
</Compile>
<Compile Include="Applications\VideoPlayer.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Applications\VideoPlayer.Designer.cs">
<DependentUpon>VideoPlayer.cs</DependentUpon>
</Compile>
<Compile Include="Applications\WidgetManagerFrontend.cs">
<SubType>UserControl</SubType>
</Compile>
@ -459,6 +465,9 @@
<EmbeddedResource Include="Applications\UpdateManager.resx">
<DependentUpon>UpdateManager.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Applications\VideoPlayer.resx">
<DependentUpon>VideoPlayer.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Applications\WidgetManagerFrontend.resx">
<DependentUpon>WidgetManagerFrontend.cs</DependentUpon>
</EmbeddedResource>

View file

@ -79,6 +79,7 @@ namespace ShiftOS.WinForms.ShiftnetSites
var fl = new FlowLayoutPanel();
fl.Dock = DockStyle.Fill;
pnlappslist.Controls.Add(fl);
fl.AutoScroll = true;
fl.Show();
foreach(var upg in upgrades)
{
@ -148,6 +149,20 @@ namespace ShiftOS.WinForms.ShiftnetSites
}
}
public bool DependenciesInstalled(ShiftoriumUpgrade upg)
{
string[] split = upg.Dependencies.Split(';');
foreach(var u in split)
{
if (!u.StartsWith("appscape_handled"))
{
if (!Shiftorium.UpgradeInstalled(u))
return false;
}
}
return true;
}
public void ViewMoreInfo(ShiftoriumUpgrade upg)
{
lbtitle.Text = upg.Name;
@ -178,11 +193,11 @@ namespace ShiftOS.WinForms.ShiftnetSites
if (cp_value.Text != "Already Purchased.")
{
var more_info = new Button();
more_info.Text = "More info";
more_info.Text = "Buy";
more_info.Click += (o, a) =>
{
//Detect if dependencies are installed.
if (Shiftorium.DependenciesInstalled(upg))
if (DependenciesInstalled(upg))
{
//Detect sufficient codepoints
if (SaveSystem.CurrentSave.Codepoints >= upg.Cost)
@ -210,6 +225,7 @@ namespace ShiftOS.WinForms.ShiftnetSites
var installation = new AppscapeInstallation(upg.Name, attrib.DownloadSize, upg.ID);
AppearanceManager.SetupWindow(installer);
installer.InitiateInstall(installation);
return;
}
}
}
@ -237,6 +253,7 @@ namespace ShiftOS.WinForms.ShiftnetSites
more_info.Left = cp_display.Width - more_info.Width - 5;
cp_display.Controls.Add(more_info);
more_info.Show();
ControlManager.SetupControls(pnlappslist);
}
var desc = new Label();
@ -311,38 +328,33 @@ namespace ShiftOS.WinForms.ShiftnetSites
public string ShiftoriumId { get; private set; }
public int Size { get; private set; }
public string Name { get; private set; }
protected override void Run()
{
this.SetStatus("Downloading...");
SetProgress(0);
new Thread(() =>
int i = 0;
while (i <= Size)
{
int i = 0;
while (i <= Size)
{
SetProgress((i / Size) * 100);
i++;
Thread.Sleep(100);
}
SetProgress(0);
SetStatus("Installing...");
i = 0;
while (i <= Size)
{
SetProgress((i / Size) * 100);
i++;
Thread.Sleep(50);
}
Shiftorium.Buy(ShiftoriumId, 0);
Desktop.InvokeOnWorkerThread(() =>
{
Infobox.Show("Install complete!", "The installation of " + Name + " has completed.");
SaveSystem.SaveGame();
});
})
{ IsBackground = true }.Start();
SetProgress((i / Size) * 100);
i++;
Thread.Sleep(100);
}
SetProgress(0);
SetStatus("Installing...");
i = 0;
while (i <= Size)
{
SetProgress((i / Size) * 100);
i++;
Thread.Sleep(50);
}
Shiftorium.Buy(ShiftoriumId, 0);
Desktop.InvokeOnWorkerThread(() =>
{
Infobox.Show("Install complete!", "The installation of " + Name + " has completed.");
SaveSystem.SaveGame();
});
}
}
}

View file

@ -208,7 +208,8 @@ namespace ShiftOS.Engine
foreach (var file in System.IO.Directory.GetFiles(folder))
{
string mfsDir = file.Replace(SharedFolder, $"{mount}:").Replace("\\", "/");
WriteAllBytes(mfsDir, System.IO.File.ReadAllBytes(file));
if (!FileExists(mfsDir))
WriteAllBytes(mfsDir, System.IO.File.ReadAllBytes(file));
}
foreach (var directory in System.IO.Directory.GetDirectories(folder))
{