feature/proxy-creds #4

Merged
frozd merged 2 commits from feature/proxy-creds into master 2026-03-09 16:27:25 +01:00
9 changed files with 17170 additions and 10824 deletions

View File

@@ -13,6 +13,12 @@
"SccProvider" = "8:" "SccProvider" = "8:"
"Hierarchy" "Hierarchy"
{ {
"Entry"
{
"MsmKey" = "8:_0044BED058CA49BBB2B3F82F51D1428A"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry" "Entry"
{ {
"MsmKey" = "8:_39292C9AEE694F0B982DDECDC0233E12" "MsmKey" = "8:_39292C9AEE694F0B982DDECDC0233E12"
@@ -122,6 +128,26 @@
} }
"File" "File"
{ {
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_0044BED058CA49BBB2B3F82F51D1428A"
{
"SourcePath" = "8:..\\..\\..\\..\\Downloads\\no_image_found.png"
"TargetName" = "8:no_image_found.png"
"Tag" = "8:"
"Folder" = "8:_D65FC38A85AF4B67B3226105F5AC96DE"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_39292C9AEE694F0B982DDECDC0233E12" "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_39292C9AEE694F0B982DDECDC0233E12"
{ {
"SourcePath" = "8:D:\\Assets\\Car Manager\\Icon\\CarMgm_Icon.ico" "SourcePath" = "8:D:\\Assets\\Car Manager\\Icon\\CarMgm_Icon.ico"
@@ -194,6 +220,39 @@
{ {
} }
} }
"{1525181F-901A-416C-8A58-119130FE478E}:_C5D9982FD32343208C540E42270152A6"
{
"Name" = "8:#1915"
"AlwaysCreate" = "11:FALSE"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Property" = "8:AppDataFolder"
"Folders"
{
"{9EF0B969-E518-4E46-987F-47570745A589}:_91D306E0AE6B4CA09DB4A07129FBDD93"
{
"Name" = "8:CarManagerV3"
"AlwaysCreate" = "11:FALSE"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Property" = "8:_EF9BB1020CF44082864BA97C60FF6F5A"
"Folders"
{
"{9EF0B969-E518-4E46-987F-47570745A589}:_D65FC38A85AF4B67B3226105F5AC96DE"
{
"Name" = "8:images"
"AlwaysCreate" = "11:FALSE"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Property" = "8:_2863EBE193234A72BFFC0A3CF7D00340"
"Folders"
{
}
}
}
}
}
}
"{1525181F-901A-416C-8A58-119130FE478E}:_FA92AB5FBB9E4B2A8DFF0A59BAB53C34" "{1525181F-901A-416C-8A58-119130FE478E}:_FA92AB5FBB9E4B2A8DFF0A59BAB53C34"
{ {
"Name" = "8:#1916" "Name" = "8:#1916"

View File

@@ -29,81 +29,82 @@
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CarCard)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CarCard));
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.lblCarDetails = new System.Windows.Forms.Label(); lblCarDetails = new System.Windows.Forms.Label();
this.lblCarName = new System.Windows.Forms.Label(); lblCarName = new System.Windows.Forms.Label();
this.pbxCar = new System.Windows.Forms.PictureBox(); pbxCar = new System.Windows.Forms.PictureBox();
this.tableLayoutPanel1.SuspendLayout(); tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxCar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)pbxCar).BeginInit();
this.SuspendLayout(); SuspendLayout();
// //
// tableLayoutPanel1 // tableLayoutPanel1
// //
this.tableLayoutPanel1.AutoSize = true; tableLayoutPanel1.AutoSize = true;
this.tableLayoutPanel1.ColumnCount = 1; tableLayoutPanel1.ColumnCount = 1;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.lblCarDetails, 0, 2); tableLayoutPanel1.Controls.Add(lblCarDetails, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.lblCarName, 0, 1); tableLayoutPanel1.Controls.Add(lblCarName, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.pbxCar, 0, 0); tableLayoutPanel1.Controls.Add(pbxCar, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.MaximumSize = new System.Drawing.Size(210, 0); tableLayoutPanel1.MaximumSize = new System.Drawing.Size(184, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1"; tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 3; tableLayoutPanel1.RowCount = 3;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 130F)); tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 122F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(210, 200); tableLayoutPanel1.Size = new System.Drawing.Size(184, 188);
this.tableLayoutPanel1.TabIndex = 0; tableLayoutPanel1.TabIndex = 0;
// //
// lblCarDetails // lblCarDetails
// //
this.lblCarDetails.AutoSize = true; lblCarDetails.AutoSize = true;
this.lblCarDetails.Location = new System.Drawing.Point(3, 174); lblCarDetails.Location = new System.Drawing.Point(3, 166);
this.lblCarDetails.Name = "lblCarDetails"; lblCarDetails.Name = "lblCarDetails";
this.lblCarDetails.Size = new System.Drawing.Size(101, 16); lblCarDetails.Size = new System.Drawing.Size(92, 15);
this.lblCarDetails.TabIndex = 5; lblCarDetails.TabIndex = 5;
this.lblCarDetails.Text = "2009 - 13.000km"; lblCarDetails.Text = "2009 - 13.000km";
// //
// lblCarName // lblCarName
// //
this.lblCarName.AutoSize = true; lblCarName.AutoSize = true;
this.lblCarName.Dock = System.Windows.Forms.DockStyle.Fill; lblCarName.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblCarName.Font = new System.Drawing.Font("Arial", 13.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); lblCarName.Font = new System.Drawing.Font("Arial", 13.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
this.lblCarName.Location = new System.Drawing.Point(3, 130); lblCarName.Location = new System.Drawing.Point(3, 122);
this.lblCarName.Name = "lblCarName"; lblCarName.Name = "lblCarName";
this.lblCarName.Size = new System.Drawing.Size(204, 44); lblCarName.Size = new System.Drawing.Size(178, 44);
this.lblCarName.TabIndex = 4; lblCarName.TabIndex = 4;
this.lblCarName.Text = "Skoda Fabia fdsdfsdfsdfsdf"; lblCarName.Text = "Skoda Fabia fdsdfsdfsdfsdf";
this.lblCarName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; lblCarName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
// //
// pbxCar // pbxCar
// //
this.pbxCar.Dock = System.Windows.Forms.DockStyle.Fill; pbxCar.Dock = System.Windows.Forms.DockStyle.Fill;
this.pbxCar.Image = ((System.Drawing.Image)(resources.GetObject("pbxCar.Image"))); pbxCar.ErrorImage = (System.Drawing.Image)resources.GetObject("pbxCar.ErrorImage");
this.pbxCar.ImageLocation = ""; pbxCar.Image = (System.Drawing.Image)resources.GetObject("pbxCar.Image");
this.pbxCar.InitialImage = ((System.Drawing.Image)(resources.GetObject("pbxCar.InitialImage"))); pbxCar.ImageLocation = "";
this.pbxCar.Location = new System.Drawing.Point(3, 3); pbxCar.InitialImage = (System.Drawing.Image)resources.GetObject("pbxCar.InitialImage");
this.pbxCar.Name = "pbxCar"; pbxCar.Location = new System.Drawing.Point(3, 3);
this.pbxCar.Size = new System.Drawing.Size(204, 124); pbxCar.Name = "pbxCar";
this.pbxCar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; pbxCar.Size = new System.Drawing.Size(178, 116);
this.pbxCar.TabIndex = 3; pbxCar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pbxCar.TabStop = false; pbxCar.TabIndex = 3;
pbxCar.TabStop = false;
// //
// CarCard // CarCard
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true; AutoSize = true;
this.BackColor = System.Drawing.SystemColors.Control; BackColor = System.Drawing.SystemColors.Control;
this.Controls.Add(this.tableLayoutPanel1); Controls.Add(tableLayoutPanel1);
this.Name = "CarCard"; Name = "CarCard";
this.Size = new System.Drawing.Size(210, 200); Size = new System.Drawing.Size(184, 188);
this.tableLayoutPanel1.ResumeLayout(false); tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout(); tableLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxCar)).EndInit(); ((System.ComponentModel.ISupportInitialize)pbxCar).EndInit();
this.ResumeLayout(false); ResumeLayout(false);
this.PerformLayout(); PerformLayout();
} }

View File

@@ -58,6 +58,10 @@ namespace CarManagerV3
{ {
this.CarImage = img; this.CarImage = img;
} }
else
{
this.CarImage = pbxCar.ErrorImage; // Set to error image if loading fails
}
}); });
} }

File diff suppressed because it is too large Load Diff

View File

@@ -13,6 +13,13 @@ namespace CarManagerV3
List<Car> cars = new List<Car>(); List<Car> cars = new List<Car>();
string filepath = ""; string filepath = "";
public static MainForm GetMainForm()
{
// This is a singleton pattern to ensure only one instance of MainForm exists.
// If you need to access the MainForm instance, you can use this method.
return Application.OpenForms.OfType<MainForm>().FirstOrDefault() ?? new MainForm();
}
public MainForm(string pathToOpen = "") public MainForm(string pathToOpen = "")
{ {
InitializeComponent(); InitializeComponent();

View File

@@ -0,0 +1,182 @@
namespace CarManagerV3.Forms
{
partial class NetCredentials
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
label1 = new System.Windows.Forms.Label();
label2 = new System.Windows.Forms.Label();
label3 = new System.Windows.Forms.Label();
tbxUsername = new System.Windows.Forms.TextBox();
label4 = new System.Windows.Forms.Label();
tbxPassword = new System.Windows.Forms.TextBox();
flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
btnAccept = new System.Windows.Forms.Button();
btnCancel = new System.Windows.Forms.Button();
flowLayoutPanel1.SuspendLayout();
flowLayoutPanel2.SuspendLayout();
SuspendLayout();
//
// flowLayoutPanel1
//
flowLayoutPanel1.Controls.Add(label1);
flowLayoutPanel1.Controls.Add(label2);
flowLayoutPanel1.Controls.Add(label3);
flowLayoutPanel1.Controls.Add(tbxUsername);
flowLayoutPanel1.Controls.Add(label4);
flowLayoutPanel1.Controls.Add(tbxPassword);
flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
flowLayoutPanel1.Name = "flowLayoutPanel1";
flowLayoutPanel1.Padding = new System.Windows.Forms.Padding(10);
flowLayoutPanel1.Size = new System.Drawing.Size(349, 248);
flowLayoutPanel1.TabIndex = 0;
//
// label1
//
label1.AutoSize = true;
label1.Font = new System.Drawing.Font("Segoe UI", 14F);
label1.Location = new System.Drawing.Point(13, 10);
label1.Name = "label1";
label1.Size = new System.Drawing.Size(232, 25);
label1.TabIndex = 0;
label1.Text = "Enter Network Credentials";
//
// label2
//
label2.AutoSize = true;
label2.Location = new System.Drawing.Point(13, 35);
label2.Name = "label2";
label2.Size = new System.Drawing.Size(308, 30);
label2.TabIndex = 1;
label2.Text = "Your network requires credentials to access data through the proxy";
//
// label3
//
label3.AutoSize = true;
label3.Location = new System.Drawing.Point(13, 85);
label3.Margin = new System.Windows.Forms.Padding(3, 20, 3, 0);
label3.Name = "label3";
label3.Size = new System.Drawing.Size(86, 15);
label3.TabIndex = 2;
label3.Text = "Your username";
//
// tbxUsername
//
tbxUsername.Location = new System.Drawing.Point(13, 103);
tbxUsername.Name = "tbxUsername";
tbxUsername.Size = new System.Drawing.Size(308, 23);
tbxUsername.TabIndex = 3;
//
// label4
//
label4.AutoSize = true;
label4.Location = new System.Drawing.Point(13, 139);
label4.Margin = new System.Windows.Forms.Padding(3, 10, 3, 0);
label4.Name = "label4";
label4.Size = new System.Drawing.Size(84, 15);
label4.TabIndex = 4;
label4.Text = "Your password";
//
// tbxPassword
//
tbxPassword.Location = new System.Drawing.Point(13, 157);
tbxPassword.Name = "tbxPassword";
tbxPassword.PasswordChar = '*';
tbxPassword.Size = new System.Drawing.Size(308, 23);
tbxPassword.TabIndex = 5;
//
// flowLayoutPanel2
//
flowLayoutPanel2.Controls.Add(btnAccept);
flowLayoutPanel2.Controls.Add(btnCancel);
flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Bottom;
flowLayoutPanel2.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
flowLayoutPanel2.Location = new System.Drawing.Point(0, 198);
flowLayoutPanel2.Name = "flowLayoutPanel2";
flowLayoutPanel2.Size = new System.Drawing.Size(349, 50);
flowLayoutPanel2.TabIndex = 1;
//
// btnAccept
//
btnAccept.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
btnAccept.Location = new System.Drawing.Point(271, 3);
btnAccept.Name = "btnAccept";
btnAccept.Size = new System.Drawing.Size(75, 23);
btnAccept.TabIndex = 0;
btnAccept.Text = "Save";
btnAccept.UseVisualStyleBackColor = true;
btnAccept.Click += btnAccept_Click;
//
// btnCancel
//
btnCancel.Location = new System.Drawing.Point(190, 3);
btnCancel.Name = "btnCancel";
btnCancel.Size = new System.Drawing.Size(75, 23);
btnCancel.TabIndex = 1;
btnCancel.Text = "Cancel";
btnCancel.UseVisualStyleBackColor = true;
//
// NetCredentials
//
AcceptButton = btnAccept;
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
CancelButton = btnCancel;
ClientSize = new System.Drawing.Size(349, 248);
ControlBox = false;
Controls.Add(flowLayoutPanel2);
Controls.Add(flowLayoutPanel1);
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
MaximizeBox = false;
Name = "NetCredentials";
StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
Text = "Enter Network Credentials";
TopMost = true;
Load += NetCredentials_Load;
flowLayoutPanel1.ResumeLayout(false);
flowLayoutPanel1.PerformLayout();
flowLayoutPanel2.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox tbxUsername;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox tbxPassword;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2;
private System.Windows.Forms.Button btnAccept;
private System.Windows.Forms.Button btnCancel;
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CarManagerV3.Forms
{
public partial class NetCredentials : Form
{
public NetCredentials()
{
InitializeComponent();
}
public NetworkCredential GetCredentails()
{
return new NetworkCredential(tbxUsername.Text, tbxPassword.Text);
}
private void NetCredentials_Load(object sender, EventArgs e)
{
this.BringToFront();
this.Focus();
}
private void btnAccept_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -1,5 +1,8 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Net;
using System.Windows.Forms;
using CarManagerV3.Forms;
namespace CarManagerV3 namespace CarManagerV3
{ {
@@ -10,6 +13,8 @@ namespace CarManagerV3
{ {
private static string _imagePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\CarManagerV3\\images"; private static string _imagePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\CarManagerV3\\images";
private static NetworkCredential myNetCred = null;
private static bool disableImageFetch = false;
/// <summary> /// <summary>
/// Initializes the image folder by creating it if it does not exist. /// Initializes the image folder by creating it if it does not exist.
@@ -88,17 +93,63 @@ namespace CarManagerV3
{ {
return; return;
} }
if (disableImageFetch) return;
string url = $"https://cdn.imagin.studio/getimage?customer=hrjavascript-mastery&zoomType=fullscreen&make={car.Make}&modelFamily={car.Model}&modelYear={car.Year}&angle=front&paintDescription={car.Color}&fileType=png"; string url = $"https://cdn.imagin.studio/getimage?customer=hrjavascript-mastery&zoomType=fullscreen&make={car.Make}&modelFamily={car.Model}&modelYear={car.Year}&angle=front&paintDescription={car.Color}&fileType=png";
//add Referer header to avoid 403 error //add Referer header to avoid 403 error
using (var client = new System.Net.WebClient()) using (var client = new System.Net.WebClient())
{ {
client.Headers.Add("Referer", "http://localhost"); client.Headers.Add("Referer", "http://localhost");
try try
{ {
client.Credentials = myNetCred;
client.Proxy.Credentials = myNetCred;
//DEBUG:: if (myNetCred == null) throw new WebException();
client.DownloadFile(url, path); client.DownloadFile(url, path);
} }
catch catch (WebException ex)
{ {
// is status code 407?
//if (ex.Response is HttpWebResponse response && response.StatusCode == HttpStatusCode.ProxyAuthenticationRequired)
//{
// Console.Error.WriteLine("Proxy authentication required. Prompting for credentials.");
//}
if (myNetCred != null)
{
DialogResult disableImgDialogRetry = MessageBox.Show("Something went wrong when fetching images. Are you credentials correct? Do you want to disable Image fetching for this session or rety with different credentials?", "Invalid Credentials", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
if(disableImgDialogRetry == DialogResult.Cancel)
{
disableImageFetch = true;
return;
}
}
NetCredentials netCredForm = new NetCredentials();
DialogResult dialogRes = netCredForm.ShowDialog();
netCredForm.BringToFront();
netCredForm.Focus();
if (dialogRes == DialogResult.OK)
{
NetworkCredential netcred = netCredForm.GetCredentails();
myNetCred = netcred;
FetchImage(car);
return;
} else
{
DialogResult disableImgDialog = MessageBox.Show("Do you want to disable image fetching for this session?", "Disable Image fetching?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if(disableImgDialog == DialogResult.Yes)
{
disableImageFetch = true;
} else
{
FetchImage(car);
return;
}
}
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
// if error, use fallback image no_image_available.png // if error, use fallback image no_image_available.png
//System.IO.File.Copy($"{_imagePath}/no_image_available.png", path); //System.IO.File.Copy($"{_imagePath}/no_image_available.png", path);
} }