From 85cb254045317d4e3e576175d5296a1e30517b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enner=20P=C3=A9rez?= Date: Tue, 26 Dec 2017 04:18:54 -0400 Subject: [PATCH] Normalization --- CHANGELOG.md | 9 + CameraToolkit/CameraToolkit.csproj | 35 +++- CameraToolkit/Forms/FormAbout.cs | 32 ++-- CameraToolkit/Forms/FormAbout.designer.cs | 15 +- CameraToolkit/Forms/FormAbout.es.resx | 3 + CameraToolkit/Forms/FormAbout.resx | 35 +++- CameraToolkit/Forms/FormMain.Designer.cs | 27 +-- CameraToolkit/Forms/FormMain.cs | 80 ++++----- CameraToolkit/Forms/FormMain.es.resx | 2 +- CameraToolkit/Forms/FormMain.resx | 16 +- CameraToolkit/Forms/FormSettings.cs | 14 +- CameraToolkit/Messages.Designer.cs | 78 ++++---- CameraToolkit/Messages.es.resx | 12 +- CameraToolkit/Messages.resx | 12 +- CameraToolkit/Program.cs | 76 ++++---- CameraToolkit/Properties/AssemblyInfo.cs | 6 +- .../Properties/Resources.Designer.cs | 30 ++-- CameraToolkit/Properties/Settings.Designer.cs | 10 +- CameraToolkit/References.cs | 167 +++++++++++------- CameraToolkit/app.config | 53 +++--- CameraToolkit/packages.config | 15 +- README.md | 4 +- Toolkit.sln | 2 +- 23 files changed, 449 insertions(+), 284 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 585046c..ca9e4a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [1.0.8] +### Changed +- Camera tile view fix +- Missing translations +- Moved to .NET 4.6.2 + +### Added +- Automatic update checker + ## [1.0.7] ### Changed - Minors bugs fixes diff --git a/CameraToolkit/CameraToolkit.csproj b/CameraToolkit/CameraToolkit.csproj index bfcc8c5..2caa382 100644 --- a/CameraToolkit/CameraToolkit.csproj +++ b/CameraToolkit/CameraToolkit.csproj @@ -10,10 +10,26 @@ Properties Toolkit CameraToolkit - v4.0 + v4.6.2 512 + false + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true AnyCPU @@ -24,6 +40,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -33,6 +50,7 @@ TRACE prompt 4 + false App.ico @@ -53,12 +71,16 @@ ..\packages\AForge.Video.DirectShow.2.2.5\lib\AForge.Video.DirectShow.dll True + + ..\packages\Octokit.0.28.0\lib\net45\Octokit.dll + ..\packages\System.Drawing.Pictograms.1.1.15.0\lib\net40\System.Drawing.Pictograms.dll True + ..\packages\System.Windows.Forms.Pictograms.1.1.15.0\lib\net40\System.Windows.Forms.Pictograms.dll True @@ -126,7 +148,7 @@ Messages.resx - ResXFileCodeGenerator + PublicResXFileCodeGenerator Messages.Designer.cs @@ -160,10 +182,17 @@ + + + False + .NET Framework 3.5 SP1 + false + + - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. diff --git a/CameraToolkit/Forms/FormAbout.cs b/CameraToolkit/Forms/FormAbout.cs index a6af4ca..5468e51 100644 --- a/CameraToolkit/Forms/FormAbout.cs +++ b/CameraToolkit/Forms/FormAbout.cs @@ -1,10 +1,7 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; +using System.Diagnostics; using System.Drawing; using System.Reflection; -using System.Text; using System.Windows.Forms; namespace Toolkit.Forms @@ -15,30 +12,41 @@ public FormAbout() { InitializeComponent(); - Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetEntryAssembly().Location); + Icon = Icon.ExtractAssociatedIcon(Assembly.GetEntryAssembly().Location); labelAbout.Text = string.Format(labelAbout.Text, ApplicationInfo.Description, ApplicationInfo.Version.ToString(), - ApplicationInfo.CopyrightHolder); + ApplicationInfo.Copyright); richTextBoxChangeLog.Text = System.Text.Encoding.UTF8.GetString(Properties.Resources.CHANGELOG); richTextBoxLicense.Text = System.Text.Encoding.UTF8.GetString(Properties.Resources.LICENSE); - pictureBoxIcon.Image = Icon.ToBitmap(); + linkLabelWeb.Text = GitHubInfo.Repo; + buttonUpdate.Visible = (GitHubInfo.LatestRelease != null && (GitHubInfo.LatestRelease.GetVersion() > ApplicationInfo.Version)); + pictureBoxIcon.Image = Icon.ToBitmap(); } - private void buttonClose_Click(object sender, EventArgs e) + private void ButtonClose_Click(object sender, EventArgs e) { this.Close(); } - private void linkLabelWeb_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + private void LinkLabelWeb_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - System.Diagnostics.Process.Start((sender as LinkLabel).Text); + Process.Start((sender as LinkLabel).Text); } - + private void ButtonUpdate_Click(object sender, EventArgs e) + { + Process.Start(GitHubInfo.Repo); + } + + private async void FormAbout_Load(object sender, EventArgs e) + { + if (GitHubInfo.LatestRelease == null) await GitHubInfo.GetLatestReleaseAsync(); + buttonUpdate.Visible = (GitHubInfo.LatestRelease != null && (GitHubInfo.LatestRelease.GetVersion() > ApplicationInfo.Version)); + } } -} +} \ No newline at end of file diff --git a/CameraToolkit/Forms/FormAbout.designer.cs b/CameraToolkit/Forms/FormAbout.designer.cs index 3f1ad49..313291e 100644 --- a/CameraToolkit/Forms/FormAbout.designer.cs +++ b/CameraToolkit/Forms/FormAbout.designer.cs @@ -38,6 +38,7 @@ private void InitializeComponent() this.tabPageLog = new System.Windows.Forms.TabPage(); this.tabPageLicense = new System.Windows.Forms.TabPage(); this.richTextBoxLicense = new System.Windows.Forms.RichTextBox(); + this.buttonUpdate = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxIcon)).BeginInit(); this.tabControl1.SuspendLayout(); this.tabPageLog.SuspendLayout(); @@ -49,7 +50,7 @@ private void InitializeComponent() resources.ApplyResources(this.buttonClose, "buttonClose"); this.buttonClose.Name = "buttonClose"; this.buttonClose.UseVisualStyleBackColor = true; - this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click); + this.buttonClose.Click += new System.EventHandler(this.ButtonClose_Click); // // labelAbout // @@ -75,7 +76,7 @@ private void InitializeComponent() this.linkLabelWeb.LinkColor = System.Drawing.SystemColors.HotTrack; this.linkLabelWeb.Name = "linkLabelWeb"; this.linkLabelWeb.TabStop = true; - this.linkLabelWeb.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelWeb_LinkClicked); + this.linkLabelWeb.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelWeb_LinkClicked); // // tabControl1 // @@ -105,6 +106,13 @@ private void InitializeComponent() this.richTextBoxLicense.Name = "richTextBoxLicense"; this.richTextBoxLicense.ReadOnly = true; // + // buttonUpdate + // + resources.ApplyResources(this.buttonUpdate, "buttonUpdate"); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click); + // // FormAbout // resources.ApplyResources(this, "$this"); @@ -113,6 +121,7 @@ private void InitializeComponent() this.Controls.Add(this.linkLabelWeb); this.Controls.Add(this.pictureBoxIcon); this.Controls.Add(this.labelAbout); + this.Controls.Add(this.buttonUpdate); this.Controls.Add(this.buttonClose); this.DoubleBuffered = true; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; @@ -121,6 +130,7 @@ private void InitializeComponent() this.Name = "FormAbout"; this.ShowInTaskbar = false; this.TopMost = true; + this.Load += new System.EventHandler(this.FormAbout_Load); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxIcon)).EndInit(); this.tabControl1.ResumeLayout(false); this.tabPageLog.ResumeLayout(false); @@ -141,5 +151,6 @@ private void InitializeComponent() private System.Windows.Forms.TabPage tabPageLog; private System.Windows.Forms.TabPage tabPageLicense; private System.Windows.Forms.RichTextBox richTextBoxLicense; + private System.Windows.Forms.Button buttonUpdate; } } \ No newline at end of file diff --git a/CameraToolkit/Forms/FormAbout.es.resx b/CameraToolkit/Forms/FormAbout.es.resx index 8c96d0d..a1dcfc2 100644 --- a/CameraToolkit/Forms/FormAbout.es.resx +++ b/CameraToolkit/Forms/FormAbout.es.resx @@ -749,4 +749,7 @@ Acerca de... + + Act&ualizar + \ No newline at end of file diff --git a/CameraToolkit/Forms/FormAbout.resx b/CameraToolkit/Forms/FormAbout.resx index a3de32e..93312cc 100644 --- a/CameraToolkit/Forms/FormAbout.resx +++ b/CameraToolkit/Forms/FormAbout.resx @@ -145,7 +145,7 @@ $this - 4 + 5 True @@ -364,6 +364,39 @@ 0 + + Bottom, Right + + + NoControl + + + 456, 403 + + + 75, 26 + + + 0 + + + &Update + + + False + + + buttonUpdate + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 4 + True diff --git a/CameraToolkit/Forms/FormMain.Designer.cs b/CameraToolkit/Forms/FormMain.Designer.cs index 07084df..44e2eab 100644 --- a/CameraToolkit/Forms/FormMain.Designer.cs +++ b/CameraToolkit/Forms/FormMain.Designer.cs @@ -64,13 +64,13 @@ private void InitializeComponent() this.contextMenuStripImage.Name = "contextMenuStripImage"; this.helpProviderMain.SetShowHelp(this.contextMenuStripImage, ((bool)(resources.GetObject("contextMenuStripImage.ShowHelp")))); resources.ApplyResources(this.contextMenuStripImage, "contextMenuStripImage"); - this.contextMenuStripImage.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripImage_Opening); + this.contextMenuStripImage.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripImage_Opening); // // toolStripMenuItemCopy // this.toolStripMenuItemCopy.Name = "toolStripMenuItemCopy"; resources.ApplyResources(this.toolStripMenuItemCopy, "toolStripMenuItemCopy"); - this.toolStripMenuItemCopy.Click += new System.EventHandler(this.copyToolStripMenuItem_Click); + this.toolStripMenuItemCopy.Click += new System.EventHandler(this.CopyToolStripMenuItem_Click); // // toolStripMenu // @@ -110,7 +110,7 @@ private void InitializeComponent() // resources.ApplyResources(this.toolStripMenuDisconnectItem, "toolStripMenuDisconnectItem"); this.toolStripMenuDisconnectItem.Name = "toolStripMenuDisconnectItem"; - this.toolStripMenuDisconnectItem.Click += new System.EventHandler(this.toolStripMenuItemDisconnect_Click); + this.toolStripMenuDisconnectItem.Click += new System.EventHandler(this.ToolStripMenuItemDisconnect_Click); // // toolStripSeparator2 // @@ -129,7 +129,7 @@ private void InitializeComponent() this.toolStripButtonCapture.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButtonCapture.Margin = new System.Windows.Forms.Padding(0); this.toolStripButtonCapture.Name = "toolStripButtonCapture"; - this.toolStripButtonCapture.Click += new System.EventHandler(this.toolStripButtonCapture_Click); + this.toolStripButtonCapture.Click += new System.EventHandler(this.ToolStripButtonCapture_Click); // // toolStripButtonSave // @@ -137,7 +137,7 @@ private void InitializeComponent() this.toolStripButtonSave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButtonSave.Margin = new System.Windows.Forms.Padding(0); this.toolStripButtonSave.Name = "toolStripButtonSave"; - this.toolStripButtonSave.Click += new System.EventHandler(this.toolStripButtonSave_Click); + this.toolStripButtonSave.Click += new System.EventHandler(this.ToolStripButtonSave_Click); // // toolStripButtonFolder // @@ -146,7 +146,7 @@ private void InitializeComponent() this.toolStripButtonFolder.Margin = new System.Windows.Forms.Padding(0); this.toolStripButtonFolder.Name = "toolStripButtonFolder"; this.toolStripButtonFolder.Visible = global::Toolkit.Properties.Settings.Default.AutoSave; - this.toolStripButtonFolder.Click += new System.EventHandler(this.toolStripButtonFolder_Click); + this.toolStripButtonFolder.Click += new System.EventHandler(this.ToolStripButtonFolder_Click); // // toolStripButtonClose // @@ -155,7 +155,7 @@ private void InitializeComponent() this.toolStripButtonClose.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButtonClose.Margin = new System.Windows.Forms.Padding(0); this.toolStripButtonClose.Name = "toolStripButtonClose"; - this.toolStripButtonClose.Click += new System.EventHandler(this.toolStripButtonClose_Click); + this.toolStripButtonClose.Click += new System.EventHandler(this.ToolStripButtonClose_Click); // // toolStripButtonAbout // @@ -164,7 +164,7 @@ private void InitializeComponent() this.toolStripButtonAbout.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButtonAbout.Margin = new System.Windows.Forms.Padding(0); this.toolStripButtonAbout.Name = "toolStripButtonAbout"; - this.toolStripButtonAbout.Click += new System.EventHandler(this.toolStripButtonAbout_Click); + this.toolStripButtonAbout.Click += new System.EventHandler(this.ToolStripButtonAbout_Click); // // toolStripButtonSettings // @@ -182,13 +182,13 @@ private void InitializeComponent() // this.toolStripMenuItemCamera.Name = "toolStripMenuItemCamera"; resources.ApplyResources(this.toolStripMenuItemCamera, "toolStripMenuItemCamera"); - this.toolStripMenuItemCamera.Click += new System.EventHandler(this.toolStripMenuItemCamera_Click); + this.toolStripMenuItemCamera.Click += new System.EventHandler(this.ToolStripMenuItemCamera_Click); // // toolStripMenuItemSystem // this.toolStripMenuItemSystem.Name = "toolStripMenuItemSystem"; resources.ApplyResources(this.toolStripMenuItemSystem, "toolStripMenuItemSystem"); - this.toolStripMenuItemSystem.Click += new System.EventHandler(this.toolStripMenuItemSystem_Click); + this.toolStripMenuItemSystem.Click += new System.EventHandler(this.ToolStripMenuItemSystem_Click); // // toolStripSeparator1 // @@ -201,19 +201,19 @@ private void InitializeComponent() this.toolStripButtonGallery.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButtonGallery.Margin = new System.Windows.Forms.Padding(0); this.toolStripButtonGallery.Name = "toolStripButtonGallery"; - this.toolStripButtonGallery.Click += new System.EventHandler(this.toolStripButtonGallery_Click); + this.toolStripButtonGallery.Click += new System.EventHandler(this.ToolStripButtonGallery_Click); // // saveFileDialogMain // this.saveFileDialogMain.DefaultExt = "jpg"; resources.ApplyResources(this.saveFileDialogMain, "saveFileDialogMain"); - this.saveFileDialogMain.FileOk += new System.ComponentModel.CancelEventHandler(this.saveFileDialogMain_FileOk); + this.saveFileDialogMain.FileOk += new System.ComponentModel.CancelEventHandler(this.SaveFileDialogMain_FileOk); // // panelCamera // + resources.ApplyResources(this.panelCamera, "panelCamera"); this.panelCamera.ContextMenuStrip = this.contextMenuStripImage; this.panelCamera.Controls.Add(this.labelPreview); - resources.ApplyResources(this.panelCamera, "panelCamera"); this.panelCamera.Name = "panelCamera"; this.helpProviderMain.SetShowHelp(this.panelCamera, ((bool)(resources.GetObject("panelCamera.ShowHelp")))); // @@ -231,6 +231,7 @@ private void InitializeComponent() // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.SystemColors.Window; this.Controls.Add(this.panelCamera); this.Controls.Add(this.toolStripMenu); this.Name = "FormMain"; diff --git a/CameraToolkit/Forms/FormMain.cs b/CameraToolkit/Forms/FormMain.cs index a4f9d61..fcdc5f8 100644 --- a/CameraToolkit/Forms/FormMain.cs +++ b/CameraToolkit/Forms/FormMain.cs @@ -8,6 +8,7 @@ using System.Drawing.Pictograms; using System.IO; using System.Linq; +using System.Reflection; using System.Windows.Forms; using System.Windows.Forms.Pictograms; @@ -46,18 +47,15 @@ public FormMain() #if DEBUG FormHelper.ExtractResources(toolStripMenu); #endif - } - private bool IsRunning() { return VideSource != null && VideSource.IsRunning; } - private void item_Click(object sender, EventArgs e) + private void Item_Click(object sender, EventArgs e) { - toolStripMenuDisconnectItem.PerformClick(); Moniker = (sender as ToolStripMenuItem).Tag.ToString(); @@ -74,14 +72,13 @@ private void item_Click(object sender, EventArgs e) try { VideSource = new VideoCaptureDevice(Moniker); - VideSource.NewFrame += new NewFrameEventHandler(captureFrame); + VideSource.NewFrame += new NewFrameEventHandler(CaptureFrame); VideSource.Start(); toolStripMenuDisconnectItem.Enabled = IsRunning(); if (Properties.Settings.Default.AskAlbumName) - Program.ShowInputDialog(ref Program.albumName, Messages.AlbumName); - + Program.ShowInputDialog(ref Program.albumName, "Album"); } catch (Exception ex) { @@ -94,8 +91,6 @@ private void item_Click(object sender, EventArgs e) toolStripButtonCapture.Enabled = IsRunning(); toolStripButtonSave.Enabled = IsRunning(); - - } public string DeviceName { get; set; } @@ -104,21 +99,22 @@ private void item_Click(object sender, EventArgs e) #region Clipboard - private void copyToolStripMenuItem_Click(object sender, EventArgs e) + private void CopyToolStripMenuItem_Click(object sender, EventArgs e) { if (panelCamera.BackgroundImage != null) Clipboard.SetImage(panelCamera.BackgroundImage); } - private void contextMenuStripImage_Opening(object sender, CancelEventArgs e) + private void ContextMenuStripImage_Opening(object sender, CancelEventArgs e) { toolStripMenuItemCopy.Enabled = panelCamera.BackgroundImage != null; } - #endregion + #endregion Clipboard private bool paused; - private void captureFrame(object sender, NewFrameEventArgs eventArgs) + + private void CaptureFrame(object sender, NewFrameEventArgs eventArgs) { if (!paused) { @@ -127,33 +123,35 @@ private void captureFrame(object sender, NewFrameEventArgs eventArgs) } } - private void FormViewer_Shown(object sender, EventArgs e) + private async void FormViewer_Shown(object sender, EventArgs e) { ToolStripMenuItem defaultDevice = null; - foreach (var item in Program.getDevices()) + foreach (var item in Program.GetDevices()) { - var _item = new ToolStripMenuItem(item.Value); - _item.Tag = item.Key; - _item.Click += item_Click; + var _item = new ToolStripMenuItem(item.Value) + { + Tag = item.Key + }; + _item.Click += Item_Click; _item.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.videocam, 48, toolStripMenu.BackColor); toolStripButtonDevices.DropDownItems.Add(_item); if (Properties.Settings.Default.AutoStart && item.Key == Properties.Settings.Default.DefaultDevice) defaultDevice = _item; - } if (defaultDevice != null) defaultDevice.PerformClick(); - + await GitHubInfo.CheckForUpdateAsync(); } + private void FormViewer_FormClosing(object sender, FormClosingEventArgs e) { toolStripMenuDisconnectItem.PerformClick(); } - private void saveFileDialogMain_FileOk(object sender, CancelEventArgs e) + private void SaveFileDialogMain_FileOk(object sender, CancelEventArgs e) { if (IsRunning()) { @@ -175,18 +173,19 @@ private void saveFileDialogMain_FileOk(object sender, CancelEventArgs e) #region ToolStrip - private void toolStripButtonCapture_Click(object sender, EventArgs e) + private void ToolStripButtonCapture_Click(object sender, EventArgs e) { if (IsRunning()) paused = !paused; toolStripButtonCapture.Checked = paused; } - private void toolStripMenuItemDisconnect_Click(object sender, EventArgs e) + + private void ToolStripMenuItemDisconnect_Click(object sender, EventArgs e) { if (IsRunning()) { VideSource.SignalToStop(); - VideSource.NewFrame -= new NewFrameEventHandler(captureFrame); + VideSource.NewFrame -= new NewFrameEventHandler(CaptureFrame); VideSource = null; panelCamera.BackgroundImage = null; } @@ -207,14 +206,12 @@ private void toolStripMenuItemDisconnect_Click(object sender, EventArgs e) toolStripMenuDisconnectItem.Enabled = IsRunning(); Program.albumName = string.Empty; - } - private void toolStripButtonSave_Click(object sender, EventArgs e) + private void ToolStripButtonSave_Click(object sender, EventArgs e) { if (IsRunning()) { - var i = 1; string filename = string.Empty; @@ -235,14 +232,13 @@ private void toolStripButtonSave_Click(object sender, EventArgs e) if (Properties.Settings.Default.AutoSave && !string.IsNullOrEmpty(Properties.Settings.Default.DefaultPath) && Directory.Exists(Properties.Settings.Default.DefaultPath)) - saveFileDialogMain_FileOk(sender, new CancelEventArgs()); + SaveFileDialogMain_FileOk(sender, new CancelEventArgs()); else saveFileDialogMain.ShowDialog(); - } } - private void toolStripButtonFolder_Click(object sender, EventArgs e) + private void ToolStripButtonFolder_Click(object sender, EventArgs e) { // Settings if (string.IsNullOrEmpty(Properties.Settings.Default.DefaultPath) || @@ -253,40 +249,38 @@ private void toolStripButtonFolder_Click(object sender, EventArgs e) Properties.Settings.Default.Save(); MessageBox.Show(Toolkit.Messages.PathNotFound, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); - } else System.Diagnostics.Process.Start(Properties.Settings.Default.DefaultPath); - } - private void toolStripButtonGallery_Click(object sender, EventArgs e) - { + private void ToolStripButtonGallery_Click(object sender, EventArgs e) + { } - private void toolStripMenuItemCamera_Click(object sender, EventArgs e) + private void ToolStripMenuItemCamera_Click(object sender, EventArgs e) { if (IsRunning()) VideSource.DisplayPropertyPage(this.Handle); } - private void toolStripMenuItemSystem_Click(object sender, EventArgs e) + + private void ToolStripMenuItemSystem_Click(object sender, EventArgs e) { var child = new FormSettings(); child.ShowDialog(); } - private void toolStripButtonAbout_Click(object sender, EventArgs e) + + private void ToolStripButtonAbout_Click(object sender, EventArgs e) { var child = new FormAbout(); child.ShowDialog(); } - private void toolStripButtonClose_Click(object sender, EventArgs e) + + private void ToolStripButtonClose_Click(object sender, EventArgs e) { Close(); } - #endregion - + #endregion ToolStrip } -} - - +} \ No newline at end of file diff --git a/CameraToolkit/Forms/FormMain.es.resx b/CameraToolkit/Forms/FormMain.es.resx index 464587e..bfbeece 100644 --- a/CameraToolkit/Forms/FormMain.es.resx +++ b/CameraToolkit/Forms/FormMain.es.resx @@ -241,7 +241,7 @@ - &Capturar + Ca&pturar diff --git a/CameraToolkit/Forms/FormMain.resx b/CameraToolkit/Forms/FormMain.resx index f4524ac..10e6415 100644 --- a/CameraToolkit/Forms/FormMain.resx +++ b/CameraToolkit/Forms/FormMain.resx @@ -233,7 +233,7 @@ 48, 48 - &Capture + Ca&pture False @@ -451,6 +451,9 @@ 304, 17 + + Stretch + Fill @@ -510,7 +513,7 @@ To start capturing panelCamera - System.Windows.Forms.BufferedPanel, CameraToolkit, Version=1.0.6208.1671, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.BufferedPanel, CameraToolkit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null $this @@ -530,9 +533,6 @@ To start capturing Segoe UI, 9.75pt - - NoControl - 3, 4, 3, 4 @@ -662,4 +662,10 @@ To start capturing System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + &Copy + + + &Disconnect + \ No newline at end of file diff --git a/CameraToolkit/Forms/FormSettings.cs b/CameraToolkit/Forms/FormSettings.cs index 2596373..ae9b934 100644 --- a/CameraToolkit/Forms/FormSettings.cs +++ b/CameraToolkit/Forms/FormSettings.cs @@ -1,10 +1,5 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Drawing; -using System.Linq; -using System.Text; using System.Windows.Forms; namespace Toolkit.Forms @@ -16,16 +11,15 @@ public FormSettings() InitializeComponent(); Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetEntryAssembly().Location); - + comboBoxDevices.DisplayMember = "Value"; comboBoxDevices.ValueMember = "Key"; - comboBoxDevices.DataSource = new BindingSource(Program.getDevices(), null); + comboBoxDevices.DataSource = new BindingSource(Program.GetDevices(), null); comboBoxDevices.DataBindings.Add("Enabled", checkBoxAutoStart, "Checked"); textBoxAutoSavePath.DataBindings.Add("Enabled", checkBoxAutoSave, "Checked"); buttonExamine.DataBindings.Add("Enabled", checkBoxAutoSave, "Checked"); checkBoxAlbumName.DataBindings.Add("Enabled", checkBoxAutoSave, "Checked"); - } private void buttonExamine_Click(object sender, EventArgs e) @@ -37,7 +31,6 @@ private void buttonExamine_Click(object sender, EventArgs e) private void buttonAccept_Click(object sender, EventArgs e) { - if (checkBoxAutoSave.Checked && !System.IO.Directory.Exists(textBoxAutoSavePath.Text)) { var question = MessageBox.Show(Toolkit.Messages.PathNotFoundAndCreate, Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question); @@ -75,6 +68,5 @@ private void FormSettings_Load(object sender, EventArgs e) if (!string.IsNullOrEmpty(Properties.Settings.Default.DefaultDevice) && comboBoxDevices.Items.Count > 0) comboBoxDevices.SelectedValue = Properties.Settings.Default.DefaultDevice; } - } -} +} \ No newline at end of file diff --git a/CameraToolkit/Messages.Designer.cs b/CameraToolkit/Messages.Designer.cs index d351978..f5c3d56 100644 --- a/CameraToolkit/Messages.Designer.cs +++ b/CameraToolkit/Messages.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// Este código fue generado por una herramienta. -// Versión de runtime:4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si -// se vuelve a generar el código. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -13,16 +13,16 @@ namespace Toolkit { /// - /// Clase de recurso fuertemente tipado, para buscar cadenas traducidas, etc. + /// A strongly-typed resource class, for looking up localized strings, etc. /// - // StronglyTypedResourceBuilder generó automáticamente esta clase - // a través de una herramienta como ResGen o Visual Studio. - // Para agregar o quitar un miembro, edite el archivo .ResX y, a continuación, vuelva a ejecutar ResGen - // con la opción /str o recompile su proyecto de VS. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Messages { + public class Messages { private static global::System.Resources.ResourceManager resourceMan; @@ -33,10 +33,10 @@ internal Messages() { } /// - /// Devuelve la instancia de ResourceManager almacenada en caché utilizada por esta clase. + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Toolkit.Messages", typeof(Messages).Assembly); @@ -47,11 +47,11 @@ internal Messages() { } /// - /// Reemplaza la propiedad CurrentUICulture del subproceso actual para todas las - /// búsquedas de recursos mediante esta clase de recurso fuertemente tipado. + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + public static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -61,54 +61,72 @@ internal Messages() { } /// - /// Busca una cadena traducida similar a Album name. + /// Looks up a localized string similar to &Cancel. /// - internal static string AlbumName { + public static string Cancel { get { - return ResourceManager.GetString("AlbumName", resourceCulture); + return ResourceManager.GetString("Cancel", resourceCulture); } } /// - /// Busca una cadena traducida similar a &Cancel. + /// Looks up a localized string similar to Do you want to exit without saving changes?. /// - internal static string Cancel { + public static string ConfirmExit { get { - return ResourceManager.GetString("Cancel", resourceCulture); + return ResourceManager.GetString("ConfirmExit", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Do you want to save current file?. + /// + public static string ConfirmSave { + get { + return ResourceManager.GetString("ConfirmSave", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to New version {VERSION} is available. Do you want to download now?. + /// + public static string NewVersion { + get { + return ResourceManager.GetString("NewVersion", resourceCulture); } } /// - /// Busca una cadena traducida similar a &OK. + /// Looks up a localized string similar to &OK. /// - internal static string OK { + public static string OK { get { return ResourceManager.GetString("OK", resourceCulture); } } /// - /// Busca una cadena traducida similar a The selected path is invalid.. + /// Looks up a localized string similar to The selected path is invalid.. /// - internal static string PathInvalid { + public static string PathInvalid { get { return ResourceManager.GetString("PathInvalid", resourceCulture); } } /// - /// Busca una cadena traducida similar a The selected path don't exist anymore.. + /// Looks up a localized string similar to The selected path don't exist anymore.. /// - internal static string PathNotFound { + public static string PathNotFound { get { return ResourceManager.GetString("PathNotFound", resourceCulture); } } /// - /// Busca una cadena traducida similar a The selected path don't exist, do you want to create?. + /// Looks up a localized string similar to The selected path don't exist, do you want to create?. /// - internal static string PathNotFoundAndCreate { + public static string PathNotFoundAndCreate { get { return ResourceManager.GetString("PathNotFoundAndCreate", resourceCulture); } diff --git a/CameraToolkit/Messages.es.resx b/CameraToolkit/Messages.es.resx index ac8e78f..87f2737 100644 --- a/CameraToolkit/Messages.es.resx +++ b/CameraToolkit/Messages.es.resx @@ -117,9 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Nombre del albúm - &Cancelar @@ -135,4 +132,13 @@ La ruta seleccionada no existe, ¿desea crearla? + + Nueva versión {VERSION} disponible. ¿Desea descargarla ahora? + + + ¿Desea salir sin guardar los cambios? + + + ¿Desea guardar los cambios? + \ No newline at end of file diff --git a/CameraToolkit/Messages.resx b/CameraToolkit/Messages.resx index 1aad3c5..ea2e82c 100644 --- a/CameraToolkit/Messages.resx +++ b/CameraToolkit/Messages.resx @@ -117,12 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Album name - &Cancel + + New version {VERSION} is available. Do you want to download now? + &OK @@ -135,4 +135,10 @@ The selected path don't exist, do you want to create? + + Do you want to exit without saving changes? + + + Do you want to save current file? + \ No newline at end of file diff --git a/CameraToolkit/Program.cs b/CameraToolkit/Program.cs index 20800b7..ffb98ab 100644 --- a/CameraToolkit/Program.cs +++ b/CameraToolkit/Program.cs @@ -7,9 +7,8 @@ namespace Toolkit { - static class Program + internal static class Program { - internal static FilterInfoCollection devices; internal static List activeDevices; internal static string sessionId; @@ -19,9 +18,8 @@ static class Program internal static List imageFiles = new List(new string[] { ".bmp", ".jpg", ".jpeg", ".jpe", ".jfif", ".png", ".gif" }); [STAThread] - static void Main() + private static void Main() { - #if DEBUG ImageHelper.GetEditorIcon(MaterialDesign.GetImage(MaterialDesign.IconType.linked_camera, 256, Color.White)); #endif @@ -35,7 +33,7 @@ static void Main() Application.Run(new Forms.FormMain()); } - internal static Dictionary getDevices() + internal static Dictionary GetDevices() { var result = new Dictionary(); @@ -50,38 +48,46 @@ internal static DialogResult ShowInputDialog(ref string input, string caption) { var size = new Size(200, 70); - var inputBox = new Form(); - inputBox.Padding = new Padding(6); - inputBox.FormBorderStyle = FormBorderStyle.FixedDialog; - inputBox.ShowIcon = false; - inputBox.ShowInTaskbar = false; - inputBox.MaximizeBox = false; - inputBox.MinimizeBox = false; - inputBox.ClientSize = size; - inputBox.Text = caption; - inputBox.StartPosition = FormStartPosition.CenterParent; - - var textBox = new TextBox(); - textBox.Dock = DockStyle.Top; - textBox.Size = new Size(size.Width - 10, 23); - textBox.Location = new Point(5, 5); - textBox.Text = input; + var inputBox = new Form + { + Padding = new Padding(6), + FormBorderStyle = FormBorderStyle.FixedDialog, + ShowIcon = false, + ShowInTaskbar = false, + MaximizeBox = false, + MinimizeBox = false, + ClientSize = size, + Text = caption, + StartPosition = FormStartPosition.CenterParent + }; + + var textBox = new TextBox + { + Dock = DockStyle.Top, + Size = new Size(size.Width - 10, 23), + Location = new Point(5, 5), + Text = input + }; inputBox.Controls.Add(textBox); - var okButton = new Button(); - okButton.DialogResult = DialogResult.OK; - okButton.Name = "okButton"; - okButton.Size = new Size(75, 23); - okButton.Text = Messages.OK; - okButton.Location = new Point(size.Width - 80 - 80, 39); + var okButton = new Button + { + DialogResult = DialogResult.OK, + Name = "okButton", + Size = new Size(75, 23), + Text = Messages.OK, + Location = new Point(size.Width - 80 - 80, 39) + }; inputBox.Controls.Add(okButton); - var cancelButton = new Button(); - cancelButton.DialogResult = DialogResult.Cancel; - cancelButton.Name = "cancelButton"; - cancelButton.Size = new Size(75, 23); - cancelButton.Text = Messages.Cancel; - cancelButton.Location = new Point(size.Width - 80, 39); + var cancelButton = new Button + { + DialogResult = DialogResult.Cancel, + Name = "cancelButton", + Size = new Size(75, 23), + Text = Messages.Cancel, + Location = new Point(size.Width - 80, 39) + }; inputBox.Controls.Add(cancelButton); inputBox.AcceptButton = okButton; @@ -92,7 +98,5 @@ internal static DialogResult ShowInputDialog(ref string input, string caption) return result; } - } - -} +} \ No newline at end of file diff --git a/CameraToolkit/Properties/AssemblyInfo.cs b/CameraToolkit/Properties/AssemblyInfo.cs index dfda633..1c749a1 100644 --- a/CameraToolkit/Properties/AssemblyInfo.cs +++ b/CameraToolkit/Properties/AssemblyInfo.cs @@ -3,7 +3,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle("CameraToolkit")] -[assembly: AssemblyDescription("Camera Toolkit for Devigners")] +[assembly: AssemblyDescription("Camera Toolkit")] #if DEBUG [assembly: AssemblyConfiguration("DEBUG")] #else @@ -14,11 +14,9 @@ [assembly: AssemblyCopyright("Copyright © Enner Pérez")] [assembly: AssemblyTrademark("CameraToolkit")] [assembly: AssemblyCulture("")] - [assembly: ComVisible(true)] - [assembly: Guid("B294CD87-C342-4A92-B5E4-3ADF08B98C27")] - [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: NeutralResourcesLanguage("en")] +[assembly: GitHub("ennerperez", "camera-toolkit")] \ No newline at end of file diff --git a/CameraToolkit/Properties/Resources.Designer.cs b/CameraToolkit/Properties/Resources.Designer.cs index a78d41b..dfc8bf1 100644 --- a/CameraToolkit/Properties/Resources.Designer.cs +++ b/CameraToolkit/Properties/Resources.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// Este código fue generado por una herramienta. -// Versión de runtime:4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si -// se vuelve a generar el código. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -13,12 +13,12 @@ namespace Toolkit.Properties { /// - /// Clase de recurso fuertemente tipado, para buscar cadenas traducidas, etc. + /// A strongly-typed resource class, for looking up localized strings, etc. /// - // StronglyTypedResourceBuilder generó automáticamente esta clase - // a través de una herramienta como ResGen o Visual Studio. - // Para agregar o quitar un miembro, edite el archivo .ResX y, a continuación, vuelva a ejecutar ResGen - // con la opción /str o recompile su proyecto de VS. + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] @@ -33,7 +33,7 @@ internal Resources() { } /// - /// Devuelve la instancia de ResourceManager almacenada en caché utilizada por esta clase. + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { @@ -47,8 +47,8 @@ internal Resources() { } /// - /// Reemplaza la propiedad CurrentUICulture del subproceso actual para todas las - /// búsquedas de recursos mediante esta clase de recurso fuertemente tipado. + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { @@ -61,7 +61,7 @@ internal Resources() { } /// - /// Busca un recurso adaptado de tipo System.Byte[]. + /// Looks up a localized resource of type System.Byte[]. /// internal static byte[] CHANGELOG { get { @@ -71,7 +71,7 @@ internal static byte[] CHANGELOG { } /// - /// Busca un recurso adaptado de tipo System.Byte[]. + /// Looks up a localized resource of type System.Byte[]. /// internal static byte[] LICENSE { get { @@ -81,7 +81,7 @@ internal static byte[] LICENSE { } /// - /// Busca un recurso adaptado de tipo System.Byte[]. + /// Looks up a localized resource of type System.Byte[]. /// internal static byte[] README { get { diff --git a/CameraToolkit/Properties/Settings.Designer.cs b/CameraToolkit/Properties/Settings.Designer.cs index c6de6bd..d2e83c1 100644 --- a/CameraToolkit/Properties/Settings.Designer.cs +++ b/CameraToolkit/Properties/Settings.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// Este código fue generado por una herramienta. -// Versión de runtime:4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si -// se vuelve a generar el código. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -12,7 +12,7 @@ namespace Toolkit.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/CameraToolkit/References.cs b/CameraToolkit/References.cs index b13bf73..20c945e 100644 --- a/CameraToolkit/References.cs +++ b/CameraToolkit/References.cs @@ -1,14 +1,18 @@ // ---------------------------------------- // References -// Version 1.0.1 -// Updated 2017-11-28 +// Version 1.0.2 +// Updated 2018-12-26 // ---------------------------------------- +using Octokit; +using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Reflection; +using System.Threading.Tasks; +using System.Windows.Forms; #if DEBUG @@ -112,8 +116,8 @@ internal static bool ConvertToIcon(Stream input, Stream output, int size = 16, b /// Wether or not the icon was succesfully generated internal static bool ConvertToIcon(string inputPath, string outputPath, int size = 16, bool preserveAspectRatio = false) { - using (FileStream inputStream = new FileStream(inputPath, FileMode.Open)) - using (FileStream outputStream = new FileStream(outputPath, FileMode.OpenOrCreate)) + using (FileStream inputStream = new FileStream(inputPath, IO.FileMode.Open)) + using (FileStream outputStream = new FileStream(outputPath, IO.FileMode.OpenOrCreate)) { return ConvertToIcon(inputStream, outputStream, size, preserveAspectRatio); } @@ -167,64 +171,6 @@ public static void ExtractResources(ToolStrip source) #endif -namespace System -{ - internal static class ApplicationInfo - { - public static Version Version { get { return Assembly.GetCallingAssembly().GetName().Version; } } - - public static string Title - { - get - { - object[] attributes = Assembly.GetCallingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false); - if (attributes.Length > 0) - { - AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; - if (titleAttribute.Title.Length > 0) return titleAttribute.Title; - } - return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); - } - } - - public static string ProductName - { - get - { - object[] attributes = Assembly.GetCallingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false); - return attributes.Length == 0 ? "" : ((AssemblyProductAttribute)attributes[0]).Product; - } - } - - public static string Description - { - get - { - object[] attributes = Assembly.GetCallingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); - return attributes.Length == 0 ? "" : ((AssemblyDescriptionAttribute)attributes[0]).Description; - } - } - - public static string CopyrightHolder - { - get - { - object[] attributes = Assembly.GetCallingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); - return attributes.Length == 0 ? "" : ((AssemblyCopyrightAttribute)attributes[0]).Copyright; - } - } - - public static string CompanyName - { - get - { - object[] attributes = Assembly.GetCallingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); - return attributes.Length == 0 ? "" : ((AssemblyCompanyAttribute)attributes[0]).Company; - } - } - } -} - namespace System.Windows.Forms { internal static partial class FormHelper @@ -259,4 +205,101 @@ public BufferedPanel() #endregion Public Constructors } +} + +namespace System.Reflection +{ + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public class GitHubAttribute : Attribute + { + public GitHubAttribute() + { + } + + public GitHubAttribute(string owner, string repo, string assetName = "") : base() + { + Owner = owner; + Repo = repo; + AssetName = assetName; + } + + public string Owner { get; private set; } + public string Repo { get; private set; } + public string AssetName { get; private set; } + + public override string ToString() + { + return $"https://github.com/{Owner}/{Repo}"; + } + } + + internal static class ApplicationInfo + { + public static Assembly Assembly => Assembly.GetCallingAssembly(); + + public static Version Version => ApplicationInfo.Assembly.GetName().Version; + public static string Title => ApplicationInfo.Assembly.GetCustomAttribute().Title; + public static string Product => ApplicationInfo.Assembly.GetCustomAttribute().Product; + public static string Description => ApplicationInfo.Assembly.GetCustomAttribute().Description; + public static string Copyright => ApplicationInfo.Assembly.GetCustomAttribute().Copyright; + public static string Company => ApplicationInfo.Assembly.GetCustomAttribute().Company; + } + + internal static class GitHubInfo + { + public static string Repo => ApplicationInfo.Assembly.GetCustomAttribute().ToString(); + public static string Owner => ApplicationInfo.Assembly.GetCustomAttribute().Owner; + public static string Name => ApplicationInfo.Assembly.GetCustomAttribute().Repo; + public static string AssetName => ApplicationInfo.Assembly.GetCustomAttribute().AssetName; + + public static Release LatestRelease { get; set; } + + public async static Task GetLatestReleaseAsync() + { + try + { + var client = new GitHubClient(new ProductHeaderValue(ApplicationInfo.Title, ApplicationInfo.Version.ToString())); + return await client.Repository.Release.GetLatest(GitHubInfo.Owner, GitHubInfo.Repo); + } + catch (Exception ex) + { + Debug.WriteLine(ex.Message); + } + return null; + } + + public async static Task CheckForUpdateAsync() + { + try + { + LatestRelease = await GetLatestReleaseAsync(); + if (ApplicationInfo.Version < LatestRelease.GetVersion()) + { + var updateMessage = Toolkit.Messages.NewVersion; + updateMessage = updateMessage.Replace("{VERSION}", LatestRelease.GetVersion().ToString()); + updateMessage = updateMessage.Replace("{CREATEDAT}", LatestRelease.CreatedAt.UtcDateTime.ToShortDateString()); + if (MessageBox.Show(updateMessage, ApplicationInfo.Title, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + var assetName = GitHubInfo.AssetName; + if (string.IsNullOrEmpty(assetName)) assetName = $"{ApplicationInfo.Product}.zip"; + var assetUrl = LatestRelease.Assets.FirstOrDefault(m => m.Name == assetName); + var url = LatestRelease.AssetsUrl; + if (assetUrl != null) url = assetUrl.BrowserDownloadUrl; + if (string.IsNullOrEmpty(url)) url = GitHubInfo.Repo; + if (!string.IsNullOrEmpty(url)) Process.Start(url); + } + } + } + catch (Exception ex) + { + Debug.WriteLine(ex.Message); + } + } + + public static Version GetVersion(this Release release) + { + Version.TryParse(release.TagName.Replace("v", ""), out Version result); + return result; + } + } } \ No newline at end of file diff --git a/CameraToolkit/app.config b/CameraToolkit/app.config index 3586e37..aca9bcd 100644 --- a/CameraToolkit/app.config +++ b/CameraToolkit/app.config @@ -1,27 +1,30 @@ - + - - -
- - - - - - - - - False - - - False - - - - - - False - - - + + +
+ + + + + + + + + False + + + False + + + + + + False + + + + + + \ No newline at end of file diff --git a/CameraToolkit/packages.config b/CameraToolkit/packages.config index 407870d..c54da54 100644 --- a/CameraToolkit/packages.config +++ b/CameraToolkit/packages.config @@ -1,10 +1,11 @@  - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 1f03a2b..422d51b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ ![logo](.editoricon.png) -# Camera Toolkit for Devigners +# Camera Toolkit -Camera Toolkit is a simple application for fast capturing images from cameras. +Fast capturing images from cameras. [![Build status](https://ci.appveyor.com/api/projects/status/59jrgu2cvdorne9u?svg=true)](https://ci.appveyor.com/project/ennerperez/camera-toolkit) diff --git a/Toolkit.sln b/Toolkit.sln index e862a5a..eb4601c 100644 --- a/Toolkit.sln +++ b/Toolkit.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.12 +VisualStudioVersion = 15.0.27130.2003 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1CB68AA1-869F-47B4-B1CA-031FDF8E7761}" ProjectSection(SolutionItems) = preProject