Skip to content

Commit

Permalink
Version 1.6.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
svenhb committed Aug 11, 2022
1 parent dd2d032 commit 79b4729
Show file tree
Hide file tree
Showing 39 changed files with 2,625 additions and 1,664 deletions.
43 changes: 26 additions & 17 deletions GRBL-Plotter/MachineControl/CheckUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,20 @@ public static void CheckVersion(bool showAnyResult, string lastEvents)

private static void AsyncCheckVersion(object foo)
{
try {
try
{
TryCheckSite2();
} //official https
catch {
catch
{
CheckSite1(@"https://api.github.com/repos/svenhb/GRBL-Plotter/releases/latest");
}
}

private static void TryCheckSite2()
{
try {
try
{
CultureInfo ci = CultureInfo.InstalledUICulture;
ci = CultureInfo.CurrentUICulture;
Logger.Trace(culture, " Vers.:{0} ID:{1} LangSet:{2} LangOri:{3} url:{4}", Application.ProductVersion, GetID(), Properties.Settings.Default.guiLanguage, ci.Name, Properties.Settings.Default.guiCheckUpdateURL);
Expand All @@ -85,16 +88,18 @@ private static void TryCheckSite2()
}
CheckSite2(Properties.Settings.Default.guiCheckUpdateURL + "/GRBL-Plotter.php" + get); // get Version-Nr and count individual ip to get an idea of amount of users
}
catch (Exception ex) {
Logger.Error(ex, "AsyncCheckVersion - CheckSite2");
catch (Exception ex)
{
Logger.Error(ex, "AsyncCheckVersion - CheckSite2");
}

}


private static string GetCounters(CounterType type)
{
try {
try
{
if (type == CounterType.import)
{
uint gcode = Properties.Settings.Default.counterImportGCode;
Expand Down Expand Up @@ -124,8 +129,9 @@ private static string GetCounters(CounterType type)
return tmp;
}
}
catch (Exception ex) {
Logger.Error(ex, " getCounters");
catch (Exception ex)
{
Logger.Error(ex, " getCounters");
}
return "0";
}
Expand All @@ -138,12 +144,13 @@ private static void CheckSite2(string site)
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
using (System.Net.WebClient wc = new System.Net.WebClient())
{
try {
string logTmp = site;
if (site.Length > 255)
logTmp = site.Substring(0,255);
try
{
string logTmp = site;
if (site.Length > 255)
logTmp = site.Substring(0, 255);
Logger.Trace(culture, "CheckSite2 {0}", logTmp);

string[] lines = wc.DownloadString(site).Split(';');
string vers = lines[0];
Logger.Trace(culture, "CheckSite2 {0}", String.Join(" | ", lines));
Expand All @@ -155,11 +162,13 @@ private static void CheckSite2(string site)
info = lines[1];
ShowResult(current, latest, info);
}
catch (WebException ex) {
catch (WebException ex)
{
Logger.Error(ex, "CheckSite2 1)");
}
catch (Exception ex) {
Logger.Error(ex, "CheckSite2 2)");
catch (Exception ex)
{
Logger.Error(ex, "CheckSite2 2)");
}
}
}
Expand Down Expand Up @@ -205,7 +214,7 @@ private static void ShowResult(Version current, Version latest, String info)
}
if (info != null)
{
Logger.Info("CheckVersion: current:{0} latest:{1} info:{2}", current, latest, info.Replace("\n","|"));
Logger.Info("CheckVersion: current:{0} latest:{1} info:{2}", current, latest, info.Replace("\n", "|"));

if (!string.IsNullOrEmpty(info))
info = "\r\n" + info + "\r\n";
Expand Down
94 changes: 49 additions & 45 deletions GRBL-Plotter/MachineControl/ControlCameraForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public partial class ControlCameraForm : Form
private XyPoint teachPoint1;
private XyPoint teachPoint2;
private XyPoint lastClickedCoordinate;
// private XyPoint positionOffsetMachine = new XyPoint();
// private XyPoint positionOffsetMachine = new XyPoint();

// private XyPoint teachPoint3;
private int coordG = 54;
Expand Down Expand Up @@ -263,13 +263,13 @@ private void Camera_form_Load(object sender, EventArgs e)
}
toolStripCameraMount.Click += ToolStripCameraMount_SelectedIndexChanged;

/* if (false) // perhaps needed in future
{
positionOffsetMachine.X = (double)Properties.Settings.Default.machineLimitsHomeX;
positionOffsetMachine.Y = (double)Properties.Settings.Default.machineLimitsHomeY;
}
else*/
// positionOffsetMachine = new XyPoint();
/* if (false) // perhaps needed in future
{
positionOffsetMachine.X = (double)Properties.Settings.Default.machineLimitsHomeX;
positionOffsetMachine.Y = (double)Properties.Settings.Default.machineLimitsHomeY;
}
else*/
// positionOffsetMachine = new XyPoint();
}
// save settings
private void Camera_form_FormClosing(object sender, FormClosingEventArgs e)
Expand Down Expand Up @@ -354,8 +354,9 @@ private void TimerFreezFrame_Tick(object sender, EventArgs e)
if (useFreezFrame)
{
if (exampleFrame == null)
{ useFreezFrame = false;
return;
{
useFreezFrame = false;
return;
}
if (cBShapeDetection.Checked || fiducialDetection)
ProcessShapeDetection((Bitmap)ProcessImage((Bitmap)exampleFrame.Clone(), (float)cameraRotation, cameraZoom));
Expand Down Expand Up @@ -448,7 +449,7 @@ private void PictureBoxVideo_Paint(object sender, PaintEventArgs e)
e.Graphics.DrawEllipse(penTeachMark, new Rectangle(xmid - radiusInPx, ymid - radiusInPx, 2 * radiusInPx, 2 * radiusInPx));
string txt = Localization.GetString("cameraNextClick") + " " + cameraTeachRadiusXy.ToString(culture);
ShowLabel(e.Graphics, stringpos, txt);
}
}
break;
}
case SetupType.TeachXyzTop:
Expand All @@ -459,7 +460,7 @@ private void PictureBoxVideo_Paint(object sender, PaintEventArgs e)
e.Graphics.DrawEllipse(penTeachMark, new Rectangle(xmid - radiusInPx, ymid - radiusInPx, 2 * radiusInPx, 2 * radiusInPx));
string txt = Localization.GetString("cameraNextClick") + " " + cameraTeachRadiusXyzTop.ToString(culture);
ShowLabel(e.Graphics, stringpos, txt);
}
}
break;
}
case SetupType.TeachXyzBot:
Expand All @@ -470,7 +471,7 @@ private void PictureBoxVideo_Paint(object sender, PaintEventArgs e)
e.Graphics.DrawEllipse(penTeachMark, new Rectangle(xmid - radiusInPx, ymid - radiusInPx, 2 * radiusInPx, 2 * radiusInPx));
string txt = Localization.GetString("cameraNextClick") + " " + cameraTeachRadiusXyzBot.ToString(culture);
ShowLabel(e.Graphics, stringpos, txt);
}
}
break;
}
case SetupType.MeasureAngle:
Expand Down Expand Up @@ -885,9 +886,10 @@ private void BtnApplyAngle_Click(object sender, EventArgs e)
private void CbShapeDetection_CheckedChanged(object sender, EventArgs e)
{
if (cBShapeDetection.Checked)
{ btnAutoCenter.Enabled = true;
ListSettings();
}
{
btnAutoCenter.Enabled = true;
ListSettings();
}
else
btnAutoCenter.Enabled = false;
}
Expand All @@ -906,35 +908,35 @@ private void FillComboBox() // on Form load
string txt;
comboBox1.Items.Clear();
txt = Properties.Settings.Default.camShapeSet1;
if (txt.IndexOf('|') < 1)
{ txt = Properties.Settings.Default.camShapeSet1 = "Paper|0|100|0|100|0|100|True|True|True|20|200|0.5|1|"; Logger.Error("FillComboBox set default for 1: {0}", txt);}
if (txt.IndexOf('|') < 1)
{ txt = Properties.Settings.Default.camShapeSet1 = "Paper|0|100|0|100|0|100|True|True|True|20|200|0.5|1|"; Logger.Error("FillComboBox set default for 1: {0}", txt); }
comboBox1.Items.Add((string.IsNullOrEmpty(txt)) ? "not set" : txt.Substring(0, txt.IndexOf('|')));

txt = Properties.Settings.Default.camShapeSet2;
if (txt.IndexOf('|') < 1)
{ txt = Properties.Settings.Default.camShapeSet2 = "Paper2|0|100|0|100|0|100|True|True|True|20|200|0.5|1|";Logger.Error("FillComboBox set default for 2: {0}", txt);}
if (txt.IndexOf('|') < 1)
{ txt = Properties.Settings.Default.camShapeSet2 = "Paper2|0|100|0|100|0|100|True|True|True|20|200|0.5|1|"; Logger.Error("FillComboBox set default for 2: {0}", txt); }
comboBox1.Items.Add((string.IsNullOrEmpty(txt)) ? "not set" : txt.Substring(0, txt.IndexOf('|')));

txt = Properties.Settings.Default.camShapeSet3;
if (txt.IndexOf('|') < 1)
{ txt = Properties.Settings.Default.camShapeSet3 = "PCB|0|150|0|150|0|150|False|False|True|20|100|0.5|1|"; Logger.Error("FillComboBox set default for 3: {0}", txt);}
if (txt.IndexOf('|') < 1)
{ txt = Properties.Settings.Default.camShapeSet3 = "PCB|0|150|0|150|0|150|False|False|True|20|100|0.5|1|"; Logger.Error("FillComboBox set default for 3: {0}", txt); }
comboBox1.Items.Add((string.IsNullOrEmpty(txt)) ? "not set" : txt.Substring(0, txt.IndexOf('|')));

txt = Properties.Settings.Default.camShapeSet4;
if (txt.IndexOf('|') < 1)
{ txt = Properties.Settings.Default.camShapeSet4 = "Wood|0|106|0|237|123|246|True|True|False|10|100|0.5|2.0|"; Logger.Error("FillComboBox set default for 4: {0}", txt);}
if (txt.IndexOf('|') < 1)
{ txt = Properties.Settings.Default.camShapeSet4 = "Wood|0|106|0|237|123|246|True|True|False|10|100|0.5|2.0|"; Logger.Error("FillComboBox set default for 4: {0}", txt); }
comboBox1.Items.Add((string.IsNullOrEmpty(txt)) ? "not set" : txt.Substring(0, txt.IndexOf('|')));
Properties.Settings.Default.Save();

byte selectedIndex = 0;
if (CameraMount == CameraMounting.Fix)
selectedIndex = filterIndexFix = Properties.Settings.Default.cameraFilterIndexFix;
else
selectedIndex = filterIndexXy = Properties.Settings.Default.cameraFilterIndexXy;
if (selectedIndex >= comboBox1.Items.Count) {Logger.Error("FillComboBox stored index too high: {0}", selectedIndex); selectedIndex = 0; }
comboBox1.SelectedIndex = (int)selectedIndex;

Properties.Settings.Default.Save();

byte selectedIndex = 0;
if (CameraMount == CameraMounting.Fix)
selectedIndex = filterIndexFix = Properties.Settings.Default.cameraFilterIndexFix;
else
selectedIndex = filterIndexXy = Properties.Settings.Default.cameraFilterIndexXy;

if (selectedIndex >= comboBox1.Items.Count) { Logger.Error("FillComboBox stored index too high: {0}", selectedIndex); selectedIndex = 0; }
comboBox1.SelectedIndex = (int)selectedIndex;
}
}

Expand Down Expand Up @@ -1132,14 +1134,14 @@ private void ToolStripCameraMount_SelectedIndexChanged(object sender, EventArgs
else
timerFreezFrame.Stop();

if ((cameraIndex >= 0) && (cameraIndex < videosources.Count))
if ((cameraIndex >= 0) && (cameraIndex < videosources.Count))
((ToolStripMenuItem)camSourceToolStripMenuItem.DropDownItems[cameraIndex]).Checked = false;
SetCameraMountDependence();
if ((cameraIndex < 0) || (cameraIndex >= videosources.Count))
cameraIndex = 0;
frameCounter = 0;
if (camSourceToolStripMenuItem.DropDownItems.Count > 0)
((ToolStripMenuItem)camSourceToolStripMenuItem.DropDownItems[cameraIndex]).Checked = true;
if (camSourceToolStripMenuItem.DropDownItems.Count > 0)
((ToolStripMenuItem)camSourceToolStripMenuItem.DropDownItems[cameraIndex]).Checked = true;
SelectCameraSource(cameraIndex, cameraResolutionX);
SaveCameraDependence();
SetMenuVisibility();
Expand Down Expand Up @@ -1202,7 +1204,8 @@ private void SelectCameraSource(int index, int resolution)
videoSource = new VideoCaptureDevice(videosources[index].MonikerString);
((ToolStripMenuItem)camSourceToolStripMenuItem.DropDownItems[index]).Checked = true;

try {
try
{
int i;
if (videoSource.VideoCapabilities.Length > 0)
{
Expand All @@ -1216,9 +1219,10 @@ private void SelectCameraSource(int index, int resolution)
}
}
}
catch (Exception ex) {
Logger.Error(ex, "SelectCameraSource ");
}
catch (Exception ex)
{
Logger.Error(ex, "SelectCameraSource ");
}
videoSource.NewFrame += new AForge.Video.NewFrameEventHandler(VideoSource_NewFrame);
videoSource.Start();
}
Expand Down
Loading

0 comments on commit 79b4729

Please sign in to comment.