예제 #1
0
        private Size ZoomByRatio(double ratio, Size origSize, CalType calType = CalType.normal)
        {
            int picNewHeigth = 0;
            int picNewWidth  = 0;

            switch (calType)
            {
            case CalType.ceiling:
            {
                picNewWidth  = Convert.ToInt32(Math.Ceiling(origSize.Width * ratio));
                picNewHeigth = Convert.ToInt32(Math.Ceiling(picNewWidth * imgHWRatio));
                break;
            }

            case CalType.normal:
            {
                picNewWidth  = Convert.ToInt32(origSize.Width * ratio);
                picNewHeigth = Convert.ToInt32(picNewWidth * imgHWRatio);
                break;
            }

            case CalType.floor:
            {
                picNewWidth  = Convert.ToInt32(Math.Floor(origSize.Width * ratio));
                picNewHeigth = Convert.ToInt32(Math.Floor(picNewWidth * imgHWRatio));
                break;
            }
            }
            return(new Size(picNewWidth, picNewHeigth));
        }
예제 #2
0
파일: Game1.cs 프로젝트: CXUtk/Algorithm
        /// <summary>
        /// 用于进行处理算法代码及动画效果
        /// </summary>
        /// <param name="para">参数,目前保留</param>
        public void Caculate(CalType alg)
        {
            switch (alg)
            {
            case CalType.InsertionSort:
                InsertSort();
                break;

            case CalType.BubbleSort:
                BubbleSort();
                break;

            case CalType.ShellSort:
                ShellSort();
                break;

            case CalType.QuickSort:
                QuickSort(datas, 0, datas.Length - 1);
                break;

            case CalType.MergeSort:
                MergeSort(datas, 0, datas.Length - 1, temp);
                break;

            default:
                break;
            }
            isFinished = true;
        }
예제 #3
0
파일: Game1.cs 프로젝트: CXUtk/Algorithm
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }
            ms       = Mouse.GetState();
            keyState = Keyboard.GetState();
            if (keyState.IsKeyDown(Keys.OemPlus))
            {
                if (Delay < 1000)
                {
                    Delay += 5;
                }
            }
            if (keyState.IsKeyDown(Keys.OemMinus))
            {
                if (Delay > 5)
                {
                    Delay -= 5;
                }
            }
            if (keyState.IsKeyDown(Keys.D1) && timers[0] > 40)
            {
                timers[0] = 0;
                nAlgorithm++;
                if (nAlgorithm >= (CalType)5)
                {
                    nAlgorithm = CalType.InsertionSort;
                }
            }
            if (ms.LeftButton == ButtonState.Pressed)
            {
                LeftDown = true;
            }
            if (ms.LeftButton == ButtonState.Released)
            {
                LeftDown = false;
            }
            if (timer1 < 180)
            {
                timer1 = 180;
            }
            if (timer1 == 190)
            {
                if (isFinished)
                {
                    timer1 = 200;
                }
            }
            timers[0]++;
            // TODO: Add your update logic here

            base.Update(gameTime);
        }
예제 #4
0
파일: Game1.cs 프로젝트: CXUtk/Algorithm
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     Components.Add(new ObjectManager(this));
     // TODO: Add your initialization logic here
     ScreenWidth  = Window.ClientBounds.Width;
     ScreenHeight = Window.ClientBounds.Height;
     rand         = new Random(DateTime.Now.Millisecond);
     for (int i = 0; i < 10; i++)
     {
         timers.Add(0);
     }
     ResetData();
     nAlgorithm = CalType.BubbleSort;
     base.Initialize();
 }
예제 #5
0
 public void AddCallInfo(int secondsDuartion, CalType type)                      // NOT working properly
 {
     this.TimeOfCall.Add(DateTime.Now);
     this.CallDuration.Add(secondsDuartion);
     this.TypeOfCall.Add(type);
 }