Click here to Skip to main content
16,007,885 members
Home / Discussions / C#
   

C#

 
GeneralRe: Hide password decryption Pin
William Engberts6-Feb-09 5:07
William Engberts6-Feb-09 5:07 
GeneralRe: Hide password decryption Pin
Ennis Ray Lynch, Jr.6-Feb-09 7:20
Ennis Ray Lynch, Jr.6-Feb-09 7:20 
AnswerRe: Hide password decryption Pin
Jon Rista6-Feb-09 10:02
Jon Rista6-Feb-09 10:02 
QuestionIdle processing and Modal dialogs - inconsistent behavior Pin
Greg Schmidt6-Feb-09 3:07
Greg Schmidt6-Feb-09 3:07 
QuestionC# Program Is Eating My CPU Cycles Like Popcorn! Pin
Michael Fritzius6-Feb-09 2:22
professionalMichael Fritzius6-Feb-09 2:22 
AnswerRe: C# Program Is Eating My CPU Cycles Like Popcorn! Pin
Pete O'Hanlon6-Feb-09 2:29
mvePete O'Hanlon6-Feb-09 2:29 
AnswerRe: C# Program Is Eating My CPU Cycles Like Popcorn Pin
Luc Pattyn6-Feb-09 5:56
sitebuilderLuc Pattyn6-Feb-09 5:56 
QuestionTimed resize of image Pin
m.otte6-Feb-09 2:16
m.otte6-Feb-09 2:16 
Hi,
I'm trying to make the images in a super slide show to automatically enlarge. Super because I want to control the images with a timer accuracy of 1 millisecond.
So I've got a timer event set up. That changes the image (according to a config file) every x ms.
When the image is shown I want the image to grow larger (including beyond the size of the screen) to create the effect of flying into the image.

I can't get it to work.

Here's the code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using Multimedia; //For the MM timer
using System.Windows.Forms;

namespace MyImage
{
public partial class Form1 : Form
{
public delegate void ScaleImageDelegate(); //public delegate void WriteDataDelegate(object sender, EventArgs eArgs);
Multimedia.Timer myTimer = new Multimedia.Timer(); //Define a new 1ms resolution timer
int TimeCounter, ImageCounter;
bool DoScale = false;
Bitmap[] myImage = new Bitmap[10];
string[] ImageName = new string[10];
int[] ImageStart = new int[10];
int[] ImageDuration = new int[10];
int TotalNumberofImages;
float Scaler = 1;

public Form1()
{
InitializeComponent();
myTimer.Mode = TimerMode.Periodic; //Make sure the timer keeps running after the set period
myTimer.Period = 10; //Set the period (when the Event is triggered) to x ms
myTimer.Resolution = 1; //Set the resolution of the timer to 1ms
this.myTimer.Tick += new System.EventHandler(this.myTimer_Tick); //Initialize the EventHandler
GetFiles(); //REad the images in an array for fast display
myTimer.Start(); //Start the timer and thus the Event Handler and do something
TimeCounter = 0; //Reset the timer counter
ImageCounter = 0;
}

void myTimer_Tick(object sender, System.EventArgs args)
{
TimeCounter += 1; //an other 10ms has elapsed
if (TimeCounter * 10 == ImageStart[ImageCounter])
{
pictureBox1.Image = myImage[ImageCounter];
ScaleImage();
}
if (TimeCounter * 10 == ImageStart[ImageCounter] + ImageDuration[ImageCounter])
{
pictureBox1.Image = myImage[4];
ImageCounter += 1;
DoScale = false;
if (ImageCounter > TotalNumberofImages)
{
Application.Exit();
}
}
if (DoScale)
{
ScaleImage();
}
}

void GetFiles()
{
TextReader tr = new StreamReader(@"c:\data\images.dat");
char[] seps = { ';' };
String line;
String[] values;
int i =0;

while ((line = tr.ReadLine()) != null)
{
values = line.Split(seps);
ImageName[i] = values[0];
ImageStart[i] = int.Parse(values[1]);
ImageDuration[i] = int.Parse(values[2]);
i++;
}
TotalNumberofImages = i - 1;

for (i = 0; i <= TotalNumberofImages; i++)
{
myImage[i] = new Bitmap(ImageName[i]);
}
// close the stream
tr.Close();
}

private void ScaleImage()
{
double myWidth, myHeight;
if (InvokeRequired)
{
BeginInvoke(new ScaleImageDelegate(ScaleImage));
return;
}
if (!DoScale)
{
Scaler = 1;
DoScale = true;
}
Scaler += 0.01f;
myWidth = Convert.ToDouble(pictureBox1.Width) * Convert.ToInt32(Scaler);
pictureBox1.Width = Convert.ToInt32(myWidth);
myHeight = Convert.ToDouble(pictureBox1.Height) * Convert.ToInt32(Scaler);
pictureBox1.Height = Convert.ToInt32(myHeight);
}
}
}

THX!
Marco
AnswerRe: Timed resize of image Pin
musefan6-Feb-09 2:19
musefan6-Feb-09 2:19 
GeneralRe: Timed resize of image [modified] Pin
m.otte6-Feb-09 2:34
m.otte6-Feb-09 2:34 
GeneralRe: Timed resize of image Pin
musefan6-Feb-09 2:48
musefan6-Feb-09 2:48 
GeneralRe: Timed resize of image Pin
m.otte6-Feb-09 3:30
m.otte6-Feb-09 3:30 
GeneralRe: Timed resize of image Pin
musefan6-Feb-09 3:34
musefan6-Feb-09 3:34 
GeneralRe: Timed resize of image Pin
musefan6-Feb-09 3:20
musefan6-Feb-09 3:20 
GeneralRe: Timed resize of image Pin
m.otte6-Feb-09 3:32
m.otte6-Feb-09 3:32 
GeneralRe: Timed resize of image Pin
musefan6-Feb-09 3:35
musefan6-Feb-09 3:35 
GeneralRe: Timed resize of image Pin
m.otte6-Feb-09 3:40
m.otte6-Feb-09 3:40 
GeneralRe: Timed resize of image Pin
musefan6-Feb-09 3:43
musefan6-Feb-09 3:43 
GeneralRe: Timed resize of image Pin
m.otte6-Feb-09 3:49
m.otte6-Feb-09 3:49 
GeneralRe: Timed resize of image Pin
musefan6-Feb-09 3:53
musefan6-Feb-09 3:53 
GeneralRe: Timed resize of image Pin
m.otte6-Feb-09 5:31
m.otte6-Feb-09 5:31 
AnswerRe: Timed resize of image [modified] Pin
Luc Pattyn6-Feb-09 6:47
sitebuilderLuc Pattyn6-Feb-09 6:47 
GeneralRe: Timed resize of image Pin
musefan6-Feb-09 6:49
musefan6-Feb-09 6:49 
AnswerRe: Timed resize of image [modified] Pin
Luc Pattyn6-Feb-09 6:45
sitebuilderLuc Pattyn6-Feb-09 6:45 
QuestionFOR EXPERTS: Template Class: Type Constraints Pin
Axonn Echysttas6-Feb-09 2:12
Axonn Echysttas6-Feb-09 2:12 

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.