프로젝트 편집창에 FTP Explorer 기능 추가

This commit is contained in:
chikyun.kim
2019-04-23 13:22:58 +09:00
parent 8941f9d871
commit 1b487e8c5d
19 changed files with 829 additions and 234 deletions

View File

@@ -81,6 +81,12 @@
<Compile Include="fBase.Designer.cs">
<DependentUpon>fBase.cs</DependentUpon>
</Compile>
<Compile Include="fFTPExplorer.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="fFTPExplorer.Designer.cs">
<DependentUpon>fFTPExplorer.cs</DependentUpon>
</Compile>
<Compile Include="fLovDateList.cs">
<SubType>Form</SubType>
</Compile>
@@ -104,6 +110,9 @@
<EmbeddedResource Include="fBase.resx">
<DependentUpon>fBase.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="fFTPExplorer.resx">
<DependentUpon>fFTPExplorer.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="fLovDateList.resx">
<DependentUpon>fLovDateList.cs</DependentUpon>
</EmbeddedResource>
@@ -118,6 +127,12 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Sub\arftp\FTPClass.csproj">
<Project>{150859d3-1c5d-4e20-b324-f9ebe188d893}</Project>
<Name>FTPClass</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages\EMGU.CV.3.4.3.3016\build\EMGU.CV.targets" Condition="Exists('..\..\packages\EMGU.CV.3.4.3.3016\build\EMGU.CV.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

View File

@@ -39,5 +39,10 @@ namespace FCOMMON
public static string libxlCompany = "Amkor Technology korea, Inc";
public static string libxlKey = "windows-282b2b0800c5e0016bb06a6fafjfd6o8";
public static int camIndex = 0;
public static string ftp_ip = "10.131.36.205";
public static string ftp_id = "project";
public static string ftp_pw = "Amkor1234";
public static int ftp_port = 2121;
public static bool ftp_passive = true;
}
}

View File

@@ -0,0 +1,222 @@
namespace FCOMMON
{
partial class fFTPExplorer
{
/// <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()
{
this.components = new System.ComponentModel.Container();
this.tbpath = new System.Windows.Forms.TextBox();
this.panel1 = new System.Windows.Forms.Panel();
this.btQuery = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.cm = new System.Windows.Forms.ContextMenuStrip(this.components);
this.uploadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.downLoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.progressBar1 = new System.Windows.Forms.ToolStripProgressBar();
this.lbPath = new System.Windows.Forms.ToolStripStatusLabel();
this.panel1.SuspendLayout();
this.cm.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// tbpath
//
this.tbpath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbpath.Font = new System.Drawing.Font("굴림", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this.tbpath.Location = new System.Drawing.Point(49, 11);
this.tbpath.Name = "tbpath";
this.tbpath.Size = new System.Drawing.Size(429, 22);
this.tbpath.TabIndex = 0;
//
// panel1
//
this.panel1.Controls.Add(this.btQuery);
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.tbpath);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(550, 42);
this.panel1.TabIndex = 1;
//
// btQuery
//
this.btQuery.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btQuery.Location = new System.Drawing.Point(483, 11);
this.btQuery.Name = "btQuery";
this.btQuery.Size = new System.Drawing.Size(55, 22);
this.btQuery.TabIndex = 2;
this.btQuery.Text = "query";
this.btQuery.UseVisualStyleBackColor = true;
this.btQuery.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(11, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(29, 12);
this.label1.TabIndex = 1;
this.label1.Text = "path";
//
// listView1
//
this.listView1.AllowDrop = true;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3,
this.columnHeader4});
this.listView1.ContextMenuStrip = this.cm;
this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView1.FullRowSelect = true;
this.listView1.Location = new System.Drawing.Point(0, 42);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(550, 308);
this.listView1.TabIndex = 2;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Name";
this.columnHeader1.Width = 202;
//
// columnHeader2
//
this.columnHeader2.Text = "Type";
this.columnHeader2.Width = 108;
//
// columnHeader3
//
this.columnHeader3.Text = "Size";
this.columnHeader3.Width = 91;
//
// columnHeader4
//
this.columnHeader4.Text = "Time";
this.columnHeader4.Width = 143;
//
// cm
//
this.cm.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.uploadToolStripMenuItem,
this.downLoadToolStripMenuItem});
this.cm.Name = "contextMenuStrip1";
this.cm.Size = new System.Drawing.Size(133, 48);
//
// uploadToolStripMenuItem
//
this.uploadToolStripMenuItem.Name = "uploadToolStripMenuItem";
this.uploadToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
this.uploadToolStripMenuItem.Text = "Upload";
this.uploadToolStripMenuItem.Click += new System.EventHandler(this.uploadToolStripMenuItem_Click);
//
// downLoadToolStripMenuItem
//
this.downLoadToolStripMenuItem.Name = "downLoadToolStripMenuItem";
this.downLoadToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
this.downLoadToolStripMenuItem.Text = "DownLoad";
this.downLoadToolStripMenuItem.Click += new System.EventHandler(this.downLoadToolStripMenuItem_Click);
//
// timer1
//
this.timer1.Interval = 500;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.progressBar1,
this.lbPath});
this.statusStrip1.Location = new System.Drawing.Point(0, 350);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(550, 22);
this.statusStrip1.TabIndex = 5;
this.statusStrip1.Text = "statusStrip1";
//
// progressBar1
//
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(200, 16);
//
// lbPath
//
this.lbPath.Name = "lbPath";
this.lbPath.Size = new System.Drawing.Size(13, 17);
this.lbPath.Text = "..";
//
// fFTPExplorer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(550, 372);
this.Controls.Add(this.listView1);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.panel1);
this.Name = "fFTPExplorer";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "fFTPExplorer";
this.Load += new System.EventHandler(this.@__Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.cm.ResumeLayout(false);
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox tbpath;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btQuery;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripProgressBar progressBar1;
private System.Windows.Forms.ToolStripStatusLabel lbPath;
private System.Windows.Forms.ContextMenuStrip cm;
private System.Windows.Forms.ToolStripMenuItem uploadToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem downLoadToolStripMenuItem;
}
}

View File

@@ -0,0 +1,216 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace FCOMMON
{
public partial class fFTPExplorer : Form
{
string homePath = string.Empty;
string curPath = string.Empty;
arUtil.FTPClient ftp;
string fn = "ftpExplorer.ini";
public fFTPExplorer(string title,string path,string ip,string id,string pw,int port=21,Boolean passvie=true)
{
InitializeComponent();
this.Text = string.Format("[FTP] {0}",title);
this.KeyPreview = true;
this.KeyDown += (s1, e1) => {
if (e1.KeyCode == Keys.Escape) this.Close();
};
this.listView1.DoubleClick += listView1_DoubleClick;
this.tbpath.KeyDown += (s1, e1) => {
if (e1.KeyCode == Keys.Enter)
btQuery.PerformClick();
};
this.FormClosed += __Closed;
ftp = new arUtil.FTPClient(ip, id, pw, port, passvie);
curPath = path;
homePath = path;
//홈폴더가 없으면 생성을 한다.
var list = ftp.directoryListSimple(homePath);
if(list.Length == 1)
{
//폴더를 생성해준다.
ftp.createDirectory(homePath);
//하위폴더
string[] subdir = new string[] { "Source","Document","Draw"};
foreach (var dir in subdir)
ftp.createDirectory(ftp.PathCombine(homePath, dir));
}
this.listView1.DragDrop += listView1_DragDrop;
this.listView1.DragEnter += listView1_DragEnter;
this.listView1.DragOver += listView1_DragOver;
}
void listView1_DragOver(object sender, DragEventArgs e)
{
this.Cursor = Cursors.Hand;
}
void listView1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
void listView1_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false);
if (files.Length < 1) return;
string msg = string.Format("{0}건의 파일을 업로드 하시겠습니까?",files.Length);
if (FCOMMON.Util.MsgQ(msg) != System.Windows.Forms.DialogResult.Yes) return;
foreach(var fileName in files)
{
System.IO.FileInfo fi = new System.IO.FileInfo(fileName);
string remote = tbpath.Text + "/" + fi.Name;
ftp.upload(remote, fi.FullName);
}
btQuery.PerformClick();
}
void __Closed(object sender, FormClosedEventArgs e)
{
//listview column width
arUtil.INIHelper ini = new arUtil.INIHelper(fn);
for (int i = 0; i < this.listView1.Columns.Count; i++)
{
var curwidth = this.listView1.Columns[i].Width;
ini.set_Data("colsize", "index_" + i.ToString(), curwidth.ToString());
}
ini.Flush();
//string item = "ftp_lv_col_";
//for (int i = 0; i < this.listView1.Columns.Count; i++)
//{
// var curwidth = this.listView1.Columns[i].Width;
// Pub.setting.Xml.set_Data(item + i.ToString(),curwidth.ToString());
//}
//Pub.setting.Save();
}
private void __Load(object sender, EventArgs e)
{
this.tbpath.Text = this.curPath;// Pub.setting.ftp_path;
if (this.tbpath.Text == "") tbpath.Text = "/";
timer1.Start();
//listview column width
string item = "ftp_lv_col_";
if (System.IO.File.Exists(fn) == false) return;
arUtil.INIHelper ini = new arUtil.INIHelper(fn);
for (int i = 0; i < this.listView1.Columns.Count; i++)
{
var cwid = ini.get_Data("colsize", "index_" + i.ToString(), "0");
this.listView1.Columns[i].Width = int.Parse(cwid);
}
btQuery.PerformClick();
}
void listView1_DoubleClick(object sender, EventArgs e)
{
var path = listView1.SelectedItems[0].Text;
var newpath = string.Empty;
if (path == "..")
newpath = ftp.getParent(curPath);
else
newpath = ftp.PathCombine(curPath, path);
search(newpath);
}
private void button1_Click(object sender, EventArgs e)
{
if (this.tbpath.Text == "/") this.tbpath.Text = homePath;
search(this.tbpath.Text);
tbpath.Focus();
tbpath.SelectAll();
}
void search(string path)
{
if (path == "") path = "/";
curPath = path;
tbpath.Text = curPath;
this.listView1.Items.Clear();
this.progressBar1.Value = 0;
// var list = ftp.directoryListSimple("/201");
var ftpdir = ftp.ListDirectoryDetail(path);
if(ftpdir == null)
{
//Util.MsgE(ftp.errorMessage);
return;
}
this.progressBar1.Maximum = ftpdir.Count;
var OrderData = ftpdir.OrderBy(t => t.FileType).OrderBy(t=>t.Filename);
foreach (var item in OrderData)
{
this.progressBar1.Value += 1;
if (item.Filename == ".") continue;
var lv = listView1.Items.Add(item.Filename);
lv.SubItems.Add(item.FileType.ToString());
lv.SubItems.Add(item.Size.ToString());
lv.SubItems.Add(item.FileDateTime.ToString());
if (item.FileType == arUtil.FTPfileInfo.DirectoryEntryTypes.Directory) lv.ForeColor = Color.Blue;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
this.lbPath.Text = curPath;
}
private void uploadToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog od = new OpenFileDialog();
if (od.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
//이파일을 현재 위치에 업로드 한다.
System.IO.FileInfo fi = new System.IO.FileInfo(od.FileName);
string newfile = ftp.PathFileCombine(curPath, fi.Name);
if (!ftp.upload(newfile, od.FileName))
Util.MsgE("upload error");
search(curPath);
}
private void downLoadToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.listView1.SelectedItems.Count < 1) return;
//이파일을 현재 위치에 업로드 한다.
var selfile = this.listView1.SelectedItems[0];
var remotefile = ftp.PathFileCombine(curPath, selfile.Text);
var onlyfilename = remotefile.Substring(remotefile.LastIndexOf("/")+1);
SaveFileDialog od = new SaveFileDialog();
od.Filter = "All files|*.*";
od.FilterIndex = 1;
od.FileName = onlyfilename;
if (od.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
System.IO.FileInfo fi = new System.IO.FileInfo(od.FileName);
string newfile = ftp.PathFileCombine(curPath, fi.Name);
if (!ftp.download(remotefile,od.FileName))
Util.MsgE("Download error");
search(curPath);
}
}
}

View File

@@ -0,0 +1,129 @@
<?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>
<metadata name="cm.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>221, 17</value>
</metadata>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>104, 17</value>
</metadata>
</root>