Beispiel #1
0
        private void AutoHideSoon()
        {
            if (autoHideCalled)
                return;

            autoHideCalled = true;

            var timer = new System.Windows.Threading.DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(3);
            timer.Tick += (sender, args) =>
            {
                timer.Stop();
                try
                {
                    if (this.Visibility == System.Windows.Visibility.Visible)
                    {
                        this.Close();
                    }
                }
                catch
                {
                    // just hide any error - probably means the user found some other way to hide us!
                }
            };
        }
Beispiel #2
0
        private async void ButtonStart_Click(object sender, RoutedEventArgs e)
        {
            ButtonStart.IsEnabled = false;
            Slider_Duration.IsEnabled = false;


            TimeSpan duration = TimeSpan.FromSeconds(this.Slider_Duration.Value);


            System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Start();
            timer.Tick += timer_Tick;


            LabelCountdown.Content = Convert.ToInt32(duration.TotalSeconds);


            try
            {
                await StartTimerAsync(duration);
            }
            finally
            {
                timer.Stop();
                ButtonStart.IsEnabled = true;
                Slider_Duration.IsEnabled = true;
                LabelCountdown.Content = 0;
            }
        }
Beispiel #3
0
        ObservableBackwardsRingBuffer<WeakReference> focussedElementBuffer = new ObservableBackwardsRingBuffer<WeakReference>(10);//because we don't know which controls to track until after the RapidFindReplaceControl is created, we must record a list and pick the first one that is pertinent
        
        public FocusMonitor(DependencyObject focusScopeToMonitor)
        {
            if (focusScopeToMonitor!=null && FocusManager.GetIsFocusScope(focusScopeToMonitor))
            {
                this.focusScopeToMonitorRef = new WeakReference(focusScopeToMonitor);
            }

            //poll for focus to track ordering of focused elements
            System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += delegate{
                if (focusScopeToMonitorRef!=null && focusScopeToMonitorRef.IsAlive)
                {
                    IInputElement logicalFocus = FocusManager.GetFocusedElement(focusScopeToMonitorRef.Target as DependencyObject);
                    IInputElement keyboardFocus = Keyboard.FocusedElement;
                    if (logicalFocus == keyboardFocus && keyboardFocus is UIElement)
                    {
                        //if(RapidFindReplaceControl.GetIsFindable(keyboardFocus as UIElement))
                            //lastKeyboardFocusRef = new WeakReference(keyboardFocus as DependencyObject);
                        if (focussedElementBuffer.Count==0 || (focussedElementBuffer[0] != null && focussedElementBuffer[0].IsAlive && focussedElementBuffer[0].Target != keyboardFocus))
                            focussedElementBuffer.AddItem(new WeakReference(keyboardFocus as UIElement));
                    }
                }
                else
                    dispatcherTimer.Stop();
            };
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100);
            dispatcherTimer.Start();
        }
        private void timerRun()
        {
            timerField = new System.Windows.Threading.DispatcherTimer();
            timerField.Tick += new EventHandler(timerTick);
            SetServerCheckInterval();

            var actAcc = clientDB.ActiveAccount();
            myCurrentImap = new List<Imap>();
            foreach (string s in actAcc.Keys)
            {
                myCurrentImap.Add(new Imap(Cryptography.Decrypt(s), Cryptography.Decrypt(actAcc[s])));
            }
            try
            {
                foreach (Imap im in myCurrentImap)
                {
                    im.Connection();
                    clientDB.UpdateAccountMessages(Cryptography.Encrypt(im.currentEmail), im.Connections.Inbox.Count);
                }
            }
            catch
            {
                timerField.Stop();
            }

            timerField.Start();
        }
        public MainPage(IDictionary<string, string> initParams)
        {
            InitializeComponent();

            HtmlPage.RegisterScriptableObject("SilverlightApp", this);

            // timer
            _timer = new System.Windows.Threading.DispatcherTimer();
            _timer.Interval = new TimeSpan(0, 0, 0, 0, 200); // 200 Milliseconds
            _timer.Tick += new EventHandler(timer_Tick);
            _timer.Stop();

            // add events
            media.BufferingProgressChanged += new RoutedEventHandler(media_BufferingProgressChanged);
            media.DownloadProgressChanged += new RoutedEventHandler(media_DownloadProgressChanged);
            media.CurrentStateChanged += new RoutedEventHandler(media_CurrentStateChanged);
            media.MediaEnded += new RoutedEventHandler(media_MediaEnded);
            media.MediaFailed += new EventHandler<ExceptionRoutedEventArgs>(media_MediaFailed);

            // get parameters
            if (initParams.ContainsKey("id"))
                _htmlid = initParams["id"];
            if (initParams.ContainsKey("file"))
                _mediaUrl = initParams["file"];
            if (initParams.ContainsKey("autoplay") && initParams["autoplay"] == "true")
                _autoplay = true;
            if (initParams.ContainsKey("debug") && initParams["debug"] == "true")
                _debug = true;
            if (initParams.ContainsKey("width"))
                Int32.TryParse(initParams["width"], out _width);
            if (initParams.ContainsKey("height"))
                Int32.TryParse(initParams["height"], out _height);

            // set stage and media sizes
            if (_width > 0)
                LayoutRoot.Width = media.Width = this.Width = _width;
            if (_height > 0)
                LayoutRoot.Height = media.Height = this.Height = _height;

            // debug
            textBox1.Visibility = (_debug) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
            textBox1.IsEnabled = false;
            textBox1.Text = "id: " + _htmlid + "\n" +
                            "file: " + _mediaUrl + "\n";

            media.AutoPlay = _autoplay;
            if (!String.IsNullOrEmpty(_mediaUrl)) {
                setSrc(_mediaUrl);
            }

            // full screen settings
            Application.Current.Host.Content.FullScreenChanged += new EventHandler(DisplaySizeInformation);
            Application.Current.Host.Content.Resized += new EventHandler(DisplaySizeInformation);
            FullscreenButton.Visibility = System.Windows.Visibility.Collapsed;

            // send out init call
            HtmlPage.Window.Invoke("html5_MediaPluginBridge_initPlugin", _htmlid);
        }
 public void MoveToMainMenu()
 {
     var timer = new System.Windows.Threading.DispatcherTimer();
     timer.Interval = new TimeSpan(0, 0, 3);
     timer.Tick += (delegate {
         NavigationService.Navigate(new Uri("/Screen/Menu.xaml", UriKind.RelativeOrAbsolute));
         timer.Stop();
     });
     timer.Start();
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="ThrottleTimer"/> class.
		/// </summary>
		/// <param name="milliseconds">Milliseconds to throttle.</param>
		/// <param name="handler">The delegate to invoke.</param>
		internal ThrottleTimer(int milliseconds, Action handler)
		{
			Action = handler;
			throttleTimer = new System.Windows.Threading.DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(milliseconds) };
			throttleTimer.Tick += (s, e) =>
			{
				if(Action!=null)
					Action.Invoke();
				throttleTimer.Stop();
			};
		}
        public static void setTimeOut(Action doWork, TimeSpan time)
        {

            System.Windows.Threading.DispatcherTimer myDispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            myDispatcherTimer.Interval = time;
            myDispatcherTimer.Tick += delegate(object s, EventArgs args)
            {
                myDispatcherTimer.Stop();
                doWork();
            };
            myDispatcherTimer.Start();
        }
 public MainPage()
 {
     InitializeComponent();
     this.listButton.ItemsSource = (App.config).Groups;
     System.Windows.Threading.DispatcherTimer tmr = new System.Windows.Threading.DispatcherTimer();
     tmr.Tick += (s, a) =>
     {
         this.CanHandleEvent = true;
         tmr.Stop();
     };
     tmr.Interval = TimeSpan.FromSeconds(0.5);
     tmr.Start();
 }
Beispiel #10
0
 private void AddProfileWindow_Loaded(object sender, RoutedEventArgs e)
 {
     System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
     this.Opacity = 0.00;
     dispatcherTimer.Tick += new EventHandler((sender1, e1) =>
     {
         if ((Opacity += 0.1) >= 1)
         {
             dispatcherTimer.Stop();
         }
     });
     dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 20);
     dispatcherTimer.Start();
 }
Beispiel #11
0
        public TaskTrayClass(Window target)
        {
            Text = "";
            notifyIcon.BalloonTipIcon = ToolTipIcon.Info;
            notifyIcon.Click += NotifyIcon_Click;
            notifyIcon.BalloonTipClicked += NotifyIcon_Click;
            // 接続先ウィンドウ
            targetWindow = target;
            LastViewState = targetWindow.WindowState;
            // ウィンドウに接続
            if (targetWindow != null) {
                targetWindow.Closing += new System.ComponentModel.CancelEventHandler(target_Closing);
            }
            notifyIcon.ContextMenuStrip = new ContextMenuStrip();

            // 指定タイムアウトでバルーンチップを強制的に閉じる
            var balloonTimer = new System.Windows.Threading.DispatcherTimer();
            balloonTimer.Tick += (sender, e) =>
            {
                if (notifyIcon.Visible)
                {
                    notifyIcon.Visible = false;
                    notifyIcon.Visible = true;
                }
                balloonTimer.Stop();
            };
            notifyIcon.BalloonTipShown += (sender, e) =>
            {
                if (Settings.Instance.ForceHideBalloonTipSec > 0)
                {
                    balloonTimer.Interval = TimeSpan.FromSeconds(Math.Max(Settings.Instance.ForceHideBalloonTipSec, 1));
                    balloonTimer.Start();
                }
            };
            notifyIcon.BalloonTipClicked += (sender, e) => balloonTimer.Stop();
            notifyIcon.BalloonTipClosed += (sender, e) => balloonTimer.Stop();
        }
Beispiel #12
0
        void Countdown(int count, TimeSpan interval, Action<int> ts)
        {
            var dt = new System.Windows.Threading.DispatcherTimer();
            dt.Interval = interval;
            dt.Tick += (_, a) =>
            {
                if (count-- == 0)
                    dt.Stop();
                else
                    ts(count);
            };
            ts(count);
            dt.Start();

        }
Beispiel #13
0
        public void Execute()
        {
            System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer()
            {
                Interval = TimeSpan.FromMilliseconds(10)
            };
            timer.Tick += (s, e) =>
            {
                timer.Stop();
                MainWindow.Current.Close();
            };
            timer.Start();

            return;
        }
Beispiel #14
0
 void close_timer_Tick(object sender, EventArgs e)
 {
     count_down--;
     if (count_down == 0)
     {
         close_button.IsEnabled = true;
         close_button.Content   = "Close";
         close_timer.Stop();
         var hWnd    = new WindowInteropHelper(this);
         var sysMenu = GetSystemMenu(hWnd.Handle, false);
         EnableMenuItem(sysMenu, SC_CLOSE, MF_BYCOMMAND | MF_ENABLED);
         return;
     }
     close_button.Content = "Close (" + count_down.ToString() + ")";
 }
Beispiel #15
0
 private void cmdRFIDTimer_Click(object sender, RoutedEventArgs e)
 {
     if (!checkRFID)
     {
         RFIDTimer.Start();
         cmdRFIDTimer.Content = "ยกเลิก (การตรวจสอบบัตร)";
         checkRFID            = true;
     }
     else
     {
         RFIDTimer.Stop();
         cmdRFIDTimer.Content = "เริ่ม (การตรวจสอบบัตร)";
         checkRFID            = false;
     }
 }
Beispiel #16
0
        private void LoadCamera(object sender, EventArgs e)
        {
            // Load Camera Test
            TimerVision.Stop();
            //if (TestCamera.Loaded())
            //{
            //    TestCamera.Load(8);
            //}
            // Load List Camera
            for (int i = 0; i < numberCameraSign; i++)
            {
                ListCameraVPro[i].Load(i);
            }

        }
Beispiel #17
0
 void client_CustomGuerdonRecordAccountCompleted(object sender, CustomGuerdonRecordAccountCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr(e.Error.Message));
     }
     else
     {
         if (e.Result == string.Empty)
         {
             Utility.ShowCustomMessage(MessageTypes.Message, Utility.GetResourceStr("SUCCESSED"), Utility.GetResourceStr("MODIFYSUCCESSED"));
         }
         //Utility.ShowCustomMessage(MessageTypes.Message, Utility.GetResourceStr("SUCCESSED"), Utility.GetResourceStr("UPDATESUCCESSED", "CUSTOMGUERDONRECORD"));
         else
         if (e.Result == "NODATA")
         {
             Utility.ShowCustomMessage(MessageTypes.Message, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("NODATA"));
         }
         else
         {
             Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("BUDGETERROR") + ": " + Utility.GetResourceStr(e.Result));
         }
     }
     timer.Stop();
     progressGenerate.Value = progressGenerate.Maximum;
     if (flag)
     {
         timer.Stop();
         progressGenerate.Value = progressGenerate.Minimum;
         EntityBrowser entBrowser = this.FindParentByType <EntityBrowser>();
         entBrowser.Close();
     }
     isSaving = false;
     RefreshUI(RefreshedTypes.ToolBar);
     RefreshUI(RefreshedTypes.ProgressBar);
 }
Beispiel #18
0
 void dt_Tick(object sender, EventArgs e)
 {
     try
     {
         string sprofile = "<provision key='5B29C449-29EE-4fd8-9E3F-04AED077690E' name=\"Asterisk\"> \n <user account='" + SIPCredentials.SIPNumber + "' password='******' uri='SIP:" + SIPCredentials.SIPNumber + "@" + SIPCredentials.SIPServer + "' /> <sipsrv addr='" + SIPCredentials.SIPServer + "' protocol='udp' auth='digest' role='registrar'> <session party='first' type='pc2ph' /> </sipsrv> </provision>\n\r";
         this.profile = ((IRTCProfile2)(this.oclient.CreateProfile(sprofile)));
         //System.Windows.MessageBox.Show(this.profile.UserURI);
         this.oclient.EnableProfile(this.oclient.CreateProfile(sprofile), 15);
         dt.Stop();
     }
     catch (Exception ex)
     {
         VMuktiHelper.ExceptionHandler(ex, "dt_Tick()", "VMuktiAudio.VistaService\\RTCAudio.cs");
     }
 }
        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            if (pgbar.Value == 100)
            {
                timer.Stop();
                main = new Main(this, h);
                main.Show();
                this.Hide();
            }

            else
            {
                pgbar.Value += 5;
            }
        }
Beispiel #20
0
        private void initialiseGameData()
        {
            gameRenderer   = new WpfCanvasRenderer(400, 400, imgBoardImage);
            gameController = new GameController(updateView, displayWinningMessage);
            updateView();

            //if a timer already exists, stop it and create a new one with the new context

            dispatcherTimer?.Stop();
            dispatcherTimer = new System.Windows.Threading.DispatcherTimer();

            dispatcherTimer.Tick    += dispatcherTimer_Tick;
            dispatcherTimer.Interval = new TimeSpan(0, 0, 2);
            dispatcherTimer.Start();
        }
Beispiel #21
0
 private void E_CircleFrame_IsMouseDirectlyOverChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (E_CircleFrame.IsMouseOver)
     {
         ActionsRM.Pause_ImageEllipseLabel(_T: out _Timer, _CI: _ChangeImage);
     }
     else
     {
         if (_Timer != null)
         {
             _CIEllipse.Visibility = Visibility.Hidden;
             _Timer.Stop();
         }
     }
 }
Beispiel #22
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     if (this.ViewModel.IsAutoClose)
     {
         System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer()
         {
             Interval = TimeSpan.FromMilliseconds(this.ViewModel.AutoCloseTime),
         };
         timer.Tick += (ss, ee) => {
             timer.Stop();
             this.Close();
         };
         timer.Start();
     }
 }
 private void autoRefresh_Click(object sender, RoutedEventArgs e)
 {
     if (autoRefresh.IsChecked)
     {
         refresh.IsEnabled = false;
         //canRunTask = true;
         timer.Start();
     }
     else
     {
         refresh.IsEnabled = true;
         //canRunTask = false;
         timer.Stop();
     }
 }
Beispiel #24
0
        private void Upt_Tick(object sender, EventArgs e)
        {
            if (td.IsCompleted)
            {
                INode m            = td.Result;
                Uri   downloadLink = client.GetDownloadLink(m);
                Clipboard.SetText(downloadLink.ToString());
                Console.WriteLine(downloadLink.ToString());
                System.Diagnostics.Process.Start(downloadLink.ToString());
                MessageBox.Show("Upload Complete!\n" + downloadLink.ToString() + "\nCopied to Clipboard!", "Finished!", MessageBoxButton.OK, MessageBoxImage.Information);

                client.Logout();
                Upt.Stop();
            }
        }
 private void BtnPause_Click(object sender, RoutedEventArgs e)
 {
     if (paused)
     {
         gameTimer.Start();
         btnPause.Content = "||";
         paused           = false;
     }
     else
     {
         gameTimer.Stop();
         btnPause.Content = ">";
         paused           = true;
     }
 }
Beispiel #26
0
 private void timerTick(object sender, EventArgs e)
 {
     if (_time > 0)
     {
         if (_time < 11)
         {
             TimerBlock.Foreground = new SolidColorBrush(Colors.Red);
         }
         _time--;
         TimerBlock.Text = string.Format($"00:{_time}");
         if (_time == 59)
         {
             TimerStop.Visibility = Visibility.Visible;
         }
     }
     else
     {
         ShowAnswerButton.IsEnabled = true;
         timer.Stop();
         //SystemSounds.Beep.Play();
         media.Play();
         TimerStartButton.IsEnabled = false;
     }
 }
Beispiel #27
0
 /// <summary>
 /// 定时生成黑方块
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnTimedEvent(object sender, EventArgs e)
 {
     if (rectangleNum < 3)
     {
         //Rect rect = SystemParameters.WorkArea;//获取工作区大小
         Random    random = new Random();
         Rectangle rtg    = new Rectangle();
         rtg.Fill    = new SolidColorBrush(Colors.Black);
         rtg.Width   = 50;
         rtg.Height  = 50;
         rtg.RadiusX = 5;
         rtg.RadiusY = 5;
         Carrier.Children.Add(rtg);
         Canvas.SetLeft(rtg, NextDouble(random, 0, Carrier.Width - rtg.Width));
         Canvas.SetTop(rtg, NextDouble(random, 0, Carrier.Height - rtg.Height));
         //Canvas.SetLeft(rtg,NextDouble(random,0,0));
         //Canvas.SetTop(rtg,NextDouble(random,0,0));
         rectangleNum++;
     }
     else
     {
         if (MessageBox.Show("你的得分是:" + scoreEF.Score.ToString() + ",你输啦,是否退出游戏?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Asterisk) == MessageBoxResult.Yes)
         {
             Application.Current.Shutdown();
         }
         else
         {
             MessageBox.Show("按R可以重新开始游戏哦!");
             if (timer != null)
             {
                 timer.Stop();
                 timer = null;
             }
         }
     }
 }
Beispiel #28
0
        private void Reset()
        {
            dispatcherTimer.Stop();
            fields          = new Rectangle[size, size];
            EpochBlock.Text = 0.ToString();
            MaxBlock.Text   = 0.ToString();
            MeanBlock.Text  = 0.ToString();
            fields          = new Rectangle[size, size];
            r           = new Random();
            it          = 0;
            maxEpochs   = 100;
            actualEpoch = 0;
            wyniki      = new List <string>();
            Draw        = false;
            Board.RowDefinitions.Clear();
            Board.ColumnDefinitions.Clear();
            Board.Children.Clear();

            InitializeBoard();
            InitializePopulation();
            InitializeTimer();
            p.size     = int.Parse(PopBOX.Text);
            firstBrain = true;
        }
        private void DispatcherTimer_Tick(object sender, EventArgs e)
        {
            textblockmensagem.Text = Variaveis.modomensagem;
            if (Variaveis.Camerafechada == true)
            {
                if (Variaveis.modomensagemaberto == true)
                {
                    Thread.Sleep(5000);
                    return;
                }
                else
                {
                    dispatcherTimer.Stop();
                    dispatcherTimer.Tick -= DispatcherTimer_Tick;

                    gifplayer.Stop();
                    this.Close();
                }
            }
            if (Variaveis.Camerafechada == false)
            {
                if (Variaveis.modomensagemaberto == true)
                {
                    Thread.Sleep(5000);
                    return;
                }
                else
                {
                    dispatcherTimer.Stop();
                    dispatcherTimer.Tick -= DispatcherTimer_Tick;

                    gifplayer.Stop();
                    this.Close();
                }
            }
        }
Beispiel #30
0
        private void StartHideTimer()
        {
            var timer = new System.Windows.Threading.DispatcherTimer();

            timer.Interval = TimeSpan.FromSeconds(0.2);
            timer.Tick    += ((sender, e) =>
            {
                if (!Keyboard.IsKeyDown(Key.LeftCtrl))
                {
                    MinimizeToTray();
                    timer.Stop();
                }
            });
            timer.Start();
        }
    private void timer1_Tick(object sender, EventArgs e)
    {
        //Remove the previous ellipse from the paint canvas.
        PaintCanvas.Children.Remove(ellipse);
        if (--loopCounter == 0)
        {
            timer.Stop();
        }

        //Add the ellipse to the canvas
        ellipse = CreateAnEllipse(20, 20);
        PaintCanvas.Children.Add(ellipse);
        Canvas.SetLeft(ellipse, rand.Next(0, 310));
        Canvas.SetTop(ellipse, rand.Next(0, 500));
    }
Beispiel #32
0
        void tooltiptimer_Tick(object sender, EventArgs e)
        {
            //测试拾取
            WpfEarthLibrary.PowerBasicObject obj = uc.objManager.pick(mouseposition);  // 拾取方法,返回拾取到的对象
            if (obj != null && (obj is pData || obj is pPowerLine || obj is pSymbolObject))
            {
                string txt = "";
                if (obj is pData)
                {
                    txt = "拾取" + (obj as pData).id + "\r\n" + (obj as pData).dataLabel;
                }
                else if (obj is pPowerLine)
                {
                    txt = (obj as pPowerLine).name;
                }
                else if (obj is pSymbolObject)
                {
                    txt = string.Format("{0}:{1},{2},{3}", obj.name, obj.VecLocation.x, obj.VecLocation.y, obj.VecLocation.z);
                }

                txtToolTips.Text = txt;


                double ToolTipOffset = 5;
                Tooltip.Placement        = System.Windows.Controls.Primitives.PlacementMode.RelativePoint;
                Tooltip.PlacementTarget  = uc;
                Tooltip.HorizontalOffset = mouseposition.X + ToolTipOffset + 5;
                Tooltip.VerticalOffset   = mouseposition.Y + ToolTipOffset;
                Tooltip.IsOpen           = true;
            }
            else
            {
                Tooltip.IsOpen = false;
            }
            tooltiptimer.Stop();
        }
Beispiel #33
0
        public static DTimer StartTimer(int ms, int steps, Func <int, bool> callback)
        {
            var timer = new DTimer {
                Interval = TimeSpan.FromMilliseconds(ms)
            };
            var step = 0;

            timer.Tick += (s, e) => {
                if (!callback.Invoke(step))
                {
                    timer.Stop();
                    return;
                }

                if (++step == steps)
                {
                    timer.Stop();
                    return;
                }
            };
            timer.Start();

            return(timer);
        }
Beispiel #34
0
        private void ResetTimer()
        {
            if (dispatcherTimer == null)
            {
                dispatcherTimer       = new System.Windows.Threading.DispatcherTimer();
                dispatcherTimer.Tick += new EventHandler(DispatcherTimer_Tick);
            }
            else
            {
                dispatcherTimer.Stop();
            }

            dispatcherTimer.Interval = new TimeSpan(0, int.Parse(Properties.Settings.Default.rotateInterval), 0);
            dispatcherTimer.Start();
        }
        public void Stop()
        {
            if (_dispatcherTimer != null)
            {
                _dispatcherTimer.Stop();
                _dispatcherTimer.Tick -= DispatcherTimer_Tick;
                _dispatcherTimer       = null;
            }

            // unlock the timer duration
            if (_timerDuration != null)
            {
                _timerDuration.Readonly = false;
            }
        }
        public ConnectWindow()
        {
            InitializeComponent();

            _udpDiscoveryClient = new UdpDiscoveryClient(
                ready => { },
                (name, address) => Dispatcher.Invoke((Action)(() =>
            {
                if (address.Contains(":?/"))     // Android emulator, so use forwarded ports
                {
                    // todo: use telnet to discover already set up port forwards, instead of hardcoding
                    address = address.Replace(":?/", String.Format(":{0}/", HttpForwardedHostPort));
                }
                var deviceItem = new MainWindow.DeviceItem
                {
                    DeviceAddress = address,
                    DeviceName = name,
                    DeviceType =
                        name.StartsWith("ProtoPad Service on ANDROID Device ")
                                ? MainWindow.DeviceTypes.Android
                                : MainWindow.DeviceTypes.iOS
                };
                if (!DevicesList.Items.Cast <object>().Any(i => (i as MainWindow.DeviceItem).DeviceAddress == deviceItem.DeviceAddress))
                {
                    DevicesList.Items.Add(deviceItem);
                }
                DevicesList.IsEnabled = true;
                //LogToResultsWindow("Found '{0}' on {1}", name, address);
            })));

            _dispatcherTimer       = new System.Windows.Threading.DispatcherTimer();
            _dispatcherTimer.Tick += (s, a) =>
            {
                if (_ticksPassed > 2)
                {
                    _dispatcherTimer.Stop();
                    if (DevicesList.Items.Count == 1)
                    {
                        DevicesList.SelectedIndex = 0;
                    }
                }
                _udpDiscoveryClient.SendServerPing();
                _ticksPassed++;
            };
            _dispatcherTimer.Interval = TimeSpan.FromMilliseconds(200);

            FindApps();
        }
Beispiel #37
0
        private void runBT_Click(object sender, RoutedEventArgs e)
        {
            if (on)
            {
                try
                {
                    String[] arr = timeTBox.Text.Split(':');
                    hour            = Convert.ToInt32(arr[0]);
                    min             = Convert.ToInt32(arr[1]);
                    sec             = Convert.ToInt32(arr[2]);
                    timeTBlock.Text = new TimeSpan(hour, min, sec).ToString();
                }
                catch (Exception)
                {
                    MessageBox.Show("Enter Time!");
                    return;
                }

                timer.Tick    += new EventHandler(tick);
                timer.Interval = new TimeSpan(0, 0, 0, 1);
                timer.Start();
                on = false;
                foreach (Railway rl in subway.GetRailways)
                {
                    foreach (Station st in rl.GetStations)
                    {
                        st.Board.Start(hour, min, sec);
                    }
                }
            }
            else
            {
                timer.Stop();
                on = true;
                foreach (Railway rl in subway.GetRailways)
                {
                    foreach (Train t in rl.Trains)
                    {
                        t.Stop(fieldCanvas, subway);
                    }
                    foreach (Station st in rl.GetStations)
                    {
                        st.Board.Stop();
                    }
                }
                timer.Tick -= new EventHandler(tick);
            }
        }
        private void OSM_AddressChanged(object sender, UrlEventArgs e)
        {
            System.Windows.Threading.DispatcherTimer dispatcher = new System.Windows.Threading.DispatcherTimer();
            dispatcher.Tick += new EventHandler(KeepFocus);
            dispatcher.Interval = new TimeSpan(0, 0, 1);

            if (OSM.Source.ToString().Contains("?movieid=" + App.Args["/movieid"] + "&amp;trkid=" + App.Args["/trackid"]))
            {
                dispatcher.Start();
                OSM.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                dispatcher.Stop();
            }
        }
        private void btnPause_Click(object sender, RoutedEventArgs e)
        {
            //timeline.MediaPlayer.Pause();
            //p.projection.MediaPlayer.Pause();
            PauseTimelineAndProjection();

            //meTest.Pause();
            //long time = p.projection.MediaPlayer.VlcMediaPlayer.Time;
            //p.projection.MediaPlayer.VlcMediaPlayer.Time = time;
            //timeline.MediaPlayer.VlcMediaPlayer.Time = p.projection.MediaPlayer.VlcMediaPlayer.Time;
            //Console.WriteLine(timeline.MediaPlayer.VlcMediaPlayer.Time+" "+ p.projection.MediaPlayer.VlcMediaPlayer.Time);
            dt.Stop();
            lastPlayerState = PlayerState.Paused;
        }
Beispiel #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ThrottleTimer"/> class.
 /// </summary>
 /// <param name="milliseconds">Milliseconds to throttle.</param>
 /// <param name="handler">The delegate to invoke.</param>
 internal ThrottleTimer(int milliseconds, Action handler)
 {
     Action        = handler;
     throttleTimer = new System.Windows.Threading.DispatcherTimer()
     {
         Interval = TimeSpan.FromMilliseconds(milliseconds)
     };
     throttleTimer.Tick += (s, e) =>
     {
         if (Action != null)
         {
             Action.Invoke();
         }
         throttleTimer.Stop();
     };
 }
Beispiel #41
0
        private void _timer_Tick(object sender, EventArgs e)
        {
            if (pos >= 1f)
            {
                _timer.Stop();
            }

            pos += delta;
            Point p;
            Point t;

            path1.GetPointAtFractionLength(pos, out p, out t);

            circ.SetValue(EllipseGeometry.CenterProperty, p);
            //circ.InvalidateProperty(EllipseGeometry.CenterProperty);
        }
Beispiel #42
0
 void dt_Tick(object sender, EventArgs e)
 {
     try
     {
         string sprofile = "<provision key='5B29C449-29EE-4fd8-9E3F-04AED077690E' name=\"Asterisk\"> \n <user account='" + SIPCredentials.SIPNumber + "' password='******' uri='SIP:" + SIPCredentials.SIPNumber + "@" + SIPCredentials.SIPServer + "' /> <sipsrv addr='" + SIPCredentials.SIPServer + "' protocol='udp' auth='digest' role='registrar'> <session party='first' type='pc2ph' /> </sipsrv> </provision>\n\r";
         this.profile = ((IRTCProfile2)(this.oclient.CreateProfile(sprofile)));
         this.oclient.EnableProfile(this.oclient.CreateProfile(sprofile), 15);
         dt.Stop();
     }
     catch (Exception ex)
     {
         ex.Data.Add("My Key", "VMukti--:--VmuktiModules--:--VmuktiModules--:--Call Center--:--AutoProgressiveSoftPhone--:--AutoProgressivePhone.Business--:--RTCAudio.cs--:--OnIRTCSessionStateChangeEvent()--");
         ClsException.LogError(ex);
         ClsException.WriteToErrorLogFile(ex);
     }
 }
Beispiel #43
0
 public void myTimerTicked(Object sender, EventArgs e)
 {
     countTime--;
     if (countTime == 0)
     {
         myTimer.Stop();
         countTime = UserTimeSet(countTime);
         for (int j = 0; j < 6; j++)
         {
             for (int i = 0; i < 6; i++)
             {
                 imageArray[i + 6 * j].Visibility = Visibility.Hidden;
             }
         }
     }
 }
Beispiel #44
0
        public ConnectWindow()
        {
            InitializeComponent();

            _udpDiscoveryClient = new UdpDiscoveryClient(
                ready => { },
                (name, address) => Dispatcher.Invoke((Action)(() =>
                {
                    if (address.Contains(":?/")) // Android emulator, so use forwarded ports
                    {
                        // todo: use telnet to discover already set up port forwards, instead of hardcoding
                        address = address.Replace(":?/", String.Format(":{0}/", HttpForwardedHostPort));
                    }
                    var deviceItem = new MainWindow.DeviceItem
                    {
                        DeviceAddress = address,
                        DeviceName = name,
                        DeviceType =
                            name.StartsWith("ProtoPad Service on ANDROID Device ")
                                ? MainWindow.DeviceTypes.Android
                                : MainWindow.DeviceTypes.iOS
                    };
                    if (!DevicesList.Items.Cast<object>().Any(i => (i as MainWindow.DeviceItem).DeviceAddress == deviceItem.DeviceAddress))
                    {
                        DevicesList.Items.Add(deviceItem);
                    }
                    DevicesList.IsEnabled = true;
                    //LogToResultsWindow("Found '{0}' on {1}", name, address);
                })));

            _dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            _dispatcherTimer.Tick += (s, a) =>
            {
                if (_ticksPassed > 2)
                {
                    _dispatcherTimer.Stop();
                    if (DevicesList.Items.Count == 1) DevicesList.SelectedIndex = 0;
                }
                _udpDiscoveryClient.SendServerPing();
                _ticksPassed++;
            };
            _dispatcherTimer.Interval = TimeSpan.FromMilliseconds(200);

            FindApps();
        }
Beispiel #45
0
        public MainWindow()
        {
            InitializeComponent();

            _currentDevice = new DeviceItem
                {
                    DeviceAddress = "http://192.168.1.104:8080/",
                    DeviceName = "Yarvik",
                    DeviceType = DeviceTypes.Android
                };
            // NOTE: Make sure that you've read through the add-on language's 'Getting Started' topic
            //   since it tells you how to set up an ambient parse request dispatcher and an ambient
            //   code repository within your application OnStartup code, and add related cleanup in your
            //   application OnExit code.  These steps are essential to having the add-on perform well.

            // Initialize the project assembly (enables support for automated IntelliPrompt features)
            _projectAssembly = new CSharpProjectAssembly("SampleBrowser");
            var assemblyLoader = new BackgroundWorker();
            assemblyLoader.DoWork += DotNetProjectAssemblyReferenceLoader;
            assemblyLoader.RunWorkerAsync();

            // Load the .NET Languages Add-on C# language and register the project assembly on it
            var language = new CSharpSyntaxLanguage();
            language.RegisterProjectAssembly(_projectAssembly);

            CodeEditor.Document.Language = language;

            CodeEditor.Document.Language.RegisterService(new IndicatorQuickInfoProvider());

            CodeEditor.PreviewKeyDown += (sender, args) =>
                {
                    if (args.Key != Key.Enter || (Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.Control) return;
                    SendCodeButton_Click(null,null);
                    args.Handled = true;
                };

            _udpDiscoveryClient = new UdpDiscoveryClient(
            //                ready => Dispatcher.Invoke((Action) (() => SendCodeButton.IsEnabled = ready)),
                ready => { },
                (name, address) => Dispatcher.Invoke(() =>
                    {
                        if (address.Contains("?")) address = address.Replace("?", AndroidPort);
                        var deviceItem = new DeviceItem
                            {
                                DeviceAddress = address,
                                DeviceName = name,
                                DeviceType = name.StartsWith("ProtoPad Service on ANDROID Device ") ? DeviceTypes.Android : DeviceTypes.iOS
                            };
                        if (!DevicesComboBox.Items.Cast<object>().Any(i => (i as DeviceItem).DeviceAddress == deviceItem.DeviceAddress))
                        {
                            DevicesComboBox.Items.Add(deviceItem);
                        }
                        DevicesComboBox.IsEnabled = true;
                        //ResultTextBox.Text += String.Format("Found '{0}' on {1}", name, address);
                    }));
            ResultTextBox.Navigated += (sender, args) =>
                {
                    var htmlDocument = ResultTextBox.Document as HTMLDocument;
                    _htmlHolder = htmlDocument.getElementById("wrapallthethings") as HTMLDivElementClass;
                    _htmlWindow = htmlDocument.parentWindow;
                    _udpDiscoveryClient.SendServerPing();
                    var ticksPassed = 0;
                    var dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
                    dispatcherTimer.Tick += (s, a) =>
                        {
                            if (ticksPassed > 2)
                            {
                                dispatcherTimer.Stop();
                                if (DevicesComboBox.Items.Count == 1)
                                {
                                    DevicesComboBox.SelectedIndex = 0;
                                }
                            }
                            _udpDiscoveryClient.SendServerPing();
                            ticksPassed++;
                        };
                    dispatcherTimer.Interval = TimeSpan.FromMilliseconds(200);
                    dispatcherTimer.Start();
                };
            ResultTextBox.NavigateToString(Properties.Resources.ResultHtmlWrap);
        }
 void updateMyBg()
 {
     try
     {
         using (var store = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication())
         {
             using (var str = store.OpenFile("bing.jpg", FileMode.Open))
             {
                 System.Windows.Media.Imaging.WriteableBitmap wb = new System.Windows.Media.Imaging.WriteableBitmap(480, 800);
                 BitmapImage bimg = new BitmapImage();
                 bimg.SetSource(str);
                 image1.Source = bimg;
             }
         }
     }
     catch
     {
         System.Windows.Threading.DispatcherTimer tim = new System.Windows.Threading.DispatcherTimer();
         tim.Interval = TimeSpan.FromSeconds(2);
         tim.Tick += new EventHandler((o, e) =>
         {
             updateMyBg();
             tim.Stop();
         });
         tim.Start();
     }
 }
        private void MakeProcess()
        {
            FAExtendECPart.ECResult ecResult = new FAExtendECPart.ECResult();

            var seq = Process;

            #region RegisterEventHandler
            seq.OnStart +=
                delegate
                {
                    RetryInfoGateChangeRetry.ClearCount();
                };
            #endregion

            #region AddSteps
            seq.Steps.Add("IncreaseGateNo", new StepInfo());
            seq.Steps.Add("RetryRequestLotClose", new StepInfo());
            seq.Steps.Add("RequestMasterInfo", new StepInfo());
            seq.Steps.Add("RequestLotClose", new StepInfo());
            seq.Steps.Add("SelectUnloadingDirection", new StepInfo());
            #endregion

            seq.AddItem(Aligner.Extend.Sequence);
            #region CheckTrayEdge
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (UseTrayIndexCheck && RFReaderUnit.EdgeSensor.IsOn)
                    {
                        string windowName = string.Empty;
                        var alarm = Utility.AlarmUtility.GetAlarm(AlarmTrayIndexDirectionFailDetected, "[RF READER MODULE] Tray Index Direction Fail.");
                        Manager.MessageWindowManager.Instance.Show(Equipment,
                            "TrayIndexDirectionFail",
                            out windowName,
                            alarm,
                            string.Empty,
                            true);

                        NextModule = FailureWayModule;
                        WriteTraceLog("Unloading to Fail C/V. Edge Sensor Detected.");
                        actor.NextStep("SelectUnloadingDirection");
                    }
                    else
                    {
                        actor.NextStep();
                    }
                });
            #endregion
            #region ConfirmManualLotIDInput
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (Equipment.RunMode == FAFramework.Equipment.RunModeTypes.DRY_RUN)
                    {
                        ProductInfo.VT8792ProductInfo.TrayCount = LotTrayCount;
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_ID = "TEST_LOT";
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_MARKING = "TEST";
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.PART_ID = "TEST";
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_X = 2;
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_Y = 3;
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.S_BOX_MOQ = LotSmallBoxMOQ;
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.L_BOX_MOQ = LotSmallBoxMOQ;
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_QTY = LotSmallBoxMOQ;
                        WriteTraceLog("Track In " + ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_ID);
                        actor.NextStep();
                    }
                    else if (Equipment.RunMode == FAFramework.Equipment.RunModeTypes.COLD_RUN)
                    {
                        ProductInfo.VT8792ProductInfo.TrayCount = LotTrayCount;
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_ID = "TEST_LOT";
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_MARKING = "TEST";
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.PART_ID = "TEST";
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_X = 2;
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_Y = 3;
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.S_BOX_MOQ = LotSmallBoxMOQ;
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.L_BOX_MOQ = LotSmallBoxMOQ;
                        ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_QTY = LotSmallBoxMOQ;
                        actor.NextStep();
                    }
                    else
                    {
                        if (UseManualLotIDInput)
                        {
                            if (LotIDList.Count > 0)
                            {
                                try
                                {
                                    ReadingLotID = LotIDList.First();
                                    string lotID = ReadingLotID;

                                    WriteTraceLog(string.Format("Read Lot ID. {0}", ReadingLotID));

                                    System.Windows.Threading.DispatcherTimer timer =
                                        new System.Windows.Threading.DispatcherTimer(System.Windows.Threading.DispatcherPriority.Normal, App.Current.Dispatcher);

                                    timer.Interval = new TimeSpan(0, 0, 0, 0, 50);
                                    timer.Tick +=
                                        delegate
                                        {
                                            try
                                            {
                                                LotIDList.Remove(lotID);
                                                timer.Stop();
                                            }
                                            catch
                                            {
                                            }
                                        };
                                    timer.Start();

                                    actor.NextStep();
                                }
                                catch
                                {
                                    actor.NextStep();
                                }
                            }
                        }
                        else
                            actor.NextStep();
                    }
                });
            #endregion
            #region IncreaseGateNo
            seq.Steps["IncreaseGateNo"].StepIndex = seq.AddItem(
                delegate(object obj)
                {
                    if (CurrentGate == GATE_NO_ZERO)
                    {
                        CurrentGate = GATE_NO_MIN;
                    }
                    else
                    {
                        CurrentGate++;
                        if (CurrentGate > GATE_NO_MAX)
                            CurrentGate = GATE_NO_MIN;
                    }
                });
            #endregion
            seq.AddItem(new FASequenceAtomicInfo(ScanAndTrayCounting, true));
            #region ConfirmReadSuccessRFID
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (Equipment.RunMode == FAFramework.Equipment.RunModeTypes.HOT_RUN)
                    {
                        if (RFIDScanSuccess)
                            actor.NextStep();
                        else
                        {
                            string windowName = string.Empty;
                            var alarm = Utility.AlarmUtility.GetAlarm(AlarmRFIDScanFail, "[RF READER MODULE] RFID Scan Fail.");
                            Manager.MessageWindowManager.Instance.Show(Equipment,
                                "RFIDScanFail",
                                out windowName,
                                alarm,
                                string.Empty,
                                true);
                            NextModule = FailureWayModule;
                            actor.NextStep("SelectUnloadingDirection");
                        }
                    }
                    else
                    {
                        actor.NextStep("SelectUnloadingDirection");
                    }
                });
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    string msg = string.Empty;
                    if (ConstainLot(ReadingLotID, out msg) == true)
                        actor.NextStep();
                    else
                    {
                        string windowName = string.Empty;
                        var alarm = Utility.AlarmUtility.GetAlarm(AlarmDuplicateLotID, "[RF READER MODULE] Duplicate LotID.");
                        Manager.MessageWindowManager.Instance.Show(Equipment,
                            "RFReaderDuplicateLotID",
                            out windowName,
                            alarm,
                            string.Format("LOT_ID={0}", ReadingLotID),
                            true);
                        NextModule = FailureWayModule;
                        actor.NextStep("SelectUnloadingDirection");
                    }
                });
            #endregion
            #region RequestMasterInfo
            seq.Steps["RequestMasterInfo"].StepIndex = seq.AddItem(
                delegate(object obj)
                {
                    FAECInfo.PACKING_MASTER_INFO_REQ command = new FAECInfo.PACKING_MASTER_INFO_REQ();
                    command.LOT_ID = ReadingLotID;
                    ecResult.Clear();
                    InterfaceUnit.ECPart.AddCommand(command, ecResult);
                });
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (ecResult.ReceiveOk)
                    {
                        if (ecResult.ParsingSuccess)
                        {
                            if (ecResult.ECInfo.PACKING_MASTER_INFO.RESULT == FAECInfo.FAECResult.PASS)
                            {
                                ProductInfo.SerialBarcodeInfo.SetBarcodeInfo(ProductInfo.ECInfo.LOT_CLOSE.SERIAL);
                                ProductInfo.PPIDBarcodeInfo.SetBarcodeInfo(ProductInfo.ECInfo.LOT_CLOSE.PPID);
                                ProductInfo.WWNBarcodeInfo.SetBarcodeInfo(ProductInfo.ECInfo.LOT_CLOSE.WWN);
                                ProductInfo.CSerialBarcodeInfo.SetBarcodeInfo(ProductInfo.ECInfo.LOT_CLOSE.C_SERIAL);
                                ProductInfo.PSIDBarcodeInfo.SetBarcodeInfo(ProductInfo.ECInfo.LOT_CLOSE.PSID);

                                WriteTraceLog("PACKING MASTER INFO RECEIVE OK");
                                ecResult.ECInfo.PACKING_MASTER_INFO.CopyTo(ProductInfo.ECInfo.PACKING_MASTER_INFO);
                                actor.NextStep();
                            }
                            else
                            {
                                string windowName = string.Empty;
                                var alarm = Utility.AlarmUtility.GetAlarm(ecResult.LastAlarmNo, "[RF READER MODULE] PACKING MASTER INFO EC RESULT FAIL.");
                                Manager.MessageWindowManager.Instance.Show(Equipment,
                                    "RFReaderECCommFail",
                                    out windowName,
                                    alarm,
                                    string.Empty,
                                    true);
                                NextModule = FailureWayModule;
                                actor.NextStep("SelectUnloadingDirection");
                            }
                        }
                        else
                        {
                            string windowName = string.Empty;
                            var alarm = Utility.AlarmUtility.GetAlarm(ecResult.LastAlarmNo, "[RF READER MODULE] EC PACKING MASTER INFO RECEIVE DATA PARSING FAIL.");
                            Manager.MessageWindowManager.Instance.Show(Equipment,
                                    "RFReaderECCommFail",
                                    out windowName,
                                    alarm,
                                    string.Empty,
                                    true);
                            NextModule = FailureWayModule;
                            actor.NextStep("SelectUnloadingDirection");
                        }
                    }
                    else if (ecResult.LastAlarmNo != 0)
                    {
                        string windowName = string.Empty;
                        var alarm = Utility.AlarmUtility.GetAlarm(ecResult.LastAlarmNo, "[RF READER MODULE] EC PACKING MASTER INFO RECEIVE FAIL.");
                        Manager.MessageWindowManager.Instance.Show(Equipment,
                                    "RFReaderECCommFail",
                                    out windowName,
                                    alarm,
                                    string.Empty,
                                    true);
                        NextModule = FailureWayModule;
                        actor.NextStep("SelectUnloadingDirection");
                    }
                });
            #endregion
            #region ConfirmStepCorrection
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    var step = ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_STEP;
                    bool result = false;
                    string windowName = string.Empty;
                    string msg = string.Empty;

                    if (string.IsNullOrEmpty(step) == true)
                        msg = string.Format("LOT_ID={0}, Step is Empty", ReadingLotID);
                    else if (step == ValidStep1 ||
                        step == ValidStep2 ||
                        step == ValidStep3)
                        result = true;
                    else
                        msg = string.Format("LOT_ID={0}, Invalid Step. {1}", ReadingLotID, step);

                    if (result == true)
                    {
                        actor.NextStep();
                    }
                    else
                    {
                        var alarm = Utility.AlarmUtility.GetAlarm(AlarmInvalidStep, msg);
                        Manager.MessageWindowManager.Instance.Show(Equipment,
                                    "InvalidStep",
                                    out windowName,
                                    alarm,
                                    msg,
                                    true);
                        NextModule = FailureWayModule;
                        actor.NextStep("SelectUnloadingDirection");
                    }
                });
            #endregion
            seq.AddItem(LoadJob);
            #region SendRecipeFileToGEM
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    var VT8792Equipment = Equipment as VT8792.SubEquipment;
                    if (VT8792Equipment.GlobalConfigModule.UseGEMCommunication == false)
                    {
                        actor.NextStep();
                        return;
                    }

                    bool raisedException = false;
                    try
                    {
                        string recipeName = ProductInfo.ECInfo.PACKING_MASTER_INFO.PRODUCT_NAME;
                        string recipeFileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), recipeName);
                        string recipe = string.Empty;
                        LotJobInfo.ToINIFormat(out recipe);
                        System.IO.File.WriteAllText(recipeFileName, recipe);
                        GEM.GEMFuncWrapper.SendRecipeFile(recipeName, recipeFileName);
                        raisedException = false;
                    }
                    catch
                    {
                        raisedException = true;
                    }
                    finally
                    {
                        if (raisedException == false)
                            actor.NextStep();
                    }
                });
            #endregion
            #region ConfirmTrayCountCorrection
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (Equipment.RunMode == FAFramework.Equipment.RunModeTypes.HOT_RUN)
                    {
                        if (UseTrayCodeOfAJob)
                            ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_MARKING = JobInfo.TrayCode;

                        var ecTrayCount = ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_QTY /
                            (ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_X * ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_Y);
                        var ssdCountInTray = ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_X * ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_Y;
                        var lotQty = ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_QTY;
                        ecTrayCount = lotQty / ssdCountInTray;

                        if (lotQty % ssdCountInTray > 0)
                            ecTrayCount += 1;

                        ProductInfo.VT8792ProductInfo.TrayCount = ecTrayCount;
                        ProductInfo.VT8792ProductInfo.RemainSSDCount = lotQty % ssdCountInTray;

                        if (ProductInfo.ECInfo.PACKING_MASTER_INFO.S_BOX_MOQ < ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_QTY)
                        {
                            NextModule = FailureWayModule;

                            string msg = string.Format("EC Data Invalid. LOT_QTY is better than S_BOX_MOQ. LOT_QTY={0}, S_BOX_MOQ={1}",
                                ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_QTY,
                                ProductInfo.ECInfo.PACKING_MASTER_INFO.S_BOX_MOQ);

                            Manager.MessageWindowManager.Instance.Show(Equipment, "TrayCountNotCorrect", msg);
                            actor.NextStep("SelectUnloadingDirection");
                        }
                        else if (ecTrayCount > TRAY_NO_MAX)
                        {
                            NextModule = FailureWayModule;

                            string msg = string.Format("EC Tray Count is better than {0}. LOT_QTY={1}, ARRAY_X={2}, ARRAY_Y={3}",
                                TRAY_NO_MAX,
                                ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_QTY,
                                ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_X,
                                ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_Y);

                            Manager.MessageWindowManager.Instance.Show(Equipment, "TrayCountNotCorrect", msg);
                            actor.NextStep("SelectUnloadingDirection");
                        }
                        else if (ecTrayCount != TrayCount - 1 && UseTrayCountCheck)
                        {
                            NextModule = FailureWayModule;

                            string msg = string.Format("Tray Count Not Correct.\n[DETECTED TRAY COUNT]={0}\n[EC INFO] TRAY_COUNT={1}, LOT_QTY={2}, ARRAY_X={3}, ARRAY_Y={4}",
                            TrayCount - 1,
                            ecTrayCount,
                            ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_QTY,
                            ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_X,
                            ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_Y);

                            Manager.MessageWindowManager.Instance.Show(Equipment, "TrayCountNotCorrect", msg);
                            actor.NextStep("SelectUnloadingDirection");
                        }
                        else
                            actor.NextStep("RequestLotClose");
                    }
                });
            #endregion
            #region RetryRequestLotClose
            seq.Steps["RetryRequestLotClose"].StepIndex = seq.AddItem(
                delegate(object obj)
                {
                    if (CurrentGate == GATE_NO_ZERO)
                    {
                        CurrentGate = GATE_NO_MIN;
                    }
                    else
                    {
                        CurrentGate++;
                        if (CurrentGate > GATE_NO_MAX)
                            CurrentGate = GATE_NO_MIN;
                    }
                });
            #endregion
            #region RequestLotClose
            seq.Steps["RequestLotClose"].StepIndex = seq.AddItem(
                delegate(object obj)
                {
                    FAECInfo.LOT_CLOSE_REQ command = new FAECInfo.LOT_CLOSE_REQ();
                    command.LOT_ID = ReadingLotID;
                    command.GATE = string.Format("GATE{0}", CurrentGate.ToString());
                    command.OPER_ID = Equipment.CurrentUser.Name;
                    ecResult.Clear();
                    InterfaceUnit.ECPart.AddCommand(command, ecResult);
                });
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (ecResult.ReceiveOk)
                    {
                        if (ecResult.ParsingSuccess)
                        {
                            if (ecResult.ECInfo.LOT_CLOSE.RESULT == FAECInfo.FAECResult.PASS)
                            {
                                Manager.MessageWindowManager.Instance.CloseWindow("GateAlreadyWorkingWarning");
                                WriteTraceLog("LOT CLOSE OK");
                                NextModule = SuccessWayModule;
                                ecResult.ECInfo.LOT_CLOSE.CopyTo(ProductInfo.ECInfo.LOT_CLOSE);
                                actor.NextStep();
                            }
                            else if (string.IsNullOrEmpty(ecResult.ECInfo.LOT_CLOSE.MSG) == false && ecResult.ECInfo.LOT_CLOSE.MSG.IndexOf(GateAlreadyWorkingMsg) >= 0)
                            {
                                if (RetryInfoGateChangeRetry.IncreaseCount() == false)
                                {
                                    Manager.MessageWindowManager.Instance.Show(Equipment, "GateAlreadyWorkingWarning", string.Concat(ecResult.ECInfo.LOT_CLOSE.MSG, ", ", ReadingLotID));
                                    NextModule = FailureWayModule;
                                    actor.NextStep("SelectUnloadingDirection");
                                }
                                else
                                    actor.NextStep("RetryRequestLotClose");
                            }
                            else
                            {
                                string windowName = string.Empty;
                                var alarm = Utility.AlarmUtility.GetAlarm(ecResult.LastAlarmNo, "[RF READER MODULE] LOT CLOSE INFO EC RESULT FAIL.");
                                Manager.MessageWindowManager.Instance.Show(Equipment,
                                    "RFReaderECCommFail",
                                    out windowName,
                                    alarm,
                                    string.Empty,
                                    true);
                                NextModule = FailureWayModule;
                                actor.NextStep("SelectUnloadingDirection");
                            }
                        }
                        else if (string.IsNullOrEmpty(ecResult.ECInfo.LOT_CLOSE.MSG) == false && ecResult.ECInfo.LOT_CLOSE.MSG.IndexOf(GateAlreadyWorkingMsg) >= 0)
                        {
                            if (RetryInfoGateChangeRetry.IncreaseCount() == false)
                            {
                                Manager.MessageWindowManager.Instance.Show(Equipment, "GateAlreadyWorkingWarning", string.Concat(ecResult.ECInfo.LOT_CLOSE.MSG, ", ", ReadingLotID));
                                NextModule = FailureWayModule;
                                actor.NextStep("SelectUnloadingDirection");
                            }
                            else
                                actor.NextStep("RetryRequestLotClose");
                        }
                        else
                        {
                            var msg = GetErrorMessageOfTrayLOTCLOSECheck(ecResult.ECInfo.LOT_CLOSE);
                            string windowName = string.Empty;
                            var alarm = Utility.AlarmUtility.GetAlarm(ecResult.LastAlarmNo, "[RF READER MODULE] EC LOT CLOSE INFO RECEIVE DATA PARSING FAIL.");
                            Manager.MessageWindowManager.Instance.Show(Equipment,
                                    "RFReaderECCommFail",
                                    out windowName,
                                    alarm,
                                    msg,
                                    true);
                            NextModule = FailureWayModule;
                            actor.NextStep("SelectUnloadingDirection");
                        }
                    }
                    else if (ecResult.LastAlarmNo != 0)
                    {
                        string windowName = string.Empty;
                        var alarm = Utility.AlarmUtility.GetAlarm(ecResult.LastAlarmNo, "[RF READER MODULE] EC LOT CLOSE INFO RECEIVE FAIL.");
                        Manager.MessageWindowManager.Instance.Show(Equipment,
                                    "RFReaderECCommFail",
                                    out windowName,
                                    alarm,
                                    string.Empty,
                                    true);
                        NextModule = FailureWayModule;
                        actor.NextStep("SelectUnloadingDirection");
                    }
                });
            #endregion
            #region SelectUnloadingDirection
            seq.Steps["SelectUnloadingDirection"].StepIndex = seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (NextModule == FailureWayModule)
                    {
                        string msg = string.Empty;
                        actor.NextTerminate();
                    }
                    else
                        actor.NextStep();
                });
            #endregion
            #region PreUnloadingAction
            seq.AddItem(
                delegate(object obj)
                {
                    if (Equipment.RunMode == FAFramework.Equipment.RunModeTypes.HOT_RUN)
                    {
                        ProductInfo.Gate = string.Format("GATE{0}", CurrentGate);

                        var ssdCountInTray = ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_X * ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_Y;
                        var lotQty = ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_QTY;
                        int trayCount = lotQty / ssdCountInTray;

                        if (lotQty % ssdCountInTray > 0)
                            trayCount += 1;

                        ProductInfo.VT8792ProductInfo.TrayCount = trayCount;
                        ProductInfo.VT8792ProductInfo.RemainSSDCount = lotQty % ssdCountInTray;
                    }
                });
            seq.AddItem((object obj) => NextModule = SuccessWayModule);
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (Equipment.RunMode == FAFramework.Equipment.RunModeTypes.DRY_RUN ||
                        Equipment.RunMode == FAFramework.Equipment.RunModeTypes.COLD_RUN)
                    {
                        if (UseTrayCoutingResultOnDryRun)
                        {
                            ProductInfo.VT8792ProductInfo.TrayCount = TrayCount - 1;
                            ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_ID = "TEST_LOT";
                            ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_MARKING = "TEST";
                            ProductInfo.ECInfo.PACKING_MASTER_INFO.PART_ID = "TEST";
                            ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_X = 2;
                            ProductInfo.ECInfo.PACKING_MASTER_INFO.TRAY_ARRAY_Y = 3;
                            ProductInfo.ECInfo.PACKING_MASTER_INFO.S_BOX_MOQ = LotSmallBoxMOQ;
                            ProductInfo.ECInfo.PACKING_MASTER_INFO.L_BOX_MOQ = LotSmallBoxMOQ;
                            ProductInfo.ECInfo.PACKING_MASTER_INFO.LOT_QTY = ProductInfo.VT8792ProductInfo.TrayCount * 2 * 3;
                            actor.NextStep();
                        }
                        else
                            actor.NextStep();
                    }
                    else
                        actor.NextStep();
                });
            seq.AddItem(
                delegate(object obj)
                {
                    string msg;
                    AddLot(ReadingLotID, out msg);
                    Equipment.LotManager.AddLot(ReadingLotID);
                });
            #endregion
        }
Beispiel #48
0
 private async static void StartTest()
 {
     dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
     foreach (var qst in listWithQuestions)
     {
         mainWindow.ChangeContext(qst);
         await WaitingForTimer(qst, dispatcherTimer);
         Report.Checker.processAnswer(qst);
     }
     Report.ReportGenerator.Instance.GenerateReport();
     dispatcherTimer.Stop();
     Report.Checker.PresentScore();
     mainWindow.PrepareTermination();
 }
Beispiel #49
0
		private void StartInvalidateTimer()
		{
			if (_invalidateTimer != null)
				return;

			_invalidateTimer = new System.Windows.Threading.DispatcherTimer();
			_invalidateTimer.Interval = TimeSpan.FromMilliseconds(10);
			_invalidateTimer.Tick += (s, a) =>
			{
				if (!_prPages.IsNeedContinuePaint)
				{
					_invalidateTimer.Stop();
					_invalidateTimer = null;
				}
				InvalidateVisual();
			};
			_invalidateTimer.Start();
		}
Beispiel #50
0
        /// <summary>
        /// 消息提示
        /// </summary>
        /// <param name="msg"></param>
        public void Show(string msg, string title, Grid layout)
        {
            try
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    var _popup = new Popup();
                    var _timer = new System.Windows.Threading.DispatcherTimer();

                    _popup.HorizontalOffset = 0;
                    _popup.VerticalOffset = 0;

                    var grid = new Grid();
                    grid.Width = App.Current.RootVisual.RenderSize.Width;
                    grid.Background = (SolidColorBrush)App.Current.Resources["MessageBoxBgBrush"];
                    grid.MinHeight = 80;
                    grid.Margin = new Thickness(0, 0, 0, 0);
                    var stackPanel = new StackPanel
                    {
                        Orientation = Orientation.Vertical
                    };
                    if (!string.IsNullOrWhiteSpace(title))
                    {
                        var tbTitle = new TextBlock
                        {
                            Text = title,
                            FontSize = 24,
                            Foreground = (SolidColorBrush)App.Current.Resources["MessageBoxTextBrush"],
                            Width = grid.Width,
                            Padding = new Thickness(10, 10, 10, 10),
                            Margin = new Thickness(0, 12, 0, 0)
                        };
                        stackPanel.Children.Add(tbTitle);
                    }
                    var tblock = new TextBlock
                    {
                        Text = msg,
                        FontSize = 24,
                        Foreground = (SolidColorBrush)App.Current.Resources["MessageBoxTextBrush"],
                        Width = grid.Width,
                        Padding = new Thickness(10, 10, 10, 10),
                        Margin = new Thickness(0, 0, 0, 0)
                    };
                    stackPanel.Children.Add(tblock);
                    grid.Children.Add(stackPanel);

                    _popup.Child = grid;

                    if (!layout.Children.Contains(_popup))
                    {
                        layout.Children.Add(_popup);
                    }
                    _popup.IsOpen = true;
                    _timer.Interval = new TimeSpan(0, 0, 0, 0, 2500); //  2.5 seconds
                    _timer.Tick += ((o, s) =>
                    {
                        _timer.Stop();
                        _popup.IsOpen = false;
                        layout.Children.Remove(_popup);
                        _popup = null;
                    });
                    _timer.Start();
                });
            }
            catch
            {
            }
        }
		public MainPage(IDictionary<string, string> initParams)
		{
			InitializeComponent();

			HtmlPage.RegisterScriptableObject("MediaElementJS", this);


			// add events
			media.BufferingProgressChanged += new RoutedEventHandler(media_BufferingProgressChanged);
			media.DownloadProgressChanged += new RoutedEventHandler(media_DownloadProgressChanged);
			media.CurrentStateChanged += new RoutedEventHandler(media_CurrentStateChanged);
			media.MediaEnded += new RoutedEventHandler(media_MediaEnded);
			media.MediaFailed += new EventHandler<ExceptionRoutedEventArgs>(media_MediaFailed);
			media.MediaOpened += new RoutedEventHandler(media_MediaOpened);
            media.MouseLeftButtonDown += new MouseButtonEventHandler(media_MouseLeftButtonDown);
            CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
            transportControls.Visibility = System.Windows.Visibility.Collapsed;

			// get parameters
			if (initParams.ContainsKey("id"))
				_htmlid = initParams["id"];			
			if (initParams.ContainsKey("file"))
				_mediaUrl = initParams["file"];
            if (initParams.ContainsKey("jsinitfunction"))
                _jsInitFunction = initParams["jsinitfunction"];
            if (initParams.ContainsKey("jscallbackfunction"))
                _jsCallbackFunction = initParams["jscallbackfunction"];
			if (initParams.ContainsKey("autoplay") && initParams["autoplay"] == "true")
				_autoplay = true;
			if (initParams.ContainsKey("debug") && initParams["debug"] == "true")
				_debug = true;
			if (initParams.ContainsKey("preload"))
				_preload = initParams["preload"].ToLower();
			else
				_preload = "";

			if (!(new string[] { "none", "metadata", "auto" }).Contains(_preload)){
				_preload = "none";
			}

			if (initParams.ContainsKey("width")) 
				Int32.TryParse(initParams["width"], out _width);			
			if (initParams.ContainsKey("height")) 
				Int32.TryParse(initParams["height"], out _height);
			if (initParams.ContainsKey("timerate"))
				Int32.TryParse(initParams["timerrate"], out _timerRate);
			if (initParams.ContainsKey("startvolume"))
				Double.TryParse(initParams["startvolume"], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _volume);

			if (_timerRate == 0)
				_timerRate = 250;

			// timer
			_timer = new System.Windows.Threading.DispatcherTimer();
			_timer.Interval = new TimeSpan(0, 0, 0, 0, _timerRate); // 200 Milliseconds 
			_timer.Tick += new EventHandler(timer_Tick);
			_timer.Stop();

			//_mediaUrl = "http://local.mediaelement.com/media/jsaddington.mp4";
			//_autoplay = true;
			
			// set stage and media sizes
			if (_width > 0)
				LayoutRoot.Width = media.Width = this.Width = _width;
			if (_height > 0)
				LayoutRoot.Height = media.Height = this.Height = _height;			
	 
			// debug
			textBox1.Visibility = (_debug) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
			textBox1.IsEnabled = false;
			textBox1.Text = "id: " + _htmlid + "\n" +
							"file: " + _mediaUrl + "\n";


			media.AutoPlay = _autoplay;
			media.Volume = _volume;
			if (!String.IsNullOrEmpty(_mediaUrl)) {
				setSrc(_mediaUrl);
				if (_autoplay || _preload != "none")
					loadMedia();
			}

			media.MouseLeftButtonUp += new MouseButtonEventHandler(media_MouseLeftButtonUp);

			// full screen settings
			Application.Current.Host.Content.FullScreenChanged += new EventHandler(DisplaySizeInformation);
			Application.Current.Host.Content.Resized += new EventHandler(DisplaySizeInformation);
			//FullscreenButton.Visibility = System.Windows.Visibility.Collapsed;
		   
			// send out init call			
			//HtmlPage.Window.Invoke("html5_MediaPluginBridge_initPlugin", new object[] {_htmlid});
			try
			{
                HtmlPage.Window.Eval(_jsInitFunction + "('" + _htmlid + "');");
			}
			catch { }
		}
Beispiel #52
0
        /// <summary>
        /// Handles the ItemsChanged event of the ItemContainerGenerator control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Controls.Primitives.ItemsChangedEventArgs"/> instance containing the event data.</param>
        private void ItemContainerGenerator_ItemsChanged(object sender, System.Windows.Controls.Primitives.ItemsChangedEventArgs e)
        {
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
            {
                Dispatcher.BeginInvoke(new ItemChangedDelegate(i =>
                {
                    ListBoxItem item = (ListBoxItem)this.ItemContainerGenerator.ContainerFromIndex(i);
                    if (item != null)
                    {
                        VisualStateManager.GoToState(item, "BeforeLoaded", false);
                        VisualStateManager.GoToState(item, "AfterLoaded", true);
                    }
                }), e.Position.Index + e.Position.Offset);
            }
            else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
            {
                Dispatcher.BeginInvoke(new ItemChangedDelegate(i =>
                {
                    ListBoxItem item = (ListBoxItem)this.ItemContainerGenerator.ContainerFromIndex(i);
                    if (item != null)
                    {
                        VisualStateManager.GoToState(item, "BeforeUnloaded", true);
                    }
                }), e.Position.Index + e.Position.Offset);
            }
            else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace)
            {
                Dispatcher.BeginInvoke(new ItemChangedDelegate(i =>
                {
                    ListBoxItem item = (ListBoxItem)this.ItemContainerGenerator.ContainerFromIndex(i);
                    if (item != null)
                    {
                        VisualStateManager.GoToState(item, "BeforeLoaded", true);
                        VisualStateManager.GoToState(item, "AfterLoaded", true);
                    }
                }), e.Position.Index + e.Position.Offset);
            }
            else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset)
            {
                var observableBefore = from t in Observable.Interval(TimeSpan.FromMilliseconds(ListAnimationInterval / 2.0d)).TimeInterval().Take(this.Items.Count)
                                       select t.Value;
                var observableAfter = from t in Observable.Interval(TimeSpan.FromMilliseconds(ListAnimationInterval / 2.0d)).TimeInterval().Take(this.Items.Count)
                                      select t.Value;

                // This timer will allow us to delay slightly the afterloaded states
                System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer();
                dt.Tick += (sen, evt) =>
                    {
                        dt.Stop();
                        observableAfter.Subscribe(i => Dispatcher.BeginInvoke(() =>
                            {
                                if (this.ItemContainerGenerator.ContainerFromIndex((int)i) == null)
                                    return;
                                VisualStateManager.GoToState(
                                    (ListBoxItem)this.ItemContainerGenerator.ContainerFromIndex((int)i), "AfterLoaded", true);
                            }));
                    };
                dt.Interval = TimeSpan.FromMilliseconds(ListAnimationInterval * 2.0d);

                observableBefore.Subscribe(i => Dispatcher.BeginInvoke(() =>
                    {
                        if (this.ItemContainerGenerator.ContainerFromIndex((int)i) == null)
                            return;
                        VisualStateManager.GoToState(
                            (ListBoxItem)this.ItemContainerGenerator.ContainerFromIndex((int)i), "BeforeLoaded", true);
                    }));
                dt.Start();
            }
        }
Beispiel #53
0
        public void StatusCoverterPause()
        {
            System.Windows.Threading.DispatcherTimer tmr = new System.Windows.Threading.DispatcherTimer()
            { Interval = TimeSpan.FromSeconds(1) };
            switch (ModeString)
            {
                case "Idle":

                    tmr.Tick += (s, a) =>
                    {
                        sleeping.Storyboard.Pause();
                        tmr.Stop();
                    };
                    tmr.Start();
                    break;
                case "Product":
                    tmr.Tick += (s, a) =>
                    {
                        testting.Storyboard.Pause();
                        tmr.Stop();
                    };
                    tmr.Start();

                    break;
                case "Verify":
                    tmr.Tick += (s, a) =>
                    {
                        damage.Storyboard.Pause();
                        tmr.Stop();
                    };
                    tmr.Start();

                    break;
                case "LEM":
                    tmr.Tick += (s, a) =>
                    {
                        fax.Storyboard.Pause();
                        tmr.Stop();
                    };
                    tmr.Start();

                    break;
            }
        }
Beispiel #54
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Grid.Children.Clear();
            map = GameMap.LoadMapFromfile(@"..\..\Box.map");

            map.OnCollision += Collision; //Обработчик колизий

            snake = new GameAPI.Snake(new GameAPI.Point(2, 2)); //Создадим змею
            map.Add(snake.CurentPosition, snake); // Добавим змею на карту

            snake.OnGrow += (Object obj, EventArgs ea) => { Grid.Children.Add((SnakeBody)obj); };//Добавим в Грид Новые куски змеи...
            snake.OnGrow += (Object obj, EventArgs ea) => { if (snake.Count % 4 ==0 ) dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, dispatcherTimer.Interval.Milliseconds / 2); };//Добавим в Грид Новые куски змеи...
    
            RandomAppleGeneration(); //Сгенерим яблочко

            PrintMap(map, this.Grid);

            //Поехали
            dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += (Object obj, EventArgs ea) => 
                                    {
                                        try
                                        {
                                            snake.Move(map);
                                        }
                                        catch (ApplicationException Aex)
                                        {
                                            dispatcherTimer.Stop(); // Остановим таймер
                                            Grid.Children.Clear();

                                            Label l = new Label();
                                            l.FontSize = 48;
                                            l.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                                            l.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;

                                            if (Aex is GameOverExeption)
                                            {
                                                l.Content = "Game Over";
                                                l.Foreground = Brushes.Red;
                                            }

                                            if (Aex is GameWinExeption)
                                            {
                                                l.Content = "Win level";
                                                l.Foreground = Brushes.Green;
                                            }

                                            Grid.Children.Add(l);
                                        }
                                    };
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 600);
            dispatcherTimer.Start();

        }
Beispiel #55
0
        public void DisplayBeamFiring(Action<System.Windows.Shapes.Path> AddWeaponAction, Action<System.Windows.Shapes.Path> RemoveWeaponAction, System.Windows.Shapes.Path WeaponPath, int delay = 100)
        {
            try
            {
                var dispatcherTimer = new System.Windows.Threading.DispatcherTimer(System.Windows.Threading.DispatcherPriority.Render);

                EventHandler handler = null;
                handler = (sender, e) =>
                {
                    // Stop the timer so it won't keep executing every X seconds
                    // and also avoid keeping the handler in memory.
                    dispatcherTimer.Tick -= handler;
                    dispatcherTimer.Stop();
                    // Perform the action.
                    AddWeaponAction(WeaponPath);
                    RemoveBeamFiring(RemoveWeaponAction, WeaponPath);
                };

                dispatcherTimer.Tick += handler;
                dispatcherTimer.Interval = TimeSpan.FromMilliseconds(delay);
                dispatcherTimer.Start();
            }
            catch (Exception ex)
            {
                if (LogEverything)
                    Logger(ex);
            }
        }
        public void MoveShipImageWithDelay(Action<StarSystem, Image, System.Drawing.Point, double> action, StarSystem system, Image shipImage, System.Drawing.Point targetLoc, double rotationAngle, int delay = 100)
        {
            try
            {
                var dispatcherTimer = new System.Windows.Threading.DispatcherTimer(System.Windows.Threading.DispatcherPriority.Render);

                EventHandler handler = null;
                handler = (sender, e) =>
                {
                    // Stop the timer so it won't keep executing every X seconds
                    // and also avoid keeping the handler in memory.
                    dispatcherTimer.Tick -= handler;
                    dispatcherTimer.Stop();
                    // Perform the action.
                    action(system, shipImage, targetLoc, rotationAngle);
                    // Start the next animation
                    NextAnimation();
                };

                dispatcherTimer.Tick += handler;
                dispatcherTimer.Interval = TimeSpan.FromMilliseconds(delay);
                dispatcherTimer.Start();
            }
            catch (Exception ex)
            {
                if (LogEverything)
                    Logger(ex);
            }
        }
 void Countdown(int count, TimeSpan interval, Action<int> ts)
 {
     var dt = new System.Windows.Threading.DispatcherTimer();
     dt.Interval = interval;
     dt.Tick += (_, a) =>
     {
         if (count-- == 0)
         {
             dt.Stop();
             button_login.Content = "anmelden";
             button_login.IsEnabled = true;
             button.IsEnabled = true;
         }
         else
         {
             ts(count);
         }
     };
     ts(count);
     dt.Start();
 }
Beispiel #58
0
        public void ShowTopNoti(Xamarin.Forms.Page p, View noti, int msTTL = 1500)
        {
            var render = Convert(noti, p);

            if (render != null)
            {
                var nanchor = p.GetRenderer() as Canvas;
                p.WidthRequest = nanchor.ActualWidth - 10;

                if (noti.HeightRequest <= 0)
                {
                    var size = noti.GetSizeRequest(nanchor.ActualWidth - 10, XFPopupConst.SCREEN_HEIGHT / 2);
                    if (size.Request.Height > XFPopupConst.SCREEN_HEIGHT / 2)
                    {
                        noti.HeightRequest = XFPopupConst.SCREEN_HEIGHT / 2;
                    }
                    else
                    {
                        noti.HeightRequest = size.Request.Height;
                    }
                }

                noti.Layout(new Rectangle(0, 0, noti.WidthRequest, noti.HeightRequest));

                var nativePopup = new System.Windows.Controls.Primitives.Popup();
                nativePopup.VerticalOffset = 0;
                nativePopup.HorizontalOffset = 0;

                var boder = new Border();
                boder.BorderThickness = new System.Windows.Thickness(1);
                boder.Padding = new System.Windows.Thickness(5);
                boder.BorderBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 50, 50, 50));
                boder.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 255, 255));

                boder.VerticalAlignment = VerticalAlignment.Top;
                boder.HorizontalAlignment = HorizontalAlignment.Stretch;

                boder.Width = noti.WidthRequest + 10;
                boder.Height = noti.HeightRequest + 10;
                boder.CornerRadius = new CornerRadius(5);

                var elm = (render as Panel);
                elm.VerticalAlignment = VerticalAlignment.Top;
                elm.HorizontalAlignment = HorizontalAlignment.Left;
                boder.Child = elm;

                nativePopup.Child = boder;
                nativePopup.IsOpen = true;

                //
                byte count = 0;
                var dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
                dispatcherTimer.Tick += (object sender, EventArgs e) => {
                    count++;
                    if (count >= 10) {
                        dispatcherTimer.Stop();
                        nativePopup.IsOpen = false;

                    }

                    boder.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb((byte)(255 - count * 25), 255, 255, 255));
                };

                dispatcherTimer.Interval = new TimeSpan(0, 0, 0,msTTL/10);
                dispatcherTimer.Start();
            }
        }
        private void listview_Loaded(object sender, RoutedEventArgs e)
        {
            //Делаем ScrollIntoView для выбранной строки, т.к.
            //на автомате оно иногда делается через одно место
            ListView listview = (ListView)sender;
            if (listview.SelectedItem != null)
            {
                //Просто Loaded или Initialized не достаточно, поэтому с задержкой, хоть это и не правильно..
                System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
                timer.Interval = new TimeSpan(0, 0, 0, 0, 10);
                timer.Tick += (a, b) =>
                {
                    if (listview.SelectedItem != null)
                        listview.ScrollIntoView(listview.SelectedItem);
                    timer.Stop();
                    timer = null;
                };
                timer.Start();
            }

            //Мы всегда оказываемся сдесь при переключении табов
            tab_lav_splitter.Visibility = Visibility.Collapsed;
            tab_lav_decoder.Visibility = Visibility.Collapsed;
        }
Beispiel #60
0
        public ClientWindow(Mubox.Model.ClientState clientState)
        {
            Mubox.View.Client.ClientWindowCollection.Instance.Add(this);
            Debug.Assert(clientState != null);
            try
            {
                this.Dispatcher.UnhandledException += (sender, e) =>
                {
                    try
                    {
                        // TODO remove this event handler, we throw during disconnect when exiting mubox because window closure and network disconnection race
                        e.Handled = e.Exception.InnerException is ObjectDisposedException;
                        if (!e.Handled)
                        {
                            StringBuilder sb = new StringBuilder();
                            Exception ex = e.Exception;
                            while (ex != null)
                            {
                                sb.AppendLine("-------- " + ex.Message).AppendLine(ex.StackTrace);
                                ex = ex.InnerException;
                            }
                            MessageBox.Show("An error has occurred. You may want to restart Mubox and re-try. If this error continues, please send a screenshot of this error pop-up" + Environment.NewLine + "to [email protected], including steps to reproduce. A fix will be provided shortly thereafter." + Environment.NewLine + Environment.NewLine + "--- BEGIN ERROR INFO" + Environment.NewLine + "---" + sb.ToString(), "Mubox Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                    catch (Exception ex)
                    {
                        ex.Log();
                    }
                };

                // create default state so we can perform initialization without errors related to state-saving
                InitializeComponent();

                clientState.GameProcessExited += (s, e) =>
                    {
                        this.Dispatcher.BeginInvoke((Action)delegate()
                        {
                            try
                            {
                                InitializeWindowPositionAndSizeInputs();
                                clientState_SetStatusText("Application Exit.");
                                buttonLaunchApplication.IsEnabled = true;
                                this.Show();
                                ToggleApplicationLaunchButton();
                            }
                            catch
                            {
                                // NOP - known issue during shutdown where client window is in a closing state before game process has exited, resulting in exception.
                            }
                        });
                    };

                clientState.GameProcessFound += (s, e) =>
                    {
                    };

                ClientState = clientState;

                textMachineName.Text = ClientState.Settings.Name;
                textServerName.Text = ClientState.Settings.ServerName;
                textPortNumber.Text = ClientState.Settings.ServerPortNumber.ToString();
                textApplicationPath.Text = ClientState.Settings.ApplicationPath;
                textApplicationArguments.Text = this.ClientState.Settings.ApplicationArguments;
                checkIsolateApplication.IsChecked = ClientState.Settings.EnableIsolation;
                checkRememberWindowPosition.IsChecked = ClientState.Settings.RememberWindowPosition;
                InitializeWindowPositionAndSizeInputs();
                ToggleWindowPositionInputs();
                checkRemoveWindowBorder.IsChecked = ClientState.Settings.RemoveWindowBorderEnabled;
                textIsolationPath.Text = ClientState.Settings.IsolationPath;
                textWorkingSetMB.Text = ClientState.Settings.MemoryMB.ToString();
                comboProcessorAffinity.Items.Add("Use All");
                for (int i = 0; i < Environment.ProcessorCount; i++)
                {
                    comboProcessorAffinity.Items.Add((i + 1).ToString());
                }
                if (clientState.Settings.ProcessorAffinity < comboProcessorAffinity.Items.Count)
                {
                    comboProcessorAffinity.SelectedIndex = (int)ClientState.Settings.ProcessorAffinity;
                }
                else
                {
                    comboProcessorAffinity.SelectedIndex = 0;
                }

                timerStatusRefresh = new System.Windows.Threading.DispatcherTimer(System.Windows.Threading.DispatcherPriority.Normal);
                timerStatusRefresh.Interval = TimeSpan.FromMilliseconds(500);
                timerStatusRefresh.Tick += (sender, e) =>
                    {
                        timerStatusRefresh.Stop();
                        timerStatusRefresh.Interval = TimeSpan.FromMilliseconds(500);
                        try
                        {
                            if (ClientState.NetworkClient != null)
                            {
                                buttonConnect.IsEnabled = false;
                                textServerName.IsEnabled = false;
                                textPortNumber.IsEnabled = false;
                                timerStatusRefresh.Interval = TimeSpan.FromMilliseconds(5000);
                            }
                            else if (clientState_AutoReconnect)
                            {
                                if (buttonConnect.IsEnabled)
                                {
                                    if (TimeSpan.FromTicks(DateTime.Now.Ticks - AutoReconnectLastAttempt).TotalSeconds >= AutoReconnectDelay)
                                    {
                                        buttonConnect_Click(null, null);
                                        AutoReconnectLastAttempt = DateTime.Now.Ticks;
                                    }
                                }
                            }
                            else if (clientState.Settings.PerformConnectOnLoad)
                            {
                                if (buttonConnect.IsEnabled)
                                {
                                    buttonConnect_Click(null, null);
                                }
                            }
                            clientState_SetStatusText(clientState_lastStatus);
                        }
                        catch (Exception ex)
                        {
                            ex.Log();
                        }
                        finally
                        {
                            timerStatusRefresh.Start();
                        }
                    };
                timerStatusRefresh.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + Environment.NewLine + "---" + Environment.NewLine + ex.StackTrace, "Exception Info");
                try
                {
                    Close();
                }
                catch (Exception L_ex)
                {
                    L_ex.Log();
                }
            }
        }