Sayfalar

Translate Blog

1 Mayıs 2013 Çarşamba

Flash AS3 Movie Klip İçinden Root'a Erişmek / How To Call A Function on Root From MovieClip

Flash Action Script 3 ile bir movieclip'in içinden ana sahnede tanımladığınız bir fonksiyonu çağırmak başa beladır. Basit bir yolu da var tabi.
Ana sahnedeki kodumuzun sahneyeGel() olsun.
Siz onu çok çok derinlerde bulunan bir movie clipten çalıştırmak istiyorsanız

If you want to run a function on root from a deep deep movieclip you can use this code to call your function. sahneyeGel() is a function that written on root. And you can call this function from any movie clip with this code.

Object(root).sahneyeGel();

Komutu işinizi görecektir.

19 Nisan 2013 Cuma

C# Word Belgesi Açmak / Open Office Word Documents

Eğer c# ile office belgelerini açmak istiyorsanız aşağıdaki gibi bir kod kullanmalısınız. Using satırına System.Diagnostics eklemelisiniz. Aksi halde ProcessStartInfo kodu çalışmayacaktır.
Belgenizi açacağınız programın yolunu çift slashlı (//) olarak yazmalı, belgenizin adını seçmeli ve hangi dizinde olduğunu (@"C:\";) da belirlemelisiniz. Bu kodda butona tıklandığında açılan bir a.docx belgesinin örneğidir. 32 veya 64 bitlik bilgisayarlarda Program Files değişmektedir, kalınızda olsun.

If you want to open any document with any program, you should use ProcessStartInfo on c#.
You can use these codes for open word file. Other file types has the same way. Show the main program way  as FileName, and your file that wanted to open as Arguments. This sample show "open a.docx file on C:/ when you click button".


using System.Diagnostics;
using System.IO; //for File.Exist() command

private void button1_Click(object sender, EventArgs e)
        {         
           ProcessStartInfo startInfo = new ProcessStartInfo();
            //32 Bits
            //startInfo.FileName = "C:\\Program Files\\Microsoft Office\\Office12\\WINWORD.EXE";

            //64 bits
            startInfo.FileName = "C:\\Program Files (x86)\\Microsoft Office\\Office12\\WINWORD.EXE";
            startInfo.Arguments = "a.docx";
            startInfo.WorkingDirectory = @"C:\";
            startInfo.WindowStyle = ProcessWindowStyle.Maximized;
            if (File.Exists(startInfo.WorkingDirectory + startInfo.Arguments))
            {
                Process process = Process.Start(startInfo);
            }
            else
            {
                MessageBox.Show("Belge Yok");
            }

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, ....