Example #1
0
 private void panel1_MouseUp(object sender, MouseEventArgs e)
 {
     SekilCiz.sekilCizUp();
     if (!sec)
     {
         if (bkare)
         {
             Point[] kareNoktalar = { new Point(x, y), new Point(x, e.Y), new Point(e.X, e.Y), new Point(e.X, y) };
             Kaydet.cokgen(strRenk, kareNoktalar);
         }
         else if (bdaire)
         {
             Kaydet.daire(strRenk, (2 * x - e.X), (2 * y - e.Y), (2 * (e.X - x)), (2 * (e.Y - y)));
         }
         else if (baltigen)
         {
             Point[] altigenNoktalar = { new Point(Math.Abs((x - (e.X - x) / 2)), Math.Abs(y - Math.Abs(e.Y - y))), new Point(Math.Abs(2 * x - e.X), y), new Point(Math.Abs((x - (e.X - x) / 2)), e.Y), new Point((x + (e.X - x) / 2), e.Y), new Point(e.X, y), new Point((x + (e.X - x) / 2), Math.Abs(y - Math.Abs(e.Y - y))) };
             Kaydet.cokgen(strRenk, altigenNoktalar);
         }
         else if (bucgen)
         {
             Point[] ucgenDizi = { new Point(x, y), new Point(Math.Abs(x - (e.X - x)), e.Y), new Point(e.X, e.Y) };
             Kaydet.cokgen(strRenk, ucgenDizi);
         }
     }
     ciz = false;
 }
Example #2
0
        private void kaydetPanel_MouseClick(object sender, MouseEventArgs e)
        {
            if (kaydetPanel.BackColor == Color.YellowGreen)
            {
                MenuArkaplanRenk.ArkaPlanDegis(kaydetPanel, Color.White);
            }
            else
            {
                MenuArkaplanRenk.ArkaPlanDegis(kaydetPanel, Color.YellowGreen);
                MenuArkaplanRenk.ArkaPlanDegis(dosyadanAcPanel, Color.White);
            }
            SaveFileDialog kayit = new SaveFileDialog();

            if (kayit.ShowDialog() == DialogResult.OK)
            {
                Kaydet.butonluKayit(kayit);
            }
        }
        /*-------------------------------------------------------METOT AYRIMI--------------------------------------------------------------- */


        public static void yenidenRenk(string renk, Panel panels) //Seçilen şekli yeniden renklendirmek için kullanıl
        {
            if (secilenSek != null)
            {
                try
                {
                    FileStream   dosyaYaz;
                    StreamWriter yaz;
                    dosyaYaz = new FileStream(Application.StartupPath.ToString() + "\\temporaryDel.tmp", FileMode.Truncate);
                    yaz      = new StreamWriter(dosyaYaz);
                    string[] geciciOku = File.ReadAllLines(Application.StartupPath.ToString() + "\\temporary.tmp");
                    string[] neu       = new string[geciciOku.Length];
                    for (int i = 0; i < geciciOku.Length; i++)
                    {
                        if (geciciOku[i] != secilenSek)
                        {
                            yaz.WriteLine(geciciOku[i]);
                        }
                        else
                        {
                            yaz.WriteLine(geciciOku[i].Replace(geciciOku[i].Split(',')[1], renk));
                        }
                    }
                    yaz.Close();
                    dosyaYaz.Close();
                    dosyaYaz = new FileStream(Application.StartupPath.ToString() + "\\temporary.tmp", FileMode.Truncate);
                    yaz      = new StreamWriter(dosyaYaz);
                    yaz.Write(File.ReadAllText(Application.StartupPath.ToString() + "\\temporaryDel.tmp"));

                    yaz.Close();
                    dosyaYaz.Close();
                    Graphics graf = panels.CreateGraphics();
                    graf.Clear(Color.Gainsboro);
                    Kaydet.dosyaOku(panels);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
        /*-------------------------------------------------------METOT AYRIMI--------------------------------------------------------------- */

        public static void sil(Panel panels) //Seçilen şekli sildirmek için oluşturulan metot.
        {
            if (secilenSek != null)
            {
                try
                {
                    FileStream   dosyaYaz;
                    StreamWriter yaz;
                    dosyaYaz = new FileStream(Application.StartupPath.ToString() + "\\temporaryDel.tmp", FileMode.Truncate);
                    yaz      = new StreamWriter(dosyaYaz);
                    string[] geciciOku = File.ReadAllLines(Application.StartupPath.ToString() + "\\temporary.tmp");
                    for (int i = 0; i < geciciOku.Length; i++)
                    {
                        if (geciciOku[i] != secilenSek)
                        {
                            yaz.WriteLine(geciciOku[i]);
                        }
                    }
                    yaz.Close();
                    dosyaYaz.Close();
                    dosyaYaz = new FileStream(Application.StartupPath.ToString() + "\\temporary.tmp", FileMode.Truncate);
                    yaz      = new StreamWriter(dosyaYaz);
                    yaz.Write(File.ReadAllText(Application.StartupPath.ToString() + "\\temporaryDel.tmp"));

                    yaz.Close();
                    dosyaYaz.Close();
                    Graphics graf = panels.CreateGraphics();
                    graf.Clear(Color.Gainsboro);
                    Kaydet.dosyaOku(panels);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
        public static void isretle(MouseEventArgs e, Panel panel1)  //Şekil seçme metodu.
        {
            int  bnX = e.X, bnY = e.Y;
            bool icerideMi = false;


            string[] oku = File.ReadAllLines(Application.StartupPath.ToString() + "\\temporary.tmp");
            for (int i = 0; i < oku.Length; i++)  //Mouse'un tıklanıldığı yede bir şeklin olup olmadığını tespit ediyorum. Eğer varsa etrafını koordinatlara göre çizdiriyorum.
            {
                if ((oku[i].Split(','))[0] == "D")
                {
                    if (bnX > Convert.ToInt16((oku[i].Split(','))[2]) && bnY > Convert.ToInt16((oku[i].Split(','))[3]) && bnX < (Convert.ToInt16((oku[i].Split(','))[4]) + Convert.ToInt16((oku[i].Split(','))[2])) && bnY < ((Convert.ToInt16((oku[i].Split(','))[5]) + Convert.ToInt16((oku[i].Split(','))[3]))))
                    {
                        secilenSek = oku[i];
                        icerideMi  = true;
                        Graphics grafik = panel1.CreateGraphics();
                        Pen      kalem  = new Pen(Color.HotPink, 3);
                        grafik.Clear(Color.Gainsboro);
                        Kaydet.dosyaOku(panel1);
                        grafik.DrawRectangle(kalem, Convert.ToInt16((oku[i].Split(','))[2]) - 16, Convert.ToInt16((oku[i].Split(','))[3]) - 16, Convert.ToInt16((oku[i].Split(','))[4]) + 32, Convert.ToInt16((oku[i].Split(','))[5]) + 32);
                    }
                }
                else if ((oku[i].Split(','))[0] == "K")
                {
                    if (bnX > Convert.ToInt16((oku[i].Split(','))[2]) && bnY > Convert.ToInt16((oku[i].Split(','))[3]) && bnX < (Convert.ToInt16((oku[i].Split(','))[6])) && bnY < ((Convert.ToInt16((oku[i].Split(','))[5]))))
                    {
                        secilenSek = oku[i];
                        icerideMi  = true;
                        Graphics grafik = panel1.CreateGraphics();
                        Pen      kalem  = new Pen(Color.HotPink, 3);
                        grafik.Clear(Color.Gainsboro);
                        Kaydet.dosyaOku(panel1);
                        grafik.DrawRectangle(kalem, Convert.ToInt16((oku[i].Split(','))[2]) - 16, Convert.ToInt16((oku[i].Split(','))[3]) - 16, Convert.ToInt16((oku[i].Split(','))[8]) - Convert.ToInt16((oku[i].Split(','))[2]) + 32, Convert.ToInt16((oku[i].Split(','))[5]) - Convert.ToInt16((oku[i].Split(','))[3]) + 32);
                    }
                }
                else if ((oku[i].Split(','))[0] == "A")
                {
                    if (bnX > Convert.ToInt16((oku[i].Split(','))[4]) && bnY > Convert.ToInt16((oku[i].Split(','))[3]) && bnX < (Convert.ToInt16((oku[i].Split(','))[10])) && bnY < ((Convert.ToInt16((oku[i].Split(','))[6]))))
                    {
                        secilenSek = oku[i];
                        icerideMi  = true;
                        Graphics grafik = panel1.CreateGraphics();
                        Pen      kalem  = new Pen(Color.HotPink, 3);
                        grafik.Clear(Color.Gainsboro);
                        Kaydet.dosyaOku(panel1);
                        grafik.DrawRectangle(kalem, Convert.ToInt16((oku[i].Split(','))[4]) - 16, Convert.ToInt16((oku[i].Split(','))[3]) - 16, Convert.ToInt16((oku[i].Split(','))[10]) - Convert.ToInt16((oku[i].Split(','))[4]) + 32, Convert.ToInt16((oku[i].Split(','))[7]) - Convert.ToInt16((oku[i].Split(','))[13]) + 32);
                    }
                }
                else if ((oku[i].Split(','))[0] == "U")
                {
                    if (bnX > Convert.ToInt16((oku[i].Split(','))[4]) && bnY > Convert.ToInt16((oku[i].Split(','))[3]) && bnX < (Convert.ToInt16((oku[i].Split(','))[6])) && bnY < ((Convert.ToInt16((oku[i].Split(','))[7]))))
                    {
                        secilenSek = oku[i];
                        icerideMi  = true;
                        Graphics grafik = panel1.CreateGraphics();
                        Pen      kalem  = new Pen(Color.HotPink, 3);
                        grafik.Clear(Color.Gainsboro);
                        Kaydet.dosyaOku(panel1);
                        grafik.DrawRectangle(kalem, Convert.ToInt16((oku[i].Split(','))[4]) - 16, Convert.ToInt16((oku[i].Split(','))[3]) - 16, Convert.ToInt16((oku[i].Split(','))[6]) - Convert.ToInt16((oku[i].Split(','))[4]) + 32, Convert.ToInt16((oku[i].Split(','))[5]) - Convert.ToInt16((oku[i].Split(','))[3]) + 32);
                    }
                }
            }
        }
Example #6
0
 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
 {
     Kaydet.dosyaTemizle();
 }