private void Window_Loaded(object sender, RoutedEventArgs e) { playSwf(); //System.Windows.Forms.Application.Idle += new EventHandler(Application_Idle); string todayDate = DateTime.Now.ToShortDateString(); try { var functionRecs = from recs in Window1.mcsCtx.mcs_function orderby recs.mcs_Function_FromTime select recs; lbl_head1.Content = functionRecs.First().mcs_Function_PartyName.ToString(); lbl_sub1.Content = functionRecs.First().mcs_Function_HallName.ToString(); lbl_Time1.Content = functionRecs.First().mcs_Function_FromTime.ToString(); lFunctions = functionRecs.ToList(); // display restaurant names updateFunctionList(nBlock); var scrollrecs = from recs in Window1.mcsCtx.mcs_scroll select recs; string tit = scrollrecs.First().mcs_Scroll_Title.ToString(); string descrip = scrollrecs.First().mcs_Scroll_Description.ToString(); AddTextBlock(tit + " " + descrip); } catch { MessageBox.Show("Check the Connection"); } canvas1.Dispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(delegate(Object state) { var node = textBlocks.First; while (node != null) { //double left = 0; if (node.Previous != null) { Canvas.SetLeft(node.Value, Canvas.GetLeft(node.Previous.Value) + node.Previous.Value.ActualWidth + gap); } else { Canvas.SetLeft(node.Value, canvas1.Width + gap); } node = node.Next; } return null; }), null); timer.Interval = timer_interval; timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); //timer.Start(); timer.Enabled = true; IdleTimer.Interval = 1; IdleTimer.Elapsed += new ElapsedEventHandler(IdleTimer_Elapsed); //IdleTimer.Start(); IdleTimer.Enabled = true; } void IdleTimer_Elapsed(object sender, ElapsedEventArgs e) { try { var idletimerecs = from recs in Window1.mcsCtx.mcs_idletimer select recs; int idletimedb = idletimerecs.First().mcs_IdleTimer_Time; int itime = idletimedb * 100; idleCounter++; if (idleCounter == itime) { //MessageBox.Show(""+itime); //Thread.CurrentThread.Abort(); //IdleTimer.Enabled = false; fn(); //Window1 win1 = new Window1(); //win1.Show(); } } catch//(Exception er) { // MessageBox.Show("ERROR"+er); } } void fn() { try { //timer.Enabled = false; //IdleTimer.Enabled = false; this.Close(); } catch (Exception exa) { MessageBox.Show("" + exa); //MessageBox.Show(""+exa.InnerException); } //ButtonAutomationPeer peer = new ButtonAutomationPeer(btn_openMain); //IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; //invokeProv.Invoke(); } void timer_Elapsed(object sender, ElapsedEventArgs e) { canvas1.Dispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(delegate(Object state) { var node = textBlocks.First; var lastNode = textBlocks.Last; while (node != null) { double newLeft = Canvas.GetLeft(node.Value) - move_amount; if (newLeft < (0 - (node.Value.ActualWidth + gap))) { textBlocks.Remove(node); var lastNodeLeftPos = Canvas.GetLeft(lastNode.Value); textBlocks.AddLast(node); if ((lastNodeLeftPos + lastNode.Value.ActualWidth + gap) > canvas1.Width) // Last element is offscreen { newLeft = lastNodeLeftPos + lastNode.Value.ActualWidth + gap; } else { newLeft = canvas1.Width + gap; } } Canvas.SetLeft(node.Value, newLeft); node = node == lastNode ? null : node.Next; } return null; }), null); } void AddTextBlock(string Text) { TextBlock tb = new TextBlock(); tb.Text = Text; tb.FontSize = 35; tb.FontWeight = FontWeights.Medium; tb.Foreground = Brushes.Gold; canvas1.Children.Add(tb); Canvas.SetTop(tb, -3); Canvas.SetLeft(tb, -999); Canvas.SetBottom(tb, 3); textBlocks.AddLast(tb); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)