Display 4 Flash从根目录一个接一个地添加 [英] Display 4 flash adds one by one from root directory

查看:87
本文介绍了Display 4 Flash从根目录一个接一个地添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 这是克里希纳
我有一个Windows应用程序,可播放图像和Flash广告.我使用三个计时器来播放这些广告.例如,我的文件夹包含1.swf,2.jpg,3.jpg,4.swf,5.swf,.... .
这里我正在使用if condition.但是我想使用,如果扩展名是.swf,那么它必须使用timer1并播放flash add.如果下一个文件扩展名是.jpg,则它必须使用timer2来做到这一点. />
我的代码如下:

 使用系统;
使用 System.Collections.Generic;
使用 System.ComponentModel;
使用 System.Data;
使用使用System.Drawing;
使用 System.Linq;
使用 System.Text;
使用使用System.Windows.Forms;

命名空间 Demo_Flash
{
    公共 部分  class  Form1:表单
    {
        计时器timer1 =  Timer();
        计时器timer2 =  Timer();
        计时器timer3 =  Timer();

         int  i =  0 ;
         int  j =  0 ;
        公共 Form1()
        {
            InitializeComponent();
            i =  1 ;
            j =  1 ;
            timer1.Tick + =  EventHandler(timer1_Tick);
            timer1.Interval =( 1000 )*  10 ;
            timer1.Enabled =  true ;
            timer1.Start();

            timer2.Tick + =  EventHandler(timer2_Tick);
            timer2.Interval =( 1000 )*  10 ;
            timer2.Enabled =  false ;
            
            timer3.Tick + =  EventHandler(timer3_Tick);
            timer3.Interval =( 1000 )*  5 ;
            timer3.Enabled =  true ;
            timer3.Start();
        }

        无效 timer1_Tick(对象发​​送者,EventArgs e)
        {
            pictureBox1.Visible =  false ;
            pictureBox1.Enabled =  false ;
            axShockwaveFlash1.Visible =  true ;
            axShockwaveFlash1.BringToFront();
  
            如果(i ==  1 )
            {
                字符串 path = System.Environment.CurrentDirectory;
                路径+ =  @" ;
                axShockwaveFlash1.LoadMovie( 0 ,路径);
                axShockwaveFlash1.Play();
                i ++;
            }
            其他 如果(i ==  2 )
            {
                字符串 path = System.Environment.CurrentDirectory;
                路径+ =  @" ;
                axShockwaveFlash1.LoadMovie( 0 ,路径);
                axShockwaveFlash1.Play();
                一世 - ;
            }
 
        }

        无效 timer2_Tick(对象发​​送者,EventArgs e)
        {
            axShockwaveFlash1.Visible =  false ;
            pictureBox1.BringToFront();
            pictureBox1.Visible =  true ;
            pictureBox1.Enabled =  true ;
            
            如果(j ==  1 )
            {
                pictureBox1.Image = Image.FromFile(" );
                j ++;
            }
            其他 如果(j ==  2 )
            {
               pictureBox1.Image = Image.FromFile(" );
                j--;
            }
        }

        无效 timer3_Tick(对象发​​送者,EventArgs e)
        {
            timer3.Enabled =  false ;
            timer2.Enabled =  true ;
            timer2.Start();
        }
    }
} 



注意:
上面的代码可能是错误的,我不是C#的专家
我的事情很简单,如下所示:

1.我有Windows窗体,我必须在根目录(或特定目录中说D:\ Images)上显示一些(闪存或图像)添加
间隔一定的时间(例如8秒)
该目录可能包含Flash或图像,我必须在同一位置显示这两个图像(例如,第一次添加是Flash,第二次添加是image,然后我的表单显示Flash在8秒钟后显示图像,无论天气如何,循环都继续,这是一幅图像或Flash),那么我该怎么做

解决方案

这段代码非常严峻.除了丑陋的其他方式之外,您还没有在电影结束时捕捉到事件,这意味着电影的播放时间将与您的计时器一样长,而不是从头到尾.您是否尝试逐步解决?我也看不到您指定计时器持续时间的任何地方.您需要进行更多调试,然后根据您自己的发现向我们提出更具体的问题.


hi this is Krishna
I have a windows application which plays image and flash ads.i used three timers to play these ads.for example my folder contains 1.swf,2.jpg,3.jpg,4.swf,5.swf,.....
here i am using if condition.but i wanted to use like if extention is .swf then it has to use timer1 and play flash add.if the next files extention is .jpg then it has to use timer2 how to do that.

my code is like below:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Demo_Flash
{
    public partial class Form1 : Form
    {
        Timer timer1 = new Timer();
        Timer timer2 = new Timer();
        Timer timer3 = new Timer();

        int i = 0;
        int j = 0;
        public Form1()
        {
            InitializeComponent();
            i = 1;
            j = 1;
            timer1.Tick += new EventHandler(timer1_Tick);
            timer1.Interval = (1000) * 10;
            timer1.Enabled = true;
            timer1.Start();

            timer2.Tick += new EventHandler(timer2_Tick);
            timer2.Interval = (1000) * 10;
            timer2.Enabled = false;
            
            timer3.Tick += new EventHandler(timer3_Tick);
            timer3.Interval = (1000) * 5;
            timer3.Enabled = true;
            timer3.Start();            
        }

        void timer1_Tick(object sender, EventArgs e)
        {
            pictureBox1.Visible = false;
            pictureBox1.Enabled = false;
            axShockwaveFlash1.Visible = true;
            axShockwaveFlash1.BringToFront();
  
            if (i == 1)
            {
                string path = System.Environment.CurrentDirectory;
                path += @"\Top_1.swf";
                axShockwaveFlash1.LoadMovie(0, path);
                axShockwaveFlash1.Play();
                i++;
            }
            else if (i == 2)
            {  
                string path = System.Environment.CurrentDirectory;
                path += @"\Top_2.swf";
                axShockwaveFlash1.LoadMovie(0, path);
                axShockwaveFlash1.Play();
                i--;
            }
 
        }

        void timer2_Tick(object sender, EventArgs e)
        {
            axShockwaveFlash1.Visible = false;
            pictureBox1.BringToFront();
            pictureBox1.Visible = true;
            pictureBox1.Enabled = true;
            
            if (j == 1)
            {        
                pictureBox1.Image = Image.FromFile("D:/Project Source/Experimented/Bulk Sms/ProjectSms/ProjectSms/bin/Debug/Advertisement1_1.jpg");
                j++;
            }
            else if (j == 2)
            {
               pictureBox1.Image = Image.FromFile("D:/Project Source/Experimented/Bulk Sms/ProjectSms/ProjectSms/bin/Debug/Advertisement2_1.jpg");
                j--;
            }
        }

        void timer3_Tick(object sender, EventArgs e)
        {
            timer3.Enabled = false;
            timer2.Enabled = true;
            timer2.Start();
        }
    }
}



Note:
the code above may be wrong i am not an expert in C#
my thing is simple like below:

1.i have windows form i have to display some(flash or images) adds on it from root directory(or a particular directory say D:\Images)
with certain intervals(ex:8 sec)
the directory may contain flash or images i have to display both on same location (for example first add is flash and second add is image then first my form display flash after 8 seconds it display image the loop is continued regardless of weather it is a image or flash) then what i have to do

解决方案

This code is pretty grim. Apart from the other ways that it''s ugly, you''re not catching an event for the end of a movie, which means it will play for as long as your timer, not from beginning to end. Have you tried stepping through it ? I also don''t see anywhere that you specify a duration for the timer. You need to do some more debugging and ask us a more specific question based on what you find out for yourself.


这篇关于Display 4 Flash从根目录一个接一个地添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆