Пример #1
0
        /// <summary>
        /// Создание маркера
        /// </summary>
        /// <param name="type">Тип маркера</param>
        /// <param name="posX">Нормированная координата маркера по горизонтали</param>
        /// <param name="posY">Нормированная координата маркера по вертикали</param>
        /// <param name="cursor">Курсор на маркере</param>
        /// <param name="anchorX">Нормированная координата якоря по горизонтали</param>
        /// <param name="anchorY">Нормированная координата якоря по вертикали</param>
        /// <param name="offsetX">Смещение координаты якоря по горизонтали </param>
        /// <param name="offsetY">Смещение координаты якоря по вертикали</param>
        /// <returns></returns>
        private Marker CreateMarker(MarkerType type, float posX, float posY, UserCursor cursor,
                                    float anchorX, float anchorY, float offsetX = 0, float offsetY = 0)
        {
            var normPoint = new PointF(posX, posY);
            var anchPoint = new PointF(anchorX, anchorY);

            return(new Marker
            {
                MarkerType = type,
                Cursor = CursorFactory.GetCursor(cursor),
                Position = _selection.ToWorldCoordinates(normPoint).Add(new PointF(offsetX, offsetY)),
                AnchorPosition = _selection.ToWorldCoordinates(anchPoint)
            });
        }
Пример #2
0
 /// <summary>
 /// Взять подготовленный курсор из словаря
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public static Cursor GetCursor(UserCursor name)
 {
     return(UserCursors.ContainsKey(name) ? UserCursors[name] : Cursors.No);
 }
Пример #3
0
        /// <summary> Draws the menu </summary>
        public void menu(MenuObj menu)
        {
            // Used to know the center of the screen
            int middle_W = max_W / 2;
            int middle_H = max_H / 2;

            // Used to get the selected word from the menu
            UserCursor cursor = new UserCursor(menu.Options[menu.selectedOption]);

            // This here is to center the words on the screen
            int n_filas = menu.Options.Length;

            // This ones measure the offset from the middle of the screen
            int leftOffset;
            int verticalOffset = n_filas / 2;

            // Variables used for a complex loop of iteration
            int j = 0;
            int i = 0;

            string temp;

            if (n_filas % 2 == 0)
            {
                Console.Clear();
                // Writes the top strings on the list and the middle one
                for (i = verticalOffset; i > 0; i--, j++)
                {
                    if (j == menu.selectedOption)
                    {
                        temp = cursor.getSelected();
                    }
                    else
                    {
                        temp = menu.Options[j];
                    }

                    leftOffset = temp.Length / 2;
                    Console.SetCursorPosition(middle_W - leftOffset, middle_H - i);
                    Console.Write(temp);
                }

                // Writes the rest of the strings
                for (i = 0; i < verticalOffset; i++, j++)
                {
                    if (j == menu.selectedOption)
                    {
                        temp = cursor.getSelected();
                    }
                    else
                    {
                        temp = menu.Options[j];
                    }

                    leftOffset = temp.Length / 2;
                    Console.SetCursorPosition(middle_W - leftOffset, middle_H + i);
                    Console.Write(temp);
                }
            }
            else
            {
                Console.Clear();
                // Writes the top strings on the list and the middle one
                for (i = verticalOffset; i >= 0; i--, j++)
                {
                    if (j == menu.selectedOption)
                    {
                        temp = cursor.getSelected();
                    }
                    else
                    {
                        temp = menu.Options[j];
                    }

                    leftOffset = temp.Length / 2;
                    Console.SetCursorPosition(middle_W - leftOffset, middle_H - i);
                    Console.Write(temp);
                }

                // Writes the rest of the strings
                for (i = 1; i <= verticalOffset; i++, j++)
                {
                    if (j == menu.selectedOption)
                    {
                        temp = cursor.getSelected();
                    }
                    else
                    {
                        temp = menu.Options[j];
                    }

                    leftOffset = temp.Length / 2;
                    Console.SetCursorPosition(middle_W - leftOffset, middle_H + i);
                    Console.Write(temp);
                }
            }
        }
Пример #4
0
 /// <summary>
 /// Добавить курсор из ресурсов программы
 /// </summary>
 /// <param name="name"></param>
 /// <param name="source"></param>
 private static void AddCursor(UserCursor name, byte[] source)
 {
     using (var stream = new MemoryStream(source))
         UserCursors.Add(name, new Cursor(stream));
 }
Пример #5
0
 public void Update()
 {
     step.Paint();
     UserField.Update();
     UserCursor.ShowCursor();
 }