From 423321e58c3d72ae2d420a6ec099dc6f145f1c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enner=20P=C3=A9rez?= Date: Tue, 26 Dec 2017 10:48:20 -0400 Subject: [PATCH 1/2] Enhancements --- CHANGELOG.md | 11 + CameraToolkit/CameraToolkit.csproj | 20 +- CameraToolkit/Controls/Gallery.Designer.cs | 225 +++++++++ CameraToolkit/Controls/Gallery.cs | 147 ++++++ CameraToolkit/Controls/Gallery.resx | 129 +++++ CameraToolkit/Forms/FormAbout.resx | 2 +- CameraToolkit/Forms/FormMain.Designer.cs | 7 +- CameraToolkit/Forms/FormMain.cs | 71 ++- CameraToolkit/Forms/FormMain.resx | 76 ++- CameraToolkit/Forms/FormSettings.Designer.cs | 19 +- CameraToolkit/Forms/FormSettings.cs | 12 +- CameraToolkit/Forms/FormSettings.resx | 63 ++- CameraToolkit/Program.cs | 98 +--- CameraToolkit/Properties/Settings.Designer.cs | 12 + CameraToolkit/Properties/Settings.settings | 3 + CameraToolkit/References.cs | 305 ------------ CameraToolkit/References/System.cs | 443 ++++++++++++++++++ .../Resources/toolStripButtonAbout.png | Bin 444 -> 450 bytes .../Resources/toolStripButtonCapture.png | Bin 690 -> 667 bytes .../Resources/toolStripButtonClose.png | Bin 297 -> 310 bytes .../Resources/toolStripButtonDevices.png | Bin 638 -> 621 bytes .../Resources/toolStripButtonFolder.png | Bin 329 -> 347 bytes .../Resources/toolStripButtonGallery.png | Bin 411 -> 416 bytes .../Resources/toolStripButtonSave.png | Bin 422 -> 430 bytes .../Resources/toolStripButtonSettings.png | Bin 488 -> 491 bytes CameraToolkit/Toolkit.cs | 93 ++++ CameraToolkit/app.config | 3 + CameraToolkit/packages.config | 2 +- 28 files changed, 1275 insertions(+), 466 deletions(-) create mode 100644 CameraToolkit/Controls/Gallery.Designer.cs create mode 100644 CameraToolkit/Controls/Gallery.cs create mode 100644 CameraToolkit/Controls/Gallery.resx delete mode 100644 CameraToolkit/References.cs create mode 100644 CameraToolkit/References/System.cs create mode 100644 CameraToolkit/Toolkit.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index ca9e4a5..0a5b95b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [1.0.9] +### Changed +- Code enhancements + +### Fixed +- Update checker +- Minors bugs + +### Added +- Gallery folder viewer + ## [1.0.8] ### Changed - Camera tile view fix diff --git a/CameraToolkit/CameraToolkit.csproj b/CameraToolkit/CameraToolkit.csproj index 2caa382..49b809b 100644 --- a/CameraToolkit/CameraToolkit.csproj +++ b/CameraToolkit/CameraToolkit.csproj @@ -40,7 +40,7 @@ DEBUG;TRACE prompt 4 - false + true AnyCPU @@ -50,7 +50,7 @@ TRACE prompt 4 - false + true App.ico @@ -71,8 +71,8 @@ ..\packages\AForge.Video.DirectShow.2.2.5\lib\AForge.Video.DirectShow.dll True - - ..\packages\Octokit.0.28.0\lib\net45\Octokit.dll + + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll @@ -95,6 +95,12 @@ + + UserControl + + + Gallery.cs + Form @@ -119,13 +125,17 @@ Messages.resx + True True Settings.settings - + + + Gallery.cs + FormAbout.cs diff --git a/CameraToolkit/Controls/Gallery.Designer.cs b/CameraToolkit/Controls/Gallery.Designer.cs new file mode 100644 index 0000000..eed9e81 --- /dev/null +++ b/CameraToolkit/Controls/Gallery.Designer.cs @@ -0,0 +1,225 @@ +namespace Toolkit.Controls +{ + partial class Gallery + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.imageListThumbs = new System.Windows.Forms.ImageList(this.components); + this.listViewItems = new System.Windows.Forms.ListView(); + this.columnHeaderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderPath = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.contextMenuStripActions = new System.Windows.Forms.ContextMenuStrip(this.components); + this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.listToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.smallIconsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.largeIconsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.detailsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.tilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.fileSystemWatcher = new System.IO.FileSystemWatcher(); + this.labelInformation = new System.Windows.Forms.Label(); + this.contextMenuStripActions.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.fileSystemWatcher)).BeginInit(); + this.SuspendLayout(); + // + // imageListThumbs + // + this.imageListThumbs.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit; + this.imageListThumbs.ImageSize = new System.Drawing.Size(48, 48); + this.imageListThumbs.TransparentColor = System.Drawing.Color.Transparent; + // + // listViewItems + // + this.listViewItems.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.listViewItems.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderName, + this.columnHeaderPath, + this.columnHeaderSize}); + this.listViewItems.ContextMenuStrip = this.contextMenuStripActions; + this.listViewItems.Dock = System.Windows.Forms.DockStyle.Fill; + this.listViewItems.FullRowSelect = true; + this.listViewItems.LargeImageList = this.imageListThumbs; + this.listViewItems.Location = new System.Drawing.Point(0, 0); + this.listViewItems.Name = "listViewItems"; + this.listViewItems.Size = new System.Drawing.Size(240, 435); + this.listViewItems.SmallImageList = this.imageListThumbs; + this.listViewItems.TabIndex = 0; + this.listViewItems.UseCompatibleStateImageBehavior = false; + this.listViewItems.Visible = false; + this.listViewItems.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.ListViewItems_MouseDoubleClick); + // + // columnHeaderName + // + this.columnHeaderName.Text = "Name"; + this.columnHeaderName.Width = 120; + // + // columnHeaderPath + // + this.columnHeaderPath.Text = "Path"; + // + // columnHeaderSize + // + this.columnHeaderSize.Text = "Size"; + this.columnHeaderSize.Width = 100; + // + // contextMenuStripActions + // + this.contextMenuStripActions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.viewToolStripMenuItem, + this.toolStripSeparator1, + this.openToolStripMenuItem, + this.deleteToolStripMenuItem}); + this.contextMenuStripActions.Name = "contextMenuStripActions"; + this.contextMenuStripActions.Size = new System.Drawing.Size(108, 76); + this.contextMenuStripActions.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripActions_Opening); + // + // viewToolStripMenuItem + // + this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.listToolStripMenuItem, + this.smallIconsToolStripMenuItem, + this.largeIconsToolStripMenuItem, + this.detailsToolStripMenuItem, + this.tilesToolStripMenuItem}); + this.viewToolStripMenuItem.Name = "viewToolStripMenuItem"; + this.viewToolStripMenuItem.Size = new System.Drawing.Size(107, 22); + this.viewToolStripMenuItem.Text = "&View"; + // + // listToolStripMenuItem + // + this.listToolStripMenuItem.Name = "listToolStripMenuItem"; + this.listToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.listToolStripMenuItem.Text = "&List"; + this.listToolStripMenuItem.Click += new System.EventHandler(this.ListToolStripMenuItem_Click); + // + // smallIconsToolStripMenuItem + // + this.smallIconsToolStripMenuItem.Name = "smallIconsToolStripMenuItem"; + this.smallIconsToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.smallIconsToolStripMenuItem.Text = "&Small icons"; + this.smallIconsToolStripMenuItem.Click += new System.EventHandler(this.SmallIconsToolStripMenuItem_Click); + // + // largeIconsToolStripMenuItem + // + this.largeIconsToolStripMenuItem.Name = "largeIconsToolStripMenuItem"; + this.largeIconsToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.largeIconsToolStripMenuItem.Text = "L&arge icons"; + this.largeIconsToolStripMenuItem.Click += new System.EventHandler(this.LargeIconsToolStripMenuItem_Click); + // + // detailsToolStripMenuItem + // + this.detailsToolStripMenuItem.Name = "detailsToolStripMenuItem"; + this.detailsToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.detailsToolStripMenuItem.Text = "&Details"; + this.detailsToolStripMenuItem.Click += new System.EventHandler(this.DetailsToolStripMenuItem_Click); + // + // tilesToolStripMenuItem + // + this.tilesToolStripMenuItem.Name = "tilesToolStripMenuItem"; + this.tilesToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.tilesToolStripMenuItem.Text = "&Tiles"; + this.tilesToolStripMenuItem.Click += new System.EventHandler(this.TilesToolStripMenuItem_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(104, 6); + // + // openToolStripMenuItem + // + this.openToolStripMenuItem.Name = "openToolStripMenuItem"; + this.openToolStripMenuItem.Size = new System.Drawing.Size(107, 22); + this.openToolStripMenuItem.Text = "&Open"; + this.openToolStripMenuItem.Click += new System.EventHandler(this.OpenToolStripMenuItem_Click); + // + // deleteToolStripMenuItem + // + this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(107, 22); + this.deleteToolStripMenuItem.Text = "&Delete"; + this.deleteToolStripMenuItem.Click += new System.EventHandler(this.DeleteToolStripMenuItem_Click); + // + // fileSystemWatcher + // + this.fileSystemWatcher.EnableRaisingEvents = true; + this.fileSystemWatcher.SynchronizingObject = this; + this.fileSystemWatcher.Changed += new System.IO.FileSystemEventHandler(this.FileSystemWatcher_Changed); + this.fileSystemWatcher.Created += new System.IO.FileSystemEventHandler(this.FileSystemWatcher_Changed); + this.fileSystemWatcher.Deleted += new System.IO.FileSystemEventHandler(this.FileSystemWatcher_Changed); + this.fileSystemWatcher.Renamed += new System.IO.RenamedEventHandler(this.FileSystemWatcher_Renamed); + // + // labelInformation + // + this.labelInformation.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelInformation.Location = new System.Drawing.Point(0, 0); + this.labelInformation.Name = "labelInformation"; + this.labelInformation.Size = new System.Drawing.Size(240, 435); + this.labelInformation.TabIndex = 1; + this.labelInformation.Text = "No items was found\r\n"; + this.labelInformation.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelInformation.Visible = false; + // + // Gallery + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.labelInformation); + this.Controls.Add(this.listViewItems); + this.Name = "Gallery"; + this.Size = new System.Drawing.Size(240, 435); + this.Load += new System.EventHandler(this.Gallery_Load); + this.contextMenuStripActions.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.fileSystemWatcher)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ImageList imageListThumbs; + private System.Windows.Forms.ListView listViewItems; + private System.IO.FileSystemWatcher fileSystemWatcher; + private System.Windows.Forms.ContextMenuStrip contextMenuStripActions; + private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; + private System.Windows.Forms.ColumnHeader columnHeaderName; + private System.Windows.Forms.ColumnHeader columnHeaderSize; + private System.Windows.Forms.ColumnHeader columnHeaderPath; + private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem listToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem smallIconsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem largeIconsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem detailsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem tilesToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.Label labelInformation; + } +} diff --git a/CameraToolkit/Controls/Gallery.cs b/CameraToolkit/Controls/Gallery.cs new file mode 100644 index 0000000..c94c5ad --- /dev/null +++ b/CameraToolkit/Controls/Gallery.cs @@ -0,0 +1,147 @@ +using System; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Toolkit.Controls +{ + public partial class Gallery : UserControl + { + public Gallery() + { + InitializeComponent(); + } + + private void ListViewItems_MouseDoubleClick(object sender, MouseEventArgs e) + { + OpenToolStripMenuItem_Click(sender, e); + } + + private async void Gallery_Load(object sender, EventArgs e) + { + listViewItems.DataBindings.Add("BackColor", this, "BackColor"); + listViewItems.DataBindings.Add("ForeColor", this, "ForeColor"); + + Width = (int)(FindForm().Width * 0.3); + FindForm().Resize += (s, v) => + { + Width = (int)((s as Form).Width * 0.3); + }; + fileSystemWatcher.Path = Path.Combine(Properties.Settings.Default.DefaultPath, Program.AlbumName); + await PopulateAsync(); + } + + private async Task PopulateAsync() + { + var path = new DirectoryInfo(fileSystemWatcher.Path); + var files = path.GetFiles().Where(m => Program.Formats.Contains(m.Extension)).ToList(); + + var images = await Task.Run(() => + (from item in files + let index = files.IndexOf(item) + let image = Image.FromFile(item.FullName) + let thumbnail = image.GetThumbnailImage(imageListThumbs.ImageSize.Width, imageListThumbs.ImageSize.Height, null, IntPtr.Zero) + select new { item.FullName, Index = index, Thumbnail = thumbnail, Size = (item.Length / 1024) }).ToList()); + + var data = from item in images + select new ListViewItem(new[] { Path.GetFileNameWithoutExtension(item.FullName), item.FullName, $"{item.Size.ToString()} Kb" }, item.Index); + + this.Invoke(new Action(() => + { + imageListThumbs.Images.Clear(); + listViewItems.Items.Clear(); + imageListThumbs.Images.AddRange(images.Select(m => m.Thumbnail).ToArray()); + listViewItems.Items.AddRange(data.ToArray()); + + listViewItems.Visible = listViewItems.Items.Count > 0; + labelInformation.Visible = !listViewItems.Visible; + + images = null; + data = null; + + GC.Collect(); + GC.WaitForPendingFinalizers(); + })); + } + + private async void FileSystemWatcher_Changed(object sender, FileSystemEventArgs e) + { + if (Program.Formats.Contains(Path.GetExtension(e.FullPath))) + await PopulateAsync(); + } + + private async void FileSystemWatcher_Renamed(object sender, RenamedEventArgs e) + { + if (Program.Formats.Contains(Path.GetExtension(e.FullPath)) || Program.Formats.Contains(Path.GetExtension(e.OldFullPath))) + await PopulateAsync(); + } + + private void OpenToolStripMenuItem_Click(object sender, EventArgs e) + { + if (listViewItems.SelectedItems != null && listViewItems.SelectedItems.OfType().Any()) + foreach (var item in listViewItems.SelectedItems) + Process.Start((item as ListViewItem).SubItems[1].Text); + } + + private void ContextMenuStripActions_Opening(object sender, System.ComponentModel.CancelEventArgs e) + { + var hasItemSelected = (listViewItems.SelectedItems != null && listViewItems.SelectedItems.OfType().Any()); + openToolStripMenuItem.Enabled = hasItemSelected; + deleteToolStripMenuItem.Enabled = hasItemSelected; + } + + private void DeleteToolStripMenuItem_Click(object sender, EventArgs e) + { + if (listViewItems.SelectedItems != null && listViewItems.SelectedItems.OfType().Any()) + foreach (var item in listViewItems.SelectedItems) + { + try + { + File.Delete((item as ListViewItem).SubItems[1].Text); + } + catch (Exception) + { + } + } + } + + public void Close() + { + fileSystemWatcher.EnableRaisingEvents = false; + fileSystemWatcher = null; + Parent.Controls.Remove(this); + Dispose(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + } + + private void ListToolStripMenuItem_Click(object sender, EventArgs e) + { + listViewItems.View = View.List; + } + + private void SmallIconsToolStripMenuItem_Click(object sender, EventArgs e) + { + listViewItems.View = View.SmallIcon; + } + + private void LargeIconsToolStripMenuItem_Click(object sender, EventArgs e) + { + listViewItems.View = View.LargeIcon; + } + + private void DetailsToolStripMenuItem_Click(object sender, EventArgs e) + { + listViewItems.View = View.Details; + } + + private void TilesToolStripMenuItem_Click(object sender, EventArgs e) + { + listViewItems.View = View.Tile; + } + } +} \ No newline at end of file diff --git a/CameraToolkit/Controls/Gallery.resx b/CameraToolkit/Controls/Gallery.resx new file mode 100644 index 0000000..ba67419 --- /dev/null +++ b/CameraToolkit/Controls/Gallery.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 316, 17 + + + 164, 17 + + \ No newline at end of file diff --git a/CameraToolkit/Forms/FormAbout.resx b/CameraToolkit/Forms/FormAbout.resx index 93312cc..12183b4 100644 --- a/CameraToolkit/Forms/FormAbout.resx +++ b/CameraToolkit/Forms/FormAbout.resx @@ -413,7 +413,7 @@ 3, 4, 3, 4 - CenterScreen + CenterParent About... diff --git a/CameraToolkit/Forms/FormMain.Designer.cs b/CameraToolkit/Forms/FormMain.Designer.cs index 44e2eab..4e8a5db 100644 --- a/CameraToolkit/Forms/FormMain.Designer.cs +++ b/CameraToolkit/Forms/FormMain.Designer.cs @@ -85,12 +85,12 @@ private void InitializeComponent() this.toolStripSeparatorMain1, this.toolStripButtonCapture, this.toolStripButtonSave, - this.toolStripButtonFolder, this.toolStripButtonClose, this.toolStripButtonAbout, this.toolStripButtonSettings, this.toolStripSeparator1, - this.toolStripButtonGallery}); + this.toolStripButtonGallery, + this.toolStripButtonFolder}); this.toolStripMenu.Name = "toolStripMenu"; this.toolStripMenu.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; this.helpProviderMain.SetShowHelp(this.toolStripMenu, ((bool)(resources.GetObject("toolStripMenu.ShowHelp")))); @@ -194,13 +194,16 @@ private void InitializeComponent() // this.toolStripSeparator1.Name = "toolStripSeparator1"; resources.ApplyResources(this.toolStripSeparator1, "toolStripSeparator1"); + this.toolStripSeparator1.Visible = global::Toolkit.Properties.Settings.Default.AutoSave; // // toolStripButtonGallery // resources.ApplyResources(this.toolStripButtonGallery, "toolStripButtonGallery"); + this.toolStripButtonGallery.CheckOnClick = true; this.toolStripButtonGallery.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButtonGallery.Margin = new System.Windows.Forms.Padding(0); this.toolStripButtonGallery.Name = "toolStripButtonGallery"; + this.toolStripButtonGallery.Visible = global::Toolkit.Properties.Settings.Default.AutoSave; this.toolStripButtonGallery.Click += new System.EventHandler(this.ToolStripButtonGallery_Click); // // saveFileDialogMain diff --git a/CameraToolkit/Forms/FormMain.cs b/CameraToolkit/Forms/FormMain.cs index fcdc5f8..de49e14 100644 --- a/CameraToolkit/Forms/FormMain.cs +++ b/CameraToolkit/Forms/FormMain.cs @@ -20,29 +20,30 @@ public FormMain() { InitializeComponent(); - Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetEntryAssembly().Location); + Icon = Icon.ExtractAssociatedIcon(Program.Assembly.Location); // saveFileDialogMain - saveFileDialogMain.DefaultExt = Program.imageFiles[0]; + saveFileDialogMain.DefaultExt = Program.Formats.FirstOrDefault(); // Icons - toolStripButtonDevices.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.linked_camera, 48, Color.White); - toolStripButtonCapture.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.camera, 48, Color.White); - toolStripButtonSave.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.save, 48, Color.White); + toolStripButtonDevices.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.linked_camera, 48, SystemColors.Control); + toolStripButtonCapture.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.camera, 48, SystemColors.Control); + toolStripButtonSave.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.save, 48, SystemColors.Control); - toolStripMenuItemCamera.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.settings_brightness, 48, toolStripMenu.BackColor); - toolStripMenuItemSystem.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.settings_system_daydream, 48, toolStripMenu.BackColor); + //toolStripMenuItemCamera.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.settings_brightness, 48, toolStripMenu.BackColor); + //toolStripMenuItemSystem.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.settings_system_daydream, 48, toolStripMenu.BackColor); - toolStripButtonGallery.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.image, 48, Color.White); - toolStripButtonFolder.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.folder_open, 48, Color.White); + toolStripMenuItemCamera.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.build, 48, toolStripMenu.BackColor); + toolStripMenuItemSystem.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.settings, 48, toolStripMenu.BackColor); - toolStripButtonSettings.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.settings, 48, Color.White); - toolStripButtonAbout.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.info, 48, Color.White); - toolStripButtonClose.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.close, 48, Color.White); + toolStripButtonGallery.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.image, 48, SystemColors.Control); + toolStripButtonFolder.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.folder_open, 48, SystemColors.Control); - toolStripMenuDisconnectItem.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.videocam_off, 48, toolStripMenu.BackColor); + toolStripButtonSettings.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.settings, 48, SystemColors.Control); + toolStripButtonAbout.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.info, 48, SystemColors.Control); + toolStripButtonClose.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.close, 48, SystemColors.Control); - toolStripMenuItemCopy.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.content_copy, 16, toolStripMenu.BackColor); + toolStripMenuDisconnectItem.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.videocam_off, 48, toolStripMenu.BackColor); #if DEBUG FormHelper.ExtractResources(toolStripMenu); @@ -78,7 +79,7 @@ private void Item_Click(object sender, EventArgs e) toolStripMenuDisconnectItem.Enabled = IsRunning(); if (Properties.Settings.Default.AskAlbumName) - Program.ShowInputDialog(ref Program.albumName, "Album"); + Program.ShowInputDialog(ref Program.AlbumName, "Album"); } catch (Exception ex) { @@ -140,10 +141,13 @@ private async void FormViewer_Shown(object sender, EventArgs e) defaultDevice = _item; } + labelPreview.Visible = defaultDevice == null; + if (defaultDevice != null) defaultDevice.PerformClick(); - await GitHubInfo.CheckForUpdateAsync(); + if (Properties.Settings.Default.CheckForUpdates) + await GitHubInfo.CheckForUpdateAsync(); } private void FormViewer_FormClosing(object sender, FormClosingEventArgs e) @@ -205,7 +209,7 @@ private void ToolStripMenuItemDisconnect_Click(object sender, EventArgs e) toolStripMenuDisconnectItem.Enabled = IsRunning(); - Program.albumName = string.Empty; + Program.AlbumName = string.Empty; } private void ToolStripButtonSave_Click(object sender, EventArgs e) @@ -217,13 +221,16 @@ private void ToolStripButtonSave_Click(object sender, EventArgs e) while (filename == string.Empty || File.Exists(filename)) { - filename = string.Format("{0}_{1}_{2}_{3}.jpg", DeviceName.Replace(' ', '_'), Program.sessionId, DateTime.Now.ToString("yyyyMMdd"), i.ToString()); + filename = string.Format("{0}_{1}_{2}_{3}.jpg", DeviceName.Replace(' ', '_'), Program.SessionId, DateTime.Now.ToString("yyyyMMdd"), i.ToString()); if (Properties.Settings.Default.AutoSave && !string.IsNullOrEmpty(Properties.Settings.Default.DefaultPath) && Directory.Exists(Properties.Settings.Default.DefaultPath)) + { + if (Properties.Settings.Default.AskAlbumName && string.IsNullOrEmpty(Program.AlbumName)) + Program.ShowInputDialog(ref Program.AlbumName, "Album"); - filename = Path.Combine(Properties.Settings.Default.DefaultPath, Program.albumName, filename); - + filename = Path.Combine(Properties.Settings.Default.DefaultPath, Program.AlbumName, filename); + } i++; } @@ -248,14 +255,31 @@ private void ToolStripButtonFolder_Click(object sender, EventArgs e) Properties.Settings.Default.DefaultPath = string.Empty; Properties.Settings.Default.Save(); - MessageBox.Show(Toolkit.Messages.PathNotFound, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(Messages.PathNotFound, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } else - System.Diagnostics.Process.Start(Properties.Settings.Default.DefaultPath); + Process.Start(Path.Combine(Properties.Settings.Default.DefaultPath, Program.AlbumName)); } private void ToolStripButtonGallery_Click(object sender, EventArgs e) { + if (!this.Controls.OfType().Any()) + { + var child = new Controls.Gallery + { + Dock = DockStyle.Right, + BackColor = toolStripMenu.BackColor, + ForeColor = SystemColors.Control + }; + Controls.Add(child); + child.BringToFront(); + } + else + { + var child = this.Controls.OfType().FirstOrDefault(); + if (child != null) + child.Close(); + } } private void ToolStripMenuItemCamera_Click(object sender, EventArgs e) @@ -268,6 +292,9 @@ private void ToolStripMenuItemSystem_Click(object sender, EventArgs e) { var child = new FormSettings(); child.ShowDialog(); + toolStripButtonGallery.Visible = Properties.Settings.Default.AutoSave; + toolStripButtonFolder.Visible = Properties.Settings.Default.AutoSave; + toolStripSeparator1.Visible = Properties.Settings.Default.AutoSave; } private void ToolStripButtonAbout_Click(object sender, EventArgs e) diff --git a/CameraToolkit/Forms/FormMain.resx b/CameraToolkit/Forms/FormMain.resx index 10e6415..ff101e7 100644 --- a/CameraToolkit/Forms/FormMain.resx +++ b/CameraToolkit/Forms/FormMain.resx @@ -163,13 +163,13 @@ None - 133, 22 + 152, 22 &Disconnect - 130, 6 + 149, 6 @@ -264,31 +264,6 @@ &Save - - False - - - - iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADgSURBVGhD7djhDYIwEIZhBmAB52APJ2ADN3AFd3EgV2ko - 3tn7QRMSildCNe+TNBij991n/CF2AAD8vXme+xjjfZqm59aR113tbW3Q5UMIL7kWa6qELDPaXrs0U0IW - udlOu619xTbOQ/IuFl2Hp4BDb/F+ZxSQzNHi/ZYFdLBchiOOzf7QTIv3WxYQgz1dnc5OERTIUaCQzk4R - FMhRoJDOThEUyFGgkM5OERTIUaCQzk4RBxaQxz/5a/SrW0oPzbR4P5m3+6bew7Lq3ZEpHSifStHfKp6j - GdWXBwAAALCu696F5IZLWtKCwgAAAABJRU5ErkJggg== - - - - None - - - Magenta - - - 48, 48 - - - &Open folder - False @@ -344,16 +319,16 @@ False - 124, 22 + 152, 22 - &Camera... + &Camera - 124, 22 + 152, 22 - &System... + &System @@ -383,9 +358,6 @@ 47, 6 - - False - False @@ -412,9 +384,31 @@ &Gallery - + False + + + iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADgSURBVGhD7djhDYIwEIZhBmAB52APJ2ADN3AFd3EgV2ko + 3tn7QRMSildCNe+TNBij991n/CF2AAD8vXme+xjjfZqm59aR113tbW3Q5UMIL7kWa6qELDPaXrs0U0IW + udlOu619xTbOQ/IuFl2Hp4BDb/F+ZxSQzNHi/ZYFdLBchiOOzf7QTIv3WxYQgz1dnc5OERTIUaCQzk4R + FMhRoJDOThEUyFGgkM5OERTIUaCQzk4RBxaQxz/5a/SrW0oPzbR4P5m3+6bew7Lq3ZEpHSifStHfKp6j + GdWXBwAAALCu696F5IZLWtKCwgAAAABJRU5ErkJggg== + + + + None + + + Magenta + + + 48, 48 + + + &Open folder + 0, 0 @@ -457,6 +451,9 @@ Fill + + Segoe UI, 18pt + NoControl @@ -533,6 +530,9 @@ To start capturing Segoe UI, 9.75pt + + NoControl + 3, 4, 3, 4 @@ -662,10 +662,4 @@ 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.Designer.cs b/CameraToolkit/Forms/FormSettings.Designer.cs index 5a459ad..3bcf30b 100644 --- a/CameraToolkit/Forms/FormSettings.Designer.cs +++ b/CameraToolkit/Forms/FormSettings.Designer.cs @@ -42,6 +42,7 @@ private void InitializeComponent() this.checkBoxAlbumName = new System.Windows.Forms.CheckBox(); this.checkBoxAutoSave = new System.Windows.Forms.CheckBox(); this.textBoxAutoSavePath = new System.Windows.Forms.TextBox(); + this.checkBoxCheckForUpdates = new System.Windows.Forms.CheckBox(); this.groupBoxAutostart.SuspendLayout(); this.groupBoxAutoSave.SuspendLayout(); this.SuspendLayout(); @@ -52,14 +53,14 @@ private void InitializeComponent() this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // // buttonAccept // resources.ApplyResources(this.buttonAccept, "buttonAccept"); this.buttonAccept.Name = "buttonAccept"; this.buttonAccept.UseVisualStyleBackColor = true; - this.buttonAccept.Click += new System.EventHandler(this.buttonAccept_Click); + this.buttonAccept.Click += new System.EventHandler(this.ButtonAccept_Click); // // comboBoxDevices // @@ -73,7 +74,7 @@ private void InitializeComponent() resources.ApplyResources(this.buttonExamine, "buttonExamine"); this.buttonExamine.Name = "buttonExamine"; this.buttonExamine.UseVisualStyleBackColor = true; - this.buttonExamine.Click += new System.EventHandler(this.buttonExamine_Click); + this.buttonExamine.Click += new System.EventHandler(this.ButtonExamine_Click); // // labelAutoSavePath // @@ -136,6 +137,15 @@ private void InitializeComponent() this.textBoxAutoSavePath.Name = "textBoxAutoSavePath"; this.textBoxAutoSavePath.Text = global::Toolkit.Properties.Settings.Default.DefaultPath; // + // checkBoxCheckForUpdates + // + resources.ApplyResources(this.checkBoxCheckForUpdates, "checkBoxCheckForUpdates"); + this.checkBoxCheckForUpdates.Checked = global::Toolkit.Properties.Settings.Default.CheckForUpdates; + this.checkBoxCheckForUpdates.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxCheckForUpdates.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::Toolkit.Properties.Settings.Default, "CheckForUpdates", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); + this.checkBoxCheckForUpdates.Name = "checkBoxCheckForUpdates"; + this.checkBoxCheckForUpdates.UseVisualStyleBackColor = true; + // // FormSettings // this.AcceptButton = this.buttonAccept; @@ -143,6 +153,7 @@ private void InitializeComponent() this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; this.CancelButton = this.buttonCancel; + this.Controls.Add(this.checkBoxCheckForUpdates); this.Controls.Add(this.groupBoxAutoSave); this.Controls.Add(this.groupBoxAutostart); this.Controls.Add(this.buttonAccept); @@ -158,6 +169,7 @@ private void InitializeComponent() this.groupBoxAutoSave.ResumeLayout(false); this.groupBoxAutoSave.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -176,5 +188,6 @@ private void InitializeComponent() private System.Windows.Forms.GroupBox groupBoxAutostart; private System.Windows.Forms.GroupBox groupBoxAutoSave; private System.Windows.Forms.CheckBox checkBoxAlbumName; + private System.Windows.Forms.CheckBox checkBoxCheckForUpdates; } } \ No newline at end of file diff --git a/CameraToolkit/Forms/FormSettings.cs b/CameraToolkit/Forms/FormSettings.cs index ae9b934..c0f2f4e 100644 --- a/CameraToolkit/Forms/FormSettings.cs +++ b/CameraToolkit/Forms/FormSettings.cs @@ -1,5 +1,6 @@ using System; using System.Drawing; +using System.IO; using System.Windows.Forms; namespace Toolkit.Forms @@ -22,23 +23,23 @@ public FormSettings() checkBoxAlbumName.DataBindings.Add("Enabled", checkBoxAutoSave, "Checked"); } - private void buttonExamine_Click(object sender, EventArgs e) + private void ButtonExamine_Click(object sender, EventArgs e) { folderBrowserDialogAutoSavePath.ShowDialog(); if (!string.IsNullOrEmpty(folderBrowserDialogAutoSavePath.SelectedPath)) textBoxAutoSavePath.Text = folderBrowserDialogAutoSavePath.SelectedPath; } - private void buttonAccept_Click(object sender, EventArgs e) + private void ButtonAccept_Click(object sender, EventArgs e) { - if (checkBoxAutoSave.Checked && !System.IO.Directory.Exists(textBoxAutoSavePath.Text)) + if (checkBoxAutoSave.Checked && !Directory.Exists(textBoxAutoSavePath.Text)) { var question = MessageBox.Show(Toolkit.Messages.PathNotFoundAndCreate, Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (question == DialogResult.Yes) { try { - System.IO.Directory.CreateDirectory(textBoxAutoSavePath.Text); + Directory.CreateDirectory(textBoxAutoSavePath.Text); } catch (Exception ex) { @@ -53,12 +54,13 @@ private void buttonAccept_Click(object sender, EventArgs e) } } + Properties.Settings.Default.AutoSave = checkBoxAutoSave.Checked; Properties.Settings.Default.DefaultDevice = comboBoxDevices.SelectedValue.ToString(); Properties.Settings.Default.Save(); Close(); } - private void buttonCancel_Click(object sender, EventArgs e) + private void ButtonCancel_Click(object sender, EventArgs e) { Close(); } diff --git a/CameraToolkit/Forms/FormSettings.resx b/CameraToolkit/Forms/FormSettings.resx index aa31038..da83e1e 100644 --- a/CameraToolkit/Forms/FormSettings.resx +++ b/CameraToolkit/Forms/FormSettings.resx @@ -121,6 +121,9 @@ Bottom, Right + + NoControl + 297, 286 @@ -145,11 +148,14 @@ $this - 3 + 4 Bottom, Right + + NoControl + 216, 286 @@ -172,7 +178,7 @@ $this - 2 + 3 Top, Left, Right @@ -207,6 +213,9 @@ False + + NoControl + 279, 69 @@ -237,6 +246,9 @@ True + + NoControl + 6, 24 @@ -264,6 +276,9 @@ True + + NoControl + 6, 24 @@ -294,6 +309,9 @@ True + + NoControl + 6, 0 @@ -337,7 +355,7 @@ $this - 1 + 2 Top, Left, Right @@ -348,6 +366,9 @@ False + + NoControl + 9, 73 @@ -375,6 +396,9 @@ True + + NoControl + 6, 0 @@ -445,6 +469,39 @@ $this + 1 + + + Bottom, Left + + + True + + + NoControl + + + 18, 290 + + + 160, 17 + + + 0 + + + Check for &updates at startup + + + checkBoxCheckForUpdates + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 diff --git a/CameraToolkit/Program.cs b/CameraToolkit/Program.cs index ffb98ab..e59ad77 100644 --- a/CameraToolkit/Program.cs +++ b/CameraToolkit/Program.cs @@ -1,102 +1,44 @@ -using AForge.Video.DirectShow; -using System; +using System; using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Pictograms; +using System.Reflection; +using System.Threading; using System.Windows.Forms; namespace Toolkit { - internal static class Program + internal static partial class Program { - internal static FilterInfoCollection devices; - internal static List activeDevices; - internal static string sessionId; + internal static bool IsNewInstance = false; + internal static Mutex Mutex = new Mutex(true, ApplicationInfo.Guid, out IsNewInstance); + internal static Assembly Assembly = Assembly.GetExecutingAssembly(); - internal static string albumName; - - internal static List imageFiles = new List(new string[] { ".bmp", ".jpg", ".jpeg", ".jpe", ".jfif", ".png", ".gif" }); + internal static Dictionary CommandArgs => ApplicationInfo.GetCommandLine(); [STAThread] private static void Main() { -#if DEBUG - ImageHelper.GetEditorIcon(MaterialDesign.GetImage(MaterialDesign.IconType.linked_camera, 256, Color.White)); -#endif + Initialize(); - sessionId = DateTime.Now.TimeOfDay.Ticks.ToString(); - activeDevices = new List(); - devices = new FilterInfoCollection(FilterCategory.VideoInputDevice); + AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledException); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Forms.FormMain()); + + if (IsNewInstance) + Application.Run(new Forms.FormMain()); + else + NewInstanceHandler(null, EventArgs.Empty); } - internal static Dictionary GetDevices() + private static void UnhandledException(object sender, UnhandledExceptionEventArgs e) { - var result = new Dictionary(); - - if (devices.Count > 0) - for (int i = 0; i < devices.Count; i++) - result.Add(devices[i].MonikerString, devices[i].Name.ToString()); - - return result; } - internal static DialogResult ShowInputDialog(ref string input, string caption) + private static void NewInstanceHandler(object sender, EventArgs e) { - var size = new Size(200, 70); - - 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 - { - 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 - { - 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; - inputBox.CancelButton = cancelButton; - - var result = inputBox.ShowDialog(); - input = textBox.Text; - - return result; + NewInstance?.Invoke(sender, e); } + + public static event EventHandler NewInstance; } } \ No newline at end of file diff --git a/CameraToolkit/Properties/Settings.Designer.cs b/CameraToolkit/Properties/Settings.Designer.cs index d2e83c1..9ca42da 100644 --- a/CameraToolkit/Properties/Settings.Designer.cs +++ b/CameraToolkit/Properties/Settings.Designer.cs @@ -82,5 +82,17 @@ public bool AskAlbumName { this["AskAlbumName"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool CheckForUpdates { + get { + return ((bool)(this["CheckForUpdates"])); + } + set { + this["CheckForUpdates"] = value; + } + } } } diff --git a/CameraToolkit/Properties/Settings.settings b/CameraToolkit/Properties/Settings.settings index 268a635..3edc501 100644 --- a/CameraToolkit/Properties/Settings.settings +++ b/CameraToolkit/Properties/Settings.settings @@ -17,5 +17,8 @@ False + + True + \ No newline at end of file diff --git a/CameraToolkit/References.cs b/CameraToolkit/References.cs deleted file mode 100644 index 20c945e..0000000 --- a/CameraToolkit/References.cs +++ /dev/null @@ -1,305 +0,0 @@ -// ---------------------------------------- -// References -// 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 - -namespace System.Drawing -{ - /// - /// Provides helper methods for imaging - /// - internal static partial class ImageHelper - { - /// - /// Converts a PNG image to a icon (ico) - /// - /// The input stream - /// The output stream - /// The size (16x16 px by default) - /// Preserve the aspect ratio - /// Wether or not the icon was succesfully generated - internal static bool ConvertToIcon(Stream input, Stream output, int size = 16, bool preserveAspectRatio = false) - { - Bitmap inputBitmap = (Bitmap)Bitmap.FromStream(input); - if (inputBitmap != null) - { - int width, height; - if (preserveAspectRatio) - { - width = size; - height = inputBitmap.Height / inputBitmap.Width * size; - } - else - { - width = height = size; - } - Bitmap newBitmap = new Bitmap(inputBitmap, new Size(width, height)); - if (newBitmap != null) - { - // save the resized png into a memory stream for future use - using (MemoryStream memoryStream = new MemoryStream()) - { - newBitmap.Save(memoryStream, ImageFormat.Png); - - BinaryWriter iconWriter = new BinaryWriter(output); - if (output != null && iconWriter != null) - { - // 0-1 reserved, 0 - iconWriter.Write((byte)0); - iconWriter.Write((byte)0); - - // 2-3 image type, 1 = icon, 2 = cursor - iconWriter.Write((short)1); - - // 4-5 number of images - iconWriter.Write((short)1); - - // image entry 1 - // 0 image width - iconWriter.Write((byte)width); - // 1 image height - iconWriter.Write((byte)height); - - // 2 number of colors - iconWriter.Write((byte)0); - - // 3 reserved - iconWriter.Write((byte)0); - - // 4-5 color planes - iconWriter.Write((short)0); - - // 6-7 bits per pixel - iconWriter.Write((short)32); - - // 8-11 size of image data - iconWriter.Write((int)memoryStream.Length); - - // 12-15 offset of image data - iconWriter.Write((int)(6 + 16)); - - // write image data - // png data must contain the whole png data file - iconWriter.Write(memoryStream.ToArray()); - - iconWriter.Flush(); - - return true; - } - } - } - return false; - } - return false; - } - - /// - /// Converts a PNG image to a icon (ico) - /// - /// The input path - /// The output path - /// The size (16x16 px by default) - /// Preserve the aspect ratio - /// 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, IO.FileMode.Open)) - using (FileStream outputStream = new FileStream(outputPath, IO.FileMode.OpenOrCreate)) - { - return ConvertToIcon(inputStream, outputStream, size, preserveAspectRatio); - } - } - - internal static bool GetEditorIcon(Image img) - { - Bitmap bmp = new Bitmap(img.Width, img.Height); - using (Graphics gfx = Graphics.FromImage(bmp)) - using (SolidBrush brush = new SolidBrush(Color.FromArgb(43, 43, 43))) - { - gfx.FillRectangle(brush, 0, 0, bmp.Width, bmp.Height); - gfx.DrawImage(img, 0, 0); - } - - var assemblyName = Assembly.GetEntryAssembly().GetName().Name; - - bmp.Save(@"..\..\.editoricon.png"); - ConvertToIcon(@"..\..\.editoricon.png", string.Format(@"..\..\{0}\App.ico", assemblyName), (img.Width + img.Height) / 2, true); - - return true; - } - } -} - -namespace System.Windows.Forms -{ - internal static partial class FormHelper - { - public static void ExtractResources(Image image, string name) - { - if (image != null) - { - var assemblyName = Assembly.GetEntryAssembly().GetName().Name; - var dirPath = string.Format(@"..\..\{0}\Resources\", assemblyName); - if (!System.IO.Directory.Exists(dirPath)) - System.IO.Directory.CreateDirectory(dirPath); - image.Save(string.Format(@"..\..\{0}\Resources\{1}.png", assemblyName, name)); - } - } - - public static void ExtractResources(ToolStrip source) - { - foreach (var item in source.Items.OfType().Where(i => i.Image != null)) - ExtractResources(item.Image, item.Name); - foreach (var item in source.Items.OfType().Where(i => i.Image != null)) - ExtractResources(item.Image, item.Name); - } - } -} - -#endif - -namespace System.Windows.Forms -{ - internal static partial class FormHelper - { - public static Rectangle GetWorkingArea() - { - int minx, miny, maxx, maxy; - minx = miny = int.MaxValue; - maxx = maxy = int.MinValue; - - foreach (Screen screen in Screen.AllScreens) - { - var bounds = screen.Bounds; - minx = Math.Min(minx, bounds.X); - miny = Math.Min(miny, bounds.Y); - maxx = Math.Max(maxx, bounds.Right); - maxy = Math.Max(maxy, bounds.Bottom); - } - - return new System.Drawing.Rectangle(0, 0, (maxx - minx), (maxy - miny)); - } - } - - internal class BufferedPanel : Panel - { - #region Public Constructors - - public BufferedPanel() - { - SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true); - } - - #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/References/System.cs b/CameraToolkit/References/System.cs new file mode 100644 index 0000000..cf7e687 --- /dev/null +++ b/CameraToolkit/References/System.cs @@ -0,0 +1,443 @@ +// ---------------------------------------- +// System References +// Version 1.0.3 +// Updated 2018-12-26 +// ---------------------------------------- + +using GitHub; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace System +{ +#if DEBUG + + namespace Drawing + { + /// + /// Provides helper methods for imaging + /// + internal static partial class ImageHelper + { + /// + /// Converts a PNG image to a icon (ico) + /// + /// The input stream + /// The output stream + /// The size (16x16 px by default) + /// Preserve the aspect ratio + /// Wether or not the icon was succesfully generated + internal static bool ConvertToIcon(Stream input, Stream output, int size = 16, bool preserveAspectRatio = false) + { + Bitmap inputBitmap = (Bitmap)Bitmap.FromStream(input); + if (inputBitmap != null) + { + int width, height; + if (preserveAspectRatio) + { + width = size; + height = inputBitmap.Height / inputBitmap.Width * size; + } + else + { + width = height = size; + } + Bitmap newBitmap = new Bitmap(inputBitmap, new Size(width, height)); + if (newBitmap != null) + { + // save the resized png into a memory stream for future use + using (MemoryStream memoryStream = new MemoryStream()) + { + newBitmap.Save(memoryStream, ImageFormat.Png); + + BinaryWriter iconWriter = new BinaryWriter(output); + if (output != null && iconWriter != null) + { + // 0-1 reserved, 0 + iconWriter.Write((byte)0); + iconWriter.Write((byte)0); + + // 2-3 image type, 1 = icon, 2 = cursor + iconWriter.Write((short)1); + + // 4-5 number of images + iconWriter.Write((short)1); + + // image entry 1 + // 0 image width + iconWriter.Write((byte)width); + // 1 image height + iconWriter.Write((byte)height); + + // 2 number of colors + iconWriter.Write((byte)0); + + // 3 reserved + iconWriter.Write((byte)0); + + // 4-5 color planes + iconWriter.Write((short)0); + + // 6-7 bits per pixel + iconWriter.Write((short)32); + + // 8-11 size of image data + iconWriter.Write((int)memoryStream.Length); + + // 12-15 offset of image data + iconWriter.Write((int)(6 + 16)); + + // write image data + // png data must contain the whole png data file + iconWriter.Write(memoryStream.ToArray()); + + iconWriter.Flush(); + + return true; + } + } + } + return false; + } + return false; + } + + /// + /// Converts a PNG image to a icon (ico) + /// + /// The input path + /// The output path + /// The size (16x16 px by default) + /// Preserve the aspect ratio + /// 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, IO.FileMode.Open)) + using (FileStream outputStream = new FileStream(outputPath, IO.FileMode.OpenOrCreate)) + { + return ConvertToIcon(inputStream, outputStream, size, preserveAspectRatio); + } + } + + internal static bool GetEditorIcon(Image img) + { + Bitmap bmp = new Bitmap(img.Width, img.Height); + using (Graphics gfx = Graphics.FromImage(bmp)) + using (SolidBrush brush = new SolidBrush(Color.FromArgb(43, 43, 43))) + { + gfx.FillRectangle(brush, 0, 0, bmp.Width, bmp.Height); + gfx.DrawImage(img, 0, 0); + } + + var assemblyName = Assembly.GetEntryAssembly().GetName().Name; + + bmp.Save(@"..\..\.editoricon.png"); + ConvertToIcon(@"..\..\.editoricon.png", string.Format(@"..\..\{0}\App.ico", assemblyName), (img.Width + img.Height) / 2, true); + + return true; + } + } + } + +#endif + + namespace Windows + { + namespace Forms + { +#if DEBUG + + internal static partial class FormHelper + { + public static void ExtractResources(Image image, string name) + { + if (image != null) + { + var assemblyName = Assembly.GetEntryAssembly().GetName().Name; + var dirPath = string.Format(@"..\..\{0}\Resources\", assemblyName); + if (!Directory.Exists(dirPath)) + Directory.CreateDirectory(dirPath); + image.Save(string.Format(@"..\..\{0}\Resources\{1}.png", assemblyName, name)); + } + } + + public static void ExtractResources(ToolStrip source) + { + foreach (var item in source.Items.OfType().Where(i => i.Image != null)) + ExtractResources(item.Image, item.Name); + foreach (var item in source.Items.OfType().Where(i => i.Image != null)) + ExtractResources(item.Image, item.Name); + } + } + +#endif + + internal static partial class FormHelper + { + public static Rectangle GetWorkingArea() + { + int minx, miny, maxx, maxy; + minx = miny = int.MaxValue; + maxx = maxy = int.MinValue; + + foreach (Screen screen in Screen.AllScreens) + { + var bounds = screen.Bounds; + minx = Math.Min(minx, bounds.X); + miny = Math.Min(miny, bounds.Y); + maxx = Math.Max(maxx, bounds.Right); + maxy = Math.Max(maxy, bounds.Bottom); + } + + return new System.Drawing.Rectangle(0, 0, (maxx - minx), (maxy - miny)); + } + } + + internal class BufferedPanel : Panel + { + #region Public Constructors + + public BufferedPanel() + { + SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true); + } + + #endregion Public Constructors + } + } + } + + namespace 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; + + public static string Guid => ApplicationInfo.Assembly.GetCustomAttribute().Value; + + internal static Dictionary GetCommandLine() + { + var commandArgs = new Dictionary(); + + var assembly = string.Format(@"""{0}"" ", Assembly.GetExecutingAssembly().Location); + var collection = Environment.CommandLine.Replace(assembly, "").Split(' ').Select(a => a.ToLower()).ToList(); + + if (collection.Any()) + foreach (var item in collection.Where(m => m.StartsWith("/"))) + if (collection.Count - 1 > collection.IndexOf(item)) + commandArgs.Add(item.ToLower(), collection[collection.IndexOf(item) + 1].Replace(@"""", @"")); + else + commandArgs.Add(item.ToLower(), null); + + return commandArgs; + } + } + + 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 + { + using (var client = new HttpClient()) + { + var url = new Uri($"https://api.github.com/repos/{GitHubInfo.Owner}/{GitHubInfo.Name}/releases/latest"); + client.DefaultRequestHeaders.Add("User-Agent", ApplicationInfo.Title); + var response = await client.GetAsync(url); + if (response.IsSuccessStatusCode) + return JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); ; + } + } + 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; + } + } + } +} + +namespace GitHub +{ + internal class Release + { + public Release() + { + Assets = new HashSet(); + } + + [JsonProperty("tarball_url")] + public string TarballUrl { get; set; } + + //[JsonProperty("author")] + //public Author Author { get; set; } + + [JsonProperty("published_at")] + public DateTimeOffset? PublishedAt { get; set; } + + [JsonProperty("created_at")] + public DateTimeOffset CreatedAt { get; set; } + + [JsonProperty("prerelease")] + public bool Prerelease { get; set; } + + [JsonProperty("draft")] + public bool Draft { get; set; } + + [JsonProperty("body")] + public string Body { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("target_commitish")] + public string TargetCommitish { get; set; } + + [JsonProperty("tag_name")] + public string TagName { get; set; } + + [JsonProperty("id")] + public int Id { get; set; } + + [JsonProperty("upload_url")] + public string UploadUrl { get; set; } + + [JsonProperty("assets_url")] + public string AssetsUrl { get; set; } + + [JsonProperty("html_url")] + public string HtmlUrl { get; set; } + + [JsonProperty("url")] + public string Url { get; set; } + + [JsonProperty("zipball_url")] + public string ZipballUrl { get; set; } + + [JsonProperty("assets")] + public ICollection Assets { get; set; } + } + + internal class Asset + { + [JsonProperty("url")] + public string Url { get; set; } + + [JsonProperty("id")] + public int Id { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("label")] + public string Label { get; set; } + + [JsonProperty("state")] + public string State { get; set; } + + [JsonProperty("content_type")] + public string ContentType { get; set; } + + [JsonProperty("size")] + public int Size { get; set; } + + [JsonProperty("download_count")] + public int DownloadCount { get; set; } + + [JsonProperty("created_at")] + public DateTimeOffset CreatedAt { get; set; } + + [JsonProperty("updated_at")] + public DateTimeOffset UpdatedAt { get; set; } + + [JsonProperty("browser_download_url")] + public string BrowserDownloadUrl { get; set; } + + //[JsonProperty("uploader")] + //public Author Uploader { get; set; } + } +} \ No newline at end of file diff --git a/CameraToolkit/Resources/toolStripButtonAbout.png b/CameraToolkit/Resources/toolStripButtonAbout.png index a625430a631a4f586e9305ac9a7eff8636d56ecc..130fa7576cb204a7432e32218d84f8a7c2765208 100644 GIT binary patch delta 373 zcmV-*0gC>-1HuE4R)1GXL_t(&L+zMh4uUWYg}H_o@Hk$CyLkz2;UNel{MWvukY$;$ zbuBW}FL{v&YrCzjlg@D*=YN>z`96;0W16Nu6u!efe(YK-%W~r&U-bFj6F<{q3=jV; z2qp}$P(7PDA71q#3P_^i^xZ%%CjzO`Y4yP?pA4c_r|bkd(tk*sZyMN*4dfuZV7c2o zp`7j%$fmFbsj~%w>*(IDOj3yqm$pms1W5Y3P?!b~(g%S+KPj+7q87$3VNSs0}y*hxg$as!wiWu?je{@@MOmW@Fisb_-MU1#=q_;QCw(MT^+bYA zAeEmKsY0>;cVYr`NRlM^9_D!-ZQO1AybZ36nszPB*bS4@G`)T|V2%p9Dg0b8BX89Z zt2FIl1#LB-^0FIpG~W#q9Hk!yIhFocSS@LW(_|+i+U7sVEq|F~uoWu4VL5GVJTx{> zrv)@57fWsHtc}zZ4rnPfjvXdE1;p<{O&b8MgAoS5b-4(%BpZX72tPKrKvVL5EZJRo zn}Md}{m=%=Ta2fLfH=wf*;ByUfH&Sv7I1+As&C?e0zz-%>SHvZfY`TF9xlpVgr|V; z2N~3w@D#9)4QRuX_Wd#kHAZLy9$*^hzfLchnSMWLfbErDIES^)J0{fcNBsh;712)Q zXtwg7F!8DrW(~1Qb1tkPW=c*Q<}jBSg zL4NW8^560ZN?;htrcv4s3LS8WZBY^_@gZf^(9qEEe{j3qKF;U!*Y$ecYF;jvPZ4=N zoKB}VC`pQc)9+7(M-hjS8}yOaWkHHzg-Z%Q@P5C)LmtYj?|<9H43SmulrnwXsXn%? zgWK_-bAu*78fA)1t4z;(+m<++5pV^#0iJ2%wN=D&r0n!Y&_wJuo>fIqb0-45dv>dv zG$v>Q9k6?RtN3-|8ZwerOYJ3Y(I*^mox)_SApMpy5vR=o1B*-bp*x@cpr5_Y4EF0}cA1cp?l_0gcIXfWHhJLCArpQ)~&2 zaWd1+hJXef^kZ+}k*v3R$7Lf7W(F_uAmY6sxxs=aoZSGB)9MgN?qK?rxQGFrbm>K< zrdY-q5EXoA^VWyZAdY~l$hkt3lGO`P_`!|_#i7j>oPR;88j)8#T`y}p3&YSJ3L1E4 zCvq^?2mM_uNbfLI_W|SlKfxJz54089kd>t0r?l#=DWgGyd$UmvLVB*|ePy7&Q^c=+ zf&`+cl2%WthW1Y3O2dCb-@#6i3mVQvg*MA9JDKZP3>e|LscGijniXQilRGKD_GYbV z@4n3iGjO_q9RnBwAC_0FekpA-C8(GCN6rJeUSel5kyf!YBGS;%(9qD( e(9jTq)#?}XQd3d>0Tsgl0000i$*sI>^8Eec!zxJB*MTL)o-UH0fe5+r+>TifPJ8S>pFckoEFlN z!i_TQ&$=G*vLp~_gK}gYad%z#d7iXgK8ax3Bu5o(7v}_Wo|gJvZcSi>{DP%$-a~aX zuLE}SJLozIW6-BK=y;v04 zyyPhBx(EFHOJFe&?4t+g(bEK=s)W_m?JJ1ii`bI(fg)g-_B`CFha90b^-RC;QxV$;B8TsnL0ya zNeo9dMPT@}UJ8@oBbSa4+cvXyE%j07^_zhq)Gut-c|Z1qLd?E8(85IgcL1kFCvgng zE=s!2sOJE2dx{(sz6aI$2d>d*G#ZUY<84{3egH&ux=<%R)5P$L_t(&L+zJA3dA4`MLj@oKF6BVxbp_n38WCLh>2EX`40lE z&DWRGO#=V`004F*#(40hnGt)Kpo3FN-+z60NeyLbkLg1Q`5%{h2+D~3{2?*{)et?| zp;$yLnMctGX?my9BG%Hgl$v1enJY@7r8RE%NkLeaZ}|%n&0)m%ktawtliz0m63xVA zZTJ1t{cVlgeNhvwJ##^eU`x*uG-8_GDOiLonMddm>B$b^6+bj$2=m*c>=OBl5eF}m i2LJ#70002IfDldvZjq=;FZw1z3OuIzcC3gKWSGS%Dc?B3pC= z{_t_f|5nfUloLh})3{FB`rW;265Fz#E!m=rii(Pg|Aout@_IU*n)CU*7B2bu_duLq z2|o>Y_{Qe>W53_OVD-i6&EatPP$BaC&Mwmc4hgZEcj-AvF@MvFz{Kjr01^93`P*7& zqw!_K=?Uk-Mrd=OLrB4n*@;~+oD)1bS{Qez&ZMw`!^h+CO`dgZ$7!$_At$n)PMDAr zuJSchc=Sm$}< z+FN;JV>(epQ33sAkDRk2#XOPzDSz+_-=|&woOIEyM<^QY|3>d7niHT_v$r zlOEAF$0P>(u;4N3t!x(^qeJ;pRKU$oL535?HFw%vJBDQifU%<<5}gOj3m~_`n@WQuFVj>$)1r(lpHzS*`Bl z17l0A{td=|8ZQ9q9}?LI8T9m}DI@8OeAv$kPAnU|K#sA0f`2o2*Vw`MZNn+lctQt| z*?$0zypWaBW4;8xlu?`#D6hC`R6b0cG!!{dBAxrO$X}YKK-v5gkW05aK_4ef0t{s6 zR8mcYjT2}y;e`CA`o##OfXb*eCB4BYo>`}3?p(;PtS5oWs5CXuTOs4utx+~1eM}z(4B54lENS)YjzbEwyo8pq49)H47tUfgEA8Lvbh7U@hJ1M zW>007*{1FwCm^$(1MXx#yn9Qs$iXrDkf9i4vnq@Nw5F+*zh1}wKK^ckj z5aTssk}Vyu_ZF1zYMuo$4~g4Tc#2&dfSkDo_@I*#KYxq^ZU`;jN+~1pV}uYvzx|0} zlzm|hQQxtCVgkc#SU{GKmC?$wjeQbZ{9iV8fI#N$Dabm?^~JY(sW&S)7#DgmY1bovfT9ToT|hy z4EMPum*zAjWSJ&iZpF+Vvk&ta$MLGsWe};Sz^1{m)p$Q5Jb%0Zj;+S~5n(K#&qKY( zB+pu-@qQpP;#w~k2X2$Y0ujiJm<4jcZE{#30+|uBKn}P~4huveGh!CV0k_Fvfe2(q z%mO*!HaYtg_{q1?M105~Q{(+?`Kb2{vWk9@fi=HXoYNLxo)AI^A%qYzPgT7E=!-;J UaKp1V00000Ne4wvM6N<$f`~4Bb^rhX delta 251 zcmV6IFhMt916E)c24a__*u)7%V>S8wDhDviP`V0Ua!tadeAgvmZ3m;^USD#Ar`< zr?YDW1zHqv(%ChF0xb$S>FgRofffavbasuPK#KxSI=e<}SU?{CZYd)))8gY~ z-s+qB2+QhsN2YY3d@8QLRU$_-x-Sm^007{%l000Q3X_`&n_hnA8r`Y=;2VRkGPO4mkZ~;}& zLzR@vi=2I{V0O7&1v2J))hy_sQp)CoO;r(3AwU9~sv@33fPVxwRYg37010fWig*eE z64+D~@zgp4bX~Wz+6}EQz%UGlFMNIy;7qDj+o+4!JfPo4)vpyEpynNwAN%;fJtQuKmExTDD^Z$LV!pK$l-xpgW5+s?7 lOB8b8000000AOtt#T_Ru4sgnHp%wrD002ovPDHLkV1f$~n8*MC delta 334 zcmV-U0kQs|1DgYoR(~)_L_t(&L+zM>4T3NbMHzrOT!00fzzN*I4P3z$oWUjB!d(FW zr>9YisIhl}(aq^8>QPy=hbjoD=ydK1V!@qDL ggb+dqF*mB}3cZDkL|&=ta{vGU07*qoM6N<$f{pZ{kN^Mx diff --git a/CameraToolkit/Resources/toolStripButtonSave.png b/CameraToolkit/Resources/toolStripButtonSave.png index 66e72a4fd00c48228367c9f9206a89c800f126e0..39760b5c2103c37fe9a9dea11f6afba39352a925 100644 GIT binary patch delta 353 zcmV-n0iOP*1Fi#*R)0fDL_t(&L+zN|je{@{gel+}NF8b5`bjBiAvMqhU0ese01vz; zJJKRqYeNEf?VL0teM*G)$Ab+58j7MQs;K(D|Cy%gdKT2tl4Uf{^FeZhYeE`$8-D>5=KfP1(Sdgec!Jjicg$MT2ZjZNe}VL^A*jbPg8iJ{_eiFhiHf7VMIwcku~9 zE#idw+f{W>`U33l`#w7fhQSzPOjDL+IU&v!;v~s7%=7#=|l4UkY15Dqs$!hcLaw21+6R(d@snza9i zfh)cfK3)lqmCP2g1{z=k85B+0O|XFsiYDzQ^f!Q~&E@XNb5ZkNx*NzQz_!%2i>?OV zH6(+5DWyms1GrR1r9Xu^O5dWJf#MN^IZEHc1~Mp`w2M4F3bQYz6zOLGEBvV;8SGP9 ziLN`an!w9#CsO$Sz~o7YfxX**1Ct&Z`gnwxpOu)*o*VF2u!hRj2gib{e{B6k3ly{Z r_pk_p_e9NzpSUr`7-Nk2YYf9TyCq{nySd;300000NkvXXu0mjfc|e>1 diff --git a/CameraToolkit/Resources/toolStripButtonSettings.png b/CameraToolkit/Resources/toolStripButtonSettings.png index 6cfc3172b73b88646e8b253341dc1b93cb57f5ca..2dc6b1d9425c5dd256e792cd8f3582200cd0d84c 100644 GIT binary patch delta 415 zcmV;Q0bu^<1M35jR)2s=L_t(&L+zODjlwVthC2WYu)r4sM}z!GuM{P5Y>MrERF2~~pTjT=CsMtj6K~ru6y%Ncv!EMq+bArLcFla3s{qE1liOoGn08M)rxsb z3*>YX?f>m&CVx4HczG4c7UE@lBuOit(ylhL+DO7Y3)8XZ|(NDRNmHQ|GwBpSz zvtp*hf0YJ*l+9xVKrZ8@LvUKg3k`@`X@jm39OBh54n`C9!iFyhI@9yVm_G*vmU47U zooKc^d@oYav3T2lp&+$-DB{Cb@t+pU{jlwVx1XDm7_y)cK8lVCypaWX^8omj-_+FB* zn`{usv15==*smK2$?~ml4|6d|I>&LG|HCv*hjAP)TOY3 z+6M1H580Im`P+V=Auw1UDX-Wqo+`5;#;-h5o|TIi_vzuw*xm=Nz;v@mIj=&Zq}FQq zSyX2f$?7F_JuoI&y`adpUoE1}wqNc#j^j9v<1|Ir-4y^ifF6oKF4YqN0000 MaterialDesign.IconType.linked_camera; + internal static string SessionId => DateTime.Now.TimeOfDay.Ticks.ToString(); + internal static FilterInfoCollection Devices => new FilterInfoCollection(FilterCategory.VideoInputDevice); + + internal static List Formats => new List(new[] { ".bmp", ".jpg", ".jpeg", ".jpe", ".jfif", ".png", ".gif" }); + + internal static string AlbumName = string.Empty; + + internal static void Initialize() + { +#if DEBUG + ImageHelper.GetEditorIcon(MaterialDesign.GetImage(Program.Icon, 256, Color.White)); +#endif + } + + internal static Dictionary GetDevices() + { + var result = new Dictionary(); + + if (Devices.Count > 0) + for (int i = 0; i < Devices.Count; i++) + result.Add(Devices[i].MonikerString, Devices[i].Name.ToString()); + + return result; + } + + internal static DialogResult ShowInputDialog(ref string input, string caption) + { + var size = new Size(200, 70); + + 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 + { + 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 + { + 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; + inputBox.CancelButton = cancelButton; + + var result = inputBox.ShowDialog(); + input = textBox.Text; + + return result; + } + } +} \ No newline at end of file diff --git a/CameraToolkit/app.config b/CameraToolkit/app.config index aca9bcd..d00a81b 100644 --- a/CameraToolkit/app.config +++ b/CameraToolkit/app.config @@ -22,6 +22,9 @@ False + + True + diff --git a/CameraToolkit/packages.config b/CameraToolkit/packages.config index c54da54..53c09a7 100644 --- a/CameraToolkit/packages.config +++ b/CameraToolkit/packages.config @@ -5,7 +5,7 @@ - + \ No newline at end of file From afcf906a0fdc133bccd7697f1ee6555cd0ee207f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enner=20P=C3=A9rez?= Date: Tue, 26 Dec 2017 12:49:29 -0400 Subject: [PATCH 2/2] General update --- CameraToolkit/CameraToolkit.csproj | 3 + CameraToolkit/Controls/Gallery.Designer.cs | 57 ++--- CameraToolkit/Controls/Gallery.es.resx | 156 +++++++++++++ CameraToolkit/Controls/Gallery.resx | 241 +++++++++++++++++++++ CameraToolkit/Forms/FormMain.cs | 2 +- CameraToolkit/Forms/FormMain.resx | 6 + CameraToolkit/Forms/FormSettings.cs | 2 +- CameraToolkit/Forms/FormSettings.es.resx | 5 +- CameraToolkit/References/System.cs | 10 +- CameraToolkit/Toolkit.cs | 13 ++ README.md | 2 +- 11 files changed, 450 insertions(+), 47 deletions(-) create mode 100644 CameraToolkit/Controls/Gallery.es.resx diff --git a/CameraToolkit/CameraToolkit.csproj b/CameraToolkit/CameraToolkit.csproj index 49b809b..100f954 100644 --- a/CameraToolkit/CameraToolkit.csproj +++ b/CameraToolkit/CameraToolkit.csproj @@ -133,6 +133,9 @@ Settings.settings + + Gallery.cs + Gallery.cs diff --git a/CameraToolkit/Controls/Gallery.Designer.cs b/CameraToolkit/Controls/Gallery.Designer.cs index eed9e81..dbba801 100644 --- a/CameraToolkit/Controls/Gallery.Designer.cs +++ b/CameraToolkit/Controls/Gallery.Designer.cs @@ -29,6 +29,7 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Gallery)); this.imageListThumbs = new System.Windows.Forms.ImageList(this.components); this.listViewItems = new System.Windows.Forms.ListView(); this.columnHeaderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -53,7 +54,7 @@ private void InitializeComponent() // imageListThumbs // this.imageListThumbs.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit; - this.imageListThumbs.ImageSize = new System.Drawing.Size(48, 48); + resources.ApplyResources(this.imageListThumbs, "imageListThumbs"); this.imageListThumbs.TransparentColor = System.Drawing.Color.Transparent; // // listViewItems @@ -64,31 +65,25 @@ private void InitializeComponent() this.columnHeaderPath, this.columnHeaderSize}); this.listViewItems.ContextMenuStrip = this.contextMenuStripActions; - this.listViewItems.Dock = System.Windows.Forms.DockStyle.Fill; + resources.ApplyResources(this.listViewItems, "listViewItems"); this.listViewItems.FullRowSelect = true; this.listViewItems.LargeImageList = this.imageListThumbs; - this.listViewItems.Location = new System.Drawing.Point(0, 0); this.listViewItems.Name = "listViewItems"; - this.listViewItems.Size = new System.Drawing.Size(240, 435); this.listViewItems.SmallImageList = this.imageListThumbs; - this.listViewItems.TabIndex = 0; this.listViewItems.UseCompatibleStateImageBehavior = false; - this.listViewItems.Visible = false; this.listViewItems.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.ListViewItems_MouseDoubleClick); // // columnHeaderName // - this.columnHeaderName.Text = "Name"; - this.columnHeaderName.Width = 120; + resources.ApplyResources(this.columnHeaderName, "columnHeaderName"); // // columnHeaderPath // - this.columnHeaderPath.Text = "Path"; + resources.ApplyResources(this.columnHeaderPath, "columnHeaderPath"); // // columnHeaderSize // - this.columnHeaderSize.Text = "Size"; - this.columnHeaderSize.Width = 100; + resources.ApplyResources(this.columnHeaderSize, "columnHeaderSize"); // // contextMenuStripActions // @@ -98,7 +93,7 @@ private void InitializeComponent() this.openToolStripMenuItem, this.deleteToolStripMenuItem}); this.contextMenuStripActions.Name = "contextMenuStripActions"; - this.contextMenuStripActions.Size = new System.Drawing.Size(108, 76); + resources.ApplyResources(this.contextMenuStripActions, "contextMenuStripActions"); this.contextMenuStripActions.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripActions_Opening); // // viewToolStripMenuItem @@ -110,61 +105,53 @@ private void InitializeComponent() this.detailsToolStripMenuItem, this.tilesToolStripMenuItem}); this.viewToolStripMenuItem.Name = "viewToolStripMenuItem"; - this.viewToolStripMenuItem.Size = new System.Drawing.Size(107, 22); - this.viewToolStripMenuItem.Text = "&View"; + resources.ApplyResources(this.viewToolStripMenuItem, "viewToolStripMenuItem"); // // listToolStripMenuItem // this.listToolStripMenuItem.Name = "listToolStripMenuItem"; - this.listToolStripMenuItem.Size = new System.Drawing.Size(134, 22); - this.listToolStripMenuItem.Text = "&List"; + resources.ApplyResources(this.listToolStripMenuItem, "listToolStripMenuItem"); this.listToolStripMenuItem.Click += new System.EventHandler(this.ListToolStripMenuItem_Click); // // smallIconsToolStripMenuItem // this.smallIconsToolStripMenuItem.Name = "smallIconsToolStripMenuItem"; - this.smallIconsToolStripMenuItem.Size = new System.Drawing.Size(134, 22); - this.smallIconsToolStripMenuItem.Text = "&Small icons"; + resources.ApplyResources(this.smallIconsToolStripMenuItem, "smallIconsToolStripMenuItem"); this.smallIconsToolStripMenuItem.Click += new System.EventHandler(this.SmallIconsToolStripMenuItem_Click); // // largeIconsToolStripMenuItem // this.largeIconsToolStripMenuItem.Name = "largeIconsToolStripMenuItem"; - this.largeIconsToolStripMenuItem.Size = new System.Drawing.Size(134, 22); - this.largeIconsToolStripMenuItem.Text = "L&arge icons"; + resources.ApplyResources(this.largeIconsToolStripMenuItem, "largeIconsToolStripMenuItem"); this.largeIconsToolStripMenuItem.Click += new System.EventHandler(this.LargeIconsToolStripMenuItem_Click); // // detailsToolStripMenuItem // this.detailsToolStripMenuItem.Name = "detailsToolStripMenuItem"; - this.detailsToolStripMenuItem.Size = new System.Drawing.Size(134, 22); - this.detailsToolStripMenuItem.Text = "&Details"; + resources.ApplyResources(this.detailsToolStripMenuItem, "detailsToolStripMenuItem"); this.detailsToolStripMenuItem.Click += new System.EventHandler(this.DetailsToolStripMenuItem_Click); // // tilesToolStripMenuItem // this.tilesToolStripMenuItem.Name = "tilesToolStripMenuItem"; - this.tilesToolStripMenuItem.Size = new System.Drawing.Size(134, 22); - this.tilesToolStripMenuItem.Text = "&Tiles"; + resources.ApplyResources(this.tilesToolStripMenuItem, "tilesToolStripMenuItem"); this.tilesToolStripMenuItem.Click += new System.EventHandler(this.TilesToolStripMenuItem_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(104, 6); + resources.ApplyResources(this.toolStripSeparator1, "toolStripSeparator1"); // // openToolStripMenuItem // this.openToolStripMenuItem.Name = "openToolStripMenuItem"; - this.openToolStripMenuItem.Size = new System.Drawing.Size(107, 22); - this.openToolStripMenuItem.Text = "&Open"; + resources.ApplyResources(this.openToolStripMenuItem, "openToolStripMenuItem"); this.openToolStripMenuItem.Click += new System.EventHandler(this.OpenToolStripMenuItem_Click); // // deleteToolStripMenuItem // this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; - this.deleteToolStripMenuItem.Size = new System.Drawing.Size(107, 22); - this.deleteToolStripMenuItem.Text = "&Delete"; + resources.ApplyResources(this.deleteToolStripMenuItem, "deleteToolStripMenuItem"); this.deleteToolStripMenuItem.Click += new System.EventHandler(this.DeleteToolStripMenuItem_Click); // // fileSystemWatcher @@ -178,23 +165,17 @@ private void InitializeComponent() // // labelInformation // - this.labelInformation.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelInformation.Location = new System.Drawing.Point(0, 0); + resources.ApplyResources(this.labelInformation, "labelInformation"); this.labelInformation.Name = "labelInformation"; - this.labelInformation.Size = new System.Drawing.Size(240, 435); - this.labelInformation.TabIndex = 1; - this.labelInformation.Text = "No items was found\r\n"; - this.labelInformation.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.labelInformation.Visible = false; // // Gallery // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.labelInformation); this.Controls.Add(this.listViewItems); + this.DoubleBuffered = true; this.Name = "Gallery"; - this.Size = new System.Drawing.Size(240, 435); this.Load += new System.EventHandler(this.Gallery_Load); this.contextMenuStripActions.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.fileSystemWatcher)).EndInit(); diff --git a/CameraToolkit/Controls/Gallery.es.resx b/CameraToolkit/Controls/Gallery.es.resx new file mode 100644 index 0000000..e794dff --- /dev/null +++ b/CameraToolkit/Controls/Gallery.es.resx @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Nombre + + + Ruta + + + Tamaño + + + &Lista + + + Iconos &pequeños + + + Iconos &grandes + + + &Detalles + + + &Mosaicos + + + &Ver + + + &Abrir + + + &Eliminar + + + No se encontraron elementos + + \ No newline at end of file diff --git a/CameraToolkit/Controls/Gallery.resx b/CameraToolkit/Controls/Gallery.resx index ba67419..e980946 100644 --- a/CameraToolkit/Controls/Gallery.resx +++ b/CameraToolkit/Controls/Gallery.resx @@ -120,10 +120,251 @@ 17, 17 + + + 48, 48 + + + Name + + + + 120 + + + Path + + + Size + + + 100 + 316, 17 + + 134, 22 + + + &List + + + 134, 22 + + + &Small icons + + + 134, 22 + + + L&arge icons + + + 134, 22 + + + &Details + + + 134, 22 + + + &Tiles + + + 107, 22 + + + &View + + + 104, 6 + + + 107, 22 + + + &Open + + + 107, 22 + + + &Delete + + + 108, 76 + + + contextMenuStripActions + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + Fill + + + 0, 0 + + + 240, 435 + + + 0 + + + False + + + listViewItems + + + System.Windows.Forms.ListView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + 164, 17 + + True + + + 6, 13 + + + Fill + + + 0, 0 + + + 240, 435 + + + 1 + + + No items was found + + + + MiddleCenter + + + False + + + labelInformation + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + 240, 435 + + + imageListThumbs + + + System.Windows.Forms.ImageList, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + columnHeaderName + + + System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + columnHeaderPath + + + System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + columnHeaderSize + + + System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + viewToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + listToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + smallIconsToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + largeIconsToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + detailsToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tilesToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + toolStripSeparator1 + + + System.Windows.Forms.ToolStripSeparator, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + openToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + deleteToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + fileSystemWatcher + + + System.IO.FileSystemWatcher, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Gallery + + + System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/CameraToolkit/Forms/FormMain.cs b/CameraToolkit/Forms/FormMain.cs index de49e14..0630f47 100644 --- a/CameraToolkit/Forms/FormMain.cs +++ b/CameraToolkit/Forms/FormMain.cs @@ -26,7 +26,7 @@ public FormMain() saveFileDialogMain.DefaultExt = Program.Formats.FirstOrDefault(); // Icons - toolStripButtonDevices.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.linked_camera, 48, SystemColors.Control); + toolStripButtonDevices.SetImage(MaterialDesign.Instance, Program.Icon, 48, SystemColors.Control); toolStripButtonCapture.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.camera, 48, SystemColors.Control); toolStripButtonSave.SetImage(MaterialDesign.Instance, MaterialDesign.IconType.save, 48, SystemColors.Control); diff --git a/CameraToolkit/Forms/FormMain.resx b/CameraToolkit/Forms/FormMain.resx index ff101e7..70f3996 100644 --- a/CameraToolkit/Forms/FormMain.resx +++ b/CameraToolkit/Forms/FormMain.resx @@ -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 c0f2f4e..f90a8dc 100644 --- a/CameraToolkit/Forms/FormSettings.cs +++ b/CameraToolkit/Forms/FormSettings.cs @@ -11,7 +11,7 @@ public FormSettings() { InitializeComponent(); - Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetEntryAssembly().Location); + Icon = Icon.ExtractAssociatedIcon(Program.Assembly.Location); comboBoxDevices.DisplayMember = "Value"; comboBoxDevices.ValueMember = "Key"; diff --git a/CameraToolkit/Forms/FormSettings.es.resx b/CameraToolkit/Forms/FormSettings.es.resx index 395783b..4fb6596 100644 --- a/CameraToolkit/Forms/FormSettings.es.resx +++ b/CameraToolkit/Forms/FormSettings.es.resx @@ -155,7 +155,7 @@ 128, 17 - &Guardado automatico + &Guardado automático @@ -775,4 +775,7 @@ Sistema + + &Buscar actualizaciones al iniciar + \ No newline at end of file diff --git a/CameraToolkit/References/System.cs b/CameraToolkit/References/System.cs index cf7e687..a4445f4 100644 --- a/CameraToolkit/References/System.cs +++ b/CameraToolkit/References/System.cs @@ -1,7 +1,7 @@ // ---------------------------------------- // System References -// Version 1.0.3 -// Updated 2018-12-26 +// Version 1.1.0 +// Updated 2017-12-26 // ---------------------------------------- using GitHub; @@ -123,8 +123,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, IO.FileMode.Open)) - using (FileStream outputStream = new FileStream(outputPath, IO.FileMode.OpenOrCreate)) + using (FileStream inputStream = new FileStream(inputPath, FileMode.Open)) + using (FileStream outputStream = new FileStream(outputPath, FileMode.OpenOrCreate)) { return ConvertToIcon(inputStream, outputStream, size, preserveAspectRatio); } @@ -200,7 +200,7 @@ public static Rectangle GetWorkingArea() maxy = Math.Max(maxy, bounds.Bottom); } - return new System.Drawing.Rectangle(0, 0, (maxx - minx), (maxy - miny)); + return new Rectangle(0, 0, (maxx - minx), (maxy - miny)); } } diff --git a/CameraToolkit/Toolkit.cs b/CameraToolkit/Toolkit.cs index d6f247c..b3221fa 100644 --- a/CameraToolkit/Toolkit.cs +++ b/CameraToolkit/Toolkit.cs @@ -1,4 +1,5 @@ using AForge.Video.DirectShow; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Drawing; @@ -17,6 +18,18 @@ internal static partial class Program internal static string AlbumName = string.Empty; + internal static JsonSerializerSettings SerializerSettings = new JsonSerializerSettings() + { + Formatting = Formatting.Indented, + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + NullValueHandling = NullValueHandling.Ignore, + MissingMemberHandling = MissingMemberHandling.Ignore, + Error = new EventHandler((object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args) => + { + args.ErrorContext.Handled = true; + }) + }; + internal static void Initialize() { #if DEBUG diff --git a/README.md b/README.md index 422d51b..b97d5bb 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ See the [changelog](CHANGELOG.md) for changes. - [x] Settings separations - [x] Album name - [x] Spanish translation -- [ ] Gallery management +- [x] Gallery management - [ ] OCR module ## Table of contents