SourceCode/PROMS/Sync/SyncMany/frmAddCompareItem.cs
2010-03-26 12:10:02 +00:00

88 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace SyncMany
{
public partial class frmAddCompareItem : Form
{
public string SourceName
{ get { return tbSource.Text; } }
public string DestinationName
{ get { return tbDestination.Text; } }
private string _SourceFolder;
public string SourceFolder
{
get { return _SourceFolder; }
set { _SourceFolder = value; }
}
private string _DestinationFolder;
public string DestinationFolder
{
get { return _DestinationFolder; }
set { _DestinationFolder = value; }
}
public frmAddCompareItem(string sourceFolder, string destinationFolder)
{
InitializeComponent();
SetupButtons();
SourceFolder = sourceFolder;
DestinationFolder = destinationFolder;
}
private void SetupButtons()
{
btnOK.Enabled = tbDestination.Text != null && tbSource != null;
}
private void frmAddCompareItem_Resize(object sender, EventArgs e)
{
if(Height != 131)
Height = 131;
}
private void tbText_TextChanged(object sender, EventArgs e)
{
SetupButtons();
}
private void btnSource_Click(object sender, EventArgs e)
{
if (tbSource.Text != "")
{
SourceFolder = SetupOpenFileDialog(tbSource.Text);
}
else
{
ofd.InitialDirectory = SourceFolder;
}
if (ofd.ShowDialog() != DialogResult.OK)
return;
tbSource.Text = ofd.FileName;
SourceFolder = SetupOpenFileDialog(ofd.FileName);
}
private string SetupOpenFileDialog(string fileName)
{
FileInfo fi = new FileInfo(fileName);
ofd.InitialDirectory = fi.Directory.FullName;
ofd.FileName = fi.Name;
return ofd.InitialDirectory;
}
private void btnDestination_Click(object sender, EventArgs e)
{
if (tbDestination.Text != "")
{
DestinationFolder = SetupOpenFileDialog(tbDestination.Text);
}
else
{
ofd.InitialDirectory = DestinationFolder;
}
if (ofd.ShowDialog() != DialogResult.OK)
return;
tbDestination.Text = ofd.FileName;
DestinationFolder = SetupOpenFileDialog(ofd.FileName);
}
}
}