示例#1
0
文件: App.cs 项目: nandorrefi/Signals
        public void OpenDocumentWithView()
        {
            string path = "";

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = "c:\\";
                openFileDialog.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    path = openFileDialog.FileName;
                }
                else
                {
                    return;
                }
            }

            string         docName   = System.IO.Path.GetFileName(path);
            SignalDocument openedDoc = new SignalDocument(docName);

            documents.Add(openedDoc);
            CreateView(openedDoc, true);

            openedDoc.LoadDocument(path);
        }
示例#2
0
 public GraphicsSignalView(SignalDocument document)
 {
     InitializeComponent();
     InitTimer();
     this.document   = document;
     signals         = document.Signals;
     prevSignalCount = signals.Count;
 }
示例#3
0
文件: App.cs 项目: Szaki/Signals
        public void NewDocument()
        {
            NewDocForm form = new NewDocForm();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            SignalDocument doc = new SignalDocument(form.DocName);

            documents.Add(doc);
            createView(doc, true);
        }
示例#4
0
文件: App.cs 项目: juzername/grafikon
        /// <summary>
        /// Megnyit egy dokumentumot. Nincs implementálva.
        /// </summary>
        public void OpenDocument()
        {
            // 1. Fájl útvonal megkérdezése a felhasználótól (OpenFileDialog).
            // http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx
            // Lényeges, hogy az MSDN-ben látható példával ellentétben NE nyissuk meg a fájlt
            // a dialóguson OpenFile hívásával, helyette egyszerűen a FileName property
            // segítségével kérdezzük le a felhasználó által megadott útvonalat (amennyiben
            // a felhasználó az OK-kal zárta be az ablakot).
            string filename = "";

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = "c:\\";
                openFileDialog.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Get the path of specified file
                    filename = openFileDialog.FileName;
                }
            }


            // 2. Új dokumentum objektum létrehozása, regisztrálása, nézet létrehozása, stb.
            // , a NewDocument művelet szolgálhat mintaként.
            // A dokumentum neve a fájl neve legyen a könyvtár nélkül (ehhez használja a
            // System.IO.Path osztály GetFileName statikus függvényét)
            Document doc = new SignalDocument(Path.GetFileName(filename));

            documents.Add(doc);
            createView(doc, true);


            // 3. Dokumentumba adatok betöltése (LoadDocument hívása  dokumentum objektumon)
            doc.LoadDocument(filename);

            // 4. Nézetek értesítése, hogy frissítsék magukat.
            // Megjegyzés. Erre alapvetően a dokumentum osztály UpdateAllViews művelete használandó.
            // Ez viszont  protected , itt nem elérhető. Ne  tegye publikussá! Helyette kövesse
            // az egységbezárás alapelvét: az előző, 3. lépésben meghívta a SignalDocument.LoadDocument
            // műveletét. Tegye az UpdateAllViews hívást a LoadDocument végére. A Document-View
            // architektúrának ez az egyik lényegi pontja: minden dokumentum módosító művelet végére
            // oda kell tenni az UpdateAllViews hívást, hogy a nézetek tükrözzék a változásokat.
        }
示例#5
0
文件: App.cs 项目: juzername/grafikon
        /// <summary>
        /// Létrehoz egy új dokumentumot a hozzá tartozó nézettel.
        /// </summary>
        public void NewDocument()
        {
            // Bekérdezzük az új font típus (dokumentum) nevét a felhasználótól egy modális dialógs ablakban.
            NewDocForm form = new NewDocForm();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            // Új dokumentum objektum létrehozása és felvétele a dokumentum listába.
            // TODO: ne a Document-et példányosítsuk, hanem a leszármazottunkat
            SignalDocument doc = new SignalDocument(form.DocName);

            documents.Add(doc);
            createView(doc, true);
        }
示例#6
0
        /// <summary>
        /// Creates a new document with a corresponding view
        /// </summary>
        public void NewDocument()
        {
            // Read the name of the document in a modal dialog
            NewDocForm form = new NewDocForm();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            // Create a new document and add it to the list of documents
            // TODO: instantiate the concrete document, instead
            SignalDocument doc = new SignalDocument(form.DocName); // changed it from Document to SignalDocument

            documents.Add(doc);                                    // add it to the list of documents
            createView(doc, true);                                 // make the view
        }
示例#7
0
        /// <summary>
        /// Opens a document. Not implemented yet.
        /// </summary>
        public void OpenDocument()
        {
            // 1. Get the file path from the user (OpenFileDialog)
            // http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx
            // As opposed to the example in the MSDN dont open the file with OpenFile.
            // Instead, just get the file path selected by the user with the FileName property
            // (only if the user pressed the OK button and not something else).

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog.FilterIndex      = 0;
            openFileDialog.RestoreDirectory = true;

            if (openFileDialog.ShowDialog() == DialogResult.OK) // after clicking OK in the Open Dialog we receive the file path(filename)
            {
                filename = openFileDialog.FileName;
            }
            ;

            // 2. Crate a new document, register it, create its first view, etc.
            // ... just like in the NewDocument method.
            // Use the filename as the name of the document (use the GetFileNam static method of System.IO.Path).

            //  NewDocForm form = new NewDocForm();

            SignalDocument doc = new SignalDocument(filename); //we create a new signal doc with the filename received

            documents.Add(doc);                                // add it to documents
            createView(doc, true);                             //make the new view

            // 3. Load the data to the document (call the LoadDocument method of the document).

            doc.LoadDocument(filename); //we load the document

            // 4. Notify the views to refresh themselves.
            // Note: the UpdateAllViews method of the document class is responsible for it.
            // Though, it is protected and you cannot access that from here. Dont make it public.
            // Follow the principle of encapsulation. In the previous step you called the
            // SignalDocument.LoadDocument method of the document. Call UpdateAllViews at the end of
            // the LoadDocument method. This is one of the crucial points of the Document-View
            // architecture that all the operations that modify the document should call the UpdateAllViews
            // methods to notify the views about the change (so that they can refresh themselves).
        }
示例#8
0
文件: App.cs 项目: Szaki/Signals
        public void OpenDocument()
        {
            OpenFileDialog od = new OpenFileDialog();

            if (od.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string path = od.FileName;


            SignalDocument doc = new SignalDocument(System.IO.Path.GetFileName(path));

            documents.Add(doc);
            createView(doc, true);


            doc.LoadDocument(path);
        }
示例#9
0
 public GraphicsSignalView(SignalDocument document)
 {
     InitializeComponent();
     this.document = document;
 }