Skip to content

Commit

Permalink
Visualize the [isModified] & [isRemoved] attribute in data grid.
Browse files Browse the repository at this point in the history
  • Loading branch information
celeron533 committed Mar 23, 2016
1 parent ff56979 commit 4f3fda4
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 74 deletions.
83 changes: 42 additions & 41 deletions Stealth.Winform/MainFOrm.Designer.cs

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

12 changes: 0 additions & 12 deletions Stealth.Winform/MainFOrm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,4 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="hWnd.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Title.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="isModified.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="isRemoved.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
55 changes: 34 additions & 21 deletions Stealth.Winform/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,20 @@ private void WindowListFilter()
!((modifiedToolStripMenuItem.Checked && !c.isModified)
//hide removed
|| (removedToolStripMenuItem.Checked && c.isRemoved))

// logic:
//{
// //show modified only
// if (modifiedToolStripMenuItem.Checked)
// if (!c.isModified)
// return false;
//{
// //show modified only
// if (modifiedToolStripMenuItem.Checked)
// if (!c.isModified)
// return false;

// //hide removed
// if (removedToolStripMenuItem.Checked)
// if (c.isRemoved)
// return false;
// return true;
//}
// if (removedToolStripMenuItem.Checked)
// if (c.isRemoved)
// return false;
// return true;
//}
)
.ToList();

Expand Down Expand Up @@ -133,15 +133,31 @@ private void dataGridView_WindowList_RowEnter(object sender, DataGridViewCellEve
}

//style
DataGridViewCellStyle isRemovedStyle = new DataGridViewCellStyle()
private void dataGridView_WindowList_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
ForeColor = Color.Gray
};
if (e.RowIndex > 0)
{
if (e.ColumnIndex == dataGridView_WindowList.Columns["isModified"].Index)
{
if ((bool)(e.Value))
{
dataGridView_WindowList.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightGreen;
}
}

DataGridViewCellStyle isModifiedStyle = new DataGridViewCellStyle()
{
BackColor = Color.LightYellow
};
if (e.ColumnIndex == dataGridView_WindowList.Columns["isRemoved"].Index)
{
if ((bool)(e.Value))
{
var cellStyle = dataGridView_WindowList.Rows[e.RowIndex].DefaultCellStyle;
cellStyle.ForeColor = Color.Gray;
if (cellStyle.Font == null)
cellStyle.Font = dataGridView_WindowList.DefaultCellStyle.Font;
cellStyle.Font = new Font(cellStyle.Font, FontStyle.Strikeout);
}
}
}
}

#endregion

Expand Down Expand Up @@ -204,9 +220,6 @@ private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
}

#endregion



}

public class WindowComparer<T> : IEqualityComparer<T>
Expand Down

0 comments on commit 4f3fda4

Please sign in to comment.