debug exception handling, beginning of a custom tree view
This commit is contained in:
parent
f640ceaee4
commit
b2d5dadf88
6 changed files with 65 additions and 23 deletions
50
CreamInstaller/Forms/Components/CustomTreeView.cs
Normal file
50
CreamInstaller/Forms/Components/CustomTreeView.cs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Windows.Forms.VisualStyles;
|
||||||
|
|
||||||
|
namespace CreamInstaller
|
||||||
|
{
|
||||||
|
public class CustomTreeView : TreeView
|
||||||
|
{
|
||||||
|
protected override void WndProc(ref Message m)
|
||||||
|
{
|
||||||
|
if (m.Msg == 0x203) m.Result = IntPtr.Zero;
|
||||||
|
else base.WndProc(ref m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomTreeView() : base()
|
||||||
|
{
|
||||||
|
//DrawMode = TreeViewDrawMode.OwnerDrawAll;
|
||||||
|
//DrawNode += new DrawTreeNodeEventHandler(DrawTreeNode);
|
||||||
|
|
||||||
|
closedGlyphRenderer = new(VisualStyleElement.TreeView.Glyph.Closed);
|
||||||
|
openedGlyphRenderer = new(VisualStyleElement.TreeView.Glyph.Opened);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly VisualStyleRenderer closedGlyphRenderer;
|
||||||
|
private readonly VisualStyleRenderer openedGlyphRenderer;
|
||||||
|
|
||||||
|
private void DrawTreeNode(object sender, DrawTreeNodeEventArgs e)
|
||||||
|
{
|
||||||
|
if (!e.Node.IsVisible) return;
|
||||||
|
e.Graphics.FillRectangle(new SolidBrush(BackColor), e.Bounds);
|
||||||
|
|
||||||
|
int startX = e.Bounds.X + (e.Node.Parent is null ? 22 : 41);
|
||||||
|
int startY = e.Bounds.Y;
|
||||||
|
|
||||||
|
if (e.Node.Parent is null && e.Node.Nodes.Count > 0)
|
||||||
|
if (e.Node.IsExpanded)
|
||||||
|
openedGlyphRenderer.DrawBackground(e.Graphics, new(e.Bounds.X + startX / 2 - 8, startY, 16, 16));
|
||||||
|
else
|
||||||
|
closedGlyphRenderer.DrawBackground(e.Graphics, new(e.Bounds.X + startX / 2 - 8, startY, 16, 16));
|
||||||
|
|
||||||
|
CheckBoxState checkBoxState = e.Node.TreeView.Enabled
|
||||||
|
? (e.Node.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal)
|
||||||
|
: (e.Node.Checked ? CheckBoxState.CheckedDisabled : CheckBoxState.UncheckedDisabled);
|
||||||
|
CheckBoxRenderer.DrawCheckBox(e.Graphics, new(startX, startY + 1), checkBoxState);
|
||||||
|
|
||||||
|
TextRenderer.DrawText(e.Graphics, e.Node.Text, e.Node.NodeFont, e.Node.Bounds.Location, Color.Black);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace CreamInstaller
|
|
||||||
{
|
|
||||||
public class ProgramSelectionTreeView : TreeView
|
|
||||||
{
|
|
||||||
protected override void WndProc(ref Message m)
|
|
||||||
{
|
|
||||||
if (m.Msg == 0x203) m.Result = IntPtr.Zero;
|
|
||||||
else base.WndProc(ref m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
4
CreamInstaller/Forms/MainForm.Designer.cs
generated
4
CreamInstaller/Forms/MainForm.Designer.cs
generated
|
@ -36,7 +36,7 @@ namespace CreamInstaller
|
||||||
this.updateButton = new System.Windows.Forms.Button();
|
this.updateButton = new System.Windows.Forms.Button();
|
||||||
this.ignoreButton = new System.Windows.Forms.Button();
|
this.ignoreButton = new System.Windows.Forms.Button();
|
||||||
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||||
this.changelogTreeView = new CreamInstaller.ProgramSelectionTreeView();
|
this.changelogTreeView = new CreamInstaller.CustomTreeView();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
|
@ -116,7 +116,7 @@ namespace CreamInstaller
|
||||||
private Button updateButton;
|
private Button updateButton;
|
||||||
private Button ignoreButton;
|
private Button ignoreButton;
|
||||||
private ProgressBar progressBar1;
|
private ProgressBar progressBar1;
|
||||||
private ProgramSelectionTreeView changelogTreeView;
|
private CustomTreeView changelogTreeView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
CreamInstaller/Forms/SelectForm.Designer.cs
generated
4
CreamInstaller/Forms/SelectForm.Designer.cs
generated
|
@ -36,7 +36,7 @@ namespace CreamInstaller
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
this.noneFoundLabel = new System.Windows.Forms.Label();
|
this.noneFoundLabel = new System.Windows.Forms.Label();
|
||||||
this.treeView1 = new CreamInstaller.ProgramSelectionTreeView();
|
this.treeView1 = new CreamInstaller.CustomTreeView();
|
||||||
this.allCheckBox = new System.Windows.Forms.CheckBox();
|
this.allCheckBox = new System.Windows.Forms.CheckBox();
|
||||||
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
@ -201,7 +201,7 @@ namespace CreamInstaller
|
||||||
private System.Windows.Forms.CheckBox allCheckBox;
|
private System.Windows.Forms.CheckBox allCheckBox;
|
||||||
private Button scanButton;
|
private Button scanButton;
|
||||||
private Label noneFoundLabel;
|
private Label noneFoundLabel;
|
||||||
private ProgramSelectionTreeView treeView1;
|
private CustomTreeView treeView1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -325,10 +325,7 @@ namespace CreamInstaller
|
||||||
selection.ToggleAllDlc(e.Node.Checked);
|
selection.ToggleAllDlc(e.Node.Checked);
|
||||||
e.Node.Nodes.Cast<TreeNode>().ToList().ForEach(treeNode => treeNode.Checked = e.Node.Checked);
|
e.Node.Nodes.Cast<TreeNode>().ToList().ForEach(treeNode => treeNode.Checked = e.Node.Checked);
|
||||||
}
|
}
|
||||||
else
|
else selection.Enabled = e.Node.Checked;
|
||||||
{
|
|
||||||
selection.Enabled = e.Node.Checked;
|
|
||||||
}
|
|
||||||
allCheckBox.CheckedChanged -= OnAllCheckBoxChanged;
|
allCheckBox.CheckedChanged -= OnAllCheckBoxChanged;
|
||||||
allCheckBox.Checked = treeNodes.TrueForAll(treeNode => treeNode.Checked);
|
allCheckBox.Checked = treeNodes.TrueForAll(treeNode => treeNode.Checked);
|
||||||
allCheckBox.CheckedChanged += OnAllCheckBoxChanged;
|
allCheckBox.CheckedChanged += OnAllCheckBoxChanged;
|
||||||
|
|
|
@ -28,7 +28,16 @@ namespace CreamInstaller
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.ApplicationExit += new(OnApplicationExit);
|
Application.ApplicationExit += new(OnApplicationExit);
|
||||||
Application.Run(new MainForm());
|
retry:
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Application.Run(new MainForm());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (ExceptionHandler.OutputException(e)) goto retry;
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mutex.Close();
|
mutex.Close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue