Skip to content

Commit

Permalink
Added save AS functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
borseno committed Feb 8, 2019
1 parent 9a255a9 commit 4311f85
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 71 deletions.
11 changes: 10 additions & 1 deletion BorsenoTextEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
</Compile>
<Compile Include="DBFileManager.cs" />
<Compile Include="DBFilePicker.cs" />
<Compile Include="EncodingExtension.cs" />
<Compile Include="ExplorerFilePicker.cs" />
<Compile Include="ExplorerFileManager.cs" />
<Compile Include="EncodingHelper.cs" />
<Compile Include="IFilePicker.cs" />
<Compile Include="IFileManager.cs" />
<Compile Include="Main menu.cs">
Expand All @@ -73,6 +73,12 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SaveAsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SaveAsForm.Designer.cs">
<DependentUpon>SaveAsForm.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="ChooseFileFromDBForm.resx">
<DependentUpon>ChooseFileFromDBForm.cs</DependentUpon>
</EmbeddedResource>
Expand All @@ -88,6 +94,9 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="SaveAsForm.resx">
<DependentUpon>SaveAsForm.cs</DependentUpon>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand Down
6 changes: 5 additions & 1 deletion ChooseFileFromDBForm.Designer.cs

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

17 changes: 13 additions & 4 deletions ChooseFileFromDBForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,25 @@ private void OnLoad(object sender, EventArgs e)
}
}

private void OnSelected(object sender, EventArgs e)
{
IsSelected = true;
}
private void filesDBdataGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
using (SolidBrush b = new SolidBrush(filesDBdataGridView.RowHeadersDefaultCellStyle.ForeColor))
{
e.Graphics.DrawString((e.RowIndex + 1).ToString(), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 10, e.RowBounds.Location.Y + 4);
}
}

private void OnOk(object sender, EventArgs e)
{
if (filesDBdataGridView.SelectedCells.Count > 0)
{
IsSelected = true;
}
}

private void OnShown(object sender, EventArgs e)
{
filesDBdataGridView.ClearSelection();
}
}
}
41 changes: 0 additions & 41 deletions ChooseOrCreateFileFromDBForm.cs

This file was deleted.

9 changes: 8 additions & 1 deletion DBFilePicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace BorsenoTextEditor
sealed class DBFilePicker : IFilePicker
{
private readonly ChooseFileFromDBForm _chooseForm;
private readonly SaveAsForm _saveAsForm;
private readonly string _connectionString;
private readonly string _tableName;
private readonly string _valueColumnName;
Expand All @@ -25,6 +26,7 @@ public DBFilePicker
_nameColumnName = nameColumnName;

_chooseForm = new ChooseFileFromDBForm(_connectionString, _tableName, _nameColumnName);
_saveAsForm = new SaveAsForm();
}

public string GetFile()
Expand All @@ -38,7 +40,12 @@ public string GetFile()

public string GetOrCreateFile()
{
throw new NotImplementedException();
_saveAsForm.ShowDialog();

if (_saveAsForm.DialogResult == DialogResult.OK)
return _saveAsForm.FileName;
else
return null;
}
}
}
59 changes: 36 additions & 23 deletions ChooseOrCreateFileFromDBForm.Designer.cs → SaveAsForm.Designer.cs

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

37 changes: 37 additions & 0 deletions SaveAsForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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 SaveAsForm : Form
{
bool _isOKPressed = false;

public string FileName
{
get
{
if (_isOKPressed && !String.IsNullOrEmpty(input.Text))
return input.Text;
return null;
}
}

public SaveAsForm()
{
InitializeComponent();
}

private void OnOk(object sender, EventArgs e)
{
_isOKPressed = true;
}
}
}
File renamed without changes.

0 comments on commit 4311f85

Please sign in to comment.