Everything I put in the mainGui class, will not become visible, because it is an overide thinggy or something.
So, I need the textboxes, timers, and all the other stuff visible for the other classes!
So I created a class, called stuffWithGui.
now, in the mainGUI class I have this:
- Code: Select all
public stuffWithGui g;
But that doesn't becomes visible for the other classes, and I need that(of course, it doesn't become visible, but I just want something so I can see my textboxes, timers, and all the stuff from the mainGui class in other classes).
Here's the source:
- Code: Select all
using System;
using System.IO;
using System.Windows.Forms;
namespace MCDzienny.Plugins
{
public class Plgn : Plugin
{
versionInfo info = new versionInfo("Repeater", "A simple text repeater for all your daily messages.(test plugin)", "joppiesaus", "1.0", 1);
System.Windows.Forms.UserControl gui = new mainGUI();
public override string Description
{
get { return info.descr; }
}
public override string Author
{
get { return info.auth; }
}
public override string Name
{
get { return info.name; }
}
public override System.Windows.Forms.UserControl MainInterface
{
get { return gui; }
}
public override string Version
{
get { return info.ver; }
}
public override int VersionNumber
{
get { return info.verNumber; }
}
public override void Initialize()
{
while (1 == 1)//infinite loop. Checks if the timer said yes.
{
Player.GlobalMessage("");
}
}
public override void Terminate()
{
// The clean up code. It may be include closing timers, ending threads, disposing
// unmanaged resources, also, saving changes to a database or a config file.
}
}
public class versionInfo
{
public string name { get; set; }
public string descr { get; set; }
public string auth { get; set; }
public string ver { get; set; }
public int verNumber { get; set; }
public versionInfo(string nameOfAssembly, string description, string author, string version, int versionNumber)
{
name = nameOfAssembly;
descr = description;
auth = author;
ver = version;
verNumber = versionNumber;
}
}
public class stuffWithGui
{
public Timer timer;
public TextBox msgTextBox;
public TextBox intervalTextBox;
public stuffWithGui(Timer timerOfTextbox, TextBox text1, TextBox interval)
{
timer = timerOfTextbox;
msgTextBox = text1;
intervalTextBox = interval;
}
/// <summary>
/// set the interval of the timer
/// </summary>
/// <param name="interval">interval of the timer. Int</param>
/// <param name="turnOn">Turn on the timer? Bool.</param>
public void setInterval(int interval, bool turnOn)
{
timer.Interval = interval;
if (turnOn)
{
timer.Enabled = true;
}
}
/// <summary>
/// turn the timer on or off.
/// </summary>
/// <param name="onOff">True or false?</param>
public void enableTimer(bool onOff)
{
if (onOff)
{
timer.Enabled = true;
}
else
{
timer.Enabled = false;
}
}
public void timer_Tick(object sender, EventArgs e)
{
displayText();
}
/// <summary>
/// display text. dontDoThat is optional.
/// </summary>
/// <param name="dontDoThat">dont do it!</param>
/// <returns>bool</returns>
public bool displayText(bool dontDoThat = false)
{
if (!dontDoThat)
{
return true;
}
else
{
return false;
}
}
public string stringOfmsgTextBox;
private void msgTextBox_TextChanged(object sender, EventArgs e)
{
stringOfmsgTextBox = msgTextBox.Text;
}
}
#region gui
public partial class mainGUI
{
public stuffWithGui g;
public mainGUI()
{
InitializeComponent();
g = new stuffWithGui(timer, msgTextBox, intervalTextBox);
}
}
partial class mainGUI : UserControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.msgTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.intervalTextBox = new System.Windows.Forms.TextBox();
this.timer = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// msgTextBox
//
this.msgTextBox.Location = new System.Drawing.Point(68, 13);
this.msgTextBox.Name = "msgTextBox";
this.msgTextBox.Size = new System.Drawing.Size(204, 20);
this.msgTextBox.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(50, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Message";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(42, 13);
this.label2.TabIndex = 2;
this.label2.Text = "Interval";
//
// intervalTextBox
//
this.intervalTextBox.Location = new System.Drawing.Point(68, 37);
this.intervalTextBox.Name = "intervalTextBox";
this.intervalTextBox.Size = new System.Drawing.Size(204, 20);
this.intervalTextBox.TabIndex = 3;
// iodjfaopijasdpoifhasdpfoihasdpfoihasdf
// mainGUI
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.intervalTextBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.msgTextBox);
this.Name = "mainGUI";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
public System.Windows.Forms.TextBox msgTextBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
public System.Windows.Forms.TextBox intervalTextBox;
public System.Windows.Forms.Timer timer;
}
#endregion
}