Ejemplo n.º 1
0
        /* События */

        /// <summary>
        /// Событие выбора элемента списка знаков
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listSigns_SelectedValueChanged(object sender, EventArgs e)
        {
            try
            {
                int index = ((ListBox)sender).SelectedIndex;

                if (index != -1)
                {
                    ImageWorker IM   = new ImageWorker();
                    road_sign   sign = PE.road_sign.ToArray <road_sign>()[index];

                    pbImage.BackgroundImage = IM.GetImageByRelativePath(sign.img);

                    tbType.Text        = PE.type_road_sign.Where(x => x.code_type_road_sign == sign.code_type_sign).First().name;
                    tbDescription.Text = sign.description;

                    listResolution.Items.Clear();
                    listProhibishin.Items.Clear();

                    foreach (act item in PE.item_list_resolution.Where(x => x.code_road_sign == sign.code_road_sign).Select(x => x.act))
                    {
                        listResolution.Items.Add(item.name);
                    }

                    foreach (act item in PE.item_list_prohibition.Where(x => x.code_road_sign == sign.code_road_sign).Select(x => x.act))
                    {
                        listProhibishin.Items.Add(item.name);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Удаление знака из контейнера выбранных знаков
        /// </summary>
        /// <param name="sign"></param>
        private void RemoveFromFlowSelectedSigns(road_sign sign)
        {
            try
            {
                PictureBox removed = null;
                foreach (PictureBox item in flowListSelectedSign.Controls)
                {
                    if (item.Tag != null && item.Tag.ToString() == sign.pdd_number)
                    {
                        removed = item;
                        break;
                    }
                }

                if (removed != null)
                {
                    flowListSelectedSign.Controls.Remove(removed);
                }

                SelectedSign.Remove(sign);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Добавление знака в контейнер выбранных знаков
        /// </summary>
        /// <param name="sign"></param>
        private void AddToFlowSelectedSigns(road_sign sign)
        {
            try
            {
                foreach (PictureBox item in flowListSelectedSign.Controls)
                {
                    if (item.Tag != null && item.Tag.ToString() == sign.pdd_number)
                    {
                        return;
                    }
                }

                ImageWorker IM = new ImageWorker();

                PictureBox pb = new PictureBox();
                pb.BackgroundImage       = IM.GetImageByRelativePath(sign.img);
                pb.Width                 = 64;
                pb.Height                = 64;
                pb.Tag                   = sign.pdd_number;
                pb.BackgroundImageLayout = ImageLayout.Stretch;

                flowListSelectedSign.Controls.Add(pb);
                SelectedSign.Add(sign);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Применение изменений
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                int index = listSigns.SelectedIndex;

                if (index != -1)
                {
                    road_sign sign = PE.road_sign.ToArray <road_sign>()[index];

                    PE.road_sign.Where(x => x.code_road_sign == sign.code_road_sign).First().description = tbDescription.Text;

                    var lP = PE.item_list_prohibition.Where(x => x.code_road_sign == sign.code_road_sign);
                    foreach (var item in lP)
                    {
                        PE.item_list_prohibition.Remove(item);
                    }

                    var lR = PE.item_list_resolution.Where(x => x.code_road_sign == sign.code_road_sign);
                    foreach (var item in lR)
                    {
                        PE.item_list_resolution.Remove(item);
                    }

                    PE.SaveChanges();

                    foreach (string item in listResolution.Items)
                    {
                        act _act = PE.act.Where(x => x.name == item).First();

                        item_list_resolution iR = new item_list_resolution();
                        iR.code_road_sign = sign.code_road_sign;
                        iR.code_act       = _act.code_act;

                        PE.item_list_resolution.Add(iR);
                        PE.SaveChanges();
                    }

                    foreach (string item in listProhibishin.Items)
                    {
                        act _act = PE.act.Where(x => x.name == item).First();

                        item_list_prohibition iP = new item_list_prohibition();
                        iP.code_road_sign = sign.code_road_sign;
                        iP.code_act       = _act.code_act;

                        PE.item_list_prohibition.Add(iP);
                        PE.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }
Ejemplo n.º 5
0
        public SignPanel(road_sign sign, Bitmap image, MainWindow parent)
        {
            InitializeComponent();

            this.Sign         = sign;
            this.ParentWindow = parent;

            this.lbNumber.Text      = sign.pdd_number;
            this.tnName.Text        = sign.name;
            this.cbSelected.Checked = false;

            ImageWorker IW = new ImageWorker();

            pbImage.BackgroundImage = IW.GetImageByRelativePath(sign.img);
        }
Ejemplo n.º 6
0
        private void tsDeleteSing_Click(object sender, EventArgs e)
        {
            if (listSigns.SelectedIndex > -1)
            {
                road_sign deleteSing = PE.road_sign.ToArray <road_sign>()[listSigns.SelectedIndex];

                PE.road_sign.Remove(deleteSing);

                PE.SaveChanges();

                InitSigns();
                MessageBox.Show("Знак удалён");

                if (listSigns.Items.Count > 0)
                {
                    listSigns.SelectedIndex = 0;
                }
            }
        }
Ejemplo n.º 7
0
        private void AddNewSign()
        {
            road_sign newSign = new road_sign();

            newSign.name           = tbName.Text;
            newSign.pdd_number     = tbNumber.Text;
            newSign.code_type_sign = PE.type_road_sign.ToArray <type_road_sign>()[cbType.SelectedIndex].code_type_road_sign;
            newSign.description    = tbDescription.Text;

            ImageWorker IM = new ImageWorker();

            IM.CopyImageByName(tbPath.Text, newSign.pdd_number.Replace('.', '_'));
            newSign.img = newSign.pdd_number.Replace('.', '_') + ".png";

            PE.road_sign.Add(newSign);
            PE.SaveChanges();

            foreach (string item in listResolution.Items)
            {
                act _act = PE.act.Where(x => x.name == item).First();

                item_list_resolution iR = new item_list_resolution();
                iR.code_road_sign = newSign.code_road_sign;
                iR.code_act       = _act.code_act;

                PE.item_list_resolution.Add(iR);
                PE.SaveChanges();
            }

            foreach (string item in listProhibishin.Items)
            {
                act _act = PE.act.Where(x => x.name == item).First();

                item_list_prohibition iP = new item_list_prohibition();
                iP.code_road_sign = newSign.code_road_sign;
                iP.code_act       = _act.code_act;

                PE.item_list_prohibition.Add(iP);
                PE.SaveChanges();
            }

            this.Close();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Выбор состояния знака выбран/не выбран
        /// </summary>
        /// <param name="sign"></param>
        /// <param name="flag"></param>
        public void SelectedItem(road_sign sign, bool flag)
        {
            try
            {
                if (flag)
                {
                    AddToFlowSelectedSigns(sign);
                }
                else
                {
                    RemoveFromFlowSelectedSigns(sign);
                }

                UpdateResult();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }