Sayfalar

Translate Blog

C Sharp etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
C Sharp etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

15 Mayıs 2014 Perşembe

C# İle Yuvarlak Koordinat Kodu / Circle Movement Create Coordinates With C#

i++; değerini bir for veya timer aracılığı ile arttırıp aşağıdaki kodu kullanırsanız YOUROBJECT isimli nesneniz yuvarlak olacak bir çizgi üzerinde hareket edecektir. 50 yarıçaptır. Çemberinizin merkezi 100,100 olarak yazılmıştır.

            Double distanceFromCenter = 50;
            Double angleInDegrees = i * 10;
            Double angleAsRadians = (angleInDegrees * Math.PI) / 180.0;
            Double centerX = 100;
            Double centerY = 100;

            Double x = centerX + Math.Cos(angleAsRadians) * distanceFromCenter;
            Double y = centerY + Math.Sin(angleAsRadians) * distanceFromCenter;
            YOUROBJECT.Location = new Point((int)x,(int)y);


If you want to make your object to spin round on a circle you can use this code. centerX centerY are center of your circle.

This code is a circle around code.

18 Nisan 2013 Perşembe

C# ile Word ve Excel Den Veri Almak / Read Docx Word File Using C#

How to get data from Microsot Office Word file, means docx files.
First of all you must add referance to your project. Rigth Click to your project, click  Add Referance.
Choose the COM tab and find Microsoft Word Object Library. This is for using below code.
Dont forget to add using row.
Below code use a.docx that stay in C drive, and add the whole text into the richedit object. So you should add a button and richedit also.

Öncelikle kodları hemen vereceğim ama office referanslarını eklemeniz lazım projenize.
Proje adınıza sağ klik Add Referance, ordan COM sekmesini açın, listede Microsoft Word Object Library seçeneğini ekleyin.

Kodlarınınzın en yukarısında bulunan using satırına ise şunları ekleyin

using Word = Microsoft.Office.Interop.Word;
Sahnenize bir RichEdit ve buton ekleyin, butonunuza şu kodları ekleyin;
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
            object miss = System.Reflection.Missing.Value;
            object path = @"C:\a.docx";
            object readOnly = true;
            Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
            string totaltext = "";
            for (int i = 0; i < docs.Paragraphs.Count; i++)
            {
                totaltext += " \r\n " + docs.Paragraphs[i + 1].Range.Text.ToString();
            }
            richTextBox1.Text = totaltext;
            docs.Close();
            word.Quit();



İşlem tamam C sürücünüzde bulunan a.docx belgesini okudunuz. Excellide siz deneyin ben denemedim ;) ONun da referansdan eklemelisiniz. Microsoft.Excel, ....