コード例 #1
0
        private void FindProcess(String distraction)
        {
            Process[] runningProcesses = Process.GetProcesses();

            foreach (Process proc in runningProcesses)
            {
                if (!String.IsNullOrEmpty(proc.MainWindowTitle))
                {
                    if (proc.MainWindowTitle.Contains(distraction))
                    {
                        if (!proc.HasExited)
                        {
                            NotificationBalloonTips.StudyBrokenAlert(distraction);
                            proc.Kill();
                        }
                    }
                    else if (proc.ProcessName.Contains(distraction))
                    {
                        if (!proc.HasExited)
                        {
                            NotificationBalloonTips.StudyBrokenAlert(distraction);
                            proc.Kill();
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void Timer_tick(object sender, EventArgs e)
        {
            seconds = seconds - 1;

            if (seconds == -1)
            {
                minutes = minutes - 1;
                seconds = 59;
            }

            if (minutes == -1)
            {
                hours   = hours - 1;
                minutes = 59;
            }

            if (hours == 0 && minutes == 0 && seconds == 0)
            {
                DTimer.Stop();
                //stop the proxy
                titan.Stop();
                //send a alert
                NotificationBalloonTips.TimerPopUp();
            }


            string hh = Convert.ToString(hours);
            string mm = Convert.ToString(minutes);
            string ss = Convert.ToString(seconds);

            VisibleHours.Content   = hh;
            VisibleMinutes.Content = mm;
            VisibleSeconds.Content = ss;
        }
コード例 #3
0
        private void FindChromeTabs()
        {
            Process[] procsChrome = Process.GetProcessesByName("chrome");
            if (procsChrome.Length <= 0)
            {
                Console.WriteLine("chrome is not running");
            }
            else
            {
                foreach (Process proc in procsChrome)
                {
                    //the chrome process must have a window
                    if (proc.MainWindowHandle == IntPtr.Zero)
                    {
                        continue;
                    }

                    //to find the tabs we firest need to locate something reliable = the New tab button
                    AutomationElement root = AutomationElement.FromHandle(proc.MainWindowHandle);
                    System.Windows.Automation.Condition conNewTab = new PropertyCondition(AutomationElement.NameProperty, "New Tab");
                    AutomationElement elmNewTab = root.FindFirst(TreeScope.Descendants, conNewTab);

                    //get the tabstrip by getting the parent of the new tab button
                    TreeWalker treewalker = TreeWalker.ContentViewWalker;
                    if (elmNewTab != null)
                    {
                        AutomationElement elmTabStrip = treewalker.GetParent(elmNewTab);

                        //loop through the tabs and et the names which is the page title
                        System.Windows.Automation.Condition condTabItem = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem);
                        foreach (AutomationElement tabitem in elmTabStrip.FindAll(TreeScope.Children, condTabItem))
                        {
                            Console.WriteLine(tabitem.Current.Name);
                            foreach (String distraction in Distractions)
                            {
                                if (tabitem.Current.Name.ToLower().Contains(distraction))
                                {
                                    //send an alert to the user
                                    NotificationBalloonTips.StudyBrokenAlert(distraction);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        private void Timer_tick(object sender, EventArgs e)
        {
            seconds = seconds - 1;

            if (seconds == -1)
            {
                minutes = minutes - 1;
                seconds = 59;
            }

            if (minutes == -1)
            {
                hours   = hours - 1;
                minutes = 59;
            }

            if (hours == 0 && minutes == 0 && seconds == 0)
            {
                DTimer.Stop();

                NotificationBalloonTips.TimerPopUp();
                IsDone = true;
            }

            //Dispatcher.Invoke(() =>
            //{
            string hh = Convert.ToString(hours);
            string mm = Convert.ToString(minutes);
            string ss = Convert.ToString(seconds);

            main.TimerLabel.Content   = hh;
            main.TimerLabelMM.Content = mm;
            main.TimerLabelSS.Content = ss;
            // });
            if (!IsDone)
            {
                ActivateCounterMeasures();
            }
        }
コード例 #5
0
        public async Task OnRequest(object sender, SessionEventArgs e)
        {
            Console.WriteLine(e.WebSession.Request.Url);
            ////read request headers
            var requestHeaders = e.WebSession.Request.RequestHeaders;

            var method = e.WebSession.Request.Method.ToUpper();

            if ((method == "POST" || method == "PUT" || method == "PATCH"))
            {
                //Get/Set request body bytes
                byte[] bodyBytes = await e.GetRequestBody();

                await e.SetRequestBody(bodyBytes);

                //Get/Set request body as string
                string bodyString = await e.GetRequestBodyAsString();

                await e.SetRequestBodyString(bodyString);

                //store request Body/request headers etc with request Id as key
                //so that you can find it from response handler using request Id
                requestBodyHistory[e.Id] = bodyString;
            }

            foreach (string website in BlackListSites)
            {
                //Redirect example
                if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains(website))
                {
                    await e.Redirect("https://lms.neumont.edu/");

                    NotificationBalloonTips.StudyBrokenAlert(website);
                }
            }
        }