Sorry that the README is not complete
This commit is contained in:
commit
c317121978
|
@ -0,0 +1,133 @@
|
|||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.log
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.Publish.xml
|
||||
*.pubxml
|
||||
*.azurePubxml
|
||||
|
||||
# NuGet Packages Directory
|
||||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
||||
packages/
|
||||
## TODO: If the tool you use requires repositories.config, also uncomment the next line
|
||||
!packages/repositories.config
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
![Ss]tyle[Cc]op.targets
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.[Pp]ublish.xml
|
||||
|
||||
*.publishsettings
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file to a newer
|
||||
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
App_Data/*.mdf
|
||||
App_Data/*.ldf
|
||||
|
||||
# =========================
|
||||
# Windows detritus
|
||||
# =========================
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Mac desktop service store files
|
||||
.DS_Store
|
||||
|
||||
_NCrunch*
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"CurrentProjectSetting": null
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"ExpandedNodes": [
|
||||
"",
|
||||
"\\Timelapse",
|
||||
"\\TimelapseApi"
|
||||
],
|
||||
"SelectedNode": "\\Timelapse\\Timelapse.csproj",
|
||||
"PreviewInSolutionExplorer": false
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": ".NET Core Launch (console)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceFolder}/Timelapse.Desktop/bin/Debug/net6.0/Timelapse.Desktop.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}/Timelapse.Desktop",
|
||||
"console": "internalConsole",
|
||||
"stopAtEntry": false
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/Timelapse.Desktop/Timelapse.Desktop.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "publish",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"publish",
|
||||
"${workspaceFolder}/Timelapse.Desktop/Timelapse.Desktop.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "watch",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"watch",
|
||||
"run",
|
||||
"--project",
|
||||
"${workspaceFolder}/Timelapse.Desktop/Timelapse.Desktop.csproj"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
# How to install this app
|
||||
except for dotnet (depending on how you install it even dotnet) everything wont need root/Administrator to install
|
||||
# Linux Users (x86_64)
|
||||
|
||||
You will need [Dotnet 6](https://dotnet.microsoft.com/en-us/download)
|
||||
|
||||
cd Timelapse.Linux
|
||||
mkdir $HOME/timelapsenow
|
||||
dotnet publish -c Release --self-contained -r linux-x64 -o $HOME/timelapsenow
|
||||
cp ../timelapse.png $HOME/timelapsenow/
|
||||
echo "[DesktopEntry]" > $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Version=1.0" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Type=Application" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Name=Timelapse Now" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Icon=$HOME/timelapsenow/timelapse.png" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Exec=$HOME/timelapsenow/Timelapse.Linux" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Terminal=false" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Categories=AudioVideo;Recorder" >> $HOME/.local/share/applications/timelapsenow.desktop;
|
||||
|
||||
# Linux Users (arm)
|
||||
|
||||
You will need [Dotnet 6](https://dotnet.microsoft.com/en-us/download)
|
||||
|
||||
cd Timelapse.Linux
|
||||
mkdir $HOME/timelapsenow
|
||||
dotnet publish -c Release --self-contained -r linux-arm -o $HOME/timelapsenow
|
||||
cp ../timelapse.png $HOME/timelapsenow/
|
||||
echo "[DesktopEntry]" > $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Version=1.0" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Type=Application" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Name=Timelapse Now" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Icon=$HOME/timelapsenow/timelapse.png" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Exec=$HOME/timelapsenow/Timelapse.Linux" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Terminal=false" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Categories=AudioVideo;Recorder" >> $HOME/.local/share/applications/timelapsenow.desktop;
|
||||
# Linux Users (arm64)
|
||||
|
||||
You will need [Dotnet 6](https://dotnet.microsoft.com/en-us/download)
|
||||
|
||||
cd Timelapse.Linux
|
||||
mkdir $HOME/timelapsenow
|
||||
dotnet publish -c Release --self-contained -r linux-arm64 -o $HOME/timelapsenow
|
||||
cp ../timelapse.png $HOME/timelapsenow/
|
||||
echo "[DesktopEntry]" > $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Version=1.0" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Type=Application" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Name=Timelapse Now" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Icon=$HOME/timelapsenow/timelapse.png" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Exec=$HOME/timelapsenow/Timelapse.Linux" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Terminal=false" >> $HOME/.local/share/applications/timelapsenow.desktop
|
||||
echo "Categories=AudioVideo;Recorder" >> $HOME/.local/share/applications/timelapsenow.desktop;
|
||||
|
||||
# Windows
|
||||
You will need [Dotnet 6](https://dotnet.microsoft.com/en-us/download)<br>
|
||||
I mainly use linux but I understand some people use windows
|
||||
## Using PowerShell/Command Prompt
|
||||
Please make a folder for timelapse and replace \path\to\timelapse\ with the path
|
||||
|
||||
if you have 32 bit windows or arm replace win-x64 with win-x86, win-arm or win-arm
|
||||
|
||||
cd Timelapse.Windows
|
||||
dotnet publish -c Release -r win-x64 --self-contained -o "\path\to\timelapse\"
|
||||
|
||||
navigate to "\path\to\timelapse\" in file explorer if you haven't already
|
||||
Right click "Timelapse.Windows.exe" and Select SendTo->Desktop (Create Shortcut) and maybe pin to Taskbar, Startmenu
|
|
@ -0,0 +1,675 @@
|
|||
### GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
### Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom
|
||||
to share and change all versions of a program--to make sure it remains
|
||||
free software for all its users. We, the Free Software Foundation, use
|
||||
the GNU General Public License for most of our software; it applies
|
||||
also to any other work released this way by its authors. You can apply
|
||||
it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you
|
||||
have certain responsibilities if you distribute copies of the
|
||||
software, or if you modify it: responsibilities to respect the freedom
|
||||
of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the
|
||||
manufacturer can do so. This is fundamentally incompatible with the
|
||||
aim of protecting users' freedom to change the software. The
|
||||
systematic pattern of such abuse occurs in the area of products for
|
||||
individuals to use, which is precisely where it is most unacceptable.
|
||||
Therefore, we have designed this version of the GPL to prohibit the
|
||||
practice for those products. If such problems arise substantially in
|
||||
other domains, we stand ready to extend this provision to those
|
||||
domains in future versions of the GPL, as needed to protect the
|
||||
freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish
|
||||
to avoid the special danger that patents applied to a free program
|
||||
could make it effectively proprietary. To prevent this, the GPL
|
||||
assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
### TERMS AND CONDITIONS
|
||||
|
||||
#### 0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds
|
||||
of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of
|
||||
an exact copy. The resulting work is called a "modified version" of
|
||||
the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user
|
||||
through a computer network, with no transfer of a copy, is not
|
||||
conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to
|
||||
the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
#### 1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work for
|
||||
making modifications to it. "Object code" means any non-source form of
|
||||
a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can
|
||||
regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same
|
||||
work.
|
||||
|
||||
#### 2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey,
|
||||
without conditions so long as your license otherwise remains in force.
|
||||
You may convey covered works to others for the sole purpose of having
|
||||
them make modifications exclusively for you, or provide you with
|
||||
facilities for running those works, provided that you comply with the
|
||||
terms of this License in conveying all material for which you do not
|
||||
control copyright. Those thus making or running the covered works for
|
||||
you must do so exclusively on your behalf, under your direction and
|
||||
control, on terms that prohibit them from making any copies of your
|
||||
copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the
|
||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||
it unnecessary.
|
||||
|
||||
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such
|
||||
circumvention is effected by exercising rights under this License with
|
||||
respect to the covered work, and you disclaim any intention to limit
|
||||
operation or modification of the work as a means of enforcing, against
|
||||
the work's users, your or third parties' legal rights to forbid
|
||||
circumvention of technological measures.
|
||||
|
||||
#### 4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
#### 5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these
|
||||
conditions:
|
||||
|
||||
- a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
- b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under
|
||||
section 7. This requirement modifies the requirement in section 4
|
||||
to "keep intact all notices".
|
||||
- c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
- d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
#### 6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms of
|
||||
sections 4 and 5, provided that you also convey the machine-readable
|
||||
Corresponding Source under the terms of this License, in one of these
|
||||
ways:
|
||||
|
||||
- a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
- b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the Corresponding
|
||||
Source from a network server at no charge.
|
||||
- c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
- d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
- e) Convey the object code using peer-to-peer transmission,
|
||||
provided you inform other peers where the object code and
|
||||
Corresponding Source of the work are being offered to the general
|
||||
public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal,
|
||||
family, or household purposes, or (2) anything designed or sold for
|
||||
incorporation into a dwelling. In determining whether a product is a
|
||||
consumer product, doubtful cases shall be resolved in favor of
|
||||
coverage. For a particular product received by a particular user,
|
||||
"normally used" refers to a typical or common use of that class of
|
||||
product, regardless of the status of the particular user or of the way
|
||||
in which the particular user actually uses, or expects or is expected
|
||||
to use, the product. A product is a consumer product regardless of
|
||||
whether the product has substantial commercial, industrial or
|
||||
non-consumer uses, unless such uses represent the only significant
|
||||
mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to
|
||||
install and execute modified versions of a covered work in that User
|
||||
Product from a modified version of its Corresponding Source. The
|
||||
information must suffice to ensure that the continued functioning of
|
||||
the modified object code is in no case prevented or interfered with
|
||||
solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or
|
||||
updates for a work that has been modified or installed by the
|
||||
recipient, or for the User Product in which it has been modified or
|
||||
installed. Access to a network may be denied when the modification
|
||||
itself materially and adversely affects the operation of the network
|
||||
or violates the rules and protocols for communication across the
|
||||
network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
#### 7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders
|
||||
of that material) supplement the terms of this License with terms:
|
||||
|
||||
- a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
- b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
- c) Prohibiting misrepresentation of the origin of that material,
|
||||
or requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
- d) Limiting the use for publicity purposes of names of licensors
|
||||
or authors of the material; or
|
||||
- e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
- f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions
|
||||
of it) with contractual assumptions of liability to the recipient,
|
||||
for any liability that these contractual assumptions directly
|
||||
impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions; the
|
||||
above requirements apply either way.
|
||||
|
||||
#### 8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license
|
||||
from a particular copyright holder is reinstated (a) provisionally,
|
||||
unless and until the copyright holder explicitly and finally
|
||||
terminates your license, and (b) permanently, if the copyright holder
|
||||
fails to notify you of the violation by some reasonable means prior to
|
||||
60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
#### 9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run
|
||||
a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
#### 10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
#### 11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned
|
||||
or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the
|
||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||
the non-exercise of one or more of the rights that are specifically
|
||||
granted under this License. You may not convey a covered work if you
|
||||
are a party to an arrangement with a third party that is in the
|
||||
business of distributing software, under which you make payment to the
|
||||
third party based on the extent of your activity of conveying the
|
||||
work, and under which the third party grants, to any of the parties
|
||||
who would receive the covered work from you, a discriminatory patent
|
||||
license (a) in connection with copies of the covered work conveyed by
|
||||
you (or copies made from those copies), or (b) primarily for and in
|
||||
connection with specific products or compilations that contain the
|
||||
covered work, unless you entered into that arrangement, or that patent
|
||||
license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
#### 12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under
|
||||
this License and any other pertinent obligations, then as a
|
||||
consequence you may not convey it at all. For example, if you agree to
|
||||
terms that obligate you to collect a royalty for further conveying
|
||||
from those to whom you convey the Program, the only way you could
|
||||
satisfy both those terms and this License would be to refrain entirely
|
||||
from conveying the Program.
|
||||
|
||||
#### 13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
#### 14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in
|
||||
detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies that a certain numbered version of the GNU General Public
|
||||
License "or any later version" applies to it, you have the option of
|
||||
following the terms and conditions either of that numbered version or
|
||||
of any later version published by the Free Software Foundation. If the
|
||||
Program does not specify a version number of the GNU General Public
|
||||
License, you may choose any version ever published by the Free
|
||||
Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions
|
||||
of the GNU General Public License can be used, that proxy's public
|
||||
statement of acceptance of a version permanently authorizes you to
|
||||
choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
#### 15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||
CORRECTION.
|
||||
|
||||
#### 16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
#### 17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
### How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to
|
||||
attach them to the start of each source file to most effectively state
|
||||
the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper
|
||||
mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands \`show w' and \`show c' should show the
|
||||
appropriate parts of the General Public License. Of course, your
|
||||
program's commands might be different; for a GUI interface, you would
|
||||
use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. For more information on this, and how to apply and follow
|
||||
the GNU GPL, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your
|
||||
program into proprietary programs. If your program is a subroutine
|
||||
library, you may consider it more useful to permit linking proprietary
|
||||
applications with the library. If this is what you want to do, use the
|
||||
GNU Lesser General Public License instead of this License. But first,
|
||||
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
@ -0,0 +1,10 @@
|
|||
# Notices
|
||||
|
||||
[FlashCap (Apache 2.0 License)](https://github.com/kekyo/FlashCap)<br>
|
||||
[Eto.Forms (BSD 3)](https://github.com/picoe/Eto)<br>
|
||||
[SixLabors.ImageSharp (Apache 2.0 License)](https://github.com/SixLabors/ImageSharp)<br>
|
||||
[Newtonsoft.Json (MIT)](https://github.com/JamesNK/Newtonsoft.Json)<br>
|
||||
[System.IO.Compression.ZipFile (Dont know license, but is part of runtime)](https://www.nuget.org/packages/System.IO.Compression.ZipFile/)<br>
|
||||
|
||||
# My library (But I will include it anyway (it used some modified source from https://github.com/dajuric/simple-http/))
|
||||
[Tesses.WebServer (MIT)](https://gitlab.tesses.net/tesses50/tesses.webserver)
|
|
@ -0,0 +1,8 @@
|
|||
# Timelapse Now
|
||||
|
||||
## Sorry the README is a work in progress
|
||||
To learn how to install click [here](INSTALL.md)
|
||||
<br>
|
||||
To see notices click [here](NOTICES.md)
|
||||
<br>
|
||||
To see license click [here](LICENSE.md)
|
|
@ -0,0 +1,10 @@
|
|||
namespace Timelapse;
|
||||
using Eto.Forms;
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
new Application().Run(new MainForm(args) { Width = 640, Height = 480, Title = "Timelapse Now" });
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RuntimeIdentifiers>linux-x64</RuntimeIdentifiers>
|
||||
<PublishReadyToRun>true</PublishReadyToRun>
|
||||
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Eto.Forms" Version="2.7.0" />
|
||||
<PackageReference Include="Eto.Platform.Gtk" Version="2.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Timelapse\Timelapse.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,266 @@
|
|||
using TimelapseApi;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO.Compression;
|
||||
/*
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
*/
|
||||
|
||||
public class TimelapsePack
|
||||
{
|
||||
public static string? BuildProject()
|
||||
{
|
||||
/*<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>*/
|
||||
string curDirName=Path.GetFileName(Environment.CurrentDirectory);
|
||||
|
||||
string fname = File.Exists($"{curDirName}.csproj") ? $"{curDirName}.csproj" : (File.Exists($"{curDirName}.vbproj") ? $"{curDirName}.vbproj" : $"{curDirName}.fsproj");
|
||||
|
||||
string? outType="";
|
||||
bool containsRef=false;
|
||||
/*
|
||||
XmlReader reader = XmlReader.Create(fname);
|
||||
XElement el = XElement.Load(reader);
|
||||
reader.Close();
|
||||
|
||||
|
||||
foreach(var item in el.Descendants())
|
||||
{
|
||||
if(item.Name=="PropertyGroup")
|
||||
{
|
||||
|
||||
foreach(var desend in item.Descendants())
|
||||
{
|
||||
if(desend.Name== "OutputType")
|
||||
{
|
||||
outType=desend.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(item.Name == "ItemGroup")
|
||||
{
|
||||
foreach (var desend in item.Descendants())
|
||||
{
|
||||
if (desend.Name == "ProjectReference")
|
||||
{
|
||||
foreach (var a in desend.Attributes())
|
||||
{
|
||||
if (a.Name == "Include")
|
||||
{
|
||||
if (a.Value.Contains("TimelapseApi"))
|
||||
{
|
||||
containsRef = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (desend.Name == "PackageReference")
|
||||
{
|
||||
foreach (var a in desend.Attributes())
|
||||
{
|
||||
if (a.Name == "Include")
|
||||
{
|
||||
if (a.Value.Contains("Tesses.TimelapseApi"))
|
||||
{
|
||||
containsRef = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
if(!string.IsNullOrWhiteSpace(outType) && outType == "Library" && containsRef)
|
||||
{
|
||||
//build the library
|
||||
Process p = new Process();
|
||||
p.StartInfo = new ProcessStartInfo("dotnet","build --configuration release");
|
||||
p.StartInfo.UseShellExecute=false;
|
||||
if(p.Start())
|
||||
{
|
||||
p.WaitForExit();
|
||||
return Path.Combine(Environment.CurrentDirectory,"bin","Release","net6.0",$"{curDirName}.dll");
|
||||
}else{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("ERROR: process not started");
|
||||
|
||||
}
|
||||
}else{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("ERROR: Project is not a library");
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static void DirCopy(string src,string dest,Func<string,bool> copyItem)
|
||||
{
|
||||
foreach(var f in Directory.GetDirectories(src))
|
||||
{
|
||||
if(copyItem != null && copyItem(f) == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string fname =Path.GetFileName(f);
|
||||
DirCopy(f,fname,copyItem);
|
||||
}
|
||||
|
||||
foreach(var f in Directory.GetFiles(src))
|
||||
{
|
||||
if(copyItem != null && copyItem(f) == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string fname =Path.GetFileName(f);
|
||||
File.Copy(f,fname);
|
||||
}
|
||||
}
|
||||
public static string? Pack(string? outname)
|
||||
{
|
||||
string[] _hasDeps=new string[] {
|
||||
"AtkSharp.dll",
|
||||
"TimelapseApi.dll",
|
||||
"Eto.dll",
|
||||
"Newtonsoft.Json.dll",
|
||||
"FlashCap.dll",
|
||||
"CarioSharp.dll",
|
||||
"GtkSharp.dll",
|
||||
"GdkSharp.dll",
|
||||
"GLibSharp.dll",
|
||||
"SixLabors.ImageSharp.dll"
|
||||
};
|
||||
var outPut=BuildProject();
|
||||
if(!string.IsNullOrWhiteSpace(outPut))
|
||||
{
|
||||
Directory.CreateDirectory("_build/extension");
|
||||
File.Copy("extension_info.json","_build/extension_info.json");
|
||||
|
||||
DirCopy(Path.GetDirectoryName(outPut),"_build/extension",(e)=>{
|
||||
if(e==outPut)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string cF = Path.GetFileName(e);
|
||||
|
||||
return !_hasDeps.Contains(cF);
|
||||
});
|
||||
string fname = $"{Path.GetFileNameWithoutExtension(outPut)}.zip";
|
||||
File.Copy(outPut,"_build/extension/extension.dll");
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(outname))
|
||||
{
|
||||
fname=outname;
|
||||
}
|
||||
if(File.Exists(fname))
|
||||
{
|
||||
File.Delete(fname);
|
||||
}
|
||||
ZipFile.CreateFromDirectory ("_build",fname,CompressionLevel.SmallestSize, false);
|
||||
Directory.Delete("_build");
|
||||
return fname;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static void Uninstall(string name)
|
||||
{
|
||||
string dir= Api.GetInternalFile("ExtensionBinaries",name);
|
||||
if(Directory.Exists(dir))
|
||||
{
|
||||
|
||||
Console.Write($"Are you sure you want to delete {name} (Yes/No): ");
|
||||
j:
|
||||
var read=Console.ReadLine().ToLower();
|
||||
if(read == "yes")
|
||||
{
|
||||
Console.WriteLine("I asked ya, you said yes so deleting");
|
||||
Directory.Delete(dir,true);
|
||||
} else if (read == "no")
|
||||
{
|
||||
Console.WriteLine("Not deleting");
|
||||
}
|
||||
else {
|
||||
Console.Write("Please type yes or no: ");
|
||||
goto j;
|
||||
}
|
||||
}else{
|
||||
Console.WriteLine($"No such extension {name}");
|
||||
}
|
||||
}
|
||||
public static void ListExtensions(bool load)
|
||||
{
|
||||
if(load)
|
||||
{
|
||||
|
||||
foreach(var item in ExtensionLoader.GetTimelapseExtensions())
|
||||
{
|
||||
Console.WriteLine($"Name=\"{item.Name}\", Id=\"{item.Id}\"");
|
||||
}
|
||||
}else{
|
||||
string dirtoitterateon= Api.GetInternalFile("ExtensionBinaries");
|
||||
if(Directory.Exists(dirtoitterateon))
|
||||
{
|
||||
foreach(var dir in Directory.GetDirectories(dirtoitterateon))
|
||||
{
|
||||
Console.WriteLine(Path.GetFileName(dir));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void Install(string? file)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(file))
|
||||
{
|
||||
TimelapseApi.ExtensionLoader.InstallExtension(file).Wait();
|
||||
return;
|
||||
}
|
||||
string? outPut=Pack(null);
|
||||
if(!string.IsNullOrWhiteSpace(outPut))
|
||||
{
|
||||
TimelapseApi.ExtensionLoader.InstallExtension(outPut).Wait();
|
||||
File.Delete(outPut);
|
||||
}
|
||||
}
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Timelapse Extension Packager");
|
||||
if(args.Length < 1)
|
||||
{
|
||||
Console.WriteLine("Usage: <command> args...");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Commands:");
|
||||
Console.WriteLine(" pack [optional-filename]");
|
||||
Console.WriteLine(" install [optional-filename]");
|
||||
Console.WriteLine(" list [--get-id (requires loading extensions partially)]");
|
||||
Console.WriteLine(" uninstall <filename>");
|
||||
return;
|
||||
}
|
||||
Console.WriteLine();
|
||||
switch(args[0])
|
||||
{
|
||||
case "pack":
|
||||
string? fname = "";
|
||||
if(args.Length >= 2) fname=args[1];
|
||||
Pack(fname);
|
||||
break;
|
||||
case "install":
|
||||
string? fname = "";
|
||||
if(args.Length >= 2) fname=args[1];
|
||||
Install(fname);
|
||||
break;
|
||||
case "list":
|
||||
|
||||
ListExtensions(args.Length >= 2 && args[1] == "--get-id");
|
||||
break;
|
||||
case "uninstall":
|
||||
if(args.Length >= 2) Uninstall(args[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TimelapseApi\TimelapseApi.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,32 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<PackageType>Template</PackageType>
|
||||
<IsPackable>true</IsPackable>
|
||||
<PackageId>Tesses.TimelapseExtension</PackageId>
|
||||
<Authors>Mike Nolan</Authors>
|
||||
<Company>Tesses</Company>
|
||||
<Version>1.0.0</Version>
|
||||
<AssemblyVersion>1.0.0</AssemblyVersion>
|
||||
<FileVersion>1.0.0</FileVersion>
|
||||
<Description>Extension templates for TimelapseNow</Description>
|
||||
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<PackageTags>Camera, Timelapse, Record</PackageTags>
|
||||
<RepositoryUrl>https://gitlab.tesses.net/tesses50/timelapsenow</RepositoryUrl>
|
||||
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
||||
<IncludeContentInPack>true</IncludeContentInPack>
|
||||
<IncludeBuildOutput>false</IncludeBuildOutput>
|
||||
<ContentTargetFolders>content</ContentTargetFolders>
|
||||
<NoWarn>$(NoWarn);NU5128</NoWarn>
|
||||
<NoDefaultExcludes>true</NoDefaultExcludes>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="templates\**\*" Exclude="templates\**\bin\**;templates\**\obj\**" />
|
||||
<Compile Remove="**\*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"$schema": "http://json.schemastore.org/template",
|
||||
"sourceName": "TimelapseExtension0001",
|
||||
"defaultName": "TimelapseExtension",
|
||||
"author": "Tesses",
|
||||
"classifications": [ "Common", "Library","Desktop" ],
|
||||
"identity": "Timelapse.ExtensionLibrary",
|
||||
"name": "Timelapse templates: Extension",
|
||||
"shortName": "timelapseext",
|
||||
"tags": {
|
||||
"language": "C#",
|
||||
"type": "project"
|
||||
},
|
||||
"description": "Extension for TimelapseNow",
|
||||
"symbols": {
|
||||
"Framework": {
|
||||
"type": "parameter",
|
||||
"description": "The target framework for the project.",
|
||||
"datatype": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"choice": "net6.0",
|
||||
"description": "Target net6.0"
|
||||
}
|
||||
],
|
||||
"replaces": "net6.0",
|
||||
"defaultValue": "net6.0"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using TimelapseApi;
|
||||
using System;
|
||||
namespace TimelapseExtension0001
|
||||
{
|
||||
public class TimelapseExtension0001 : TimelapseExtension
|
||||
{
|
||||
public override string Name => "TimelapseExtension0001";
|
||||
public override Guid Id => Guid.Parse("{1cb8b576-e2e8-44d5-a8e1-e25a47eb0564}"); //https://duckduckgo.com/?q=guid&t=ffab&ia=answer
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Tesses.TimelapseApi" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "TimelapseExtension0001",
|
||||
"author": "YourNameOrCompanyName",
|
||||
"version": "1.0.0",
|
||||
"description": "Some Description"
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"$schema": "http://json.schemastore.org/template",
|
||||
"sourceName": "TimelapseExtension0001",
|
||||
"defaultName": "TimelapseExtension",
|
||||
"author": "Tesses",
|
||||
"classifications": [ "Common", "Library","Desktop" ],
|
||||
"identity": "Timelapse.ExtensionLibrary",
|
||||
"name": "Timelapse templates: Extension",
|
||||
"shortName": "timelapseext",
|
||||
"tags": {
|
||||
"language": "F#",
|
||||
"type": "project"
|
||||
},
|
||||
"description": "Extension for TimelapseNow",
|
||||
"symbols": {
|
||||
"Framework": {
|
||||
"type": "parameter",
|
||||
"description": "The target framework for the project.",
|
||||
"datatype": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"choice": "net6.0",
|
||||
"description": "Target net6.0"
|
||||
}
|
||||
],
|
||||
"replaces": "net6.0",
|
||||
"defaultValue": "net6.0"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
namespace TimelapseExtension0001
|
||||
open TimelapseApi
|
||||
open System
|
||||
|
||||
type TimelapseExtension0001() = inherit TimelapseExtension()
|
||||
override this.Name
|
||||
with get () = "TimelapseExtension0001"
|
||||
|
||||
override this.Id
|
||||
with get () = Guid.Parse("{1cb8b576-e2e8-44d5-a8e1-e25a47eb0564}") //https://duckduckgo.com/?q=guid&t=ffab&ia=answer
|
|
@ -0,0 +1,15 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>TimelapseExtension0001</RootNamespace>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Extension.fs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Tesses.TimelapseApi" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "TimelapseExtension0001",
|
||||
"author": "YourNameOrCompanyName",
|
||||
"version": "1.0.0",
|
||||
"description": "Some Description"
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"$schema": "http://json.schemastore.org/template",
|
||||
"sourceName": "TimelapseExtension0001",
|
||||
"defaultName": "TimelapseExtension",
|
||||
"author": "Tesses",
|
||||
"classifications": [ "Common", "Library","Desktop" ],
|
||||
"identity": "Timelapse.ExtensionLibrary",
|
||||
"name": "Timelapse templates: Extension",
|
||||
"shortName": "timelapseext",
|
||||
"tags": {
|
||||
"language": "VB",
|
||||
"type": "project"
|
||||
},
|
||||
"description": "Extension for TimelapseNow",
|
||||
"symbols": {
|
||||
"Framework": {
|
||||
"type": "parameter",
|
||||
"description": "The target framework for the project.",
|
||||
"datatype": "choice",
|
||||
"choices": [
|
||||
{
|
||||
"choice": "net6.0",
|
||||
"description": "Target net6.0"
|
||||
}
|
||||
],
|
||||
"replaces": "net6.0",
|
||||
"defaultValue": "net6.0"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
Imports TimelapseApi
|
||||
Imports System
|
||||
Public Class TimelapseExtension0001
|
||||
Inherits TimelapseExtension
|
||||
|
||||
Public Overrides ReadOnly Property Name As String
|
||||
Get
|
||||
Return "TimelapseExtension0001"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Overrides ReadOnly Property Id As Guid
|
||||
Get
|
||||
Return Guid.Parse("{1cb8b576-e2e8-44d5-a8e1-e25a47eb0564}")
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
|
@ -0,0 +1,8 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<RootNamespace>TimelapseExtension0001</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "TimelapseExtension0001",
|
||||
"author": "YourNameOrCompanyName",
|
||||
"version": "1.0.0",
|
||||
"description": "Some Description"
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
namespace Timelapse;
|
||||
using Eto.Forms;
|
||||
using System;
|
||||
|
||||
public class Program
|
||||
{
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
new Application().Run(new MainForm(args) {Width=640,Height=480, Title="Timelapse Now"});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="favicon.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Timelapse\Timelapse.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Eto.Platform.Wpf" Version="2.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
|
@ -0,0 +1,131 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using Eto.Forms;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using TimelapseApi;
|
||||
namespace Timelapse.Desktop;
|
||||
internal class ExportWindow : Dialog
|
||||
{
|
||||
public class Export
|
||||
{
|
||||
public Export(string text)
|
||||
{
|
||||
Text=text;
|
||||
}
|
||||
|
||||
public string Text {get;set;}
|
||||
public override string ToString()
|
||||
{
|
||||
return Text;
|
||||
}
|
||||
}
|
||||
public class Share
|
||||
{
|
||||
public Share(string text,Func<Window,string,Task> show)
|
||||
{
|
||||
ShowDialog = show;
|
||||
Text = text;
|
||||
}
|
||||
public Func<Window,string,Task> ShowDialog {get;set;}
|
||||
public string Text {get;set;}
|
||||
public override string ToString()
|
||||
{
|
||||
return Text.ToString();
|
||||
}
|
||||
}
|
||||
public ExportWindow(Form main,Api instance,GuiData guiData,bool share)
|
||||
{
|
||||
Title=share ? "Export and Share" : "Export";
|
||||
DynamicLayout lyt=new DynamicLayout();
|
||||
lyt.BeginHorizontal();
|
||||
lyt.BeginVertical();
|
||||
Button acceptBtn =new Button()
|
||||
{
|
||||
Text=share ? "Export and Share" : "Export",
|
||||
Enabled=false
|
||||
};
|
||||
ObservableCollection<Share> shares=new ObservableCollection<Share>();
|
||||
|
||||
List<Export> exports=new List<Export>();
|
||||
DropDown export = new DropDown();
|
||||
lyt.Add(export,true);
|
||||
DropDown shareDD = new DropDown() {Enabled=false,DataStore=shares};
|
||||
if(share)
|
||||
{
|
||||
lyt.EndBeginHorizontal();
|
||||
lyt.Add(shareDD);
|
||||
}
|
||||
lyt.EndHorizontal();
|
||||
|
||||
lyt.EndBeginVertical();
|
||||
lyt.AddSpace(true,true);
|
||||
lyt.BeginHorizontal();
|
||||
lyt.AddSpace(true);
|
||||
lyt.Add(acceptBtn);
|
||||
lyt.EndHorizontal();
|
||||
lyt.EndVertical();
|
||||
|
||||
this.Content=lyt;
|
||||
|
||||
|
||||
if(guiData.Export != null)
|
||||
{
|
||||
foreach(var item in guiData.Export)
|
||||
{
|
||||
exports.Add(new Export(item.Text));
|
||||
}
|
||||
export.DataStore=exports;
|
||||
export.SelectedIndexChanged += (sender,e)=>{
|
||||
int index=export.SelectedIndex;
|
||||
if(index > -1 && exports.Count > 0)
|
||||
{
|
||||
if(share)
|
||||
{
|
||||
acceptBtn.Enabled=false;
|
||||
shareDD.Enabled=true;
|
||||
shares.Clear();
|
||||
if(guiData.Share != null)
|
||||
{
|
||||
|
||||
|
||||
foreach(var item in guiData.Share)
|
||||
{
|
||||
var j=new Share(item.Text,item.ShareActionAsync);
|
||||
shares.Add(j);
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
acceptBtn.Enabled=true;
|
||||
}
|
||||
} else {
|
||||
acceptBtn.Enabled=false;
|
||||
shareDD.Enabled=false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
shareDD.SelectedIndexChanged+=(sender,e)=>{
|
||||
int index=shareDD.SelectedIndex;
|
||||
|
||||
acceptBtn.Enabled=index > -1 && shares.Count > 0;
|
||||
|
||||
};
|
||||
|
||||
acceptBtn.Click += async (sender,e)=>{
|
||||
int pos = export.SelectedIndex;
|
||||
|
||||
Func<Window,string,Task>? dlg=null;
|
||||
if(share)
|
||||
dlg=shares[shareDD.SelectedIndex].ShowDialog;
|
||||
|
||||
var filename= await instance.Export(main,pos);
|
||||
|
||||
if(share && dlg != null && !string.IsNullOrWhiteSpace(filename) && File.Exists(filename))
|
||||
{
|
||||
await dlg(main,filename);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
namespace Timelapse.Desktop;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
public class NewFrameEventArgs : EventArgs
|
||||
{
|
||||
public NewFrameEventArgs(Image<Rgb24> img)
|
||||
{
|
||||
Image=img;
|
||||
|
||||
}
|
||||
|
||||
public Image<Rgb24> Image {get;internal set;}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
using Eto.Drawing;
|
||||
using Eto.Forms;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
using TimelapseApi;
|
||||
|
||||
namespace Timelapse.Desktop;
|
||||
|
||||
|
||||
public class PictureBox : Panel
|
||||
{
|
||||
LockObj lockObj=LockObj.Create();
|
||||
ImageView view =new ImageView();
|
||||
public PictureBox()
|
||||
{
|
||||
this.Content=view;
|
||||
this.SizeChanged+=(sender,e)=>{
|
||||
Resize();
|
||||
|
||||
};
|
||||
}
|
||||
private void SetImage(Stream strm)
|
||||
{
|
||||
if(view.Image != null && !view.Image.IsDisposed)
|
||||
{
|
||||
view.Image.Dispose();
|
||||
}
|
||||
view.Image = new Bitmap(strm);
|
||||
}
|
||||
private Image<Rgb24>? img=null;
|
||||
public Image<Rgb24>? Image {get {return img;} set{ if(value !=null){SetImage(value);}}}
|
||||
|
||||
public void SetImage(Image<Rgb24> image)
|
||||
{
|
||||
lockObj.Lock(()=>{
|
||||
img=image;
|
||||
if(img !=null)
|
||||
{
|
||||
using(var img2=img.Clone())
|
||||
{
|
||||
img2.Mutate((e)=>{
|
||||
e.Resize(Width <= 0 ? 640 : Width,Height <= 0 ? 480 : Height,false);
|
||||
});
|
||||
MemoryStream strm=new MemoryStream();
|
||||
img2.SaveAsBmp(strm);
|
||||
strm.Position=0;
|
||||
SetImage(strm);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void Resize()
|
||||
{
|
||||
lockObj.Lock(()=>{
|
||||
try{
|
||||
if(img !=null)
|
||||
{
|
||||
using(var img2=img.Clone())
|
||||
{
|
||||
img2.Mutate((e)=>{
|
||||
e.Resize(Width <= 0 ? 640 : Width,Height <= 0 ? 480 : Height,false);
|
||||
});
|
||||
MemoryStream strm=new MemoryStream();
|
||||
img2.SaveAsBmp(strm);
|
||||
strm.Position=0;
|
||||
SetImage(strm);
|
||||
}
|
||||
}
|
||||
}catch(Exception ex)
|
||||
{
|
||||
_=ex;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,433 @@
|
|||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using Eto.Drawing;
|
||||
using Eto.Forms;
|
||||
using FlashCap;
|
||||
using FlashCap.Utilities;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using Timelapse.Desktop;
|
||||
using TimelapseApi;
|
||||
using Image = SixLabors.ImageSharp.Image;
|
||||
using System.Reflection;
|
||||
|
||||
public class MainForm : Form
|
||||
{
|
||||
TimelapseWebServer? svr;
|
||||
string[] args;
|
||||
public GuiData Gui {get;set;}
|
||||
public Api Instance {get;set;}
|
||||
|
||||
public SynchronizationContext? synchContext;
|
||||
|
||||
// Constructed capture device.
|
||||
private CaptureDevice? captureDevice;
|
||||
private PictureBox d;
|
||||
private CheckCommand record;
|
||||
private CheckCommand oneX;
|
||||
public MainForm(string[] args)
|
||||
{
|
||||
var asm=Assembly.GetExecutingAssembly();
|
||||
|
||||
var strm=asm.GetManifestResourceStream("Timelapse.ServerFiles.favicon.ico");
|
||||
if(strm != null)
|
||||
{
|
||||
this.Icon = new Icon(strm);
|
||||
}
|
||||
|
||||
record=new CheckCommand{
|
||||
MenuText="&Record",
|
||||
ToolBarText="Record"
|
||||
};
|
||||
|
||||
oneX = new CheckCommand{
|
||||
MenuText="&Real Time",
|
||||
ToolBarText="Real Time"
|
||||
};
|
||||
this.args=args;
|
||||
Gui=new GuiData();
|
||||
|
||||
|
||||
|
||||
Instance=new Api(Gui);
|
||||
Gui.Instance=Instance;
|
||||
Gui.CurrentFSIndex=0;
|
||||
Gui.Set().Wait();
|
||||
d=new PictureBox();
|
||||
}
|
||||
|
||||
public void CreateMenu()
|
||||
{
|
||||
Command close = new Command((sender,e)=>{Environment.Exit(0);});
|
||||
close.MenuText="&Exit";
|
||||
|
||||
Instance.RealTimeChanged += RealTime_Changed;
|
||||
Instance.RecordingChanged += Recording_Changed;
|
||||
Instance.ProjectOpened += ProjectOpened;
|
||||
Instance.ProjectClosed += ProjectClosed;
|
||||
record.CheckedChanged += Record_CheckedChanged;
|
||||
oneX.CheckedChanged += RealTime_CheckedChanged;
|
||||
NewFrame += NewFrameEvent;
|
||||
Command export=new Command(async(sender,e)=>{
|
||||
using(ExportWindow window = new ExportWindow(this,Instance,Gui,false))
|
||||
{
|
||||
await window.ShowModalAsync(this);
|
||||
}
|
||||
}){
|
||||
MenuText="&Export Project",
|
||||
ToolBarText="Export"
|
||||
};
|
||||
Command share = new Command(async(sender,e)=>{
|
||||
using(ExportWindow window = new ExportWindow(this,Instance,Gui,true))
|
||||
{
|
||||
await window.ShowModalAsync(this);
|
||||
}
|
||||
}){
|
||||
MenuText="&Share Project",
|
||||
ToolBarText="Share"
|
||||
};
|
||||
Command changeProjectSettings = new Command(async(sender,e)=>{
|
||||
var p = Instance.Project;
|
||||
if(p != null)
|
||||
{
|
||||
Instance.Project=null;
|
||||
using(TimelapseProjectSettings settings=new TimelapseProjectSettings(p))
|
||||
await settings.ShowModalAsync(this);
|
||||
|
||||
p.Save();
|
||||
Instance.Project=p;
|
||||
}
|
||||
}){
|
||||
MenuText="&Project Settings",
|
||||
ToolBarText="Project"
|
||||
|
||||
};
|
||||
|
||||
|
||||
Command newProject=new Command(async(sender,e)=>{
|
||||
|
||||
var cfs=Gui.CurrentFileSystem;
|
||||
if(cfs != null)
|
||||
{
|
||||
string? path=cfs.ShowSaveDialog(this,new FileFilter[]{new FileFilter("Timelapse Project",".tlnp")});
|
||||
if(!string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
string? changed=Path.ChangeExtension(path,"");
|
||||
if(!string.IsNullOrWhiteSpace(changed))
|
||||
{
|
||||
var ss= cfs+changed.Substring(0,changed.Length-1);
|
||||
if(ss != null)
|
||||
{
|
||||
|
||||
var proj=new TimelapseProject();
|
||||
|
||||
proj.ProjectLocation=ss;
|
||||
using(TimelapseProjectSettings settings=new TimelapseProjectSettings(proj))
|
||||
await settings.ShowModalAsync(this);
|
||||
proj.Save();
|
||||
Instance.Project = proj;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}){
|
||||
MenuText="&New Project",
|
||||
ToolBarText="New"
|
||||
};
|
||||
|
||||
Command openProject=new Command((sender,e)=>{
|
||||
var cfs=Gui.CurrentFileSystem;
|
||||
if(cfs != null)
|
||||
{
|
||||
string? path=cfs.ShowOpenDialog(this,new FileFilter[]{new FileFilter("Timelapse Project",".tlnp")});
|
||||
if(!string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
if(cfs.FileExists(path))
|
||||
{
|
||||
|
||||
string? changed=Path.ChangeExtension(path,"");
|
||||
if(!string.IsNullOrWhiteSpace(changed))
|
||||
{
|
||||
var ss= cfs+changed.Substring(0,changed.Length-1);
|
||||
if(ss != null)
|
||||
{
|
||||
Instance.Project = TimelapseProject.Open(ss);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}){
|
||||
MenuText="&Open Project",
|
||||
ToolBarText="Open"
|
||||
};
|
||||
|
||||
|
||||
|
||||
var FsItem = new ButtonMenuItem {
|
||||
Text="File System",
|
||||
};
|
||||
var gfs = Gui.FileSystems;
|
||||
if(gfs != null){
|
||||
int i=0;
|
||||
foreach(var fs in gfs)
|
||||
{
|
||||
int j=i++;
|
||||
var rb =new RadioMenuItem();
|
||||
rb.Text=fs.Text;
|
||||
rb.CheckedChanged+=(sender,e)=>{
|
||||
if(rb.Checked)
|
||||
{
|
||||
Gui.CurrentFSIndex=j;
|
||||
Gui.FSChanged();
|
||||
}
|
||||
};
|
||||
FsItem.Items.Add(rb);
|
||||
}
|
||||
}
|
||||
var ExtSettings = new ButtonMenuItem {
|
||||
Text="Extension Settings"
|
||||
};
|
||||
var exts = Gui.ExtensionSettings;
|
||||
Dictionary<TimelapseExtension,List<ButtonMenuItem>> extBtns=new Dictionary<TimelapseExtension, List<ButtonMenuItem>>();
|
||||
if(exts != null)
|
||||
{
|
||||
foreach(var item in exts)
|
||||
{
|
||||
if(!extBtns.ContainsKey(item.Extension))
|
||||
{
|
||||
extBtns.Add(item.Extension,new List<ButtonMenuItem>());
|
||||
}
|
||||
var btn=new ButtonMenuItem{Text=item.Text};
|
||||
btn.Click += async(sender,e)=>{
|
||||
try{
|
||||
using(var dlg = item.Dialog())
|
||||
{
|
||||
await dlg.ShowModalAsync(this);
|
||||
}
|
||||
}catch(Exception ex)
|
||||
{
|
||||
_=ex;
|
||||
}
|
||||
};
|
||||
extBtns[item.Extension].Add(btn);
|
||||
}
|
||||
foreach(var item in extBtns)
|
||||
{
|
||||
var btn = new ButtonMenuItem() {Text=item.Key.Name};
|
||||
foreach(var item2 in item.Value)
|
||||
{
|
||||
btn.Items.Add(item2);
|
||||
}
|
||||
ExtSettings.Items.Add(btn);
|
||||
}
|
||||
}
|
||||
ToolBar = new ToolBar{
|
||||
Items = {
|
||||
new ButtonToolItem(newProject),
|
||||
new ButtonToolItem(openProject),
|
||||
new SeparatorToolItem(),
|
||||
new ButtonToolItem(export),
|
||||
new ButtonToolItem(share),
|
||||
new SeparatorToolItem(),
|
||||
new ButtonToolItem(changeProjectSettings),
|
||||
new CheckToolItem(record),
|
||||
new CheckToolItem(oneX)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Menu = new MenuBar {
|
||||
QuitItem=new ButtonMenuItem(close),
|
||||
ApplicationItems={
|
||||
new ButtonMenuItem(newProject),
|
||||
new ButtonMenuItem(openProject),
|
||||
new SeparatorMenuItem(),
|
||||
new ButtonMenuItem(export),
|
||||
new ButtonMenuItem(share),
|
||||
|
||||
},
|
||||
Items={
|
||||
|
||||
new ButtonMenuItem {
|
||||
Text="&Project",
|
||||
Items={
|
||||
|
||||
new CheckMenuItem(record),
|
||||
new CheckMenuItem(oneX),
|
||||
new ButtonMenuItem(changeProjectSettings)
|
||||
}
|
||||
},
|
||||
new ButtonMenuItem
|
||||
{
|
||||
Text="&Options",
|
||||
Items={
|
||||
FsItem,
|
||||
ExtSettings
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void NewFrameEvent(object? sender, NewFrameEventArgs e)
|
||||
{
|
||||
if(synchContext != null)
|
||||
synchContext.Post(_ =>
|
||||
{
|
||||
// HACK: on .NET Core, will be leaked (or delayed GC?)
|
||||
// So we could release manually before updates.
|
||||
this.d.Image=e.Image;
|
||||
d.Image.Dispose();
|
||||
}, null);
|
||||
}
|
||||
|
||||
protected override async void OnShown(EventArgs e)
|
||||
{ this.synchContext = SynchronizationContext.Current;
|
||||
await SetCamera();
|
||||
CreateMenu();
|
||||
|
||||
|
||||
|
||||
|
||||
this.Content=d;
|
||||
|
||||
|
||||
this.SizeChanged+=(sender,e)=>{
|
||||
d.Height = ClientSize.Height- d.Location.Y;
|
||||
d.Width = ClientSize.Width-d.Location.X;
|
||||
};
|
||||
}
|
||||
public event EventHandler<NewFrameEventArgs>? NewFrame;
|
||||
public async Task FrameChanged(Image<Rgb24> image)
|
||||
{
|
||||
await Instance.SendFrame(image);
|
||||
|
||||
NewFrame?.Invoke(this,new NewFrameEventArgs(image));
|
||||
|
||||
|
||||
}
|
||||
public async Task SetCamera()
|
||||
{
|
||||
|
||||
TimelapseCamera? c=null;
|
||||
using(SelectCamera camera=new SelectCamera())
|
||||
{
|
||||
c=await camera.ShowModalAsync(this);
|
||||
}
|
||||
svr=new TimelapseWebServer(this);
|
||||
Thread t = new Thread(()=>{
|
||||
svr.Listen();
|
||||
});
|
||||
t.Start();
|
||||
|
||||
if(c == null)
|
||||
{
|
||||
MessageBox.Show("You will need to restart app to record");
|
||||
return;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Initialize and start capture device
|
||||
|
||||
// Enumerate capture devices:
|
||||
|
||||
|
||||
// Use first device.
|
||||
var descriptor0 =c.DeviceDescriptor;
|
||||
if (descriptor0 != null)
|
||||
{
|
||||
var characteristics = c.VideoCharacteristics;
|
||||
// Show status.
|
||||
|
||||
// Open capture device:
|
||||
if(characteristics != null){
|
||||
|
||||
this.captureDevice = await descriptor0.OpenAsync(
|
||||
characteristics,
|
||||
this.OnPixelBufferArrived);
|
||||
|
||||
// Start capturing.
|
||||
this.captureDevice.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
private async void OnPixelBufferArrived(PixelBufferScope bufferScope)
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Pixel buffer has arrived.
|
||||
// NOTE: Perhaps this thread context is NOT UI thread.
|
||||
|
||||
// Or, refer image data binary directly.
|
||||
// (Advanced manipulation, see README.)
|
||||
ArraySegment<byte> image = bufferScope.Buffer.ReferImage();
|
||||
|
||||
// Convert to Stream (using FlashCap.Utilities)
|
||||
using (var stream = image.AsStream())
|
||||
{
|
||||
// Decode image data to a bitmap:
|
||||
|
||||
Image<Rgb24> img = Image.Load<Rgb24>(stream);
|
||||
await FrameChanged(img);
|
||||
|
||||
// `bitmap` is copied, so we can release pixel buffer now.
|
||||
bufferScope.ReleaseNow();
|
||||
|
||||
// Switch to UI thread.
|
||||
// HACK: Here is using `SynchronizationContext.Post()` instead of `Control.Invoke()`.
|
||||
// Because in sensitive states when the form is closing,
|
||||
// `Control.Invoke()` can fail with exception.
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Record_CheckedChanged(object? sender,EventArgs args)
|
||||
{
|
||||
Instance.RecordingChanged -= Recording_Changed;
|
||||
Instance.Recording = record.Checked;
|
||||
Instance.RecordingChanged += Recording_Changed;
|
||||
}
|
||||
private void RealTime_CheckedChanged(object? sender,EventArgs args)
|
||||
{
|
||||
Instance.RealTimeChanged -= RealTime_Changed;
|
||||
Instance.RealTime = oneX.Checked;
|
||||
Instance.RealTimeChanged += RealTime_Changed;
|
||||
}
|
||||
|
||||
private void Recording_Changed(object? sender,EventArgs args)
|
||||
{
|
||||
|
||||
record.CheckedChanged -= Record_CheckedChanged;
|
||||
record.Checked = Instance.Recording;
|
||||
record.CheckedChanged += Record_CheckedChanged;
|
||||
}
|
||||
private void RealTime_Changed(object? sender,EventArgs args)
|
||||
{
|
||||
oneX.CheckedChanged -= RealTime_CheckedChanged;
|
||||
oneX.Checked = Instance.RealTime;
|
||||
oneX.CheckedChanged += RealTime_CheckedChanged;
|
||||
}
|
||||
|
||||
public void ProjectClosed(object? sender,EventArgs args)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public void ProjectOpened(object? sender,EventArgs args)
|
||||
{
|
||||
|
||||
if(Instance.Project != null)
|
||||
{
|
||||
Instance.Recording=false;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
using FlashCap.Devices;
|
||||
using FlashCap.Utilities;
|
||||
using FlashCap;
|
||||
using Eto.Forms;
|
||||
using TimelapseApi;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Timelapse.Desktop
|
||||
{
|
||||
public class TimeSpanControl : StackLayout
|
||||
{
|
||||
private NumericStepper[] steppers=new NumericStepper[] {
|
||||
new NumericStepper {MinValue=0,MaxValue=int.MaxValue},
|
||||
new NumericStepper {MinValue=0,MaxValue=23},
|
||||
new NumericStepper {MinValue=0,MaxValue=60},
|
||||
new NumericStepper {MinValue=0,MaxValue=60}
|
||||
};
|
||||
private Label[] lbls=new Label[] {
|
||||
new Label {Text="Days: "},
|
||||
new Label {Text="Hours: "},
|
||||
new Label {Text="Minutes: "},
|
||||
new Label {Text="Seconds: " }
|
||||
};
|
||||
public TimeSpanControl()
|
||||
{
|
||||
foreach(var stepper in steppers)
|
||||
{
|
||||
stepper.ValueChanged += (sender,e)=>{
|
||||
ValueChanged?.Invoke(this,EventArgs.Empty);
|
||||
};
|
||||
}
|
||||
Orientation=Orientation.Vertical;
|
||||
StackLayout lyt=new StackLayout {Orientation = Orientation.Horizontal};
|
||||
lyt.Items.Add(lbls[0]);
|
||||
lyt.Items.Add(steppers[0]);
|
||||
lyt.Items.Add(lbls[1]);
|
||||
lyt.Items.Add(steppers[1]);
|
||||
Items.Add(lyt);
|
||||
lyt=new StackLayout {Orientation=Orientation.Horizontal};
|
||||
lyt.Items.Add(lbls[2]);
|
||||
lyt.Items.Add(steppers[2]);
|
||||
lyt.Items.Add(lbls[3]);
|
||||
lyt.Items.Add(steppers[3]);
|
||||
Items.Add(lyt);
|
||||
}
|
||||
public event EventHandler<EventArgs>? ValueChanged;
|
||||
public TimeSpan Value {get {return new TimeSpan((int)steppers[0].Value,(int)steppers[1].Value,(int)steppers[2].Value,(int)steppers[3].Value);} set { steppers[0].Value=value.Days; steppers[1].Value = value.Hours; steppers[2].Value=value.Minutes; steppers[3].Value = value.Seconds; }}
|
||||
}
|
||||
|
||||
public class TimelapseProjectSettings : Dialog
|
||||
{
|
||||
public TimelapseProjectSettings(TimelapseProject proj)
|
||||
{
|
||||
|
||||
Title="Project Settings";
|
||||
Button saveBtn=new Button {Text="Save"};
|
||||
ComboBox cbox=new ComboBox();
|
||||
|
||||
|
||||
if(proj.ProjectLocation!= null && proj.ProjectLocation.DirectoryExists("Sections"))
|
||||
|
||||
foreach(var f in proj.ProjectLocation.GetDirectories("Sections"))
|
||||
{
|
||||
cbox.Items.Add(f);
|
||||
}
|
||||
|
||||
cbox.Text = proj.SectionName;
|
||||
cbox.TextChanged += (sender,e)=>{
|
||||
proj.SectionName =cbox.Text;
|
||||
};
|
||||
|
||||
|
||||
DynamicLayout lyt=new DynamicLayout();
|
||||
lyt.BeginVertical();
|
||||
lyt.BeginHorizontal();
|
||||
lyt.Add(new Label {Text="Section name:"});
|
||||
lyt.EndBeginHorizontal();
|
||||
lyt.Add(cbox,true);
|
||||
lyt.EndBeginHorizontal();
|
||||
|
||||
TabControl control = new TabControl();
|
||||
|
||||
TimeSpanControl ctl=new TimeSpanControl();
|
||||
ctl.Value = proj.Interval;
|
||||
ctl.ValueChanged += (sender,e)=>{
|
||||
proj.Interval = ctl.Value;
|
||||
};
|
||||
StackLayout lyt0=new StackLayout();
|
||||
lyt0.Orientation = Orientation.Vertical;
|
||||
lyt0.Items.Add(new Label {Text="Estimated Project Length:"});
|
||||
TimeSpanControl estProjLen = new TimeSpanControl();
|
||||
estProjLen.Value=proj.Interval.EstimatedProjectLength;
|
||||
estProjLen.ValueChanged += (sender,e)=>{
|
||||
proj.Interval.EstimatedProjectLength = estProjLen.Value;
|
||||
};
|
||||
lyt0.Items.Add(estProjLen);
|
||||
lyt0.Items.Add(new Label {Text="Estimated Video Length:"});
|
||||
TimeSpanControl estVidLen = new TimeSpanControl();
|
||||
estVidLen.Value=proj.Interval.EstimatedVideoLength;
|
||||
estVidLen.ValueChanged += (sender,e)=>{
|
||||
proj.Interval.EstimatedVideoLength = estVidLen.Value;
|
||||
};
|
||||
lyt0.Items.Add(estVidLen);
|
||||
|
||||
control.Pages.Add(new TabPage {Content=lyt0,Text="Estimated"});
|
||||
control.Pages.Add(new TabPage {Content=ctl,Text="Interval"});
|
||||
control.SelectedIndex = proj.Interval.UseEstimated ? 0 : 1;
|
||||
control.SelectedIndexChanged += (sender,e)=>{
|
||||
proj.Interval.UseEstimated = control.SelectedIndex == 1;
|
||||
};
|
||||
lyt.Add(control,true);
|
||||
lyt.EndHorizontal();
|
||||
lyt.EndBeginVertical();
|
||||
lyt.BeginHorizontal();
|
||||
|
||||
lyt.AddSpace(true);
|
||||
lyt.Add(saveBtn);
|
||||
lyt.EndHorizontal();
|
||||
lyt.EndVertical();
|
||||
|
||||
saveBtn.Click += (sender,e)=>{
|
||||
this.Close();
|
||||
};
|
||||
Content=lyt;
|
||||
Resizable=true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
using FlashCap.Devices;
|
||||
using FlashCap.Utilities;
|
||||
using FlashCap;
|
||||
using Eto.Forms;
|
||||
using TimelapseApi;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Timelapse.Desktop
|
||||
{
|
||||
public class SelectCamera : Dialog<TimelapseCamera?>
|
||||
{
|
||||
public class CameraObject
|
||||
{
|
||||
public CameraObject(CaptureDeviceDescriptor desc)
|
||||
{
|
||||
Descriptor=desc;
|
||||
}
|
||||
public CaptureDeviceDescriptor Descriptor {get;set;}
|
||||
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
return Descriptor.Name;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public class CharacteristicsObject
|
||||
{
|
||||
public CharacteristicsObject(VideoCharacteristics chr)
|
||||
{
|
||||
Characteristics=chr;
|
||||
}
|
||||
public VideoCharacteristics Characteristics {get;set;}
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
return Characteristics.ToString();
|
||||
}
|
||||
}
|
||||
public SelectCamera()
|
||||
{
|
||||
|
||||
this.Title="Select Camera";
|
||||
|
||||
Button accept=new Button(){Text="Select",Enabled=false};
|
||||
DropDown cameraSelector = new DropDown();
|
||||
|
||||
DropDown characteristicsSelector=new DropDown();
|
||||
var devices = new CaptureDevices();
|
||||
|
||||
List<CameraObject> cobj=new List<CameraObject>();
|
||||
ObservableCollection<CharacteristicsObject> chrobj=new ObservableCollection<CharacteristicsObject>();
|
||||
foreach (var descriptor in devices.EnumerateDescriptors())
|
||||
{
|
||||
if(descriptor.Characteristics.Length >0)
|
||||
{
|
||||
cobj.Add(new CameraObject(descriptor));
|
||||
}
|
||||
}
|
||||
|
||||
cameraSelector.DataStore=cobj;
|
||||
characteristicsSelector.DataStore=chrobj;
|
||||
characteristicsSelector.Enabled=false;
|
||||
characteristicsSelector.SelectedIndexChanged+=(sender,e)=>
|
||||
{
|
||||
accept.Enabled=characteristicsSelector.SelectedIndex > -1;
|
||||
};
|
||||
cameraSelector.SelectedIndexChanged += (sender,e)=>{
|
||||
if(cameraSelector.SelectedIndex > -1)
|
||||
{
|
||||
|
||||
characteristicsSelector.Enabled=true;
|
||||
chrobj.Clear();
|
||||
foreach(var item in cobj[cameraSelector.SelectedIndex].Descriptor.Characteristics)
|
||||
{
|
||||
chrobj.Add(new CharacteristicsObject(item));
|
||||
}
|
||||
}
|
||||
};
|
||||
bool close=false;
|
||||
accept.Click +=(sender,e)=>{
|
||||
int cSI=cameraSelector.SelectedIndex;
|
||||
int charSI = characteristicsSelector.SelectedIndex;
|
||||
if(cSI > -1 && cobj.Count > 0 && charSI > -1 && chrobj.Count > 0)
|
||||
{
|
||||
Result=new TimelapseCamera(cobj[cSI].Descriptor,chrobj[charSI].Characteristics);
|
||||
|
||||
close=true;
|
||||
Close();
|
||||
}
|
||||
};
|
||||
Closing += (sender,e)=>{
|
||||
if(!close)
|
||||
{
|
||||
Result=null;
|
||||
|
||||
}
|
||||
};
|
||||
DynamicLayout lyt=new DynamicLayout();
|
||||
lyt.BeginVertical();
|
||||
lyt.BeginHorizontal();
|
||||
lyt.Add(cameraSelector,true);
|
||||
lyt.EndBeginHorizontal();
|
||||
lyt.Add(characteristicsSelector);
|
||||
lyt.EndBeginHorizontal();
|
||||
lyt.Add(accept);
|
||||
lyt.EndHorizontal();
|
||||
lyt.EndVertical();
|
||||
|
||||
this.Content=lyt;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2018 Materialize
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,39 @@
|
|||
|
||||
.img-container
|
||||
{
|
||||
background-image: url('../api/stream.jpg');
|
||||
background-size: contain;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
;
|
||||
}
|
||||
.drop2
|
||||
{
|
||||
width: 25%;
|
||||
}
|
||||
.timelapse-state
|
||||
{
|
||||
|
||||
position: absolute;
|
||||
right: 5%;
|
||||
top: 10px;
|
||||
}
|
||||
.timelapse-state .rec
|
||||
{
|
||||
color: greenyellow;
|
||||
}
|
||||
.timelapse-state .real-time
|
||||
{
|
||||
color: lightblue;
|
||||
}
|
||||
.form0
|
||||
{
|
||||
height: 100vh;
|
||||
}
|
||||
.bott
|
||||
{
|
||||
|
||||
bottom: 0px;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
|
@ -0,0 +1,115 @@
|
|||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<!--Import Google Icon Font-->
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<!--Import materialize.css-->
|
||||
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>
|
||||
<title>Timelapse Now WebServer</title>
|
||||
<!--Let browser know website is optimized for mobile-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<link rel="stylesheet" href="css/timelapse.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<div class="nav-wrapper">
|
||||
<a href="#!" class="brand-logo center">Timelapse Now</a>
|
||||
<a href="#" data-target="mobile-demo" class="sidenav-trigger"><i class="material-icons">menu</i></a>
|
||||
<ul class="center hide-on-med-and-down">
|
||||
<li><a href="#" onclick="record()">Record</a></li>
|
||||
<li><a href="#" onclick="realtime()">Real Time</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Dropdown Structure -->
|
||||
|
||||
|
||||
<ul class="sidenav" id="mobile-demo">
|
||||
<li><a href="#" onclick="record()">Record</a></li>
|
||||
<li><a href="#" onclick="realtime()">Real Time</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<div class="img-container">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="timelapse-state">
|
||||
<div class="rec" id="rec">Stopped</div>
|
||||
<div class="real-time" id="real-time">Interval</div><br>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="js/jquery.min.js"></script>
|
||||
<!--JavaScript at end of body for optimized loading-->
|
||||
<script type="text/javascript" src="js/materialize.min.js"></script>
|
||||
<script>
|
||||
var record_text=document.getElementById("rec");
|
||||
var rt_text=document.getElementById("real-time");
|
||||
function setText()
|
||||
{
|
||||
record_text.innerText = rec ? "Recording" : "Stopped";
|
||||
rt_text.innerText = real ? "Real Time" : "Inerval";
|
||||
}
|
||||
var rec=false;
|
||||
var real=false;
|
||||
$(document).ready(function(){
|
||||
$('.sidenav').sidenav();
|
||||
|
||||
yourFunction();
|
||||
});
|
||||
|
||||
function record()
|
||||
{
|
||||
get(`api/setstate.cgi?rec=${!rec}&real=${real}`,(e)=>{
|
||||
var j=JSON.parse(e);
|
||||
rec=j.Recording;
|
||||
real=j.RealTime;
|
||||
setText();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
function realtime()
|
||||
{
|
||||
|
||||
get(`api/setstate.cgi?rec=${rec}&real=${!real}`,(e)=>{
|
||||
var j=JSON.parse(e);
|
||||
rec=j.Recording;
|
||||
real=j.RealTime;
|
||||
setText();
|
||||
});
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function yourFunction(){
|
||||
// do whatever you like here
|
||||
get("api/state.json",(e)=>{
|
||||
var j=JSON.parse(e);
|
||||
rec=j.Recording;
|
||||
real=j.RealTime;
|
||||
setText();
|
||||
});
|
||||
|
||||
setTimeout(yourFunction,2000);
|
||||
}
|
||||
function get(url,resp)
|
||||
{
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
// Typical action to be performed when the document is ready:
|
||||
resp(xhttp.responseText);
|
||||
}
|
||||
};
|
||||
xhttp.open("GET", url, true);
|
||||
xhttp.send();
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,29 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Eto.Forms" Version="2.7.0" />
|
||||
|
||||
<PackageReference Include="FlashCap" Version="1.2.0" />
|
||||
|
||||
<PackageReference Include="Tesses.WebServer" Version="1.0.3.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TimelapseApi\TimelapseApi.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="ServerFiles\*" />
|
||||
<EmbeddedResource Include="ServerFiles\*\*" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,24 @@
|
|||
namespace Timelapse.Desktop;
|
||||
using FlashCap;
|
||||
using FlashCap.Devices;
|
||||
using FlashCap.Utilities;
|
||||
|
||||
public class TimelapseCamera
|
||||
{
|
||||
|
||||
|
||||
public TimelapseCamera(CaptureDeviceDescriptor desc,VideoCharacteristics characteristics)
|
||||
{
|
||||
DeviceDescriptor=desc;
|
||||
VideoCharacteristics = characteristics;
|
||||
|
||||
}
|
||||
|
||||
public CaptureDeviceDescriptor? DeviceDescriptor {get;set;}
|
||||
|
||||
|
||||
public VideoCharacteristics? VideoCharacteristics {get;set;}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,268 @@
|
|||
namespace Timelapse.Desktop;
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Eto.Forms;
|
||||
using FlashCap;
|
||||
using FlashCap.Devices;
|
||||
using FlashCap.Utilities;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using Tesses.WebServer;
|
||||
|
||||
public class proxsvr : Tesses.WebServer.IServer
|
||||
{
|
||||
public proxsvr(IServer svr)
|
||||
{
|
||||
dest=svr;
|
||||
}
|
||||
IServer dest;
|
||||
public void AddCors(ServerContext ctx)
|
||||
{
|
||||
|
||||
dest.AddCors(ctx);
|
||||
}
|
||||
|
||||
public async Task<bool> BeforeAsync(ServerContext ctx)
|
||||
{
|
||||
return await dest.BeforeAsync(ctx);
|
||||
}
|
||||
|
||||
public async Task GetAsync(ServerContext ctx)
|
||||
{
|
||||
await dest.GetAsync(ctx);
|
||||
if(ctx.RawUrl != "/api/stream.jpg")
|
||||
{
|
||||
await ctx.NetworkStream.DisposeAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OptionsAsync(ServerContext ctx)
|
||||
{
|
||||
await dest.OptionsAsync(ctx);
|
||||
await ctx.NetworkStream.DisposeAsync();
|
||||
}
|
||||
|
||||
public async Task OtherAsync(ServerContext ctx)
|
||||
{
|
||||
await dest.OtherAsync(ctx);
|
||||
await ctx.NetworkStream.DisposeAsync();
|
||||
}
|
||||
|
||||
public async Task PostAsync(ServerContext ctx)
|
||||
{
|
||||
await dest.PostAsync(ctx);
|
||||
await ctx.NetworkStream.DisposeAsync();
|
||||
}
|
||||
}
|
||||
public class EmbeadedServer : Server
|
||||
{
|
||||
|
||||
public EmbeadedServer(string extname)
|
||||
{
|
||||
this.extname=extname;
|
||||
}
|
||||
string extname;
|
||||
|
||||
public override async Task GetAsync(ServerContext ctx)
|
||||
{
|
||||
var asm=Assembly.GetExecutingAssembly();
|
||||
|
||||
if(asm != null)
|
||||
{
|
||||
string j=$"{extname}{ctx.UrlPath.Replace('/','.')}";
|
||||
var strm=asm.GetManifestResourceStream(j);
|
||||
if(strm != null)
|
||||
{
|
||||
await ctx.SendStreamAsync(strm,HeyRed.Mime.MimeTypesMap.GetMimeType(ctx.UrlPath));
|
||||
return;
|
||||
}
|
||||
|
||||
j=j.TrimEnd('.') + ".index.html";
|
||||
strm=asm.GetManifestResourceStream(j);
|
||||
if(strm != null)
|
||||
{
|
||||
await ctx.SendStreamAsync(strm,HeyRed.Mime.MimeTypesMap.GetMimeType("index.html"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
await NotFoundServer.ServerNull.GetAsync(ctx);
|
||||
}
|
||||
}
|
||||
public class TimelapseWebServer
|
||||
{
|
||||
MainForm frm;
|
||||
public TimelapseWebServer(MainForm frm)
|
||||
{
|
||||
this.frm=frm;
|
||||
}
|
||||
CancellationTokenSource? tokenSrc;
|
||||
TcpListener? _listener;
|
||||
|
||||
private async Task CommunicateHostAsync(HttpServerListener listener,TcpClient clt)
|
||||
{
|
||||
try{
|
||||
//<METHOD> <PATH> HTTP/1.1\r\n
|
||||
//HEADER1\r\n
|
||||
//HEADER2\r\n
|
||||
//......
|
||||
//HEADERN\r\n
|
||||
//\r\n
|
||||
//OPTIONAL REQUEST BODY
|
||||
|
||||
//RESPONSE
|
||||
|
||||
var strm = listener.GetStream(clt);
|
||||
|
||||
|
||||
await listener.PushAsync(strm,clt.Client.LocalEndPoint,clt.Client.RemoteEndPoint);
|
||||
|
||||
}catch(Exception ex)
|
||||
{
|
||||
_=ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task ListenAsync(HttpServerListener svr,CancellationToken token,Action<IPEndPoint> endpoint)
|
||||
{
|
||||
if(_listener == null) return;
|
||||
_listener.Start();
|
||||
if(endpoint != null)
|
||||
{
|
||||
endpoint((IPEndPoint)_listener.LocalEndpoint);
|
||||
}
|
||||
using (var r = token.Register(() => _listener.Stop())) {
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
try{
|
||||
var socket=await _listener.AcceptTcpClientAsync();
|
||||
await CommunicateHostAsync(svr,socket).ConfigureAwait(false);
|
||||
}catch(Exception ex)
|
||||
{
|
||||
_=ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public async void Listen()
|
||||
{
|
||||
if(tokenSrc != null)
|
||||
{
|
||||
tokenSrc.Cancel();
|
||||
tokenSrc.Dispose();
|
||||
|
||||
}
|
||||
if(!frm.Instance.Model.enableWebServer) return;
|
||||
tokenSrc=new CancellationTokenSource();
|
||||
//#if (!DEBUG)
|
||||
EmbeadedServer esvr=new EmbeadedServer("Timelapse.ServerFiles");
|
||||
// #else
|
||||
// StaticServer esvr=new StaticServer("ServerFiles");
|
||||
//#endif
|
||||
RouteServer rs=new RouteServer();
|
||||
rs.Add("/stream.jpg",StreamImage);
|
||||
rs.Add("/state.json",State);
|
||||
rs.Add("/setstate.cgi",SetState);
|
||||
MountableServer isvr=new MountableServer(esvr);
|
||||
isvr.Mount("/api/",rs);var p=new System.Net.IPEndPoint(System.Net.IPAddress.Any,frm.Instance.Model.timelapsePort);
|
||||
_listener=new TcpListener(p);
|
||||
HttpServerListener svr=new HttpServerListener(p,new proxsvr(isvr));
|
||||
Console.WriteLine("Almost ready to listen");
|
||||
await ListenAsync(svr,tokenSrc.Token,(e)=>{
|
||||
int port=e.Port;
|
||||
string dns=Dns.GetHostName();
|
||||
|
||||
var localIPs =string.Join('\n', Dns.GetHostAddresses(dns).Where(e=>{return !IPAddress.IsLoopback(e);}).Select<IPAddress,string>(e=>{
|
||||
return $"http://{e.ToString()}:{port}/";
|
||||
}));
|
||||
if(frm.synchContext != null)
|
||||
frm.synchContext.Post((e)=>{
|
||||
|
||||
|
||||
MessageBox.Show($"Listening on:\n{localIPs}\nhttp://localhost:{port}\nhttp://{dns}:{port}/",MessageBoxButtons.OK);
|
||||
},null);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private async Task SetState(ServerContext ctx)
|
||||
{
|
||||
string rec;
|
||||
if(ctx.QueryParams.TryGetFirst("rec",out rec))
|
||||
{
|
||||
frm.Instance.Recording= rec != "false";
|
||||
}
|
||||
string real;
|
||||
if(ctx.QueryParams.TryGetFirst("real",out real))
|
||||
{
|
||||
frm.Instance.RealTime= real != "false";
|
||||
}
|
||||
await ctx.SendRedirectAsync("./state.json");
|
||||
|
||||
}
|
||||
|
||||
private async Task State(ServerContext ctx)
|
||||
{
|
||||
await ctx.SendJsonAsync(new{Recording=frm.Instance.Recording,RealTime=frm.Instance.RealTime});
|
||||
}
|
||||
|
||||
private byte[] GetBytes(Image<Rgb24> img)
|
||||
{
|
||||
using(var ms=new MemoryStream())
|
||||
{
|
||||
img.SaveAsJpeg(ms);
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
private async Task StreamImage(ServerContext ctx)
|
||||
{
|
||||
ctx.ResponseHeaders.Add("Content-Type","multipart/x-mixed-replace; boundary=--boundary");
|
||||
await ctx.WriteHeadersAsync();
|
||||
frm.NewFrame += (sender,e)=>{
|
||||
try{
|
||||
var img=e.Image.Clone();
|
||||
Thread t =new Thread(()=>{
|
||||
|
||||
|
||||
try{
|
||||
lock(ctx){
|
||||
StringBuilder b = new StringBuilder();
|
||||
byte[] data = GetBytes(img);
|
||||
img.Dispose();
|
||||
b.Append("\r\n");
|
||||
b.Append("--boundary\r\n");
|
||||
b.Append("Content-Type: image/jpeg\r\n");
|
||||
b.Append($"Content-Length: {data.Length}\r\n");
|
||||
b.Append("\r\n");
|
||||
|
||||
byte[] hdr= Encoding.ASCII.GetBytes(b.ToString());
|
||||
byte[] crlf = Encoding.ASCII.GetBytes("\r\n");
|
||||
ctx.NetworkStream.Write(hdr,0,hdr.Length);
|
||||
ctx.NetworkStream.Write(data,0,data.Length);
|
||||
ctx.NetworkStream.Write(crlf,0,crlf.Length);
|
||||
ctx.NetworkStream.Flush();
|
||||
}
|
||||
|
||||
}catch(Exception ex)
|
||||
{
|
||||
try{
|
||||
ctx.NetworkStream.Dispose();
|
||||
}catch(Exception ex2)
|
||||
{
|
||||
_=ex2;
|
||||
}
|
||||
_=ex;
|
||||
}
|
||||
});
|
||||
t.Start();
|
||||
}catch(Exception ex)
|
||||
{
|
||||
_=ex;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,259 @@
|
|||
namespace TimelapseApi;
|
||||
using FlashCap;
|
||||
using FlashCap.Utilities;
|
||||
using FlashCap.Devices;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using Eto.Forms;
|
||||
using TimelapseApi.ClassExtensions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class GuiData
|
||||
{
|
||||
public async Task Set()
|
||||
{
|
||||
if(Instance ==null) return;
|
||||
var s= Instance._extSettings;
|
||||
ExtensionLoader.Data=this;
|
||||
s.Add((
|
||||
()=>{
|
||||
return new TimelapseSettings(Instance);
|
||||
},"Settings",TimelapseExtension.Null
|
||||
));
|
||||
foreach(var ext in ExtensionLoader.GetTimelapseExtensions())
|
||||
{
|
||||
ext.Instance=Instance;
|
||||
Instance.Extensions.Add(ext);
|
||||
await ext._Create();
|
||||
}
|
||||
}
|
||||
public void FSChanged()
|
||||
{
|
||||
if(Instance != null)
|
||||
{
|
||||
if(Instance.Project != null)
|
||||
{
|
||||
Instance.Project=null;
|
||||
}
|
||||
}
|
||||
}
|
||||
public IEnumerable<(Func<IEnumerable<Image<Rgb24>>,string,CancellationToken,Task> Export,string Text,TimelapseExtension Extension,FileFilter[] SaveDialogFilters)>? Export {get {
|
||||
if(Instance == null) return null;
|
||||
return Instance._export;
|
||||
}}
|
||||
|
||||
public IEnumerable<(Func<Dialog> Dialog,string Text,TimelapseExtension Extension)>? ExtensionSettings {get {if(Instance == null) return null; return Instance._extSettings;}}
|
||||
public Api? Instance {get;set;}
|
||||
|
||||
public List<(TimelapseFileSystem FileSystem,string Text,TimelapseExtension)>? FileSystems {get { if(Instance==null)return null; return Instance._fs;}}
|
||||
public TimelapseFileSystem? CurrentFileSystem {get {var fs=FileSystems; if(fs==null) return null; return fs[CurrentFSIndex].FileSystem;} }
|
||||
|
||||
public IEnumerable<(Func<Window,string,Task> ShareActionAsync,string Text,TimelapseExtension extension)>? Share {get {if(Instance==null) return null;return Instance._share;}}
|
||||
public int CurrentFSIndex {get;set;}
|
||||
}
|
||||
public class Api
|
||||
{
|
||||
public TimelapseSettingsModel Model = LoadModel();
|
||||
internal static string ModelLocation = GetInternalFile("config.json");
|
||||
private static TimelapseSettingsModel LoadModel()
|
||||
{
|
||||
|
||||
Directory.CreateDirectory(GetInternalFile("ExtensionBinaries"));
|
||||
Directory.CreateDirectory(GetInternalFile("ExtensionData"));
|
||||
if(File.Exists(ModelLocation))
|
||||
{
|
||||
TimelapseSettingsModel? model= JsonConvert.DeserializeObject<TimelapseSettingsModel>(File.ReadAllText(ModelLocation));
|
||||
if(model != null) return model;
|
||||
}
|
||||
return new TimelapseSettingsModel();
|
||||
}
|
||||
public void SaveModel()
|
||||
{
|
||||
Directory.CreateDirectory(GetInternalFile());
|
||||
|
||||
File.WriteAllText(ModelLocation, JsonConvert.SerializeObject(Model));
|
||||
|
||||
}
|
||||
|
||||
private static string Get()
|
||||
{
|
||||
if(File.Exists("appdir.txt") )
|
||||
return File.ReadAllText("appdir.txt");
|
||||
else
|
||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"TimelapseNow");
|
||||
}
|
||||
public static string GetInternalFile(params string[] paths)
|
||||
{
|
||||
if(paths.Length == 0) return Get();
|
||||
return Path.Combine(Get(),Path.Combine(paths));
|
||||
}
|
||||
public event EventHandler<EventArgs>? ProjectClosed;
|
||||
|
||||
public event EventHandler<EventArgs>? ProjectOpened;
|
||||
public Api(GuiData data)
|
||||
{
|
||||
|
||||
Gui=data;
|
||||
}
|
||||
|
||||
private TimelapseProject? _proj=null;
|
||||
public TimelapseProject? Project {get {return _proj;} set {
|
||||
|
||||
if(value != null)
|
||||
{
|
||||
if(_proj != null)
|
||||
{
|
||||
ProjectClosed?.Invoke(this,EventArgs.Empty);
|
||||
}
|
||||
_proj=value;
|
||||
ProjectOpened?.Invoke(this,EventArgs.Empty);
|
||||
}else{
|
||||
ProjectClosed?.Invoke(this,EventArgs.Empty);
|
||||
_proj=value;
|
||||
}
|
||||
|
||||
}}
|
||||
public event EventHandler<EventArgs>? RecordingChanged;
|
||||
|
||||
public event EventHandler<EventArgs>? RealTimeChanged;
|
||||
|
||||
bool _rec,_real;
|
||||
|
||||
public bool Recording {get {
|
||||
if(Project == null) return false;
|
||||
return _rec;} set {
|
||||
_rec=value;
|
||||
RecordingChanged?.Invoke(this,EventArgs.Empty);
|
||||
}}
|
||||
|
||||
public bool RealTime { get{if(Project == null) return false; return _real;} set{
|
||||
_real =value;
|
||||
RealTimeChanged?.Invoke(this,EventArgs.Empty);
|
||||
}}
|
||||
|
||||
|
||||
public async Task RecordFrame(Image<Rgb24> img)
|
||||
{
|
||||
|
||||
if(Project !=null && Recording)
|
||||
{
|
||||
var interval = RealTime ? TimeSpan.FromSeconds(1) : (TimeSpan)Project.Interval;
|
||||
var now=DateTime.Now;
|
||||
if((Project.LastFrameTaken + (interval/10)) <= now)
|
||||
{
|
||||
Project.LastFrameTaken=now;
|
||||
await Project.Save(img);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public async Task SendFrame(Image<Rgb24> img)
|
||||
{
|
||||
bool canRecordFrame=true;
|
||||
foreach(var item in _frameHandlers)
|
||||
{
|
||||
if(ExtensionAllowedToBeFrameHandler(item.Extension))
|
||||
{
|
||||
if(item.Handler != null)
|
||||
{
|
||||
var res=await item.Handler(img);
|
||||
if(!res && ExtensionsCanBlockFrames(item.Extension)) canRecordFrame=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(canRecordFrame)
|
||||
{
|
||||
await RecordFrame(img);
|
||||
}
|
||||
}
|
||||
internal bool ExtensionsCanBlockFrames(TimelapseExtension ext)
|
||||
{
|
||||
if(!Model.canBlockFrames) return false;
|
||||
|
||||
return !Model.deniedBlockExtensions.Contains( ext.Id);
|
||||
}
|
||||
internal bool ExtensionAllowedToBeFrameHandler(TimelapseExtension ext)
|
||||
{
|
||||
if(!Model.canOverlayVideo) return false;
|
||||
|
||||
return !Model.deniedOverlayExtensions.Contains( ext.Id);
|
||||
|
||||
}
|
||||
private GuiData Gui;
|
||||
public int CurrentFileSystemIndex {get {return Gui.CurrentFSIndex;}}
|
||||
|
||||
internal List<(TimelapseFileSystem FileSystem,string Text,TimelapseExtension Extension)> _fs = CreateFileSystemList();
|
||||
|
||||
internal List<IDisposable> Extensions =new List<IDisposable>();
|
||||
private static List<(TimelapseFileSystem FileSystem,string Text,TimelapseExtension Extension)> CreateFileSystemList()
|
||||
{
|
||||
List<(TimelapseFileSystem FileSystem,string Text,TimelapseExtension Extension)> fs=new List<(TimelapseFileSystem FileSystem,string Text,TimelapseExtension Extension)>();
|
||||
fs.Add((new NativeFileSystem(),"Native",TimelapseExtension.Null));
|
||||
return fs;
|
||||
}
|
||||
|
||||
internal List<(Func<Image<Rgb24>,Task<bool>> Handler,string HandlerName, TimelapseExtension Extension)> _frameHandlers=new List<(Func<Image<Rgb24>, Task<bool>> Handler,string HandlerName, TimelapseExtension Extension)>();
|
||||
|
||||
internal List<(Func<Dialog> Dialog,string Text,TimelapseExtension Extension)> _extSettings= new List<(Func<Dialog> Dialog,string Text,TimelapseExtension Extension)>();
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<string?> Export(Window w,int exportId)
|
||||
{
|
||||
if(Project == null) return null;
|
||||
var e=_export[exportId];
|
||||
using(var sfd = new SaveFileDialog())
|
||||
{
|
||||
foreach(var item in e.SaveDialogFilters)
|
||||
{
|
||||
sfd.Filters.Add(item);
|
||||
}
|
||||
if(sfd.ShowDialog(w) == DialogResult.Ok)
|
||||
{
|
||||
try{
|
||||
using(var cts=new CancellationTokenSource())
|
||||
{
|
||||
using(ExportForm frm=new ExportForm(Project,cts))
|
||||
{
|
||||
frm.Show();
|
||||
await e.Export(frm,sfd.FileName,cts.Token);
|
||||
|
||||
}
|
||||
}
|
||||
return sfd.FileName;
|
||||
}catch(Exception ex)
|
||||
{
|
||||
_=ex;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
internal List<(Func<IEnumerable<Image<Rgb24>>,string,CancellationToken,Task> Export,string Text,TimelapseExtension Extension,FileFilter[] SaveDialogFilters)> _export=GetExports();
|
||||
|
||||
private static List<(Func<IEnumerable<Image<Rgb24>>, string, CancellationToken, Task> Export, string Text, TimelapseExtension Extension, FileFilter[] SaveDialogFilters)> GetExports()
|
||||
{
|
||||
var exp=new List<(Func<IEnumerable<Image<Rgb24>>,string,CancellationToken,Task> Export,string Text,TimelapseExtension Extension,FileFilter[] SaveDialogFilters)>();
|
||||
Func<IEnumerable<Image<Rgb24>>,string,CancellationToken,Task> callback=async(images,fname,token)=>{
|
||||
using(var vfc=new VideoFileCreator(fname))
|
||||
{
|
||||
foreach(var img in images)
|
||||
{
|
||||
await vfc.AddAsync(img);
|
||||
if(token.IsCancellationRequested)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
exp.Add((callback,"Export (FFmpeg)",TimelapseExtension.Null,new FileFilter[]{new FileFilter("MPEG-4",".mp4"),new FileFilter("MKV",".mkv")}));
|
||||
return exp;
|
||||
}
|
||||
|
||||
internal List<(Func<Window,string,Task> ShareActionAsync,string Text,TimelapseExtension Extension)> _share=new List<(Func<Window,string, Task> ShareActionAsync, string Text,TimelapseExtension Extension)>();
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
|
||||
namespace TimelapseApi.ClassExtensions;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
public static async Task AddAsync(this VideoFileCreator video, Image<Rgb24> img)
|
||||
{
|
||||
using(var ms = new MemoryStream())
|
||||
{
|
||||
img.SaveAsPng(ms);
|
||||
byte[] data =ms.ToArray();
|
||||
await video.AddAsync(data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static void Add(this VideoFileCreator video,Image<Rgb24> img)
|
||||
{
|
||||
|
||||
using(var ms = new MemoryStream())
|
||||
{
|
||||
img.SaveAsPng(ms);
|
||||
byte[] data =ms.ToArray();
|
||||
video.Add(data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
using System.Collections;
|
||||
using Eto.Forms;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
namespace TimelapseApi;
|
||||
|
||||
internal class ExportForm :Form, IEnumerator<Image<Rgb24>> , IEnumerable<Image<Rgb24>>
|
||||
{
|
||||
|
||||
int _i=-1;
|
||||
int i {get {return _i;} set{bar.Value=value+1; bar.Invalidate(); _i=value; }}
|
||||
int count;
|
||||
ProgressBar bar;
|
||||
Button cancel;
|
||||
CancellationTokenSource src;
|
||||
TimelapseProject _proj;
|
||||
public ExportForm(TimelapseProject proj,CancellationTokenSource token)
|
||||
{
|
||||
Width=258; Height=73;
|
||||
|
||||
Title="Exporting";
|
||||
_proj=proj;
|
||||
src=token;
|
||||
bar=new ProgressBar {MaxValue=proj.FrameCount,MinValue=0};
|
||||
cancel=new Button {Text = "Cancel"};
|
||||
count=proj.FrameCount;
|
||||
|
||||
|
||||
DynamicLayout lyt=new DynamicLayout();
|
||||
lyt.BeginVertical();
|
||||
lyt.BeginHorizontal();
|
||||
lyt.Add(bar,true);
|
||||
lyt.EndHorizontal();
|
||||
lyt.EndBeginVertical();
|
||||
lyt.AddSpace(true,true);
|
||||
lyt.BeginHorizontal();
|
||||
lyt.AddSpace(true);
|
||||
lyt.Add(cancel);
|
||||
lyt.EndHorizontal();
|
||||
lyt.EndVertical();
|
||||
Content=lyt;
|
||||
|
||||
|
||||
}
|
||||
private Image<Rgb24> GetImage()
|
||||
{
|
||||
if(_proj.ProjectLocation==null)
|
||||
{
|
||||
return new Image<Rgb24>(1280,720);
|
||||
}
|
||||
using(var s=_proj.ProjectLocation.Open($"Sections/{_proj.SectionName}/{i}.png",FileMode.Open,FileAccess.Read,FileShare.Read))
|
||||
{
|
||||
return Image.Load<Rgb24>(s);
|
||||
}
|
||||
}
|
||||
public Image<Rgb24> Current {
|
||||
get {
|
||||
return GetImage();
|
||||
}
|
||||
}
|
||||
|
||||
object IEnumerator.Current {get{return Current;}}
|
||||
public IEnumerator<Image<Rgb24>> GetEnumerator()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
return ++i < count;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
i=-1;
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
namespace TimelapseApi;
|
||||
using Eto.Forms;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
|
||||
public sealed class ExtensionFeatures
|
||||
{
|
||||
internal Api? Instance {get { return Extension.Instance;}}
|
||||
internal TimelapseExtension Extension {get;private set;}
|
||||
internal bool Valid {get;private set;}
|
||||
internal ExtensionFeatures(TimelapseExtension ext)
|
||||
{
|
||||
Extension=ext;
|
||||
Valid=true;
|
||||
}
|
||||
public ExtensionFeatures RegisterSettingsDialog(Func<Dialog> dialog,string text)
|
||||
{
|
||||
if(!Valid || Instance == null) return this;
|
||||
|
||||
Instance._extSettings.Add((dialog,text,Extension));
|
||||
return this;
|
||||
}
|
||||
public ExtensionFeatures RegisterAsyncFrameHandler(Func<Image<Rgb24>,Task<bool>> handler,string handlerName)
|
||||
{
|
||||
if(!Valid || Instance == null) return this;
|
||||
Instance._frameHandlers.Add((handler,handlerName,Extension));
|
||||
return this;
|
||||
}
|
||||
public ExtensionFeatures RegisterFileSystem(TimelapseFileSystem fs,string name)
|
||||
{
|
||||
if(!Valid || Instance == null) return this;
|
||||
Instance._fs.Add((fs,name,Extension));
|
||||
return this;
|
||||
}
|
||||
public ExtensionFeatures RegisterFrameHandler(Func<Image<Rgb24>,bool> handler,string handlerName)
|
||||
{
|
||||
if(!Valid) return this;
|
||||
RegisterAsyncFrameHandler(async(e)=>{
|
||||
if(handler !=null)
|
||||
{
|
||||
return await Task.Run<bool>(()=>{
|
||||
return handler(e);
|
||||
});
|
||||
}
|
||||
return true;
|
||||
},handlerName);
|
||||
return this;
|
||||
}
|
||||
public ExtensionFeatures RegisterExport(Func<IEnumerable<Image<Rgb24>>,string,CancellationToken,Task> export,FileFilter[] filter,string text)
|
||||
{
|
||||
if(!Valid || Instance == null) return this;
|
||||
if(export != null)
|
||||
Instance._export.Add((export,text,Extension,filter));
|
||||
return this;
|
||||
}
|
||||
public ExtensionFeatures RegisterAsyncShareTarget(Func<Window,string,Task> share,string text)
|
||||
{
|
||||
if(!Valid || Instance == null) return this;
|
||||
if(share != null)
|
||||
Instance._share.Add((share,text,Extension));
|
||||
return this;
|
||||
}
|
||||
public ExtensionFeatures RegisterShareTarget(Action<Window,string> share,string text)
|
||||
{
|
||||
if(!Valid) return this;
|
||||
return RegisterAsyncShareTarget(async(s,e)=>{
|
||||
await Task.Run(
|
||||
()=>{
|
||||
if(share !=null)
|
||||
{
|
||||
share(s,e);
|
||||
}
|
||||
}
|
||||
);
|
||||
},text);
|
||||
}
|
||||
public void Close()
|
||||
{
|
||||
Valid=false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
namespace TimelapseApi
|
||||
{
|
||||
public class ExtensionInfo
|
||||
{
|
||||
public ExtensionInfo()
|
||||
{
|
||||
name="N/A";
|
||||
author="N/A";
|
||||
version="0.0.0";
|
||||
description="";
|
||||
}
|
||||
/* {
|
||||
"name": "TimelapseExtension0001",
|
||||
"author": "YourNameOrCompanyName",
|
||||
"version": "1.0.0",
|
||||
"description": "Some Description"
|
||||
}*/
|
||||
public string name {get;set;}
|
||||
|
||||
public string author {get;set;}
|
||||
public string version {get;set;}
|
||||
|
||||
public string description {get;set;}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
namespace TimelapseApi;
|
||||
|
||||
using System.Reflection;
|
||||
using Eto.Forms;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using System.IO.Compression;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class ExtensionLoader
|
||||
{
|
||||
private static GuiData? _data;
|
||||
public static GuiData Data {set{
|
||||
_data=value;
|
||||
}}
|
||||
|
||||
public static async Task InstallExtension(string path,bool add=false)
|
||||
{
|
||||
string dirTmp = Api.GetInternalFile("ExtTMP");
|
||||
if(Directory.Exists(dirTmp))
|
||||
{
|
||||
Directory.Delete(dirTmp,true);
|
||||
}
|
||||
ZipFile.ExtractToDirectory(path,dirTmp);
|
||||
var info=GetExtensionInfo(Path.Combine(dirTmp,"extension_info.json"));
|
||||
if(info != null)
|
||||
{
|
||||
Directory.CreateDirectory(Api.GetInternalFile("ExtensionInfo"));
|
||||
File.Copy(Path.Combine(dirTmp,"extension_info.json"),Api.GetInternalFile("ExtensionInfo",$"{info.name}.json"));
|
||||
Directory.Move(Path.Combine(dirTmp,"ExtTMP","extension"),Api.GetInternalFile("ExtensionBinaries",info.name));
|
||||
File.Move(Api.GetInternalFile("ExtensionBinaries",info.name,"extension.dll"),Api.GetInternalFile("ExtensionBinaries",info.name,$"{info.name}.dll"));
|
||||
|
||||
if(add)
|
||||
{
|
||||
string dir=Api.GetInternalFile("ExtensionBinaries",info.name);
|
||||
string dirname=Path.GetFileName(dir);
|
||||
string extname = Path.Combine(dir,$"{dirname}.dll");
|
||||
|
||||
var asm= Assembly.LoadFrom(extname);
|
||||
foreach(var ext in asm.GetExportedTypes())
|
||||
{
|
||||
if(ext.IsAssignableTo(typeof(TimelapseExtension)))
|
||||
{
|
||||
var ext2= (TimelapseExtension?)Activator.CreateInstance(ext);
|
||||
|
||||
if(ext2 !=null && _data != null && _data.Instance != null)
|
||||
{
|
||||
var instance=_data.Instance;
|
||||
ext2.FileName = dirname;
|
||||
ext2.Instance=instance;
|
||||
instance.Extensions.Add(ext2);
|
||||
await ext2._Create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public static ExtensionInfo? GetExtensionInfo(string filename)
|
||||
{
|
||||
if(!File.Exists(filename))
|
||||
{
|
||||
filename=Api.GetInternalFile("ExtensionInfo",$"{filename}.json");
|
||||
if(!File.Exists(filename))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return JsonConvert.DeserializeObject<ExtensionInfo>(File.ReadAllText(filename));
|
||||
}
|
||||
public static IEnumerable<TimelapseExtension> GetTimelapseExtensions()
|
||||
{
|
||||
string dirtoitterateon= Api.GetInternalFile("ExtensionBinaries");
|
||||
if(!Directory.Exists(dirtoitterateon)) yield break;
|
||||
foreach(var dir in Directory.GetDirectories(dirtoitterateon))
|
||||
{
|
||||
//get dirname
|
||||
string dirname = Path.GetFileName(dir);
|
||||
string extname = Path.Combine(dir,$"{dirname}.dll");
|
||||
|
||||
if(File.Exists(extname))
|
||||
{
|
||||
var asm= Assembly.LoadFrom(extname);
|
||||
foreach(var ext in asm.GetExportedTypes())
|
||||
{
|
||||
if(ext.IsAssignableTo(typeof(TimelapseExtension)))
|
||||
{
|
||||
var ext2= (TimelapseExtension?)Activator.CreateInstance(ext);
|
||||
|
||||
if(ext2 !=null)
|
||||
{
|
||||
ext2.FileName = dirname;
|
||||
yield return ext2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
namespace TimelapseApi;
|
||||
///<summary>
|
||||
///an empty object to use lock() { } with
|
||||
///</summary>
|
||||
public class LockObj
|
||||
{
|
||||
private LockObj()
|
||||
{
|
||||
|
||||
}
|
||||
public static LockObj Create()
|
||||
{
|
||||
return new LockObj();
|
||||
}
|
||||
public void Lock(Action a)
|
||||
{
|
||||
if(a ==null)
|
||||
return;
|
||||
lock(this)
|
||||
{
|
||||
|
||||
a();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>true</IsPackable>
|
||||
<PackageId>Tesses.TimelapseApi</PackageId>
|
||||
<Authors>Mike Nolan</Authors>
|
||||
<Company>Tesses</Company>
|
||||
<Version>1.0.0</Version>
|
||||
<AssemblyVersion>1.0.0</AssemblyVersion>
|
||||
<FileVersion>1.0.0</FileVersion>
|
||||
<Description>The api for TimelapseNow</Description>
|
||||
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<PackageTags>Camera, Timelapse, Record</PackageTags>
|
||||
<RepositoryUrl>https://gitlab.tesses.net/tesses50/timelapsenow</RepositoryUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Eto.Forms" Version="2.7.0" />
|
||||
<PackageReference Include="FlashCap" Version="1.2.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.1" />
|
||||
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,65 @@
|
|||
namespace TimelapseApi;
|
||||
|
||||
public abstract class TimelapseExtension : IDisposable
|
||||
{
|
||||
|
||||
public Api? Instance {get;internal set;}
|
||||
private class Nill : TimelapseExtension
|
||||
{
|
||||
public override string Name => "Timelapse";
|
||||
public override Guid Id => Guid.Empty;
|
||||
}
|
||||
private static Nill _null=new Nill();
|
||||
|
||||
|
||||
public static TimelapseExtension Null {get {return _null;}}
|
||||
public abstract string Name {get;}
|
||||
|
||||
public string? FileName {get;internal set;}
|
||||
|
||||
public abstract Guid Id {get;}
|
||||
|
||||
protected virtual async Task OnCreateAsync(ExtensionFeatures features)
|
||||
{
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
protected virtual void OnCreate(ExtensionFeatures features)
|
||||
{
|
||||
|
||||
}
|
||||
public string GetExtensionFolder()
|
||||
{
|
||||
string p = Api.GetInternalFile($"ExtensionData/{Id}");
|
||||
Directory.CreateDirectory(p);
|
||||
return p;
|
||||
|
||||
}
|
||||
public TimelapseFileSystem? GetProjectSpecificLocation()
|
||||
{
|
||||
if(Instance != null && Instance.Project != null && Instance.Project.ProjectLocation != null)
|
||||
{
|
||||
Instance.Project.ProjectLocation.CreateDirectory("ExtensionData");
|
||||
Instance.Project.ProjectLocation.CreateDirectory($"ExtensionData/{Id}");
|
||||
var f= Instance.Project.ProjectLocation + $"ExtensionData/{Id}";
|
||||
return new Protect(f);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
internal async Task _Create()
|
||||
{
|
||||
ExtensionFeatures features=new ExtensionFeatures(this);
|
||||
await OnCreateAsync(features);
|
||||
OnCreate(features);
|
||||
features.Close();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
OnDestroy();
|
||||
}
|
||||
protected virtual void OnDestroy()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,417 @@
|
|||
namespace TimelapseApi;
|
||||
using Eto.Forms;
|
||||
|
||||
public class Protect : TimelapseFileSystem
|
||||
{
|
||||
TimelapseFileSystem fs;
|
||||
public Protect(TimelapseFileSystem fs)
|
||||
{
|
||||
this.fs=fs;
|
||||
}
|
||||
|
||||
public override void CreateDirectory(string path)
|
||||
{
|
||||
fs.CreateDirectory(path);
|
||||
}
|
||||
|
||||
public override void DeleteDirectory(string path)
|
||||
{
|
||||
fs.DeleteDirectory(path);
|
||||
}
|
||||
|
||||
public override void DeleteFile(string path)
|
||||
{
|
||||
fs.DeleteFile(path);
|
||||
}
|
||||
|
||||
public override bool DirectoryExists(string path)
|
||||
{
|
||||
return fs.DirectoryExists(path);
|
||||
}
|
||||
|
||||
public override bool FileExists(string path)
|
||||
{
|
||||
return fs.FileExists(path);
|
||||
}
|
||||
|
||||
public override Stream Open(string path, FileMode mode, FileAccess access, FileShare share)
|
||||
{
|
||||
return fs.Open(path,mode,access,share);
|
||||
}
|
||||
|
||||
protected override IEnumerable<string> GetDirectoriesImpl(string path, string filter = "*")
|
||||
{
|
||||
foreach(var items in fs.GetDirectories(path,filter))
|
||||
{
|
||||
yield return CombinePath(path,items);
|
||||
}
|
||||
}
|
||||
public override string? ShowSaveDialog(Window parent, FileFilter[] filters, string startDir = "")
|
||||
{
|
||||
return fs.ShowSaveDialog(parent, filters, startDir);
|
||||
}
|
||||
public override string[] ShowOpenDialog(Window parent, FileFilter[] filters, bool multi, string startDir = "")
|
||||
{
|
||||
return fs.ShowOpenDialog(parent, filters, multi, startDir);
|
||||
}
|
||||
public override string? ShowDirectoryDialog(Window parent, string startDir = "")
|
||||
{
|
||||
return fs.ShowDirectoryDialog(parent,startDir);
|
||||
}
|
||||
protected override IEnumerable<string> GetFilesImpl(string path, string filter = "*")
|
||||
{
|
||||
foreach(var items in fs.GetFiles(path,filter))
|
||||
{
|
||||
yield return CombinePath(path,items);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class NativeFileSystem : TimelapseFileSystem
|
||||
{
|
||||
public override void CreateDirectory(string path)
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
public override void DeleteDirectory(string path)
|
||||
{
|
||||
Directory.Delete(path);
|
||||
}
|
||||
|
||||
public override void DeleteFile(string path)
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
|
||||
public override bool DirectoryExists(string path)
|
||||
{
|
||||
return Directory.Exists(path);
|
||||
}
|
||||
|
||||
public override bool FileExists(string path)
|
||||
{
|
||||
return File.Exists(path);
|
||||
}
|
||||
|
||||
public override Stream Open(string path, FileMode mode, FileAccess access, FileShare share)
|
||||
{
|
||||
|
||||
return File.Open(path,mode,access,share);
|
||||
}
|
||||
|
||||
protected override IEnumerable<string> GetDirectoriesImpl(string path, string filter = "*")
|
||||
{
|
||||
return Directory.EnumerateDirectories(path,filter);
|
||||
}
|
||||
public override string? ShowDirectoryDialog(Window parent, string startDir = "")
|
||||
{
|
||||
using(var d = new SelectFolderDialog())
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(startDir))
|
||||
{
|
||||
d.Directory = startDir;
|
||||
}
|
||||
return d.ShowDialog(parent) == DialogResult.Ok ? d.Directory : null;
|
||||
}
|
||||
}
|
||||
public override string[] ShowOpenDialog(Window parent, FileFilter[] filters,bool multi, string startDir = "")
|
||||
{
|
||||
using(var ofd=new OpenFileDialog())
|
||||
{
|
||||
ofd.MultiSelect = multi;
|
||||
if(!string.IsNullOrWhiteSpace(startDir))
|
||||
{
|
||||
ofd.Directory = new Uri(startDir);
|
||||
}
|
||||
foreach(var f in filters)
|
||||
{
|
||||
ofd.Filters.Add(f);
|
||||
}
|
||||
return ofd.ShowDialog(parent) == DialogResult.Ok ? ofd.Filenames.ToArray() : new string[0];
|
||||
}
|
||||
}
|
||||
public override string? ShowSaveDialog(Window parent, FileFilter[] filters, string startDir = "")
|
||||
{
|
||||
using(var sfd=new SaveFileDialog())
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(startDir))
|
||||
{
|
||||
sfd.Directory = new Uri(startDir);
|
||||
}
|
||||
foreach(var f in filters)
|
||||
{
|
||||
sfd.Filters.Add(f);
|
||||
}
|
||||
return sfd.ShowDialog(parent) == DialogResult.Ok ? sfd.FileName : null;
|
||||
}
|
||||
}
|
||||
public override void DeleteDirectory(string path, bool recursive)
|
||||
{
|
||||
Directory.Delete(path,recursive);
|
||||
}
|
||||
|
||||
protected override IEnumerable<string> GetFilesImpl(string path, string filter = "*")
|
||||
{
|
||||
return Directory.EnumerateFiles(path,filter);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class TimelapseFileSystem
|
||||
{
|
||||
public string ReadAllText(string path)
|
||||
{
|
||||
using (var s=Open(path,FileMode.Open,FileAccess.Read,FileShare.Read))
|
||||
{
|
||||
using(var sr=new StreamReader(s))
|
||||
{
|
||||
return sr.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void WriteAllText(string path,string? contents)
|
||||
{
|
||||
using (var s=Open(path,FileMode.Create,FileAccess.Write,FileShare.None))
|
||||
{
|
||||
using(var sw=new StreamWriter(s))
|
||||
{
|
||||
sw.Write(contents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string? ShowOpenDialog(Window parent,FileFilter[] filters,string startDir="")
|
||||
{
|
||||
var res=ShowOpenDialog(parent,filters,false,startDir);
|
||||
return res.Length == 1 ? res[0] : null;
|
||||
}
|
||||
public virtual string[] ShowOpenDialog(Window parent,FileFilter[] filters,bool multi,string startDir="")
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
public virtual string? ShowSaveDialog(Window parent,FileFilter[] filters,string startDir="")
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
public virtual string? ShowDirectoryDialog(Window parent,string startDir="")
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
public int GetNumberOfFiles(string path,string filter="*")
|
||||
{
|
||||
return GetFilesImpl(path,filter).Count();
|
||||
}
|
||||
public int GetNumberOfDirectories(string path,string filter="*")
|
||||
{
|
||||
return GetDirectoriesImpl(path,filter).Count();
|
||||
}
|
||||
public IEnumerable<string> GetFiles(string path,string filter="*")
|
||||
{
|
||||
foreach(var f in GetFilesImpl(path,filter))
|
||||
{
|
||||
yield return Path.GetFileName(f);
|
||||
}
|
||||
}
|
||||
public IEnumerable<string> GetDirectories(string path,string filter="*")
|
||||
{
|
||||
foreach(var f in GetDirectoriesImpl(path,filter))
|
||||
{
|
||||
yield return Path.GetFileName(f);
|
||||
}
|
||||
}
|
||||
public static string CombinePath(params string[] path)
|
||||
{
|
||||
if(path.Length==0) return "/";
|
||||
string path0=path[0];
|
||||
foreach(var p in path.Skip(1))
|
||||
{
|
||||
path0= CombinePath(path0,p);
|
||||
}
|
||||
return path0;
|
||||
}
|
||||
public abstract void DeleteFile(string path);
|
||||
|
||||
public abstract void DeleteDirectory(string path);
|
||||
|
||||
public virtual void DeleteDirectory(string path,bool recursive)
|
||||
{
|
||||
if(recursive)
|
||||
{
|
||||
foreach(var d in GetDirectories(path))
|
||||
{
|
||||
DeleteDirectory(CombinePath(path,d),recursive);
|
||||
}
|
||||
foreach(var f in GetFiles(path))
|
||||
{
|
||||
DeleteFile(CombinePath(path,f));
|
||||
}
|
||||
}
|
||||
DeleteDirectory(path);
|
||||
}
|
||||
|
||||
public abstract void CreateDirectory(string path);
|
||||
|
||||
public abstract bool FileExists(string path);
|
||||
public abstract bool DirectoryExists(string path);
|
||||
public static string CombinePath(string p1,string p2)
|
||||
{
|
||||
return Path.Combine(p1,p2).Replace(Path.DirectorySeparatorChar,'/');
|
||||
}
|
||||
|
||||
public abstract Stream Open(string path,FileMode mode,FileAccess access,FileShare share);
|
||||
protected abstract IEnumerable<string> GetFilesImpl(string path,string filter="*");
|
||||
|
||||
protected abstract IEnumerable<string> GetDirectoriesImpl(string path,string filter="*");
|
||||
public static SubFileSystem operator+(TimelapseFileSystem fs,string name)
|
||||
{
|
||||
SubFileSystem _fs=new SubFileSystem(fs,name);
|
||||
|
||||
return _fs;
|
||||
}
|
||||
}
|
||||
|
||||
public class SubFileSystem : TimelapseFileSystem
|
||||
{
|
||||
public SubFileSystem(TimelapseFileSystem fs,string name)
|
||||
{
|
||||
var _fs = fs as SubFileSystem;
|
||||
if(_fs != null)
|
||||
{
|
||||
FileSystem = _fs.FileSystem;
|
||||
CurrentDirectory = CombinePath(_fs.CurrentDirectory,name);
|
||||
|
||||
}else{
|
||||
FileSystem =fs;
|
||||
CurrentDirectory = CombinePath("/",name);
|
||||
}
|
||||
}
|
||||
public TimelapseFileSystem FileSystem {get;set;}
|
||||
public string CurrentDirectory {get;set;}
|
||||
|
||||
public override void CreateDirectory(string path)
|
||||
{
|
||||
FileSystem.CreateDirectory(CombinePath(CurrentDirectory,path));
|
||||
}
|
||||
|
||||
public override void DeleteDirectory(string path)
|
||||
{
|
||||
FileSystem.DeleteDirectory(CombinePath(CurrentDirectory,path));
|
||||
}
|
||||
|
||||
public override void DeleteFile(string path)
|
||||
{
|
||||
FileSystem.DeleteFile(CombinePath(CurrentDirectory,path));
|
||||
}
|
||||
|
||||
public override bool DirectoryExists(string path)
|
||||
{
|
||||
return FileSystem.DirectoryExists(CombinePath(CurrentDirectory,path));
|
||||
}
|
||||
|
||||
public override bool FileExists(string path)
|
||||
{
|
||||
return FileSystem.FileExists(CombinePath(CurrentDirectory,path));
|
||||
}
|
||||
|
||||
public override Stream Open(string path, FileMode mode, FileAccess access, FileShare share)
|
||||
{
|
||||
return FileSystem.Open(CombinePath(CurrentDirectory,path),mode,access,share);
|
||||
}
|
||||
|
||||
protected override IEnumerable<string> GetDirectoriesImpl(string path, string filter = "*")
|
||||
{
|
||||
foreach(var file in FileSystem.GetDirectories(CombinePath(CurrentDirectory,path),filter))
|
||||
{
|
||||
yield return Path.GetFileName(file);
|
||||
}
|
||||
}
|
||||
public override string[] ShowOpenDialog(Window parent, FileFilter[] filters, bool multi, string startDir = "")
|
||||
{
|
||||
string startDir1;
|
||||
if(string.IsNullOrWhiteSpace(startDir))
|
||||
{
|
||||
startDir1=CurrentDirectory;
|
||||
}else{
|
||||
startDir1=CombinePath(CurrentDirectory,startDir);
|
||||
}
|
||||
|
||||
var res=FileSystem.ShowOpenDialog(parent,filters,multi,startDir1);
|
||||
List<string> validUrls=new List<string>();
|
||||
foreach(var url in res)
|
||||
{
|
||||
if(url.StartsWith(CurrentDirectory))
|
||||
{
|
||||
validUrls.Add(url);
|
||||
}else
|
||||
{
|
||||
MessageBox.Show($"You can't open file \"{url}\" because it exists outside of \"{CurrentDirectory}\"",MessageBoxButtons.OK,MessageBoxType.Error);
|
||||
}
|
||||
}
|
||||
return validUrls.ToArray();
|
||||
}
|
||||
public override string? ShowSaveDialog(Window parent, FileFilter[] filters, string startDir = "")
|
||||
{
|
||||
string startDir1;
|
||||
if(string.IsNullOrWhiteSpace(startDir))
|
||||
{
|
||||
startDir1=CurrentDirectory;
|
||||
}else{
|
||||
startDir1=CombinePath(CurrentDirectory,startDir);
|
||||
}
|
||||
|
||||
var url = FileSystem.ShowSaveDialog(parent,filters,startDir1);
|
||||
if(!string.IsNullOrWhiteSpace(url) && !url.StartsWith(CurrentDirectory))
|
||||
{
|
||||
MessageBox.Show($"You can't save file \"{url}\" because it exists outside of \"{CurrentDirectory}\"",MessageBoxButtons.OK,MessageBoxType.Error);
|
||||
return null;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
public override string? ShowDirectoryDialog(Window parent, string startDir = "")
|
||||
{
|
||||
string startDir1;
|
||||
if(string.IsNullOrWhiteSpace(startDir))
|
||||
{
|
||||
startDir1=CurrentDirectory;
|
||||
}else{
|
||||
startDir1=CombinePath(CurrentDirectory,startDir);
|
||||
}
|
||||
|
||||
var url = FileSystem.ShowDirectoryDialog(parent,startDir1);
|
||||
if(!string.IsNullOrWhiteSpace(url) && !url.StartsWith(CurrentDirectory))
|
||||
{
|
||||
MessageBox.Show($"You can't open directory \"{url}\" because it exists outside of \"{CurrentDirectory}\"",MessageBoxButtons.OK,MessageBoxType.Error);
|
||||
return null;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
protected override IEnumerable<string> GetFilesImpl(string path, string filter = "*")
|
||||
{
|
||||
foreach(var file in FileSystem.GetFiles(CombinePath(CurrentDirectory,path),filter))
|
||||
{
|
||||
yield return Path.GetFileName(file);
|
||||
}
|
||||
}
|
||||
|
||||
public static SubFileSystem operator-(SubFileSystem fs,int num)
|
||||
{
|
||||
string path=fs.CurrentDirectory;
|
||||
for(int i = 0;i < num;i++)
|
||||
{
|
||||
string? p=Path.GetDirectoryName(path);
|
||||
if(string.IsNullOrWhiteSpace(p))
|
||||
{
|
||||
path="/";
|
||||
break;
|
||||
}else{
|
||||
path = p;
|
||||
}
|
||||
|
||||
}
|
||||
return new SubFileSystem(fs.FileSystem,path);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,166 @@
|
|||
using Newtonsoft.Json;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
|
||||
namespace TimelapseApi
|
||||
{
|
||||
public class TimelapseProject
|
||||
{
|
||||
public TimelapseProject()
|
||||
{
|
||||
SectionName="Default";
|
||||
Interval = TimeSpan.FromSeconds(1);
|
||||
|
||||
}
|
||||
public void Save()
|
||||
{
|
||||
if(ProjectLocation !=null)
|
||||
{
|
||||
string name=Path.GetFileName(ProjectLocation.CurrentDirectory);
|
||||
var fs2=ProjectLocation-1;
|
||||
fs2.WriteAllText($"{name}.tlnp",JsonConvert.SerializeObject(this));
|
||||
}
|
||||
}
|
||||
|
||||
public static TimelapseProject? Open(SubFileSystem fs)
|
||||
{
|
||||
TimelapseProject? proj;
|
||||
string name=Path.GetFileName(fs.CurrentDirectory);
|
||||
|
||||
SubFileSystem fs2=fs-1;
|
||||
|
||||
proj=JsonConvert.DeserializeObject<TimelapseProject>(fs2.ReadAllText($"{name}.tlnp"));
|
||||
|
||||
if(proj == null)
|
||||
{
|
||||
return proj;
|
||||
}
|
||||
|
||||
proj.ProjectLocation = fs;
|
||||
return proj;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public SubFileSystem? ProjectLocation {get;set;}
|
||||
[JsonIgnore]
|
||||
private string _SectionForFrame="";
|
||||
[JsonIgnore]
|
||||
private int _cframe;
|
||||
|
||||
[JsonIgnore]
|
||||
private int CurrentFrame {get {
|
||||
SetCFName();
|
||||
return _cframe++;
|
||||
}}
|
||||
|
||||
public int FrameCount {get {
|
||||
SetCFName();
|
||||
return _cframe;
|
||||
}}
|
||||
|
||||
[JsonIgnore]
|
||||
public DateTime LastFrameTaken {get;set;}
|
||||
|
||||
public string SectionName {get;set;}
|
||||
|
||||
public TimelapseInterval Interval {get;set;}
|
||||
|
||||
|
||||
private void SetCFName()
|
||||
{
|
||||
if(ProjectLocation == null)
|
||||
{
|
||||
_cframe=-1;
|
||||
return;
|
||||
}
|
||||
if(!SectionName.Equals(_SectionForFrame,StringComparison.Ordinal))
|
||||
{
|
||||
_SectionForFrame=SectionName;
|
||||
if(!ProjectLocation.DirectoryExists($"Sections/{SectionName}"))
|
||||
{
|
||||
ProjectLocation.CreateDirectory($"Sections/{SectionName}");
|
||||
}
|
||||
|
||||
_cframe=ProjectLocation.GetNumberOfFiles($"Sections/{SectionName}","*.png");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task Save(Image<Rgb24> img)
|
||||
{
|
||||
if(ProjectLocation == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string p=$"Sections/{SectionName}/{CurrentFrame}.png";
|
||||
if(!ProjectLocation.FileExists(p))
|
||||
{
|
||||
using(var f = ProjectLocation.Open(p,FileMode.Create,FileAccess.Write,FileShare.None))
|
||||
{
|
||||
await img.SaveAsPngAsync(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TimelapseInterval
|
||||
{
|
||||
public TimelapseInterval()
|
||||
{
|
||||
UseEstimated=false;
|
||||
EstimatedVideoLength=TimeSpan.FromSeconds(1);
|
||||
EstimatedProjectLength =TimeSpan.FromSeconds(1);
|
||||
}
|
||||
public TimelapseInterval(TimeSpan estVidLen,TimeSpan estProjLen)
|
||||
{
|
||||
UseEstimated = true;
|
||||
EstimatedVideoLength=estVidLen;
|
||||
EstimatedProjectLength=estProjLen;
|
||||
}
|
||||
public TimelapseInterval(TimeSpan interval)
|
||||
{
|
||||
UseEstimated=false;
|
||||
EstimatedVideoLength =TimeSpan.FromSeconds(1);
|
||||
EstimatedProjectLength=interval;
|
||||
}
|
||||
public bool UseEstimated {get;set;}
|
||||
|
||||
public TimeSpan EstimatedVideoLength {get;set;}
|
||||
|
||||
public TimeSpan EstimatedProjectLength {get;set;}
|
||||
|
||||
public TimeSpan GetTimeSpan()
|
||||
{
|
||||
if(UseEstimated && EstimatedProjectLength.TotalSeconds != 0.0)
|
||||
{
|
||||
|
||||
return TimeSpan.FromSeconds(EstimatedProjectLength.TotalSeconds/EstimatedVideoLength.TotalSeconds);
|
||||
}
|
||||
return EstimatedVideoLength;
|
||||
}
|
||||
|
||||
public static explicit operator double(TimelapseInterval interval)
|
||||
{
|
||||
return interval.GetTimeSpan().TotalSeconds;
|
||||
}
|
||||
public static implicit operator TimeSpan(TimelapseInterval interval)
|
||||
{
|
||||
return interval.GetTimeSpan();
|
||||
}
|
||||
public static implicit operator (TimeSpan estVidLen,TimeSpan estProjLen)(TimelapseInterval span)
|
||||
{
|
||||
return (span.EstimatedProjectLength,span.EstimatedVideoLength);
|
||||
}
|
||||
public static implicit operator TimelapseInterval(TimeSpan span)
|
||||
{
|
||||
return new TimelapseInterval(span);
|
||||
}
|
||||
|
||||
public static implicit operator TimelapseInterval((TimeSpan span1,TimeSpan span2) span)
|
||||
{
|
||||
return new TimelapseInterval(span.span1,span.span2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,247 @@
|
|||
namespace TimelapseApi;
|
||||
|
||||
using System.Diagnostics;
|
||||
using Eto.Forms;
|
||||
|
||||
internal class FrameHandlerSettingsForm : Dialog
|
||||
{
|
||||
|
||||
internal class FrameHandlerSettingsCollection
|
||||
{
|
||||
public FrameHandlerSettingsCollection(List<FrameHandlerSettings> img)
|
||||
{
|
||||
|
||||
Items=img;
|
||||
}
|
||||
|
||||
public CheckBox? OverlayEnabled {get;set;}
|
||||
public CheckBox? BlockEnabled {get;set;}
|
||||
public List<FrameHandlerSettings> Items {get;set;}
|
||||
|
||||
|
||||
}
|
||||
|
||||
internal class FrameHandlerSettings
|
||||
{
|
||||
public Guid Guid;
|
||||
CheckBox? cb;
|
||||
private bool? _chk;
|
||||
|
||||
public FrameHandlerSettings(TimelapseExtension ext,string handlerName,bool overlay,bool block)
|
||||
{
|
||||
ExtensionName=ext.Name;
|
||||
Guid=ext.Id;
|
||||
HandlerName = handlerName;
|
||||
OverlayChecked=overlay;
|
||||
BlockChecked=block;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public string HandlerName {get;set;}
|
||||
public string ExtensionName {get;set;}
|
||||
public bool OverlayChecked {get;set;}
|
||||
public bool BlockChecked {get;set;}
|
||||
}
|
||||
public FrameHandlerSettingsForm(FrameHandlerSettingsCollection col)
|
||||
{
|
||||
if(col.OverlayEnabled == null || col.BlockEnabled == null) return;
|
||||
|
||||
Width = 640;
|
||||
Height=240;
|
||||
Resizable=true;
|
||||
Title="Frame Handler Settings";
|
||||
|
||||
Button okBtn = new Button{Text="OK"};
|
||||
okBtn.Click +=(sender,e)=>{
|
||||
this.Close();
|
||||
};
|
||||
|
||||
DynamicLayout lyt=new DynamicLayout();
|
||||
GridView<FrameHandlerSettings> itemsList=new GridView<FrameHandlerSettings>();
|
||||
|
||||
itemsList.Columns.Add(new GridColumn{
|
||||
HeaderText="HandlerName",
|
||||
DataCell=new TextBoxCell("HandlerName"),
|
||||
Editable=false
|
||||
});
|
||||
|
||||
itemsList.Columns.Add(new GridColumn{
|
||||
HeaderText="Extension Name",
|
||||
DataCell=new TextBoxCell("ExtensionName"),
|
||||
Editable=false
|
||||
});
|
||||
itemsList.Columns.Add(new GridColumn{
|
||||
HeaderText="Allow Overlay",
|
||||
DataCell=new CheckBoxCell("OverlayChecked"),
|
||||
Editable=true
|
||||
});
|
||||
itemsList.Columns.Add(new GridColumn{
|
||||
HeaderText="Allow Block from Recording frame",
|
||||
DataCell=new CheckBoxCell("BlockChecked"),
|
||||
Editable=true
|
||||
});
|
||||
itemsList.DataStore=col.Items;
|
||||
|
||||
col.OverlayEnabled.Text="Allow Overlay";
|
||||
col.BlockEnabled.Text="Allow Block from Recording frame";
|
||||
lyt.BeginVertical();
|
||||
lyt.BeginHorizontal();
|
||||
lyt.Add(col.OverlayEnabled,true);
|
||||
lyt.EndBeginHorizontal();
|
||||
lyt.Add(col.BlockEnabled,true);
|
||||
lyt.EndBeginHorizontal();
|
||||
lyt.Add(itemsList,true,true);
|
||||
lyt.EndBeginHorizontal();
|
||||
lyt.Add(okBtn,true);
|
||||
lyt.EndHorizontal();
|
||||
lyt.EndVertical();
|
||||
Content=lyt;
|
||||
}
|
||||
}
|
||||
internal class TimelapseSettings : Dialog
|
||||
{
|
||||
public TimelapseSettings(Api api)
|
||||
{
|
||||
bool overLayBoxState=api.Model.canOverlayVideo;
|
||||
bool blockBoxState=api.Model.canBlockFrames;
|
||||
|
||||
List<FrameHandlerSettingsForm.FrameHandlerSettings> imgs=new List<FrameHandlerSettingsForm.FrameHandlerSettings>();
|
||||
List<TimelapseExtension> ext=new List<TimelapseExtension>();
|
||||
var coll=new FrameHandlerSettingsForm.FrameHandlerSettingsCollection(imgs);
|
||||
|
||||
foreach(var item in api._frameHandlers)
|
||||
{
|
||||
if(!ext.Contains(item.Extension))
|
||||
{
|
||||
|
||||
imgs.Add(new FrameHandlerSettingsForm.FrameHandlerSettings(item.Extension,item.HandlerName,!api.Model.deniedOverlayExtensions.Contains(item.Extension.Id),!api.Model.deniedBlockExtensions.Contains(item.Extension.Id)));
|
||||
ext.Add(item.Extension);
|
||||
}
|
||||
}
|
||||
ext.Clear();
|
||||
|
||||
Width = 320;
|
||||
Height=240;
|
||||
Title="Settings";
|
||||
Button ExtensionsFrameHandler=new Button{
|
||||
Text="Frame Handler Settings"
|
||||
};
|
||||
Button configFolder = new Button{
|
||||
Text="Configuration folder"
|
||||
};
|
||||
Button installExtension = new Button{
|
||||
Text="Install Extension"
|
||||
};
|
||||
CheckBox enableExt=new CheckBox();
|
||||
enableExt.Text="Add extensions on install";
|
||||
enableExt.Checked = api.Model.addExtensionOnInstall;
|
||||
installExtension.Click += async(sender,e)=>{
|
||||
using(var ofd=new OpenFileDialog())
|
||||
{
|
||||
ofd.MultiSelect=true;
|
||||
ofd.Filters.Add(new FileFilter("Timelapse Extension",".tle",".zip"));
|
||||
if(ofd.ShowDialog(this)==DialogResult.Ok)
|
||||
{
|
||||
foreach(var ext in ofd.Filenames)
|
||||
{
|
||||
await ExtensionLoader.InstallExtension(ext,enableExt.Checked.GetValueOrDefault());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
CheckBox enableServer = new CheckBox();
|
||||
enableServer.Text="Enable webserver";
|
||||
enableServer.Checked=api.Model.enableWebServer;
|
||||
|
||||
configFolder.Click +=(sender,e)=>{
|
||||
using(Process p=new Process()){
|
||||
p.StartInfo = new ProcessStartInfo(Api.GetInternalFile());
|
||||
p.StartInfo.UseShellExecute=true;
|
||||
p.Start();
|
||||
}
|
||||
};
|
||||
ExtensionsFrameHandler.Click +=(sender,e)=>{
|
||||
coll.OverlayEnabled=new CheckBox();
|
||||
coll.BlockEnabled=new CheckBox();
|
||||
|
||||
coll.OverlayEnabled.Checked=overLayBoxState;
|
||||
coll.BlockEnabled.Checked=blockBoxState;
|
||||
using(var img=new FrameHandlerSettingsForm(coll))
|
||||
img.ShowModal(this);
|
||||
overLayBoxState = coll.OverlayEnabled.Checked.GetValueOrDefault();
|
||||
blockBoxState = coll.BlockEnabled.Checked.GetValueOrDefault();
|
||||
|
||||
/* Console.WriteLine($"Global overlay state: {overLayBoxState}");
|
||||
Console.WriteLine($"Global block state: {blockBoxState}");
|
||||
foreach(var item in coll.Items)
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($"Extension name: {item.ExtensionName}");
|
||||
Console.WriteLine($"Handler name: {item.HandlerName}");
|
||||
Console.WriteLine($"Overlay state: {item.OverlayChecked}");
|
||||
Console.WriteLine($"Block state: {item.BlockChecked}");
|
||||
|
||||
}*/
|
||||
|
||||
};
|
||||
DynamicLayout lyt1=new DynamicLayout();
|
||||
Scrollable scrollable=new Scrollable();
|
||||
|
||||
DynamicLayout lyt2=new DynamicLayout();
|
||||
scrollable.Content=lyt2;
|
||||
lyt2.BeginVertical();
|
||||
lyt2.AddRow(ExtensionsFrameHandler);
|
||||
lyt2.AddRow(configFolder);
|
||||
|
||||
StackLayout lyt=new StackLayout();
|
||||
lyt.Orientation= Orientation.Horizontal;
|
||||
lyt.Items.Add(enableServer);
|
||||
NumericStepper stepper=new NumericStepper();
|
||||
stepper.MinValue=0;
|
||||
stepper.MaxValue=65535;
|
||||
stepper.Value = api.Model.timelapsePort;
|
||||
lyt.Items.Add(stepper);
|
||||
lyt2.AddRow(lyt);
|
||||
lyt2.AddRow(installExtension);
|
||||
lyt2.AddRow(enableExt);
|
||||
lyt2.AddRow(null);
|
||||
lyt2.EndVertical();
|
||||
|
||||
lyt1.BeginVertical();
|
||||
lyt1.BeginHorizontal();
|
||||
lyt1.Add(scrollable,true,true);
|
||||
|
||||
Button saveBtn = new Button {Text="Save"};
|
||||
saveBtn.Click += (sender,e)=>{
|
||||
api.Model.canBlockFrames=blockBoxState;
|
||||
api.Model.canOverlayVideo=overLayBoxState;
|
||||
|
||||
api.Model.deniedBlockExtensions.Clear();
|
||||
api.Model.deniedOverlayExtensions.Clear();
|
||||
api.Model.enableWebServer=enableServer.Checked.GetValueOrDefault();
|
||||
api.Model.timelapsePort=(ushort)stepper.Value;
|
||||
api.Model.addExtensionOnInstall = enableExt.Checked.GetValueOrDefault();
|
||||
foreach(var item in coll.Items)
|
||||
{
|
||||
if(!item.OverlayChecked)
|
||||
{
|
||||
api.Model.deniedOverlayExtensions.Add(item.Guid);
|
||||
}
|
||||
if(!item.BlockChecked)
|
||||
{
|
||||
api.Model.deniedBlockExtensions.Add(item.Guid);
|
||||
}
|
||||
|
||||
}
|
||||
api.SaveModel();
|
||||
};
|
||||
|
||||
lyt1.EndBeginHorizontal();
|
||||
lyt1.Add(saveBtn,true);
|
||||
lyt1.EndHorizontal();
|
||||
lyt1.EndVertical();
|
||||
|
||||
this.Content=lyt1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
namespace TimelapseApi;
|
||||
|
||||
public class TimelapseSettingsModel
|
||||
{
|
||||
public TimelapseSettingsModel()
|
||||
{
|
||||
canOverlayVideo=true;
|
||||
deniedOverlayExtensions=new List<Guid>();
|
||||
deniedBlockExtensions=new List<Guid>();
|
||||
enableWebServer=false;
|
||||
timelapsePort=49290;
|
||||
canBlockFrames=true;
|
||||
addExtensionOnInstall=true;
|
||||
|
||||
}
|
||||
public bool addExtensionOnInstall {get;set;}
|
||||
public bool canOverlayVideo {get;set;}
|
||||
public bool canBlockFrames {get;set;}
|
||||
public List<Guid> deniedOverlayExtensions {get;set;}
|
||||
public List<Guid> deniedBlockExtensions {get;set;}
|
||||
public bool enableWebServer {get;set;}
|
||||
public ushort timelapsePort {get;set;}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
namespace TimelapseApi;
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
|
||||
public class VideoFileCreator : IAsyncDisposable, IDisposable
|
||||
{
|
||||
Process? p;
|
||||
Stream? iStrm;
|
||||
string output;
|
||||
double fps_src;
|
||||
double fps_dest;
|
||||
bool open;
|
||||
|
||||
public bool OpenResult {get;private set;}
|
||||
public VideoFileCreator(string path,double fps_src=10,double fps_dest=30,bool autoOpen=true)
|
||||
{
|
||||
this.fps_src=fps_src;
|
||||
this.fps_dest =fps_dest;
|
||||
output = path;
|
||||
this.open=false;
|
||||
if(autoOpen)
|
||||
{
|
||||
Open();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Open()
|
||||
{
|
||||
if(open)
|
||||
{
|
||||
return OpenResult;
|
||||
}
|
||||
p=new Process();
|
||||
p.StartInfo=new ProcessStartInfo("ffmpeg",$"-f image2pipe -framerate {fps_src} -i - -c:v libx264 -vf format=yuv420p -r {fps_dest} -movflags +faststart \"{output}\"") {UseShellExecute=false,RedirectStandardInput=true,CreateNoWindow=true,WindowStyle=ProcessWindowStyle.Hidden};
|
||||
var r=p.Start();
|
||||
if(r)
|
||||
{
|
||||
iStrm = p.StandardInput.BaseStream;
|
||||
}
|
||||
open=true;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
public void Add(byte[] data)
|
||||
{
|
||||
if(iStrm != null)
|
||||
{
|
||||
|
||||
iStrm.Write(data,0,data.Length);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
public async Task AddAsync(byte[] data)
|
||||
{
|
||||
if(iStrm != null)
|
||||
{
|
||||
|
||||
await iStrm.WriteAsync(data,0,data.Length);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
public void Add(string file)
|
||||
{
|
||||
if(iStrm != null)
|
||||
{
|
||||
byte[] data=File.ReadAllBytes(file);
|
||||
iStrm.Write(data,0,data.Length);
|
||||
}
|
||||
}
|
||||
public async Task AddAsync(string file)
|
||||
{
|
||||
if(iStrm != null)
|
||||
{
|
||||
byte[] data=await File.ReadAllBytesAsync(file);
|
||||
await iStrm.WriteAsync(data,0,data.Length);
|
||||
}
|
||||
}
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
if(iStrm!= null)
|
||||
{
|
||||
await iStrm.DisposeAsync();
|
||||
}
|
||||
if(p != null)
|
||||
{
|
||||
await p.WaitForExitAsync();
|
||||
p.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if(iStrm!= null)
|
||||
{
|
||||
iStrm.Dispose();
|
||||
}
|
||||
if(p != null)
|
||||
{
|
||||
p.WaitForExit();
|
||||
p.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 857 B |
Loading…
Reference in New Issue