277 lines
9.5 KiB
C#
277 lines
9.5 KiB
C#
using System;
|
||
using System.Linq;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.IO;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
|
||
using INT69DB_2A_ImageDll;
|
||
using INT69DB_2A.DialogForms;
|
||
|
||
namespace INT69DB_2A.Forms
|
||
{
|
||
public partial class FormDataBackup : Form
|
||
{
|
||
#region Field
|
||
private FormMain m_ParentForm;
|
||
private int FileIndex;
|
||
#endregion
|
||
|
||
#region Constructor
|
||
public FormDataBackup(FormMain parent)
|
||
{
|
||
InitializeComponent();
|
||
|
||
this.ParentForm = parent;
|
||
|
||
this.InitializeDesign();
|
||
this.DefaultSetting();
|
||
}
|
||
#endregion
|
||
|
||
#region Property
|
||
public FormMain ParentForm
|
||
{
|
||
get { return this.m_ParentForm; }
|
||
private set { this.m_ParentForm = value; }
|
||
}
|
||
#endregion
|
||
|
||
#region Method
|
||
private void InitializeDesign()
|
||
{
|
||
ImageDll images = new ImageDll();
|
||
|
||
if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Korean)
|
||
{
|
||
|
||
}
|
||
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.English)
|
||
{
|
||
this.labelTitle.Text = "Data backup";
|
||
this.labelStaticDataBackup.Text = "Backup";
|
||
//this.groupBoxSavedFiles.Text = "Check the saved files";
|
||
this.labelStaticList.Text = "Lists of files";
|
||
this.labelWarning.Text = "※Caution : Data in system are deleted when data is back up to USB memory";
|
||
|
||
this.buttonBackup.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackupDown));
|
||
this.buttonBackup.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackupUp));
|
||
|
||
this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackDown));
|
||
this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackUp));
|
||
}
|
||
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
|
||
{
|
||
this.labelTitle.Text = "数据备份";
|
||
this.labelStaticDataBackup.Text = "备份";
|
||
//this.groupBoxSavedFiles.Text = "Check the saved files";
|
||
this.labelStaticList.Text = "文件";
|
||
this.labelWarning.Text = "※注意:当数据保存到USB中后,系统数据被删除";
|
||
this.smartLabel1.Text = "USB标识符";
|
||
|
||
this.buttonBackup.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackupDown));
|
||
this.buttonBackup.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackupUp));
|
||
|
||
this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackDown));
|
||
this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackUp));
|
||
|
||
this.buttonDataBackupEnable.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnEnable));
|
||
this.buttonDataBackupEnable.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnDisable));
|
||
}
|
||
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
|
||
{
|
||
|
||
}
|
||
else
|
||
{
|
||
|
||
}
|
||
}
|
||
private void DefaultSetting()
|
||
{
|
||
this.FileIndex = 0;
|
||
}
|
||
|
||
private void FileCopy(FileInfo file, string fileName)
|
||
{
|
||
try
|
||
{
|
||
if (this.FileIndex == 0)
|
||
{
|
||
file.CopyTo(fileName);
|
||
this.FileIndex = 0;
|
||
}
|
||
else
|
||
{
|
||
file.CopyTo(fileName.Insert(fileName.Length - 4, "_" + this.FileIndex.ToString()));
|
||
this.FileIndex = 0;
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
this.FileIndex++;
|
||
this.FileCopy(file, fileName);
|
||
}
|
||
}
|
||
|
||
public void DisplayRefresh()
|
||
{
|
||
bool directoryCheck = false;
|
||
|
||
this.ParentForm.SystemConfig.CurrentForm = DataStore.FormStore.FormDataBackup;
|
||
|
||
DirectoryInfo dir = new DirectoryInfo(this.ParentForm.PathDataBackupFolder);
|
||
|
||
directoryCheck = dir.Exists;
|
||
// 폴더 체크
|
||
if (directoryCheck == false)
|
||
dir.Create();
|
||
|
||
FileInfo[] files = dir.GetFiles();
|
||
|
||
this.listBoxDataList.Items.Clear();
|
||
|
||
foreach (FileInfo file in files)
|
||
{
|
||
this.listBoxDataList.Items.Add(file.Name);
|
||
}
|
||
|
||
if (this.ParentForm.SystemConfig.IsDataBackup == true)
|
||
this.buttonDataBackupEnable.ButtonDown();
|
||
else
|
||
this.buttonDataBackupEnable.ButtonUp();
|
||
|
||
this.labelFileCount.Text = this.listBoxDataList.Items.Count.ToString();
|
||
|
||
this.labelUsbId.Text = this.ParentForm.SystemConfig.UsbID.ToString();
|
||
}
|
||
#endregion
|
||
|
||
#region Event Handler
|
||
private void labelUsbId_Click(object sender, EventArgs e)
|
||
{
|
||
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelUsbId.Text, 2, 0, false, this.ParentForm.SystemConfig.Language);
|
||
myKeyPad.Location = new Point(270, 70);
|
||
|
||
if (myKeyPad.ShowDialog() == DialogResult.OK)
|
||
{
|
||
if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 99)
|
||
{
|
||
// 입력범위를 확인하세요
|
||
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
|
||
myMsg.ShowDialog();
|
||
}
|
||
else
|
||
{
|
||
this.labelUsbId.Text = myKeyPad.doubleValue.ToString();
|
||
|
||
this.ParentForm.SystemConfig.UsbID = myKeyPad.IntValue;
|
||
|
||
this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void buttonDataBackupEnable_Click(object sender, EventArgs e)
|
||
{
|
||
if (this.ParentForm.SystemConfig.IsDataBackup == true)
|
||
{
|
||
this.ParentForm.SystemConfig.IsDataBackup = false;
|
||
this.buttonDataBackupEnable.ButtonUp();
|
||
}
|
||
else
|
||
{
|
||
this.ParentForm.SystemConfig.IsDataBackup = true;
|
||
this.buttonDataBackupEnable.ButtonDown();
|
||
}
|
||
|
||
this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig);
|
||
}
|
||
|
||
private void buttonBackup_Click(object sender, EventArgs e)
|
||
{
|
||
int count = 0;
|
||
bool directoryCheck = false;
|
||
string filePath = "";
|
||
SmartX.SmartSplash splash;
|
||
|
||
splash = new SmartX.SmartSplash();
|
||
splash.CenterPosition = true;
|
||
splash.AnimationInterval = 100;
|
||
splash.LoadingImagePathname = "SmartLoading4";
|
||
|
||
count = this.listBoxDataList.Items.Count;
|
||
|
||
// ADC값 로그, 통신 로그 찍기 중지
|
||
this.ParentForm.timerAdcLog.Enabled = false;
|
||
this.ParentForm.smartFileCommunicationLog.Close();
|
||
this.ParentForm.smartFileAdcLog.Close();
|
||
this.ParentForm.IsCommunicationLogOpen = false;
|
||
this.ParentForm.IsAdcLogOpen = false;
|
||
|
||
if (count == 0)
|
||
{
|
||
DialogFormMessage msg = new DialogFormMessage(4, this.ParentForm.SystemConfig.Language);
|
||
msg.ShowDialog();
|
||
return;
|
||
}
|
||
|
||
splash.Start();
|
||
|
||
try
|
||
{
|
||
DirectoryInfo dinfo = new DirectoryInfo("하드 디스크\\");
|
||
dinfo.GetDirectories();
|
||
}
|
||
catch
|
||
{
|
||
DialogFormMessage msg = new DialogFormMessage(5, this.ParentForm.SystemConfig.Language);
|
||
splash.Finish();
|
||
msg.ShowDialog();
|
||
return;
|
||
}
|
||
|
||
try
|
||
{
|
||
filePath = "하드 디스크\\";
|
||
DirectoryInfo dir = new DirectoryInfo(this.ParentForm.PathDataBackupFolder);
|
||
|
||
directoryCheck = dir.Exists;
|
||
// 폴더 체크
|
||
if (directoryCheck == false)
|
||
dir.Create();
|
||
|
||
FileInfo[] files = dir.GetFiles();
|
||
|
||
foreach (FileInfo file in files)
|
||
{
|
||
this.FileCopy(file, filePath + file.Name);
|
||
|
||
this.listBoxDataList.Items.Remove(file.Name);
|
||
file.Delete();
|
||
}
|
||
this.labelFileCount.Text = this.listBoxDataList.Items.Count.ToString();
|
||
DialogFormMessage msg = new DialogFormMessage(count.ToString(), this.ParentForm.SystemConfig.Language);
|
||
splash.Finish();
|
||
msg.ShowDialog();
|
||
}
|
||
catch
|
||
{
|
||
DialogFormMessage msg = new DialogFormMessage(6, this.ParentForm.SystemConfig.Language);
|
||
splash.Finish();
|
||
msg.ShowDialog();
|
||
return;
|
||
}
|
||
}
|
||
|
||
private void buttonBack_Click(object sender, EventArgs e)
|
||
{
|
||
this.ParentForm.ChildFormMenu.DisplayRefresh();
|
||
((FormMain)(Owner)).smartForm.Show((int)DataStore.FormStore.FormMenu);
|
||
}
|
||
#endregion
|
||
}
|
||
} |