Click here to Skip to main content
15,914,385 members
Home / Discussions / C#
   

C#

 
GeneralRe: String Formatting when Printing Pin
bfoo7511-Jun-07 14:19
bfoo7511-Jun-07 14:19 
QuestionHow to make a Textbox only take numbers? Pin
dipuks11-Jun-07 11:33
dipuks11-Jun-07 11:33 
AnswerRe: How to make a Textbox only take numbers? Pin
Giorgi Dalakishvili11-Jun-07 11:44
mentorGiorgi Dalakishvili11-Jun-07 11:44 
AnswerRe: How to make a Textbox only take numbers? Pin
sxbluebird11-Jun-07 19:17
sxbluebird11-Jun-07 19:17 
GeneralRe: How to make a Textbox only take numbers? Pin
dipuks12-Jun-07 4:07
dipuks12-Jun-07 4:07 
AnswerRe: How to make a Textbox only take numbers? Pin
Revathij12-Jun-07 2:18
Revathij12-Jun-07 2:18 
QuestionMaking an animated UI Pin
RobMacAF11-Jun-07 11:20
RobMacAF11-Jun-07 11:20 
AnswerRe: Making an animated UI Pin
RobMacAF11-Jun-07 15:12
RobMacAF11-Jun-07 15:12 
Ok, I got this working. I just used a sliding graphic and it works quite well. I just made the graphic slide in when clicked then auto go back. Making it stop and go back when clicked again is easy enough to add in. I am not sure how this will behave when I stick more then one slider on top of each other but it should be fine.

This is the bar graphic I am using.. http://themcclellanfamily.com/Bar.bmp (put this in your debug folder for the project)
This is the code I am using in case anyone wants to see or tweak it. It is nothing special, it is just a scrolling graphic but my plan is to make the tabs huge, someone clicks on it, it opens, loads in the controls, buttons, etc for that topic for that tab. They click on the open tab and it will remove the controls then close itself. Adding the controls dynamically is easy, this is what was giving me issues. Anywho...here is the code


using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace sliding
{

public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Timer t;
private System.Drawing.Size playerSize;
private System.Drawing.Point playerPosition;
bool back = false;
bool goFull = false;
bool stopMove = true;
int mouseX=0;
Image pic;


public Form1()
{
InitializeComponent();
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
pic = Image.FromFile("Bar.bmp");
t = new Timer();
t.Interval = 40;
t.Tick += new System.EventHandler(TimerOnTick);
t.Enabled = true;
playerSize = new Size(540, 20);
playerPosition = new Point(-300, 20);
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Form1MouseClick);
}


protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}


private void InitializeComponent()
{
this.SuspendLayout();
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(640, 480);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
this.Name = "Form1";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Form1";
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1MouseClick);
this.ResumeLayout(false);
}

private void TimerOnTick(object sender, System.EventArgs e)
{
if (this.PlayerPosition.X >-20)
{back = true;
goFull= false;
}
if (this.PlayerPosition.X < -300 && back==true)
{
goFull = false;
back = false;
stopMove= true;
}
if (!stopMove && back==false)
{this.PlayerPosition = new Point(this.PlayerPosition.X
+ 15,
this.PlayerPosition.Y);
goFull = true;
}
else if (!stopMove && back==true)
{this.PlayerPosition = new Point(this.PlayerPosition.X
- 15,
this.PlayerPosition.Y);
goFull = true;
}
this.Refresh();
this.Text = " " + this.PlayerPosition.ToString() + " "+mouseX+" "+stopMove;
}


protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{

Graphics dc = e.Graphics;
dc.DrawImageUnscaled(pic, this.PlayerPosition);
base.OnPaint(e);
}


private Point PlayerPosition
{
get
{
return this.playerPosition;
}
set
{


this.playerPosition.X = value.X;



this.playerPosition.Y = value.Y;

}
}

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

void Form1MouseClick(object sender, MouseEventArgs e)
{
mouseX = e.X;
this.Text = Convert.ToString(e.X);
if (e.X < playerPosition.X + playerSize.Width && e.X > playerPosition.X && !stopMove &&goFull==false )
{
stopMove = true;
goFull = true;
}
else if (e.X < playerPosition.X + playerSize.Width && e.X > playerPosition.X && stopMove &&goFull==false)
{
goFull = true;
stopMove = false;
}

}
}
}

QuestionDLL import, parameters, strings, etc Pin
esunder11-Jun-07 11:03
esunder11-Jun-07 11:03 
QuestionCompiling /unsafe and GetHashCode Pin
jon-8011-Jun-07 9:54
professionaljon-8011-Jun-07 9:54 
AnswerRe: Compiling /unsafe and GetHashCode Pin
Robert Rohde11-Jun-07 10:07
Robert Rohde11-Jun-07 10:07 
QuestionModal Popup (TCartwright's) Pin
stormcandi11-Jun-07 9:22
stormcandi11-Jun-07 9:22 
AnswerRe: Modal Popup (TCartwright's) Pin
Not Active11-Jun-07 9:28
mentorNot Active11-Jun-07 9:28 
GeneralRe: Modal Popup (TCartwright's) Pin
stormcandi11-Jun-07 9:31
stormcandi11-Jun-07 9:31 
QuestionGraphic - Exact string sizes Pin
skuggbo11-Jun-07 9:13
skuggbo11-Jun-07 9:13 
AnswerRe: Graphic - Exact string sizes Pin
Not Active11-Jun-07 9:31
mentorNot Active11-Jun-07 9:31 
GeneralRe: Graphic - Exact string sizes Pin
skuggbo11-Jun-07 10:14
skuggbo11-Jun-07 10:14 
GeneralRe: Graphic - Exact string sizes Pin
Luc Pattyn11-Jun-07 10:39
sitebuilderLuc Pattyn11-Jun-07 10:39 
AnswerRe: Graphic - Exact string sizes Pin
J. Dunlap11-Jun-07 13:13
J. Dunlap11-Jun-07 13:13 
QuestionEvent Firing Pin
tobriain11-Jun-07 8:13
tobriain11-Jun-07 8:13 
AnswerRe: Event Firing Pin
Luc Pattyn11-Jun-07 9:15
sitebuilderLuc Pattyn11-Jun-07 9:15 
GeneralRe: Event Firing Pin
tobriain11-Jun-07 10:11
tobriain11-Jun-07 10:11 
GeneralRe: Event Firing Pin
Luc Pattyn11-Jun-07 10:36
sitebuilderLuc Pattyn11-Jun-07 10:36 
GeneralRe: Event Firing Pin
Leslie Sanford11-Jun-07 10:53
Leslie Sanford11-Jun-07 10:53 
GeneralRe: Event Firing Pin
tobriain11-Jun-07 11:21
tobriain11-Jun-07 11:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.