Exemplo n.º 1
0
 /// <summary>
 /// Инициализирует экземпляр класса
 /// </summary>
 private void Initialize(PultType Type)
 {
     this.type = Type;
     this.rows = new List <Row>();
     for (int i = 0; i < Type.RowCount; i++)
     {
         Row r = new Row();
         r.Views.Add(new View());
         this.rows.Add(r);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Проверяет, является ли указанный тип пульта допустимым
        /// для текущего процессора
        /// </summary>
        public bool PultTypeAllowed(PultType type)
        {
            bool res = false;

            for (int i = 0; i < this.AvailablePultTypes.Length; i++)
            {
                if (this.AvailablePultTypes[i].Equals(type))
                {
                    res = true;
                }
            }
            return(res);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Возвращает класс, описывающий пульт с указанным числом
        /// строк  символов в каждой из них
        /// </summary>
        public static PultType GetPultType(int RowCount, int SymbolsInRow)
        {
            PultType res = PultType.Pult2x16;

            switch (RowCount)
            {
            case 2:
                if (SymbolsInRow == 12)
                {
                    res = PultType.Pult2x12;
                }
                break;

            case 4:
                res = PultType.Pult4x20;
                break;
            }
            return(res);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Преобразает модель к указанному типу пульта
        /// </summary>
        public void ChangePultType(PultType NewPultType)
        {
            if (!this.IsEmpty && (this.type.RowCount > NewPultType.RowCount || this.type.SymbolsInRow > NewPultType.SymbolsInRow))
            {
                throw new Exception("Невозможно пеобразовать пульт к указанному типу");
            }
            if (this.IsEmpty)
            {
                this.rows.Clear();
                for (int i = 0; i < NewPultType.RowCount; i++)
                {
                    Row r = new Row();
                    r.Views.Add(new View());
                    this.rows.Add(r);
                }
                this.Type = NewPultType;
                return;
            }
            string s = new string(' ', NewPultType.SymbolsInRow - this.type.SymbolsInRow);

            foreach (Row row in this.rows)
            {
                foreach (View view in row.Views)
                {
                    view.Text += s;
                }
            }
            //for (int i = this.type.RowCount; i < NewPultType.RowCount; i++)
            //{
            //    Row r = new Row();
            //    r.Views.Add(new View());
            //    this.rows.Insert(i - this.type.RowCount, r);
            //}
            for (int i = 1; i < 3; i++)
            {
                Row r = new Row();
                r.Views.Add(new View());
                this.rows.Insert(i, r);
            }

            this.type = NewPultType;
        }
Exemplo n.º 5
0
        /// <summary>
        /// загружает модель пульта из указанного файла
        /// </summary>
        public static RelkonPultModel FromFile(string FileName)
        {
            RelkonPultModel res     = null;
            PultFileVersion version = RelkonPultModel.GetPultFileVersion(FileName);

            switch (version)
            {
            //case PultFileVersion.v35:
            //    res = RelkonPultModel.GetPultModelFromFpr(FileName);
            //    break;
            //case PultFileVersion.v37:
            //    res = RelkonPultModel.GetPultModelFromPlt37(FileName);
            //    break;
            case PultFileVersion.v50:
                res = RelkonPultModel.GetPultModelFromPlt5(FileName);
                break;
            }
            res.fileName = FileName;
            if (res.type == null)
            {
                res.type = PultType.GetPultType(res.rows.Count, res.rows[0].Views[0].Text.Length);
            }
            return(res);
        }
Exemplo n.º 6
0
        private string fileName; // содержит имя файла, из которого была загружена модель

        public RelkonPultModel(PultType Type)
        {
            this.Initialize(Type);
        }