2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Drawing;
|
2014-03-05 09:21:28 +00:00
|
|
|
using System.Runtime.InteropServices;
|
2009-04-19 18:07:22 +00:00
|
|
|
using System.Text;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Windows
|
|
|
|
{
|
2014-10-22 13:07:17 +00:00
|
|
|
public partial class ErrorsForm : DelayedForm
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
#region ================== Variables
|
|
|
|
|
2016-03-23 14:52:33 +00:00
|
|
|
//mxd. Window setup stuff
|
|
|
|
private static Point location = Point.Empty;
|
|
|
|
private static Size size = Size.Empty;
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
public ErrorsForm()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
2016-03-23 14:52:33 +00:00
|
|
|
|
|
|
|
//mxd. Apply window settings
|
|
|
|
if(location != Point.Empty)
|
|
|
|
{
|
|
|
|
this.StartPosition = FormStartPosition.Manual;
|
|
|
|
this.Location = location;
|
|
|
|
}
|
|
|
|
if(size != Size.Empty) this.Size = size;
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
FillList();
|
|
|
|
checkerrors.Start();
|
|
|
|
checkshow.Checked = General.Settings.ShowErrorsWindow;
|
2016-01-27 14:08:15 +00:00
|
|
|
grid.Focus(); //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// This sets up the list
|
|
|
|
private void FillList()
|
|
|
|
{
|
|
|
|
// Fill the list with the items we don't have yet
|
|
|
|
General.ErrorLogger.HasChanged = false;
|
2016-01-27 14:08:15 +00:00
|
|
|
|
|
|
|
//mxd. Rewritten to get only the new items from the ErrorLogger
|
2009-05-10 16:02:08 +00:00
|
|
|
int startindex = grid.Rows.Count;
|
2016-01-27 14:08:15 +00:00
|
|
|
IEnumerable<ErrorItem> errors = General.ErrorLogger.GetErrors(startindex);
|
|
|
|
foreach(ErrorItem e in errors)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2009-05-10 16:02:08 +00:00
|
|
|
Image icon = (e.type == ErrorType.Error) ? Properties.Resources.ErrorLarge : Properties.Resources.WarningLarge;
|
|
|
|
int index = grid.Rows.Add();
|
|
|
|
DataGridViewRow row = grid.Rows[index];
|
|
|
|
row.Cells[0].Value = icon;
|
|
|
|
row.Cells[0].Style.Alignment = DataGridViewContentAlignment.TopCenter;
|
|
|
|
row.Cells[0].Style.Padding = new Padding(0, 5, 0, 0);
|
|
|
|
row.Cells[1].Value = e.message;
|
|
|
|
row.Cells[1].Style.WrapMode = DataGridViewTriState.True;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Events
|
|
|
|
|
|
|
|
// Close clicked
|
|
|
|
private void close_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
this.Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Closing
|
|
|
|
private void ErrorsForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
{
|
|
|
|
checkerrors.Stop();
|
|
|
|
General.Settings.ShowErrorsWindow = checkshow.Checked;
|
2016-03-23 14:52:33 +00:00
|
|
|
|
|
|
|
//mxd. Save window settings
|
|
|
|
location = this.Location;
|
|
|
|
size = this.Size;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Checking for more errors
|
|
|
|
private void checkerrors_Tick(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
// If errors have been added, update the list
|
2016-03-23 14:52:33 +00:00
|
|
|
if(General.ErrorLogger.HasChanged) FillList();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This clears all errors
|
|
|
|
private void clearlist_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
General.ErrorLogger.Clear();
|
2009-05-10 16:02:08 +00:00
|
|
|
grid.Rows.Clear();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Copy selection
|
|
|
|
private void copyselected_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
StringBuilder str = new StringBuilder("");
|
2009-05-10 16:02:08 +00:00
|
|
|
if(grid.SelectedCells.Count > 0)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
Clipboard.Clear();
|
2009-05-10 16:02:08 +00:00
|
|
|
foreach(DataGridViewCell c in grid.SelectedCells)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2009-05-10 16:02:08 +00:00
|
|
|
if(c.ValueType != typeof(Image))
|
|
|
|
{
|
|
|
|
if(str.Length > 0) str.Append("\r\n");
|
2014-02-21 14:42:12 +00:00
|
|
|
str.Append(c.Value);
|
2009-05-10 16:02:08 +00:00
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
2014-03-05 09:21:28 +00:00
|
|
|
|
|
|
|
//mxd
|
2014-12-03 23:15:26 +00:00
|
|
|
try
|
|
|
|
{
|
2016-05-06 08:47:30 +00:00
|
|
|
Clipboard.SetDataObject(str.ToString(), true, 5, 200);
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
catch(ExternalException)
|
|
|
|
{
|
2014-03-05 09:21:28 +00:00
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Failed to perform a Clipboard operation...");
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Help requested
|
|
|
|
private void ErrorsForm_HelpRequested(object sender, HelpEventArgs hlpevent)
|
|
|
|
{
|
|
|
|
General.ShowHelp("w_errorsandwarnings.html");
|
|
|
|
hlpevent.Handled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
2009-05-10 16:02:08 +00:00
|
|
|
|
|
|
|
private void ErrorsForm_Shown(object sender, EventArgs e)
|
|
|
|
{
|
2014-12-03 23:15:26 +00:00
|
|
|
if(grid.Rows.Count > 0) grid.Rows[0].Selected = false;
|
2009-05-10 16:02:08 +00:00
|
|
|
}
|
2012-07-28 20:36:28 +00:00
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
private void grid_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
copyselected.Enabled = true;
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|