473,554 Members | 2,855 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

(C#) Opacity - Animation

Atran
319 Contributor
Hello EveryBody, I write this code but the code not work:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8.  
  9. namespace WindowsApplication1
  10. {
  11.     public partial class Form1 : Form
  12.     {
  13.         public Form1()
  14.         {
  15.             InitializeComponent();
  16.             //Set the form opacity = 0.
  17.             this.Opacity = 0.00;
  18.             for (double i = 0.00; i < 1.01; i = i + 0.01)
  19.             {
  20.                 //Make the form opacity a motion.
  21.                 this.Opacity += i;
  22.                 if (this.Opacity.Equals(1.00) == true)
  23.                 {
  24.                     break;
  25.                 }
  26.             }
  27.         }
  28.     }
  29. }
  30.  
Can anyone help me?
--------------------------------
And how I can do an animation using C# (If you can give me an example).
Thanks for anyhelp.
Jun 6 '07 #1
16 7438
Plater
7,872 Recognized Expert Expert
What do you want this to do? because that will execute WAY to fast for you to see
Jun 6 '07 #2
TRScheel
638 Recognized Expert Contributor
What do you want this to do? because that will execute WAY to fast for you to see
That and the check for opactiy.equals is redundant
Jun 6 '07 #3
Atran
319 Contributor
What do you want this to do? because that will execute WAY to fast for you to see
Hello, When I write:

Expand|Select|Wrap|Line Numbers
  1.   this.Opacity = 0.00;
  2.  
The form be invisible (it works but cant see).
So I want to be a motion tween, I mean when I run my app:
I want the form Opacity = 0.
and three after three grow to the opacity, I mean:

Expand|Select|Wrap|Line Numbers
  1. this.Opacity = 0.00;
  2. this.Opacity = 0.03;
  3. this.Opacity = 0.06;
  4. this.Opacity = 0.09;
  5. this.Opacity = 0.12;
  6. //.................To 1.00
  7. //So I want this like animation from "0.00 to 1.00".
  8.  
Thanks for anyhelp.
Jun 6 '07 #4
TRScheel
638 Recognized Expert Contributor
Hello, When I write:

Expand|Select|Wrap|Line Numbers
  1.   this.Opacity = 0.00;
  2.  
The form be invisible (it works but cant see).
So I want to be a motion tween, I mean when I run my app:
I want the form Opacity = 0.
and three after three grow to the opacity, I mean:

Expand|Select|Wrap|Line Numbers
  1. this.Opacity = 0.00;
  2. this.Opacity = 0.03;
  3. this.Opacity = 0.06;
  4. this.Opacity = 0.09;
  5. this.Opacity = 0.12;
  6. //.................To 1.00
  7. //So I want this like animation from "0.00 to 1.00".
  8.  
Thanks for anyhelp.
Add something like

Expand|Select|Wrap|Line Numbers
  1. Thread.Sleep(1000);
between each change. It will add 1000 milliseconds ( or 1 second ) between each change. This will mean that at .01 change, it will take 100 seconds to go from invisible to visible, so I might suggest lowering it.
Jun 6 '07 #5
Atran
319 Contributor
Add something like

Expand|Select|Wrap|Line Numbers
  1. Thread.Sleep(1000);
between each change. It will add 1000 milliseconds ( or 1 second ) between each change. This will mean that at .01 change, it will take 100 seconds to go from invisible to visible, so I might suggest lowering it.
Thanks very much....
Jun 6 '07 #6
Atran
319 Contributor
But can anyone till me how to create a simple animation?
example: In my form I have a basic line.
So I want to make a tween motion to the line, I mean make the line move from a position to another position (make animation for the line).
Thanks for anyhelp.
Jun 6 '07 #7
Plater
7,872 Recognized Expert Expert
DirectX I think is what you want. TR can probably help you better as I've never used it.

If you wanted just static pictures, you could play with the Graphic object in the Paint functions
Jun 6 '07 #8
Atran
319 Contributor
DirectX I think is what you want. TR can probably help you better as I've never used it.

If you wanted just static pictures, you could play with the Graphic object in the Paint functions
Thanks......... ..............
Jun 6 '07 #9
TRScheel
638 Recognized Expert Contributor
DirectX I think is what you want. TR can probably help you better as I've never used it.

If you wanted just static pictures, you could play with the Graphic object in the Paint functions

Actually you can use window's inherit graphics to do something simple like the line drawing. You just need to force a redraw, which is semi-redundant. The problem with the windows GDI for drawing is that if I say draw a line on my form, and then move IE over my form, then look at my form again, the line wont be there anymore unless I force a redraw. The issue is that you need to capture when and how to redraw, and know that the GDI is very... very... slow in comparison to say DirectX. Slow enough that expecting 60 - 100 updates per second on anything more complicated then say... a line... is probably not going to happen. Which is fine for your purposes, and in all reality you probably only need about 30 fps, if not less considering they are not going to notice the jumps if we lowered it to 10 fps and the line grew at a slow enough speed.

And to be honest, DirectX is overkill for a simple line.


I have to work on a few machines around this building, but when I get back I will throw up a code snippet showing how to do it.
Jun 7 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
10206
by: Marek Mänd | last post by:
This posting will express my concern about the future of css3 forthcoming recommendation. I think for long time now, that the current implementation of CSS attribute opacity is less than usable in practical real life situations. The soon forthcoming CSS3 recommendation does not serve the public interests in this area not at all. The problem...
2
1543
by: Frank Rizzo | last post by:
I have a little animation where I fade out the form by manipulating its opacity. However, the screen seems to flicker just a little bit. Are there any tricks to making the form disappear smoother? Thanks
5
2896
by: Webmaster | last post by:
The following style sets the opacity or semi-transparency in Mozilla and Explorer browsers for an image: #myImage{ filter: alpha(opacity=50); -moz-opacity:0.50; opacity: 0.50; } <img src="someimage.jpg" name="myImage" id="myImage"> The alpha(opacity=50 does it in IE and the opacity: 0.50 does it Mozilla.
1
2624
by: mhoeneveld | last post by:
I am writing a small script to fade the opacity of an image/object. The script itself works fine only I do have some unwanted behaviour. I do use a tablecell object and the mouseover/mouseout to activate the script. In the same cell are some links listed and when you move the cursor over the links the image starts to flicker. This is...
3
1529
by: Cico1 | last post by:
sorry another one problem here... i have ink which points to this function: opacty= 0 function opacOff() { opacty+=10; document.getElementById('m').style.filter = "alpha(opacity="+ opacty +")"; document.getElementById('m').style.MozOpacity = oopacty/100; document.getElementById('m').style.opacity=opacty/100; ...
16
2943
by: Darko | last post by:
Hi, I'm trying to get and set an element's opacity, but I'm stuck with, what a hell of surprise, Internet Explorer. As for getting the element's opacity, I have the following (not working) lines of code: if ( targetObject.filters && targetObject.filters.length 0 ) opacity =...
15
3701
by: Sunny | last post by:
Hi, I can change the lement opacity in IE using. abc.style.filter = 'alpha(opacity=' + 10 + ')'; But this dont work in firefox, In firefox it throws error. How I can change the opacity of an element in Firefox.
0
7506
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7782
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8018
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7541
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7872
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5423
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3545
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2006
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
823
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.