Пример #1
0
        public void load(string path)
        {
            //clear lists
            elements.Clear();
            connections.Clear();
            element_counter = 0;
            //load file
            savable temp = new savable();

            using (StreamReader file = File.OpenText(path))
            {
                JsonSerializer serializer = new JsonSerializer();
                temp = (savable)serializer.Deserialize(file, typeof(savable));
            }
            foreach (element_object e in temp.elements)
            {
                PictureBox p = new PictureBox();
                p.SizeMode   = PictureBoxSizeMode.StretchImage;
                p.ClientSize = new Size(e.width, e.hight);
                p.Location   = e.location;
                p.BackColor  = e.colour;
                p.Name       = e.type + element_counter;
                element_counter++;
                p.Visible = true;
                p.Draggable(true);
                Component c = new Component(e.name, e.voltage, e.current, e.resistance, e.numconnections, p, e.type);
                elements.Add(c);
            }
            foreach (Tuple <string, string> t in temp.connections)
            {
                connections.Add(t);
            }
            element_counter = temp.element_counter;
        }
Пример #2
0
        private void pictureBox4_Click(object sender, EventArgs e)      //While
        {
            PictureBox namelabel = new PictureBox();

            namelabel.Location = new Point(1659, 36);
            namelabel.Tag      = "While";
            namelabel.AutoSize = true;
            // namelabel.DragDrop += new DragEventHandler(namelabel_DragDrop);
            namelabel.Draggable(true);
            namelabel.Image = global::WindowsFormsApplication2.Properties.Resources._while;
            this.Controls.Add(namelabel);
            namelabel.BringToFront();
        }
Пример #3
0
        public void GenerarDetectorZona(int posx, int posy, string tipo, int sizepx, string name, bool mover, int idDetector, Image img, string identificador, string dispositivo, string tipoDispositivo, string figura)

        {
            try
            {
                PictureBox p = new PictureBox();
                p.Location = new Point(posx, posy);

                p.BringToFront();
                if (figura == "Círculo")
                {
                    var path = new System.Drawing.Drawing2D.GraphicsPath();
                    path.AddEllipse(0, 0, sizepx, sizepx);

                    p.Region = new Region(path);
                }
                else
                {
                    p.Size = new Size(sizepx, sizepx);
                }

                p.Tag       = tipo + "*" + idDetector.ToString() + "*" + identificador + "*" + sizepx.ToString() + "*" + name.Trim() + "*" + dispositivo + "*" + tipoDispositivo + "*" + figura;
                p.Image     = null;
                p.BackColor = Color.Transparent;
                p.SizeMode  = PictureBoxSizeMode.StretchImage;
                p.BackColor = Color.Transparent;
                p.Draggable(mover);
                p.MouseHover += new EventHandler(Panel_Hover);
                p.MouseLeave += new EventHandler(Panel_Leave);

                PictureBox pic = FindPictureBox();



                Action action = () =>
                {
                    pic.Controls.Add(p);
                };
                pic.Invoke(action);
            }

            catch (ArgumentNullException ex)
            {
                Console.WriteLine("MONITOREO GENERAR DETECTOR");
                TimerLeerStatusDetector.Start();
                border_timer.Start();
            }
        }
Пример #4
0
        private void LoadXmlData(string filename)
        {
            string path = Path.GetDirectoryName(filename) + "\\";

            XmlDocument xml = new XmlDocument();

            xml.Load(filename);

            XmlNode root = xml.SelectNodes("/map")[0];

            path += root.Attributes.GetNamedItem("name").InnerText + "\\";

            XmlNode image = xml.SelectNodes("/map/firstregion/image")[0];

            _frmMain.MapImage = Image.FromFile(path + image.InnerText);

            txtImage.Text = path + image.InnerText;

            lstRegion.Items.Clear();

            foreach (XmlNode pr in xml.SelectNodes("/map/firstregion/region"))
            {
                string name = pr.Attributes.GetNamedItem("text").InnerText;
                Point  loc  = new Point(Convert.ToInt32(pr.SelectNodes("loc")[0].InnerText.Split(',')[0]), Convert.ToInt32(pr.SelectNodes("loc")[0].InnerText.Split(',')[1]));

                PictureBox pb = new PictureBox();
                pb.Image     = Image.FromFile(".\\ico_region.png");
                pb.Size      = new Size(32, 32);
                pb.Location  = loc;
                pb.SizeMode  = PictureBoxSizeMode.StretchImage;
                pb.BackColor = Color.Transparent;
                _frmMain.toolTip.SetToolTip(pb, name);
                pb.Draggable(true);

                _frmMain.Controls.Add(pb);

                Region reg = new Region();
                reg.Name = name;

                _map.Regions.Add(reg, pb);
                lstRegion.Items.Add(name);
            }
        }
Пример #5
0
        public PictureBox addelement(Color colour, string name, int x, int y, double v, double c, double r, double n)
        {
            PictureBox temp = new PictureBox();

            temp.SizeMode   = PictureBoxSizeMode.StretchImage;
            temp.ClientSize = new Size(x, y);
            temp.Location   = new Point(100, 40);
            temp.BackColor  = colour;
            temp.Name       = name + element_counter;
            element_counter++;
            temp.Visible = true;
            temp.Draggable(true);
            //test.Image = Image.FromFile("images\\resistor.jpg");    add images later, replace colour with image file
            //creates the resistor object
            Component element = new Component(temp.Name, v, c, r, n, temp, name);

            elements.Add(element);
            return(temp);
        }
Пример #6
0
        private void btnAddRegion_Click(object sender, EventArgs e)
        {
            string region_name = Microsoft.VisualBasic.Interaction.InputBox("지역 이름을 입력해 주세요.");

            if (region_name.Trim() == string.Empty)
            {
                MessageBox.Show("지역 이름은 공백일 수 없습니다.", "RTMapTool", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (_map.Regions.Keys.FirstOrDefault(x => x.Name == region_name) != null)
            {
                MessageBox.Show("이미 존재하는 지역입니다.", "RTMapTool", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            PictureBox pb = new PictureBox();

            pb.Image     = Image.FromFile(".\\ico_region.png");
            pb.Size      = new Size(32, 32);
            pb.Location  = new Point(_frmMain.ClientSize.Width / 2, _frmMain.ClientSize.Height / 2);
            pb.SizeMode  = PictureBoxSizeMode.StretchImage;
            pb.BackColor = Color.Transparent;
            _frmMain.toolTip.SetToolTip(pb, region_name);
            pb.Draggable(true);

            _frmMain.Controls.Add(pb);

            Region reg = new Region();

            reg.Name = region_name;

            _map.Regions.Add(reg, pb);
            lstRegion.Items.Add(region_name);

            isSaved = false;
        }
Пример #7
0
        public void GenerarDetectorZona(int posx, int posy, string tipo, int sizepx, string name, bool mover, int idDetector, Image img, string identificador, string dispositivo, string tipoDispositivo, string figura)
        {
            //NameZoneForm form = new NameZoneForm();
            //form.ShowDialog();


            PictureBox p = new PictureBox();

            p.Location = new Point(posx, posy);
            pictureBox1.Controls.Add(p);
            p.BringToFront();
            if (figura == "Círculo")
            {
                var path = new System.Drawing.Drawing2D.GraphicsPath();
                path.AddEllipse(0, 0, sizepx, sizepx);

                p.Region = new Region(path);
            }
            else
            {
                p.Size = new Size(sizepx, sizepx);
            }

            p.Tag       = tipo + "*" + idDetector.ToString() + "*" + identificador + "*" + sizepx.ToString() + "*" + name.Trim() + "*" + dispositivo + "*" + tipoDispositivo + "*" + figura;
            p.Image     = img;
            p.SizeMode  = PictureBoxSizeMode.StretchImage;
            p.BackColor = Color.Transparent;
            p.Draggable(mover);
            p.MouseHover += new EventHandler(Panel_Hover);
            p.MouseLeave += new EventHandler(Panel_Leave);
            if (mover)
            {
                p.MouseUp     += new MouseEventHandler(Panel_Click);
                p.DoubleClick += new EventHandler(Panel_DoubleClick);
            }
        }
Пример #8
0
        public bool Load_v100(string filename)
        {
            try
            {
                using (BinaryReader sr = new BinaryReader(File.Open(filename, FileMode.Open)))
                {
                    string path = Path.GetDirectoryName(filename) + @"\";

                    byte[] mark = sr.ReadBytes(4);
                    if (Encoding.UTF8.GetString(mark) != "RTAF")
                    {
                        throw new Exception("올바른 에드온 파일이 아닙니다.");
                    }

                    int ver = sr.ReadInt32();

                    if (ver != 100)
                    {
                        throw new Exception("지원하지 않는 에드온 파일 버전 입니다.");
                    }

                    bool pass = sr.ReadBoolean();
                    Developer = GetDecodeStr(sr.ReadString(), pass);

                    if (pass)
                    {
                        string temp = sr.ReadString();

                        Password = string.Empty;
                        while (Password == string.Empty)
                        {
                            Password = Microsoft.VisualBasic.Interaction.InputBox("비밀 번호를 입력하세요.", "RTMapTool");

                            if (Password != GetDecodeStr(temp, true))
                            {
                                Password = string.Empty;

                                if (MessageBox.Show("올바르지 않은 비밀번호 입니다.", "RTMapTool", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.Cancel)
                                {
                                    return(false);
                                }
                            }
                        }
                    }

                    // 맵 정보
                    string proj_name = GetDecodeStr(sr.ReadString(), pass);
                    path += proj_name + "\\";
                    Name  = proj_name;

                    // 1차 행정구역
                    string image = GetDecodeStr(sr.ReadString(), pass);
                    BackImage = path + image;
                    int count = sr.ReadInt32();

                    for (int i = 0; i < count; i++)
                    {
                        string name = GetDecodeStr(sr.ReadString(), pass);

                        PictureBox pb = new PictureBox();
                        pb.Image     = Image.FromFile(".\\ico_region.png");
                        pb.Size      = new Size(32, 32);
                        pb.Location  = new Point(sr.ReadInt32(), sr.ReadInt32());
                        pb.SizeMode  = PictureBoxSizeMode.StretchImage;
                        pb.BackColor = Color.Transparent;
                        pb.Draggable(true);

                        Region reg = new Region();
                        reg.Name = name;

                        _regions.Add(reg, pb);
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "RTMapTool", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }