Skip to content

Commit

Permalink
design changes
Browse files Browse the repository at this point in the history
  • Loading branch information
borseno committed Feb 7, 2019
1 parent 90f65ee commit c33259f
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 16 deletions.
6 changes: 6 additions & 0 deletions BorsenoTextEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CellSelectionDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="CellSelectionDialog.Designer.cs">
<DependentUpon>CellSelectionDialog.cs</DependentUpon>
</Compile>
<Compile Include="ChooseFileFromDBForm.cs">
<SubType>Form</SubType>
</Compile>
Expand Down
39 changes: 39 additions & 0 deletions CellSelectionDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions CellSelectionDialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BorsenoTextEditor
{
public partial class CellSelectionDialog : Form
{
public DataGridViewSelectedCellCollection Cells { get; set; }
public CellSelectionDialog()
{
InitializeComponent();
}
}
}
2 changes: 1 addition & 1 deletion ChooseFileFromDBForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 27 additions & 3 deletions ChooseFileFromDBForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ public partial class ChooseFileFromDBForm : Form
private readonly string _connectionString;
private readonly string _tableName;
private readonly string _nameColumnName;
private bool _isSelected = false;
private CellSelectionDialog csd = null;

public bool IsSelected { get; private set; } = false;

public string SelectedFileName
{
get
{
if (_isSelected)
if (IsSelected)
return filesDBdataGridView.SelectedCells[0].ToString();
return null;
}
Expand All @@ -49,14 +51,36 @@ private void OnLoad(object sender, EventArgs e)
dataAdapter.Fill(dataSet);
filesDBdataGridView.DataSource = dataSet.Tables[0];
}
csd = new CellSelectionDialog();
csd.FormClosing += CellSelectionDialog_FormClosing;
csd.Show();
}

private void OnSelected(object sender, EventArgs e)
{
if (filesDBdataGridView.SelectedCells.Count == 1)
_isSelected = true;
IsSelected = true;
else
MessageBox.Show(@"You can choose only one cell");
}

private void OnSelectionChanged(object sender, EventArgs e)
{
if (csd != null)
{
csd.Cells = filesDBdataGridView.SelectedCells;
csd.BringToFront();
}
}
private void CellSelectionDialog_FormClosing(object sender, FormClosingEventArgs e)
{
if (csd.DialogResult == DialogResult.OK)
{
//Do something with csd.cells
MessageBox.Show(csd.Cells[0].Value.ToString());
//set the form to null;
csd = null;
}
}
}
}
16 changes: 4 additions & 12 deletions DBFilePicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,15 @@ public DBFilePicker

public string GetFile()
{
_chooseForm.FormClosed += OnFormClosed;
_chooseForm.Show();



throw new NotImplementedException();
// ??? I know it's a bad idea... I Tried to inherit from CommonDialog
while (!_chooseForm.IsSelected)
;
return _chooseForm.SelectedFileName;
}

public string GetOrCreateFile()
{
throw new NotImplementedException();
}

private void OnFormClosed(object sender, EventArgs e)
{
_name = ((ChooseFileFromDBForm) sender).SelectedFileName;
GetFile();
}
}
}

0 comments on commit c33259f

Please sign in to comment.