我在WPF中使用web browser控件,全屏打开一个flash,代码如下:<Window x:Class="B1Motion.ViewDashboard"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="ViewDashboard" Height="1010" Width="1900">
    <Grid>
        <WebBrowser x:Name="WebBrowser1"  Source="file://127.0.0.1/c$/dashboard1.swf"></WebBrowser>
    </Grid>
</Window>
我希望鼠标移动到某个位置时,可以在鼠标下方显示一个浮动的进度条,这个进度条可以是一张动态的图片,不需要考虑实际进度,请问各位大侠有没有好的方法,我在google上没有找到比较有价值的资料,最好是基于.net framework4.0的版本。弹出窗口也行,但是要求隐藏掉窗口的标题栏和状态栏。

解决方案 »

  1.   

    有大侠研究过吗?any idea都有分哦。
      

  2.   

    http://www.aijiw.com/art/20110809/08494585.htm
    这个站点有说到“C#进度条在弹出窗口中显示”,但是我在WPF中没法调试通,有可能用的是winform,我对于桌面应用这块不是很熟悉,请教WPF达人把这段代码改为WPF的实现,或者WPF调用winform控件也可以啊!
      

  3.   

    刚刚才开始学WPF,winform实现应该不难
      

  4.   

    如果是gif图   我记得 要拆成一帧一帧的  来显示成  动态的 
      

  5.   

    我找下 代码  一会发上来  读取gif图 显示成滚动条wpf的  
      

  6.   

    xaml 代码
     
     <local:GifImage Background="Transparent" Source="/Resources/load.gif" Height="14" Width="190" Margin="260,244,66,57"></local:GifImage>c#  代码
    [code=C#]
    public class GifImage : System.Windows.Controls.UserControl
        {
            private GifAnimation gifAnimation = null;
            private Image image = null;        public GifImage()
            {
            }        public static readonly DependencyProperty ForceGifAnimProperty = DependencyProperty.Register("ForceGifAnim", typeof(bool), typeof(GifImage), new FrameworkPropertyMetadata(false));
            public bool ForceGifAnim
            {
                get
                {
                    return (bool)this.GetValue(ForceGifAnimProperty);
                }
                set
                {
                    this.SetValue(ForceGifAnimProperty, value);
                }
            }        public static readonly DependencyProperty SourceProperty = DependencyProperty.Register("Source", typeof(string), typeof(GifImage), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, new PropertyChangedCallback(OnSourceChanged)));
            private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
            {
                GifImage obj = (GifImage)d;
                string s = (string)e.NewValue;
                obj.CreateFromSourceString(s);
            }
            public string Source
            {
                get
                {
                    return (string)this.GetValue(SourceProperty);
                }
                set
                {
                    this.SetValue(SourceProperty, value);
                }
            }
            public static readonly DependencyProperty StretchProperty = DependencyProperty.Register("Stretch", typeof(Stretch), typeof(GifImage), new FrameworkPropertyMetadata(Stretch.Fill, FrameworkPropertyMetadataOptions.AffectsMeasure, new PropertyChangedCallback(OnStretchChanged)));
            private static void OnStretchChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
            {
                GifImage obj = (GifImage)d;
                Stretch s = (Stretch)e.NewValue;
                if (obj.gifAnimation != null)
                {
                    obj.gifAnimation.Stretch = s;
                }
                else
                    if (obj.image != null)
                    {
                        obj.image.Stretch = s;
                    }
            }
            public Stretch Stretch
            {
                get
                {
                    return (Stretch)this.GetValue(StretchProperty);
                }
                set
                {
                    this.SetValue(StretchProperty, value);
                }
            }        public static readonly DependencyProperty StretchDirectionProperty = DependencyProperty.Register("StretchDirection", typeof(StretchDirection), typeof(GifImage), new FrameworkPropertyMetadata(StretchDirection.Both, FrameworkPropertyMetadataOptions.AffectsMeasure, new PropertyChangedCallback(OnStretchDirectionChanged)));
            private static void OnStretchDirectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
            {
                GifImage obj = (GifImage)d;
                StretchDirection s = (StretchDirection)e.NewValue;
                if (obj.gifAnimation != null)
                {
                    obj.gifAnimation.StretchDirection = s;
                }
                else
                    if (obj.image != null)
                    {
                        obj.image.StretchDirection = s;
                    }
            }
            public StretchDirection StretchDirection
            {
                get
                {
                    return (StretchDirection)this.GetValue(StretchDirectionProperty);
                }
                set
                {
                    this.SetValue(StretchDirectionProperty, value);
                }
            }        public delegate void ExceptionRoutedEventHandler(object sender, GifImageExceptionRoutedEventArgs args);        public static readonly RoutedEvent ImageFailedEvent = EventManager.RegisterRoutedEvent("ImageFailed", RoutingStrategy.Bubble, typeof(ExceptionRoutedEventHandler), typeof(GifImage));        public event ExceptionRoutedEventHandler ImageFailed
            {
                add
                {
                    AddHandler(ImageFailedEvent, value);
                }
                remove
                {
                    RemoveHandler(ImageFailedEvent, value);
                }
            }        void image_ImageFailed(object sender, ExceptionRoutedEventArgs e)
            {
                RaiseImageFailedEvent(e.ErrorException);
            }
            void RaiseImageFailedEvent(Exception exp)
            {
                GifImageExceptionRoutedEventArgs newArgs = new GifImageExceptionRoutedEventArgs(ImageFailedEvent, this);
                newArgs.ErrorException = exp;
                RaiseEvent(newArgs);
            }
            private void DeletePreviousImage()
            {
                if (image != null)
                {
                    this.RemoveLogicalChild(image);
                    image = null;
                }
                if (gifAnimation != null)
                {
                    this.RemoveLogicalChild(gifAnimation);
                    gifAnimation = null;
                }
            }        private void CreateNonGifAnimationImage()
            {
                image = new Image();
                image.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(image_ImageFailed);
                ImageSource src = (ImageSource)(new ImageSourceConverter().ConvertFromString(Source));
                image.Source = src;
                image.Stretch = Stretch;
                image.StretchDirection = StretchDirection;
                this.AddChild(image);
            }
          
      

  7.   

    //////////一个用户只允许连续回复3次。  private void CreateGifAnimation(MemoryStream memoryStream)
            {
                gifAnimation = new GifAnimation();
                gifAnimation.CreateGifAnimation(memoryStream);
                gifAnimation.Stretch = Stretch;
                gifAnimation.StretchDirection = StretchDirection;
                this.AddChild(gifAnimation);
            }
            private void CreateFromSourceString(string source)
            {
                DeletePreviousImage();
                Uri uri;            try
                {
                    uri = new Uri(source, UriKind.RelativeOrAbsolute);
                }
                catch (Exception exp)
                {
                    RaiseImageFailedEvent(exp);
                    return;
                }            if (source.Trim().ToUpper().EndsWith(".GIF") || ForceGifAnim)
                {
                    if (!uri.IsAbsoluteUri)
                    {
                        GetGifStreamFromPack(uri);
                    }
                    else
                    {                    string leftPart = uri.GetLeftPart(UriPartial.Scheme);                    if (leftPart == "http://" || leftPart == "ftp://" || leftPart == "file://")
                        {
                            GetGifStreamFromHttp(uri);
                        }
                        else
                            if (leftPart == "pack://")
                            {
                                GetGifStreamFromPack(uri);
                            }
                            else
                            {
                                CreateNonGifAnimationImage();
                            }
                    }
                }
                else
                {
                    CreateNonGifAnimationImage();
                }
            }        private delegate void WebRequestFinishedDelegate(MemoryStream memoryStream);        private void WebRequestFinished(MemoryStream memoryStream)
            {
                CreateGifAnimation(memoryStream);
            }
            private delegate void WebRequestErrorDelegate(Exception exp);
            private void WebRequestError(Exception exp)
            {
                RaiseImageFailedEvent(exp);
            }        private void WebResponseCallback(IAsyncResult asyncResult)
            {
                WebReadState webReadState = (WebReadState)asyncResult.AsyncState;
                WebResponse webResponse;
                try
                {
                    webResponse = webReadState.webRequest.EndGetResponse(asyncResult);
                    webReadState.readStream = webResponse.GetResponseStream();
                    webReadState.buffer = new byte[100000];
                    webReadState.readStream.BeginRead(webReadState.buffer, 0, webReadState.buffer.Length, new AsyncCallback(WebReadCallback), webReadState);
                }
                catch (WebException exp)
                {
                    this.Dispatcher.Invoke(DispatcherPriority.Render, new WebRequestErrorDelegate(WebRequestError), exp);
                }
            }        private void WebReadCallback(IAsyncResult asyncResult)
            {
                WebReadState webReadState = (WebReadState)asyncResult.AsyncState;
                int count = webReadState.readStream.EndRead(asyncResult);
                if (count > 0)
                {
                    webReadState.memoryStream.Write(webReadState.buffer, 0, count);
                    try
                    {
                        webReadState.readStream.BeginRead(webReadState.buffer, 0, webReadState.buffer.Length, new AsyncCallback(WebReadCallback), webReadState);
                    }
                    catch (WebException exp)
                    {
                        this.Dispatcher.Invoke(DispatcherPriority.Render, new WebRequestErrorDelegate(WebRequestError), exp);
                    }
                }
                else
                {
                    this.Dispatcher.Invoke(DispatcherPriority.Render, new WebRequestFinishedDelegate(WebRequestFinished), webReadState.memoryStream);
                }
            }        private void GetGifStreamFromHttp(Uri uri)
            {
                try
                {
                    WebReadState webReadState = new WebReadState();
                    webReadState.memoryStream = new MemoryStream();
                    webReadState.webRequest = WebRequest.Create(uri);
                    webReadState.webRequest.Timeout = 10000;                webReadState.webRequest.BeginGetResponse(new AsyncCallback(WebResponseCallback), webReadState);
                }
                catch (SecurityException)
                {
                    CreateNonGifAnimationImage();
                }
            }
            private void ReadGifStreamSynch(Stream s)
            {
                byte[] gifData;
                MemoryStream memoryStream;
                using (s)
                {
                    memoryStream = new MemoryStream((int)s.Length);
                    BinaryReader br = new BinaryReader(s);
                    gifData = br.ReadBytes((int)s.Length);
                    memoryStream.Write(gifData, 0, (int)s.Length);
                    memoryStream.Flush();
                }
                CreateGifAnimation(memoryStream);
            }        private void GetGifStreamFromPack(Uri uri)
            {
                try
                {
                    StreamResourceInfo streamInfo;                if (!uri.IsAbsoluteUri)
                    {
                        streamInfo = Application.GetContentStream(uri);
                        if (streamInfo == null)
                        {
                            streamInfo = Application.GetResourceStream(uri);
                        }
                    }
                    else
                    {
                        if (uri.GetLeftPart(UriPartial.Authority).Contains("siteoforigin"))
                        {
                            streamInfo = Application.GetRemoteStream(uri);
                        }
                        else
                        {
                            streamInfo = Application.GetContentStream(uri);
                            if (streamInfo == null)
                            {
                                streamInfo = Application.GetResourceStream(uri);
                            }
                        }
                    }
                    if (streamInfo == null)
                    {
                        throw new FileNotFoundException("Resource not found.", uri.ToString());
                    }
                    ReadGifStreamSynch(streamInfo.Stream);
                }
                catch (Exception exp)
                {
                    RaiseImageFailedEvent(exp);
                }
            }
        }
    [/code] 
      

  8.   

    这个不难啊,以前就弄过类似的东西,两种常见的方案:一种是Popup控件,一种是Window控件。回去找找给你看看
      

  9.   

    //简单写几个   Popup 在wpf中没用过  呵呵  
     Popup p = new Popup();
    panel1.Children.Clear();
     panel1.Children.Add(XXXX);
      p.VerticalOffset = 25;
                    p.HorizontalOffset = 25;
                    p.IsOpen = true;
      

  10.   

    后面换方案,主要是无法控制flash里控件的响应,全部改用wpf画控件来做。
    结贴吧!感谢各位的回答。