Exemplo n.º 1
0
 public StickyNote(ApplicationController _app, StickyNote _creator)
 {
     InitializeComponent();
     this.SetStyle(ControlStyles.ResizeRedraw, true);
     app = _app;
     creator = _creator;
 }
Exemplo n.º 2
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();
                }

            }
        }
Exemplo n.º 3
0
        public StickyNote(String _key, String _created, String _modified, String _text,
                          int _show, int _width, int _height, int _font, int _color,
                          Point _p, ApplicationController _app, StickyNote _creator)
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.ResizeRedraw, true);

            app = _app;
            creator = _creator;
            key = _key;
            NoteTextBox.Text = _text;
            created = _created;
            modified = _modified;
            this.Width = _width;
            this.Height = _height;
            this.Location = _p;

            //            setFont();
            //            setColor();
        }
Exemplo n.º 4
0
        public void addRecord(StickyNote note)
        {
            try {
                //addDoc = new XmlDocument();
                //addDoc.Load(document);
                //Select main node
                XmlElement root = activeDocument.DocumentElement;
                XmlElement new_record = activeDocument.CreateElement("note");
                new_record.InnerXml = "<key>" + note.Key + "</key>" +
                    "<show>" + note.NoteShow + "</show>" + "<created>" + note.NoteCreated + "</created>" +
                    "<modified>" + note.Modified + "</modified>" + "<text>" + note.Content + "</text>" +
                    "<topleft>" + Convert.ToString(note.Location.X) + "," + Convert.ToString(note.Location.Y) + "</topleft>" +
                    "<width>" + Convert.ToString(note.Width) + "</width>" + "<height>" + Convert.ToString(note.Height) + "</height>" +
                    "<font>" + Convert.ToString(note.NoteFont) + "</font>" + "<color>" + Convert.ToString(note.NoteColor) + "</color>";

                root.AppendChild(new_record);
                activeDocument.PreserveWhitespace = false;
                activeDocument.Save(document);
                //addDoc = null;
            }
            catch (Exception e) {
                System.Console.WriteLine("Error in Add: " + e.Message);
            }
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
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);
     }
 }
Exemplo n.º 7
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);
            }
        }
Exemplo n.º 8
0
        public void updateRecord(StickyNote note)
        {
            try {
                //updateDoc = new XmlDocument();
                //updateDoc.Load(document);
                XmlNode old_record;
                XmlElement root = activeDocument.DocumentElement;

                old_record = root.SelectSingleNode("/notelist/note[key='" + note.Key + "']");

                XmlElement new_record = activeDocument.CreateElement("note");
                new_record.InnerXml = "<key>" + note.Key + "</key>" +
                    "<show>" + note.NoteShow + "</show>" + "<created>" + note.NoteCreated + "</created>" +
                    "<modified>" + note.Modified + "</modified>" + "<text>" + note.Content + "</text>" +
                    "<topleft>" + Convert.ToString(note.Location.X) + "," + Convert.ToString(note.Location.Y) + "</topleft>" +
                    "<width>" + Convert.ToString(note.Width) + "</width>" + "<height>" + Convert.ToString(note.Height) + "</height>" +
                    "<font>" + Convert.ToString(note.NoteFont) + "</font>" + "<color>" + Convert.ToString(note.NoteColor) + "</color>";

                root.ReplaceChild(new_record, old_record);
                activeDocument.PreserveWhitespace = false;
                activeDocument.Save(document);
                //activeDocument = null;

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