コード例 #1
0
        private void MouseDraw(MainWindow main, Point p)
        {
            //randomize at some point?
             Shape shape = new Ellipse
             {
            Stroke = SystemColors.WindowTextBrush,
            StrokeThickness = 0,
            Fill = Utils.GetGradientBrush(Utils.GetRandomColor()),
            Width = 50,
            Height = 50
             };

             ellipsesQueue.Enqueue(shape);
             main.mouseDragCanvas.Children.Add(shape);
             Canvas.SetLeft(shape, p.X - 25);
             Canvas.SetTop(shape, p.Y - 25);

             if (Settings.Default.MouseDraw)
            audio.PlayWavResourceYield(".Resources.Sounds." + "smallbumblebee.wav");

             if (ellipsesQueue.Count > 30) //this is arbitrary
             {
            Shape shapeToRemove = ellipsesQueue.Dequeue();
            main.mouseDragCanvas.Children.Remove(shapeToRemove);
             }
        }
コード例 #2
0
        public void Launch()
        {
            timer.Tick += new EventHandler(timer_Tick);
             timer.Interval = new TimeSpan(0, 0, 1);
             int Number = 0;

             if (ApplicationDeployment.IsNetworkDeployed)
             {
            deployment = ApplicationDeployment.CurrentDeployment;
            deployment.UpdateCompleted += new System.ComponentModel.AsyncCompletedEventHandler(deployment_UpdateCompleted);
            deployment.UpdateProgressChanged += deployment_UpdateProgressChanged;
            deployment.CheckForUpdateCompleted += deployment_CheckForUpdateCompleted;
            try
            {
               deployment.CheckForUpdateAsync();
            }
            catch (InvalidOperationException e)
            {
               Debug.WriteLine(e.ToString());
            }
             }

             foreach (WinForms.Screen s in WinForms.Screen.AllScreens)
             {
            MainWindow m = new MainWindow(this)
                               {
                                  WindowStartupLocation = WindowStartupLocation.Manual,
                                  Left = s.WorkingArea.Left,
                                  Top = s.WorkingArea.Top,
                                  Width = s.WorkingArea.Width,
                                  Height = s.WorkingArea.Height,
                                  WindowStyle = WindowStyle.None,
                                  Topmost = true,
                                  AllowsTransparency = Settings.Default.TransparentBackground,
                              Background = (Settings.Default.TransparentBackground ? new SolidColorBrush(Color.FromArgb(1, 0, 0, 0)) : Brushes.WhiteSmoke),
                                  Name = "Window" + Number++.ToString()
             				};

            ellipsesUserControlQueue[m.Name] = new Queue<UserControl>();

            m.Show();
            m.MouseLeftButtonDown += HandleMouseLeftButtonDown;
            m.MouseWheel += HandleMouseWheel;

            #if false
            m.Width = 700;
            m.Height = 600;
            m.Left = 900;
            m.Top = 500;
            #else
            m.WindowState = WindowState.Maximized;
            #endif
            windows.Add(m);
             }

            //Only show the info label on the FIRST monitor.
             windows[0].infoLabel.Visibility = Visibility.Visible;

             //Startup sound
             audio.PlayWavResourceYield(".Resources.Sounds." + "EditedJackPlaysBabySmash.wav");

             string[] args = Environment.GetCommandLineArgs();
             string ext = System.IO.Path.GetExtension(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);

             if (ApplicationDeployment.IsNetworkDeployed && (ApplicationDeployment.CurrentDeployment.IsFirstRun || ApplicationDeployment.CurrentDeployment.UpdatedVersion != ApplicationDeployment.CurrentDeployment.CurrentVersion))
             {
            //if someone made us a screensaver, then don't show the options dialog.
            if ((args != null && args[0] != "/s") && String.CompareOrdinal(ext, ".SCR") != 0)
            {
               ShowOptionsDialog();
            }
             }
            #if !false
             timer.Start();
            #endif
        }
コード例 #3
0
 public void MouseUp(MainWindow main, MouseButtonEventArgs e)
 {
     isDrawing = false;
      if (Settings.Default.MouseDraw) return;
      main.ReleaseMouseCapture();
 }
コード例 #4
0
 public void MouseWheel(MainWindow main, MouseWheelEventArgs e)
 {
     if (e.Delta > 0)
      {
     audio.PlayWavResourceYield(".Resources.Sounds." + "rising.wav");
      }
      else
      {
     audio.PlayWavResourceYield(".Resources.Sounds." + "falling.wav");
      }
 }
コード例 #5
0
        public void MouseMove(MainWindow main, MouseEventArgs e)
        {
            if (isOptionsDialogShown)
              {
              main.ReleaseMouseCapture();
              return;
              }
              if (Settings.Default.MouseDraw && main.IsMouseCaptured == false)
            main.CaptureMouse();

              Debug.WriteLine(String.Format("MouseMove! {0} {1} {2}", Settings.Default.MouseDraw, main.IsMouseCaptured, isOptionsDialogShown));

             if (isDrawing || Settings.Default.MouseDraw)
             {
            MouseDraw(main, e.GetPosition(main));
             }

             //Cheesy, but hotkeys are ignored when the mouse is captured.
             // However, if we don't capture and release, the shapes will draw forever.
             if (Settings.Default.MouseDraw && main.IsMouseCaptured)
            main.ReleaseMouseCapture();
        }
コード例 #6
0
        public void MouseDown(MainWindow main, MouseButtonEventArgs e)
        {
            if (isDrawing || Settings.Default.MouseDraw) return;

             // Create a new Ellipse object and add it to canvas.
             Point ptCenter = e.GetPosition(main.mouseCursorCanvas);
             MouseDraw(main, ptCenter);
             isDrawing = true;
             main.CaptureMouse();

             audio.PlayWavResource(".Resources.Sounds." + "smallbumblebee.wav");
        }
コード例 #7
0
 //private static void ResetCanvas(MainWindow main)
 //{
 //   main.ResetCanvas();
 //}
 public void LostMouseCapture(MainWindow main, MouseEventArgs e)
 {
     if (Settings.Default.MouseDraw) return;
      if (isDrawing) isDrawing = false;
 }
コード例 #8
0
ファイル: Controller.cs プロジェクト: rmarinho/babysmash
 public void MouseWheel(MainWindow main, MouseWheelEventArgs e)
 {
     if (e.Delta > 0)
     {
         Win32Audio.PlayWavResourceYield("rising.wav");
     }
     else
     {
         Win32Audio.PlayWavResourceYield("falling.wav");
     }
 }
コード例 #9
0
ファイル: Controller.cs プロジェクト: chrisortman/babysmash
      public void Launch()
      {
         timer.Tick += new EventHandler(timer_Tick);
         timer.Interval = new TimeSpan(0, 0, 1);
         int Number = 0;

         if (ApplicationDeployment.IsNetworkDeployed)
         {
            deployment = ApplicationDeployment.CurrentDeployment;
            deployment.UpdateCompleted += new System.ComponentModel.AsyncCompletedEventHandler(deployment_UpdateCompleted);
            deployment.UpdateProgressChanged += deployment_UpdateProgressChanged;
            deployment.CheckForUpdateCompleted += deployment_CheckForUpdateCompleted;
            try
            {
               deployment.CheckForUpdateAsync();
            }
            catch (InvalidOperationException e)
            {
               Debug.WriteLine(e.ToString());
            }
         }

         foreach (WinForms.Screen s in WinForms.Screen.AllScreens)
         {
            MainWindow m = new MainWindow(this)
                               {
                                  WindowStartupLocation = WindowStartupLocation.Manual,
                                  Left = s.WorkingArea.Left,
                                  Top = s.WorkingArea.Top,
                                  Width = s.WorkingArea.Width,
                                  Height = s.WorkingArea.Height,
                                  WindowStyle = WindowStyle.None,
                                  Topmost = true,
                                  AllowsTransparency = Settings.Default.TransparentBackground,
	                          Background = (Settings.Default.TransparentBackground ? new SolidColorBrush(Color.FromArgb(1, 0, 0, 0)) : Brushes.WhiteSmoke),
                                  Name = "Window" + Number++.ToString()
 				};


            
            ellipsesUserControlQueue[m.Name] = new Queue<UserControl>();

            m.Show();
            m.MouseLeftButtonDown += HandleMouseLeftButtonDown;
            m.MouseWheel += HandleMouseWheel;

#if true
            m.Width = 700;
            m.Height = 600;
            m.Left = 900;
            m.Top = 500;
#else
            m.WindowState = WindowState.Maximized;
#endif
            windows.Add(m);

             //var keyPresses =
             //    Observable.FromEventPattern<KeyEventArgs>(m, "KeyUp").Throttle(TimeSpan.FromMilliseconds(300)).Select(kp => kp.EventArgs.Key.ToString());

             //keyPresses.Subscribe(kp => {
             //   _dictionary.SendKey(kp);
             //});

         }

	    //Only show the info label on the FIRST monitor.
         windows[0].infoLabel.Visibility = Visibility.Visible;

         //Startup sound
         audio.PlayWavResourceYield(".Resources.Sounds." + "EditedJackPlaysBabySmash.wav");

         string[] args = Environment.GetCommandLineArgs();
         string ext = System.IO.Path.GetExtension(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);

         if (ApplicationDeployment.IsNetworkDeployed && (ApplicationDeployment.CurrentDeployment.IsFirstRun || ApplicationDeployment.CurrentDeployment.UpdatedVersion != ApplicationDeployment.CurrentDeployment.CurrentVersion))            
         {
            //if someone made us a screensaver, then don't show the options dialog.
            if ((args != null && args[0] != "/s") && String.CompareOrdinal(ext, ".SCR") != 0)
            {
               ShowOptionsDialog();
            }
         }
#if !false
         timer.Start();
#endif
          _dictionary.AddWord("dog");
          _dictionary.AddWord("cat");
          _dictionary.AddWords("lincoln","preston","damon","mason","clara","mom","dad","cow","ball","car","tractor");

          _dictionary.WordEntered.Subscribe(word => {
              if (_currentlySpeaking != null)
              {
                  Thread.Sleep(300);
                  _currentlySpeaking.ContinueWith(t => SpeakString(word));
              }
              else {
                  this.SpeakString(word);
              }
          });
      }