本文整理汇总了C#中System.Windows.Forms.Panel.Focus方法的典型用法代码示例。如果您正苦于以下问题:C# Panel.Focus方法的具体用法?C# Panel.Focus怎么用?C# Panel.Focus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Panel
的用法示例。
在下文中一共展示了Panel.Focus方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addNewTab
public void addNewTab(string path){
bool hasTab = false;
FileInfo fi = new FileInfo(path);
foreach (TabPage tp in tabControlEditor.TabPages)
{
if (tp.Tag.ToString()==fi.FullName)
{
hasTab = true;
}
}
if (!hasTab)
{
tabControlEditor.TabPages.Add(fi.FullName, fi.Name, 0);
WebKit.WebKitBrowser wb = new WebKit.WebKitBrowser();
wb.Dock = DockStyle.Fill;
Panel p = new Panel();
p.Controls.Add(wb);
p.Dock=DockStyle.Fill;
tabControlEditor.TabPages[fi.FullName].Controls.Add(p);
tabControlEditor.TabPages[fi.FullName].Tag = fi.FullName;
string html = Properties.Resources.editor.ToString();
html = html.Replace("{{code}}", File.ReadAllText(path));
wb.DocumentText = html;
p.Select();
p.Focus();
}
tabControlEditor.SelectedTab = tabControlEditor.TabPages[fi.FullName];
//tabControlEditor.Select();
//tabControlEditor.Focus();
}
示例2: samplesListbox_SelectedIndexChanged
async void samplesListbox_SelectedIndexChanged(object sender, EventArgs e)
{
currentApplication?.Engine.Exit();
currentApplication = null;
await semaphoreSlim.WaitAsync();
var type = (Type) samplesListbox.SelectedItem;
if (type == null) return;
urhoSurfacePlaceholder.Controls.Clear(); //urho will destroy previous control so we have to create a new one
var urhoSurface = new Panel { Dock = DockStyle.Fill };
urhoSurfacePlaceholder.Controls.Add(urhoSurface);
await Task.Delay(100);//give some time for GC to cleanup everything
currentApplication = Application.CreateInstance(type, new ApplicationOptions("Data") { ExternalWindow = urhoSurface.Handle });
urhoSurface.Focus();
currentApplication.Run();
semaphoreSlim.Release();
}
示例3: RunGame
async void RunGame(TypeInfo value)
{
currentApplication?.Exit();
if (value == null) return;
await semaphoreSlim.WaitAsync();
//urho will destroy our Panel on Exit so let's create it for each sample
var urhoSurface = new Panel { Dock = DockStyle.Fill };
//TODO: capture mouse inside the control
WindowsFormsHost.Child = urhoSurface;
WindowsFormsHost.Focus();
urhoSurface.Focus();
await Task.Yield();
var appOptions = new ApplicationOptions(assetsFolder: "Data")
{
ExternalWindow = RunInSdlWindow.IsChecked.Value ? IntPtr.Zero : urhoSurface.Handle,
LimitFps = false, //true means "limit to 200fps"
};
currentApplication = Urho.Application.CreateInstance(value.Type, appOptions);
currentApplication.Run();
semaphoreSlim.Release();
}
示例4: cEditor
public cEditor(fMain fmain, Panel editor, PictureBox rule, PictureBox report, TabPage editorTab) {
m_fmain = fmain;
m_editor = editor;
m_editor.AutoScroll = true;
m_picRule = rule;
m_picRule.SetBounds(cUtil.mp(1), cUtil.mp(1), cUtil.mp(50), cUtil.mp(297));
m_picRule.BackColor = Color.PeachPuff;
m_picReport = report;
m_picReport.SetBounds(cUtil.mp(50) + cUtil.mp(1), cUtil.mp(1), cUtil.mp(210), cUtil.mp(297));
m_picReport.BackColor = Color.Beige;
m_picReport.Paint += new PaintEventHandler(m_picReport_Paint);
m_picRule.Paint += new PaintEventHandler(m_picRule_Paint);
// mouse events
//
m_picReport.MouseDown += new MouseEventHandler(m_picReport_MouseDown);
m_picReport.MouseUp += new MouseEventHandler(m_picReport_MouseUp);
m_picReport.MouseMove += new MouseEventHandler(m_picReport_MouseMove);
// mouse well
//
// se me cae un lagrimon :(
//
m_picReport.Click += (s, e) => { editor.Focus(); };
// tab
//
m_editorTab = editorTab;
m_editorTab.Enter += (s, e) => { cMainEditor.setDocActive(this); };
m_editorTab.Tag = this;
}
示例5: attachTo
public void attachTo(Panel mainGUI, bool userInput = false)
{
mainGUI.SuspendLayout();
for (int i = 0; i < this.ColumnCount; ++i)
this.Columns[i].Width = cellWidth;
Point p = userInput ? new Point(0, offsetH) : SetFreeLocation();
if (userInput)
Location = p;
titleLabel.Location = new Point(p.X, p.Y - 17);
titleLabel.Width = Width;
titleLabel.Height = 17;
titleLabel.TextAlign = ContentAlignment.MiddleCenter;
titleLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
titleLabel.FlatStyle = FlatStyle.System;
titleLabel.BackColor = Color.LightBlue;
titleLabel.Text = userInput ? "User X" : "X #" + objectCounter;
mainGUI.Controls.Add(this);
mainGUI.Controls.Add(titleLabel);
mainGUI.ResumeLayout(false);
mainGUI.Focus();
}
示例6: OnMouseDown
protected override void OnMouseDown(MouseEventArgs e)
{
this.Focus();
this.Leave += new EventHandler(p_Leave);
img = ResClass.GetImgRes("login_inputbtn_down");
if (Items != null)
{
p = new Panel();
p.Left = 2;
p.Top = 24;
p.Width = this.Width - 5;
p.Height = Items.Length * 20;
p.AutoScroll = true;
p.Focus();
p.Leave+=new EventHandler(p_Leave);
bool isScroll = false;
int maxHeight = this.Parent.Height - this.Top - 24;
int h = 20 * Items.Length + 5;
if (h > maxHeight)
{
isScroll = true;
}
else
{
isScroll = false;
}
for (int i = 0; i < Items.Length; i++)
{
QQComboBoxItem item = new QQComboBoxItem();
item.Name = "qqcomboBoxItem_" + i;
item.Texts = Items[i];
item.Left = 0;
item.Top = 20 * i;
if (isScroll)
item.Width = p.Width - 20;
else
item.Width = p.Width;
item.Height = 20;
item.MouseClick += new MouseEventHandler(item_MouseClick);
p.Controls.Add(item);
}
this.Controls.Add(p);
if (this.Height == 26)
{
if (isScroll)
{
this.Height += 20 * (maxHeight / 20) + 5;
p.Height = 20 * (maxHeight / 20);
}
else
{
this.Height += h;
p.Height = h - 5;
}
showed = true;
}
else
{
this.Height = 26;
p.Height = 0;
showed = false;
p.Controls.Remove(p);
p.Dispose();
}
ControlCollection cce = this.Parent.Controls;
for (int i = 0; i < cce.Count; i++)
{
if (cce[i] is BasicComboBox && !cce[i].Name.Equals(this.Name))
(cce[i] as BasicComboBox).CloseListPanel();
}
}
this.BringToFront();
this.Invalidate();
}
示例7: BindToInput
public void BindToInput(Form form, Panel panel)
{
// handle alt+enter ourselves
panel.KeyDown += (o, e) =>
{
if (e.KeyCode == Keys.W)
{
m_InputDesc.wPressed = true;
}
if (e.KeyCode == Keys.S)
{
m_InputDesc.sPressed = true;
}
if (e.KeyCode == Keys.A)
{
m_InputDesc.aPressed = true;
}
if (e.KeyCode == Keys.D)
{
m_InputDesc.dPressed = true;
}
};
panel.KeyUp += (o, e) =>
{
if (e.KeyCode == Keys.W)
{
m_InputDesc.wPressed = false;
}
if (e.KeyCode == Keys.S)
{
m_InputDesc.sPressed = false;
}
if (e.KeyCode == Keys.A)
{
m_InputDesc.aPressed = false;
}
if (e.KeyCode == Keys.D)
{
m_InputDesc.dPressed = false;
}
};
panel.MouseMove += (o, e) =>
{
float deltaX = (float)e.X - m_InputDesc.prevX;
float deltaY = (float)e.Y - m_InputDesc.prevY;
m_InputDesc.prevX = (float)e.X;
m_InputDesc.prevY = (float)e.Y;
if (e.Button == MouseButtons.Left)
{
m_RotationX += deltaX / 90.0f;
m_RotationY += deltaY / 90.0f;
m_RotationY = Math.Min(Math.Max(m_RotationY, -(float)Math.PI / 2.0f + 0.01f), (float)Math.PI / 2.0f - 0.01f);
}
};
panel.MouseDown += (o, e) =>
{
Program.m_ClickedX = e.X;
Program.m_ClickedY = e.Y;
panel.Focus();
};
}