本文整理汇总了C#中System.Windows.Forms.Form.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Form.GetType方法的具体用法?C# Form.GetType怎么用?C# Form.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Form
的用法示例。
在下文中一共展示了Form.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddForm
public void AddForm(Form form)
{
if (_forms.ContainsKey(form.GetType()))
{
var formValues = _forms[form.GetType()];
if (!formValues.Any(x => x == form))
{
formValues.Add(form);
}
}
else
{
_forms.Add(form.GetType(), new List<Form>() { form });
}
if (!_isPageRemovedEventAttached)
{
var pageTab = form.Parent as RadPageViewPage;
if (pageTab != null)
{
pageTab.Owner.PageRemoved += OwnerOnPageRemoved;
}
_isPageRemovedEventAttached = true;
}
}
示例2: addSubfomHelper_
Form addSubfomHelper_(Form par)
{
if(!windows_.ContainsKey(par.GetType()))
{
windows_.Add(par.GetType(),new ArrayList());
}
ArrayList storage = windows_[par.GetType()];
storage.Add(par);
return par;
}
示例3: RestoreWindow
static protected void RestoreWindow(Form aForm) {
bool xShowForm = true;
//http://social.msdn.microsoft.com/forums/en-US/winforms/thread/72b2edaf-0719-4d22-885e-48d643dc626b
var x = Settings.DS.Window.FindByName(aForm.GetType().Name);
if (x != null) {
if (!x.IsLeftNull()) {
aForm.Left = x.Left;
}
if (!x.IsTopNull()) {
aForm.Top = x.Top;
}
if (!x.IsWidthNull()) {
aForm.Width = x.Width;
}
if (!x.IsHeightNull()) {
aForm.Height = x.Height;
}
// On load the often end up behind other apps, so we do this to force them up on first show
if (!x.IsVisibleNull()) {
// Technically we should do this if any size exists, generally
// they should be all present or all missing. so we just use
// this one attribute for now.
aForm.StartPosition = FormStartPosition.Manual;
xShowForm = x.Visible;
}
}
if (xShowForm) {
Show(aForm);
}
}
示例4: MobsModelChoice
public MobsModelChoice(Form Window, TextBox Form)
{
if (Window.GetType() == typeof(LoadNPCTemplate))
{
loadNPCTemplateWindow = Window as LoadNPCTemplate;
NPCTemplateModelTextBox = Form;
this.Text = "NPCTemplate Models Chooser";
}
else if (Window.GetType() == typeof(LoadMob))
{
loadMobWindow = Window as LoadMob;
MobModelTextBox = Form;
this.Text = "Mob Model Chooser";
}
InitializeComponent();
}
示例5: GetSettings
public static CtrlSettings GetSettings(Form form)
{
Lewis.SST.Settings.CtrlSettings cs = null;
if (form != null)
{
try
{
cs = new Lewis.SST.Settings.CtrlSettings(form.GetType().ToString());
if (typeof(Lewis.SST.Gui.Main).IsInstanceOfType(form))
{
cs.LastDirectory = ((Lewis.SST.Gui.Main)form).LastDirectory;
}
cs.Name = form.Name;
cs.Location = form.Location;
cs.Size = form.Size;
ArrayList arl = WalkControls(form.Controls);
if (arl != null && arl.Count > 0)
{
cs.ChildCtrlsToPersist = (Lewis.SST.Settings.CtrlSettings[])arl.ToArray(typeof(Lewis.SST.Settings.CtrlSettings));
}
}
catch (Exception ex)
{
logger.Error(SQLSchemaTool.ERRORFORMAT, ex.Message, ex.Source, ex.StackTrace);
}
}
return cs;
}
示例6: LocalizeForm
private static void LocalizeForm(Form frm)
{
var manager = new ComponentResourceManager(frm.GetType());
manager.ApplyResources(frm, "$this");
ApplyResources(manager, frm.Controls);
}
示例7: ProcessDeletion
private static void ProcessDeletion(Form AMainWindow, Int64 AConferenceKey, string AConferenceName)
{
TVerificationResultCollection VerificationResult;
MethodInfo method;
if (!TRemote.MConference.Conference.WebConnectors.DeleteConference(AConferenceKey, out VerificationResult))
{
MessageBox.Show(
string.Format(Catalog.GetString("Deletion of Conference '{0}' failed"), AConferenceName) + "\r\n\r\n" +
VerificationResult.BuildVerificationResultString(),
Catalog.GetString("Deletion failed"),
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
else
{
MessageBox.Show(
string.Format(Catalog.GetString("Conference '{0}' has been deleted"), AConferenceName),
Catalog.GetString("Deletion successful"),
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
method = AMainWindow.GetType().GetMethod("ShowCurrentConferenceInfoInStatusBar");
if (method != null)
{
method.Invoke(AMainWindow, new object[] { });
}
}
示例8: Manage
/// <summary>
/// Instructs the listener to manage the specified form
/// </summary>
/// <param name="f">The form to manage</param>
/// <param name="key">The key under which this form's settings will be saved</param>
/// <param name="restore">A flag that indicates whether the form's state should be initially restored</param>
/// <returns></returns>
public bool Manage(Form f, string key, bool restore)
{
// save the form reference
_form = f;
_key = key;
_restore = restore;
// format a path to this form's data
_path = System.IO.Path.Combine(_path, f.GetType().FullName);
_path = System.IO.Path.Combine(_path, key);
// bind the the form's relevent events
f.Load += new EventHandler(OnLoad);
f.SizeChanged += new EventHandler(OnSizeChanged);
f.LocationChanged += new EventHandler(OnLocationChanged);
f.Move += new EventHandler(OnMove);
f.Closed += new EventHandler(OnClosed);
// start out with updated information
this.GleamWindowData();
// if we need to
if (restore && f.Visible)
{
// immediately restore the form's information
this.ReadWindowData();
this.ApplyWindowData();
}
return true;
}
示例9: InstanceFormChild
public static void InstanceFormChild(Form frmChild, Form frmParent, bool modal)
{
if (frmParent != null)
foreach (var item in frmParent.MdiChildren)
{
if (item.GetType() == frmChild.GetType())
{
frmChild.Focus();
frmChild.BringToFront();
frmChild.Activate();
return;
}
}
frmChild.ShowInTaskbar = false;
if (modal)
{
frmChild.TopLevel = true;
frmChild.ShowDialog();
}
else
{
if (frmParent != null)
frmChild.MdiParent = frmParent;
frmChild.Show();
}
}
示例10: ProcessDeletion
private static void ProcessDeletion(Form AMainWindow, Int32 ALedgerNumber, string ALedgerNameAndNumber)
{
TVerificationResultCollection VerificationResult;
MethodInfo method;
if (!TRemote.MFinance.Setup.WebConnectors.DeleteLedger(ALedgerNumber, out VerificationResult))
{
MessageBox.Show(
string.Format(Catalog.GetString("Deletion of Ledger '{0}' failed"), ALedgerNameAndNumber) + "\r\n\r\n" +
VerificationResult.BuildVerificationResultString(),
Catalog.GetString("Deletion failed"),
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
else
{
MessageBox.Show(
string.Format(Catalog.GetString("Ledger '{0}' has been deleted"), ALedgerNameAndNumber),
Catalog.GetString("Deletion successful"),
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
method = AMainWindow.GetType().GetMethod("ShowCurrentLedgerInfoInStatusBar");
if (method != null)
{
method.Invoke(AMainWindow, new object[] { });
}
}
示例11: CloseAllWindows
/// <summary>
/// 关闭窗体及其所有的属性中定义的窗体
/// </summary>
/// <param name="form">窗体</param>
/// <returns>属性中定义的窗体是否已经全部关闭</returns>
public static bool CloseAllWindows(Form form)
{
bool result = true;
try // 获取属性的过程可能会产生异常
{
Type t = form.GetType();
foreach (PropertyInfo pi in t.GetProperties()) // 用反射获取窗体的所有属性,并将属性窗体关闭
{
object o = t.InvokeMember(pi.Name, BindingFlags.GetProperty, null, form, null);
if (o is Form) // 窗口属性
{
Form newForm = o as Form;
if (newForm != null)
{
newForm.Close();
if (!newForm.IsDisposed && newForm.Visible) // 部分窗口如表元编辑器,只隐藏没关闭,需要做特殊判断
{
result = false;
break;
}
}
}
}
}
catch { } // 忽略异常
if(result) // 所有窗体属性已经成功关闭
{
IntPtr ptr = FindWindow(null, form.Text);
PostMessage(ptr, 0x10, IntPtr.Zero, null);
}
return result;
}
示例12: PFTableForm
public PFTableForm(Form parent)
{
InitializeComponent();
if (parent.GetType() == typeof(ApplicationForm))
{
this.parent = parent as ApplicationForm;
}
}
示例13: showFormInfo
public static void showFormInfo(Form form)
{
StringBuilder str = new StringBuilder();
str.Append("Tên lớp: " + form.GetType().FullName);
str.AppendLine();
str.Append("Màn hình public: " + (form is IPublicForm ? "Có" : "Không"));
HelpDebug.ShowString(str.ToString());
}
示例14: RemoveForm
public void RemoveForm(Form form)
{
var type = form.GetType();
if (_allForms.ContainsKey(type) == false)
return;
_allForms[type].Remove(form);
}
示例15: LocalizeControls
public void LocalizeControls(Form form)
{
XmlNode controlsNode = this.langDoc.SelectSingleNode("//" + form.Name + "/Controls");
if(controlsNode == null)
{
return;
}
foreach(XmlNode node in controlsNode.ChildNodes)
{
if(node.HasChildNodes && node.FirstChild.NodeType != XmlNodeType.Text)
{
FieldInfo fi = form.GetType().GetField(
node.Name,
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
PropertyInfo items = fi.FieldType.GetProperty("Items");
MethodInfo clear = items.PropertyType.GetMethod("Clear");
clear.Invoke(items.GetValue(fi.GetValue(form),null),null);
foreach(XmlNode itemNode in node.ChildNodes)
{
MethodInfo add = items.PropertyType.GetMethod("Add");
object [] addParams = new object[1];
addParams[0] = itemNode.InnerText;
add.Invoke(items.GetValue(fi.GetValue(form),null),addParams);
}
if(node.Attributes["ToolTipText"] != null)
{
PropertyInfo pi = fi.FieldType.GetProperty("ToolTipText");
pi.SetValue(fi.GetValue(form),node.Attributes["ToolTipText"].Value,null);
}
}
else if(node.NodeType != XmlNodeType.Comment)
{
if(node.InnerText != string.Empty)
{
if(node.Name.ToUpper() == "SELF")
{
form.Text = node.InnerText;
}
else
{
FieldInfo fi = form.GetType().GetField(
node.Name,
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
PropertyInfo pi = fi.FieldType.GetProperty("Text");
pi.SetValue(fi.GetValue(form),node.InnerText,null);
}
}
if(node.Attributes["ToolTipText"] != null)
{
FieldInfo fi = form.GetType().GetField(
node.Name,
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
PropertyInfo pi = fi.FieldType.GetProperty("ToolTipText");
pi.SetValue(fi.GetValue(form),node.Attributes["ToolTipText"].Value,null);
}
}
}
}