Exemple #1
0
        private static void DurationPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            Marquee marquee = sender as Marquee;

            if (marquee != null)
            {
                //marquee._storyboard.Duration = (Duration)e.NewValue;

                marquee._storyboard.Stop();
                marquee._storyboard.Begin();
            }
        }
Exemple #2
0
        public Text(RegionOptions options) : base(options.Width, options.Height, options.Top, options.Left)
        {
            //NavigatedEventHandler handler = null;
            this._filePath = options.Uri;
            this._direction = options.direction??"left";
            this._backgroundImage = options.backgroundImage;
            this._backgroundColor = options.backgroundColor;
            //this._scaleFactor = options.ScaleFactor==0?3:options.ScaleFactor;
            //this._backgroundTop = options.BackgroundTop + "px";
            //this._backgroundLeft = options.BackgroundLeft + "px";
            //this._documentText = File.ReadAllText(_filePath);//options.text;
            //this._scrollSpeed = 50;//options.scrollSpeed;
            //this._headJavaScript = options.javaScript;
            //this._tempHtml = new TemporaryHtml();
            //this.GenerateHeadHtml();
            //this.GenerateBodyHtml();
            //this._webBrowser = new WebBrowser();
            //this._webBrowser.Height = options.Height;
            //this._webBrowser.Width = options.Width;
            //this._webBrowser.Margin = new Thickness(0.0, 0.0, 0.0, 0.0);
            //this._webBrowser.LoadCompleted += new LoadCompletedEventHandler(this.WebBrowserDocumentCompleted);
            //if (handler == null)
            //{
            //    handler =new NavigatedEventHandler((t,r)=>{
            //        this.HideScriptErrors(this._webBrowser, true);
            //    });
            //}
            //this._webBrowser.Navigated += handler;
            //this._webBrowser.Navigate(this._tempHtml.Path);
            //base.MediaCanvas.Children.Add(this._webBrowser);
            //Todo : Detect newlines and replace with tabs on horiz scroll
            var text = File.ReadAllText(_filePath).Replace("\n", " ").Replace("\r", " ") + "      ";
           // var text = "Welcome to this cool app Welcome to this cool app Welcome to this cool app Welcome to this cool app Welcome to this cool app ";
         //   text =
             //   "WELCOME TO THIS COOL APP WELCOME TO THIS COOL APP WELCOME TO THIS COOL APP WELCOME TO THIS COOL APP ";
            marquee =new Marquee();

       

        //    options.Height = options.Height/2;
         //   options.Width = options.Width/5;

            // Create the initial formatted text string.
            FormattedText formattedText = new FormattedText(
                text,
                CultureInfo.GetCultureInfo("en-us"),
                FlowDirection.LeftToRight,
                new Typeface("Arial"),
                options.Height,
                Brushes.Black);

            //// Set a maximum width and height. If the text overflows these values, an ellipsis "..." appears.
            //formattedText.MaxTextWidth = 300;
            //formattedText.MaxTextHeight = 240;
            
            marquee.MarqueeContent = new TextBlock();
            marquee.Width = options.Width;
            marquee.Height = options.Height;
            marquee.MarqueeContent.Text = text; //_marquee.MarqueeContent.ActualWidth.ToString();
            marquee.MarqueeContent.FontFamily = new FontFamily("Arial");
            marquee.MarqueeContent.Height = options.Height;
            marquee.MarqueeContent.FontSize = options.Height;
            marquee.MarqueeContent.TextWrapping = TextWrapping.NoWrap;
            marquee.VerticalAlignment = VerticalAlignment.Center;
            marquee.DesiredWidth = options.Width;
            var dur = ((formattedText.Width / options.Height)) /2  ;//1.2;
                
         //       (((options.Width)*options.Height) * text.Length)/
       //          211637
            ;
            marquee.Duration = new Duration(
                TimeSpan.FromSeconds(dur
              
                ));
            marquee.MarqueeContent.Foreground = System.Windows.Media.Brushes.Black;

            marquee.MarqueeContent.Background = System.Windows.Media.Brushes.LawnGreen;

       //     marquee.LeftToRight = true;
            //new SigMarquee()
                               //      {Message = text, Font = new SigFont() {Size = options.Height}, Speed = 8, Interval=TimeSpan.FromSeconds(100)})
               //     {TextBanner = {TextWrapping = TextWrapping.NoWrap}, Height = options.Height, Width = options.Width};
            //marquee = new MarqueeText();
            //marquee.Background =System.Windows.Media.Brushes.Red;
            //marquee.MarqueeTimeInSeconds = options.Duration;
            //marquee.Foreground = System.Windows.Media.Brushes.Black;
            //marquee.MarqueeType = MarqueeType.RightToLeft; ;
            //marquee.MarqueeContent = File.ReadAllText(_filePath);
            base.MediaCanvas.Children.Add(this.marquee);
        }