pascalabcnet/ICSharpCode.TextEditorLinux/Src/Gui/CompletionWindow/DeclarationViewWindow.cs
2022-10-04 20:50:34 +02:00

133 lines
2.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version>$Revision: 1965 $</version>
// </file>
using System;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.TextEditor.Util;
namespace ICSharpCode.TextEditor.Gui.CompletionWindow
{
public interface IDeclarationViewWindow
{
string Description {
get;
set;
}
void ShowDeclarationViewWindow();
void CloseDeclarationViewWindow();
}
public class DeclarationViewWindow : Form, IDeclarationViewWindow
{
private ICSharpCode.TextEditor.TextEditorControl textEditorControl;
string description = String.Empty;
public string Description {
get {
return description;
}
set {
description = value;
if (value == null && Visible) {
Visible = false;
} else if (value != null) {
if (!Visible) ShowDeclarationViewWindow();
Refresh();
}
}
}
public ICSharpCode.TextEditor.TextEditorControl TextEditorControl
{
get
{
return textEditorControl;
}
set
{
textEditorControl = value;
}
}
public bool HideOnClick;
public DeclarationViewWindow(Form parent)
{
SetStyle(ControlStyles.Selectable, false);
StartPosition = FormStartPosition.Manual;
FormBorderStyle = FormBorderStyle.None;
Owner = parent;
ShowInTaskbar = false;
Size = new Size(0, 0);
base.CreateHandle();
}
protected override CreateParams CreateParams {
get {
CreateParams p = base.CreateParams;
AbstractCompletionWindow.AddShadowToWindow(p);
return p;
}
}
protected override bool ShowWithoutActivation {
get {
return true;
}
}
protected override void OnGotFocus(EventArgs e)
{
base.OnGotFocus(e);
if (textEditorControl != null)
{
textEditorControl.Focus(); // Да, именно так!!!!!!!!!!!!!! Не удалять!!!
}
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
if (HideOnClick) Hide();
}
public void ShowDeclarationViewWindow()
{
Show();
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
}
public void CloseDeclarationViewWindow()
{
Close();
Dispose();
}
protected override void OnPaint(PaintEventArgs pe)
{
if (description != null && description.Length > 0) {
TipPainterTools.DrawHelpTipFromCombinedDescription(this, pe.Graphics, Font, null, description);
}
}
protected override void OnPaintBackground(PaintEventArgs pe)
{
pe.Graphics.FillRectangle(SystemBrushes.Info, pe.ClipRectangle);
}
}
}