Пример #1
0
        public void begin()
        {
            if (Properties.Settings.Default.firstrun == true) {
                // If this is the first time ever the application is being launched.
                Properties.Settings.Default.firstrun = false;
                Properties.Settings.Default.Save();
                app.Main = new MainWindow(2,true,app);

                if (app.Notelist.Count == 0) {  // Nothing stored in XML File
                    StickyNote note = new StickyNote(app, null);
                    app.Notelist.Add(note);
                    app.Xml.addRecord(note);
                    note.Location = new Point(50, 50);
                    note.Show();
                }
            }
            else {
                // Read locally stored XML file and fill notelist Array
                app.Main = new MainWindow(0, Properties.Settings.Default.showmain, app);
                loadLocalContent();
                if (app.Notelist.Count == 0) {  // Nothing stored in XML File
                    StickyNote note = new StickyNote(app, null);
                    app.Notelist.Add(note);
                    app.Xml.addRecord(note);
                    note.Location = new Point(190, 210);
                    note.Show();
                }

            }
        }
Пример #2
0
        private void AddNoteButton_Click(object sender, MouseEventArgs e)
        {
            StickyNote newNote = new StickyNote(app, this);
            Screen screen = Screen.FromControl(this);
            Rectangle workingArea = screen.WorkingArea;
            int workingAreaHalf_X = screen.WorkingArea.Width / 2;
            int workingAreaMax_Y = screen.WorkingArea.Height;

            newX = this.Location.X + this.Width + (newCount * 10);
            newY = this.Location.Y + ((newCount-1) * 10);

            if ((newY +183) > workingAreaMax_Y) {
                newY = this.Location.Y;
                newX = this.Location.X + this.Width + (newCount * 10);
                if (newX > workingAreaHalf_X) {
                    newX = this.Location.X - this.Width - (newCount * 10);
                }
            }
            if (newX > workingAreaHalf_X) {
                newX = this.Location.X - this.Width - (newCount * 10);
            }
            newCount++;
            newNote.Location = new Point(newX, newY);
            app.Notelist.Add(newNote);
            //sync to simplenote to get key, modified, etc.
            app.Xml.addRecord(newNote);
            newNote.Show();
        }
Пример #3
0
 private void newNoteButton_Click_1(object sender, EventArgs e)
 {
     StickyNote newNote;
     try {
         if (app.Notelist.Count > 0) {
             newNote = app.Notelist[app.Notelist.Count - 1];
             if (newNote != null) {
                 newNote.spawnNewNote();
             }
         }
         else {
             newNote = new StickyNote(app, null);
             app.Notelist.Add(newNote);
             newNote.Location = new Point(190, 210);
             newNote.Show();
         }
     }
     catch (Exception errorCreatingNewNote) {
         System.Console.WriteLine(errorCreatingNewNote.Message);
     }
 }
Пример #4
0
        public void Read(List<StickyNote> notelist)
        {
            try {
                if (!System.IO.File.Exists(document)) {
                    // create new XML file here
                    XmlTextWriter textWritter = new XmlTextWriter(document, null);
                    textWritter.WriteStartDocument();
                    textWritter.WriteStartElement("notelist");
                    textWritter.WriteEndElement();

                    textWritter.Close();
                }
                else {

                    xmlReader = new XmlTextReader(document);
                    loading = true;
                    while (xmlReader.Read()) {
                        switch (xmlReader.NodeType) {
                            case XmlNodeType.Element: // The node is an element.
                                if (xmlReader.Name == "key") {
                                    key = xmlReader.ReadString();
                                }
                                if (xmlReader.Name == "created") {
                                    created = xmlReader.ReadString();
                                }
                                if (xmlReader.Name == "modified") {
                                    modified = xmlReader.ReadString();
                                }
                                if (xmlReader.Name == "text") {
                                    text = xmlReader.ReadString();
                                }
                                if (xmlReader.Name == "show") {
                                    show = Convert.ToInt32(xmlReader.ReadString());
                                }
                                if (xmlReader.Name == "topleft") {
                                    String[] temp = xmlReader.ReadString().Split(new char[] { ',' });
                                    topleft = new Point(Convert.ToInt32(temp[0]), Convert.ToInt32(temp[1]));
                                }
                                if (xmlReader.Name == "width") {
                                    width = Convert.ToInt32(xmlReader.ReadString());
                                }
                                if (xmlReader.Name == "height") {
                                    height = Convert.ToInt32(xmlReader.ReadString());
                                }
                                if (xmlReader.Name == "font") {
                                    font = Convert.ToInt32(xmlReader.ReadString());
                                }
                                if (xmlReader.Name == "color") {
                                    color = Convert.ToInt32(xmlReader.ReadString());
                                }
                                break;
                            case XmlNodeType.EndElement:

                                if (xmlReader.Name == "note") { // Create a new Stickynote and insert it into the notelist
                                    note = new StickyNote(key, created, modified, text, show, width, height, font, color, topleft, app, null);
                                    app.Notelist.Add(note);
                                    note.Show();
                                }
                                break;
                        }
                    }
                    loading = false;
                    xmlReader.Close();

                }
            }
            catch (Exception e) {
                System.Console.WriteLine("ERROR in XMLREAD: " + e.Message);
            }
        }