Example #1
0
        public bool JsonModifyPos(string Title, string Note, string ID, int x, int y, int width, int height, int ColorR, int ColorG, int ColorB)
        {
            List <NotesData> list = new List <NotesData>();

            list = GetAllNotes();

            int index = Convert.ToInt16(ID);

            foreach (NotesData element in list)
            {
                if (element.ID == index)
                {
                    list.Remove(element);
                    break;
                }
            }
            NotesData n = new NotesData();

            n.ID     = index;
            n.Title  = Title;
            n.Note   = Note;
            n.x      = x;
            n.y      = y;
            n.Width  = width;
            n.Height = height;
            n.ColorR = ColorR;
            n.ColorG = ColorG;
            n.ColorB = ColorB;
            list.Add(n);
            return(JsonWrite(list));
        }
Example #2
0
        public bool DeleteNote(string ID)
        {
            List <NotesData> list = new List <NotesData>();

            list = GetAllNotes();
            int       index = Convert.ToInt16(ID);
            NotesData n     = new NotesData();

            foreach (NotesData element in list)
            {
                if (element.ID == index)
                {
                    n = element;
                }
            }
            list.Remove(n);

            if (JsonWrite(list))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        public bool JsonModify(string Title, string Note, string ID)
        {
            List <NotesData> list = new List <NotesData>();

            list = GetAllNotes();

            int       index = Convert.ToInt16(ID);
            NotesData n     = new NotesData();

            n.ID    = index;
            n.Title = Title;
            n.Note  = Note;
            foreach (NotesData element in list)
            {
                if (element.ID == index)
                {
                    n.x = element.x;
                    n.y = element.y;
                    list.Remove(element);
                    break;
                }
            }

            list.Add(n);
            return(JsonWrite(list));
        }
Example #4
0
        public bool JsonWrite(string Title, string Note, int x, int y)
        {
            string path = Application.StartupPath + "\\" + defaultFoldName + "\\" + defaultFileName;

            if (!JsonExist(path))
            {
                JsonCreate();
            }

            string text = System.IO.File.ReadAllText(path);

            //List<NotesData> NoteList = JsonConvert.DeserializeObject<List<NotesData>>(text);
            //if (NoteList == null)
            //{
            //    NoteList = new List<NotesData>();
            //}
            List <NotesData> list = new List <NotesData>();

            NotesData[] node = JsonConvert.DeserializeObject <NotesData[]>(text);
            if (node != null)
            {
                foreach (NotesData i in node)
                {
                    list.Add(i);
                }
            }

            //List<NotesData> NoteList = new List<NotesData>();
            NotesData n = new NotesData();

            n.ID     = GetNoteNum() + 1;
            n.Title  = Title;
            n.Note   = Note;
            n.x      = x;
            n.y      = y;
            n.ColorR = 130;
            n.ColorG = 177;
            n.ColorB = 255;
            //NoteList.Add(n);
            //node[node.Length + 1] = n;
            list.Add(n);
            string JsonData = JsonConvert.SerializeObject(list);

            System.IO.File.WriteAllText(path, JsonData);
            //System.IO.StreamWriter file;
            //file = File.AppendText(path);
            //file.WriteLine(JsonData);
            //file.Close();
            return(true);
        }
Example #5
0
        public NotesData getNote(string ID)
        {
            List <NotesData> list = new List <NotesData>();

            list = GetAllNotes();
            int       index = Convert.ToInt16(ID);
            NotesData n     = new NotesData();

            foreach (NotesData element in list)
            {
                if (element.ID == index)
                {
                    n = element;
                }
            }
            return(n);
        }