コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Figure"/> class. All fields will be random
 /// </summary>
 protected Figure()
 {
     this.Rand       = new RandomNotNull();
     this.X          = this.Rand.Next(50, 440);
     this.Y          = this.Rand.Next(50, 150);
     this.Dx         = this.Rand.Next(-5, 5);
     this.Dy         = this.Rand.Next(-5, 5);
     this.color      = Color.FromArgb(this.Rand.Next(128, 255), this.Rand.Next(128, 255), this.Rand.Next(128, 255), this.Rand.Next(128, 255));
     this.IsMoveble  = true;
     this.IsSelected = false;
     this.NewClash  += this.ClashFigure;
     this.Beep      += SystemSounds.Beep.Play;
 }
コード例 #2
0
ファイル: Figure.cs プロジェクト: AlexKhatun/RunningFigures
 /// <summary>
 /// Initializes a new instance of the <see cref="Figure"/> class. All fields will be random
 /// </summary>
 protected Figure()
 {
     this.Rand = new RandomNotNull();
     this.X = this.Rand.Next(50, 440);
     this.Y = this.Rand.Next(50, 150);
     this.Dx = this.Rand.Next(-5, 5);
     this.Dy = this.Rand.Next(-5, 5);
     this.color = Color.FromArgb(this.Rand.Next(128, 255), this.Rand.Next(128, 255), this.Rand.Next(128, 255), this.Rand.Next(128, 255));
     this.IsMoveble = true;
     this.IsSelected = false;
     this.NewClash += this.ClashFigure;
     this.Beep += SystemSounds.Beep.Play;
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Figure"/> class.
 /// </summary>
 /// <param name="x">X Coordinate</param>
 /// <param name="y">Y Coordinate</param>
 /// <param name="dx">X Speed</param>
 /// <param name="dy">Y Speed</param>
 /// <param name="color">Figure Color</param>
 /// <param name="model">Rectangle Model</param>
 /// <param name="isMove">Can this figure move?</param>
 protected Figure(int x, int y, int dx, int dy, Color color, Rectangle model, bool isMove)
 {
     this.X          = x;
     this.Y          = y;
     this.Dx         = dx;
     this.Dy         = dy;
     this.color      = color;
     this.Model      = model;
     this.IsMoveble  = isMove;
     this.IsSelected = false;
     this.Rand       = new RandomNotNull();
     this.NewClash  += this.ClashFigure;
     this.Beep      += SystemSounds.Beep.Play;
 }
コード例 #4
0
        public void DetourIsBypassedByOriginalFunction()
        {
            using (var hook = LocalHook.Create(
                       LocalHook.GetProcAddress("kernel32.dll", "Beep"),
                       new BeepDelegate(BeepHook),
                       this))
            {
                _beepHookCalled = false;

                hook.ThreadACL.SetInclusiveACL(new int[] { 0 });

                BeepDelegate beep = (BeepDelegate)Marshal.GetDelegateForFunctionPointer(hook.HookBypassAddress, typeof(BeepDelegate));

                Assert.True(beep(100, 100));

                Assert.False(_beepHookCalled);
            }
        }
コード例 #5
0
        public void HookBypassAddress_DoesNotCallHook()
        {
            // Install MAX_HOOK_COUNT hooks (i.e. 1024)
            LocalHook lh = LocalHook.Create(
                LocalHook.GetProcAddress("kernel32.dll", "Beep"),
                new BeepDelegate(BeepHook),
                this);

            lh.ThreadACL.SetInclusiveACL(new int[] { 0 });

            Assert.IsFalse(Beep(100, 100));

            Assert.IsTrue(_beepHookCalled);

            _beepHookCalled = false;

            BeepDelegate b = (BeepDelegate)Marshal.GetDelegateForFunctionPointer(lh.HookBypassAddress, typeof(BeepDelegate));

            b(100, 100);
            Assert.IsFalse(_beepHookCalled);
        }
コード例 #6
0
ファイル: Figure.cs プロジェクト: AlexKhatun/RunningFigures
 /// <summary>
 /// Initializes a new instance of the <see cref="Figure"/> class. 
 /// </summary>
 /// <param name="x">X Coordinate</param>
 /// <param name="y">Y Coordinate</param>
 /// <param name="dx">X Speed</param>
 /// <param name="dy">Y Speed</param>
 /// <param name="color">Figure Color</param>
 /// <param name="model">Rectangle Model</param>
 /// <param name="isMove">Can this figure move?</param>
 protected Figure(int x, int y, int dx, int dy, Color color, Rectangle model, bool isMove)
 {
     this.X = x;
     this.Y = y;
     this.Dx = dx;
     this.Dy = dy;
     this.color = color;
     this.Model = model;
     this.IsMoveble = isMove;
     this.IsSelected = false;
     this.Rand = new RandomNotNull();
     this.NewClash += this.ClashFigure;
     this.Beep += SystemSounds.Beep.Play;
 }
コード例 #7
0
ファイル: Figure.cs プロジェクト: AlexKhatun/RunningFigures
 /// <summary>
 /// Remove beep from Figure clash event
 /// </summary>
 public void RemoveBeep()
 {
     this.Beep -= SystemSounds.Beep.Play;
 }
コード例 #8
0
ファイル: Figure.cs プロジェクト: AlexKhatun/RunningFigures
 /// <summary>
 /// Add beep to Figure clash event
 /// </summary>
 public void AddBeep()
 {
     this.Beep += SystemSounds.Beep.Play;
 }
コード例 #9
0
 /// <summary>
 /// Remove beep from Figure clash event
 /// </summary>
 public void RemoveBeep()
 {
     this.Beep -= SystemSounds.Beep.Play;
 }
コード例 #10
0
 /// <summary>
 /// Add beep to Figure clash event
 /// </summary>
 public void AddBeep()
 {
     this.Beep += SystemSounds.Beep.Play;
 }