//convertToGameScoreItems == convertToNote
 public static List<NoteData> convertToNote(string json)
 {
     List<NoteData> rsp = new List<NoteData>();
     try
     {
         DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(List<NoteData>));
         using (MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json)))
         {
             rsp = serializer.ReadObject(ms) as List<NoteData>;
         }
     }
     catch (Exception ex) { }
     return rsp;
 }
Example #2
0
        public void Load()
        {
            XmlDocument xDoc = new XmlDocument();
            xDoc.Load(savePath + saveFolder + saveFile);

            foreach(XmlNode xNode in xDoc.SelectNodes("Information/Columns/Column"))
            {
                bool exists = false;
                foreach(DataGridViewColumn col in this.Columns)
                {
                    if (col.HeaderText.Equals(xNode.InnerText))
                    {
                        exists = true;
                        break;
                    }
                }

                if (!exists)
                    this.Columns.Add(xNode.InnerText, xNode.InnerText);
            }

            foreach (XmlNode xNode in xDoc.SelectNodes("Information/Contacts/Person"))
            {
                List<string> info = new List<string>();

                if(xNode.HasChildNodes)
                    foreach(XmlNode node in xNode.ChildNodes)
                        info.Add(node.InnerText);

                bool isEmpty = true;

                foreach(string s in info)
                    if(!String.IsNullOrEmpty(s))
                    {
                        isEmpty = false;
                        break;
                    }

                string[] array = info.ToArray();
                if(!isEmpty)
                    this.Rows.Add(array);
            }
        }
Example #3
0
        private void ReadFromFile()
        {
            if (File.Exists("entries.xml"))
            {
                string xmlString = File.ReadAllText("entries.xml");
                List<LogEntry> entries = new List<LogEntry>();

                using (StreamReader fs = File.OpenText("entries.xml"))
                {
                    var xs = new XmlSerializer(entries.GetType());
                    entries = (List<LogEntry>)xs.Deserialize(fs);
                }

                foreach (LogEntry l in entries)
                {
                    AddEntry(l);
                }
            }
        }
Example #4
0
        private void SaveToFile()
        {
            List<LogEntry> entries = new List<LogEntry>();

            foreach (var c in entriesPanel.Controls)
            {
                LogEntryControl entry = c as LogEntryControl;
                entries.Add(entry.LogEntry);
            }

            var xs = new XmlSerializer(entries.GetType());
            var xml = new StringWriter();
            xs.Serialize(xml, entries);

            File.WriteAllText("entries.xml", xml.ToString());
        }
Example #5
0
        public void Save()
        {
            CheckDirectory();
            XmlDocument xDoc = new XmlDocument();
            xDoc.Load(savePath + saveFolder + saveFile);
            XmlNode xNode = xDoc.SelectSingleNode("Information/Contacts");
            xNode.RemoveAll();
            XmlNode xNode2 = xDoc.SelectSingleNode("Information/Columns");
            xNode2.RemoveAll();

            for (int i = 0; i < this.Columns.Count; i++)
            {
                XmlNode column = xDoc.CreateElement("Column");
                column.InnerText = this.Columns[i].HeaderText;
                xDoc.DocumentElement.SelectSingleNode("Columns").AppendChild(column);
            }

            foreach(DataGridViewRow row in this.Rows)
            {
                XmlNode xTop = xDoc.CreateElement("Person");
                List<XmlNode> otherNodes = new List<XmlNode>();

                for(int i = 0; i < row.Cells.Count; i++)
                {
                    string name = Regex.Replace(this.Columns[i].HeaderText, @"\s+", "");
                    XmlNode node = xDoc.CreateElement(name);
                    node.InnerText = (row.Cells[i].Value == null) ? "" : row.Cells[i].Value.ToString();
                    otherNodes.Add(node);
                }

                foreach (XmlNode node in otherNodes)
                    xTop.AppendChild(node);

                xDoc.DocumentElement.SelectSingleNode("Contacts").AppendChild(xTop);
            }
            xDoc.Save(savePath + saveFolder + saveFile);
        }
Example #6
0
 /// <summary>
 /// Log of all files for installed package
 /// </summary>
 /// <param name="packageFiles">List of intalled package files</param>
 public abstract void SavePackageFiles(List<PackageFile> packageFiles);
Example #7
0
 /// <summary>
 /// Save package files
 /// </summary>
 /// <param name="packageFiles">List of package files</param>
 public static void InsertPackageFiles(List<PackageFile> packageFiles)
 {
     Provider.SavePackageFiles(packageFiles);
 }
Example #8
0
 /// <summary>
 /// конструктор: у точки набор оценок - отрезков
 /// </summary>
 /// <param name="_ratings"> лист оценок </param>
 /// <param name="_name"> имя точки </param>
 public SetRating(List<Segment> _ratings)
 {
     for (int i = 0; i < _ratings.Count; i++)
         ratings.Add(_ratings[i]);
 }
Example #9
0
        public static void TestMethod4()
        {
            int Count = 5;

            Segment[] ratings = new Segment[Count];
            List<Segment> list = new List<Segment>()
                {
                    new Segment(2, 5),
                    new Segment(-1, 9),
                };

            SetRating r = new SetRating(list);
            Segment s = SetRating.Intersection(r);
            ratings[0] = s;

            list = new List<Segment>()
                {
                    new Segment(12, 14),
                    new Segment(12, 15),
                    new Segment(12, 14),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[1] = s;

            list = new List<Segment>()
                {
                    new Segment(1, 2),
                    new Segment(2, 3),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[2] = s;

            list = new List<Segment>()
                {
                    new Segment(2, 9),
                    new Segment(6, 13),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[3] = s;

            list = new List<Segment>()
                {
                    new Segment(2, 29),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[4] = s;

            SetRating.Output(SetRating.GetMatrixOfPartialOrder(ref ratings));

            Console.WriteLine("_________________________");
        }
Example #10
0
        public static void TestMethod1()
        {
            int Count = 3;
            Segment[] ratings = new Segment[Count];

            List<Segment> list = new List<Segment>()
                {
                    new Segment(5, 10),
                    new Segment(7, 9),
                    new Segment(7.0001, 8.5),
                };

            SetRating r = new SetRating(list);
            Segment s = SetRating.Intersection(r);
            ratings[0] = s;

            list = new List<Segment>()
                {
                    new Segment(0.003, 14),
                    new Segment(0.01, 10),
                    new Segment(5, 15),
                    new Segment(4, 20),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[1] = s;

            list = new List<Segment>()
                {
                    new Segment(2, 12),
                    new Segment(3, 4),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[2] = s;

            SetRating.Output(SetRating.GetMatrixOfPartialOrder(ref ratings));

            Console.WriteLine("_________________________");
        }
Example #11
0
        public static void TestMethod()
        {
            int Count = 3;
            Segment[] ratings = new Segment[Count];

            List<Segment> list = new List<Segment>()
                {
                    new Segment(0.0001, 0.0002),
                    new Segment(0.00011, 0.00021),
                    new Segment(0.000111, 0.000211),
                    new Segment(0.0001111, 0.0002111)
                };

            SetRating r = new SetRating(list);
            Segment s = SetRating.Intersection(r);
            ratings[0] = s;

            list = new List<Segment>()
                {
                    new Segment(0.001, 0.01),
                    new Segment(0.0011, 0.011),
                    new Segment(0.00111, 0.0111),
                    new Segment(0.001111, 0.01111),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[1] = s;

            list = new List<Segment>()
                {
                    new Segment(0.1, 1),
                    new Segment(0.11, 1.1),
                    new Segment(0.111, 1.11),
                    new Segment(0.1111, 1.111),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[2] = s;

            SetRating.Output(SetRating.GetMatrixOfPartialOrder(ref ratings));

            Console.WriteLine("_________________________");
        }
Example #12
0
 private void LoadNotes()
 {
     if (this.InvokeRequired) {
         this.Invoke(new ProcessBookDelegate(LoadNotes));
     } else {
         if (string.IsNullOrEmpty(Setting.NotesPath) == false) {
             List<FileInfo> fileInfos = new List<FileInfo>();
             var files = Directory.GetFiles(Setting.NotesPath);
             foreach (string f in files) {
                 fileInfos.Add(new FileInfo(f));
             }
             fileInfos = (from f in fileInfos orderby f.LastWriteTime descending select f).ToList();
             string content = string.Empty;
             DisplayFile filePanel = null;
             NotesList.Controls.Clear();
             Regex regex;
             foreach (var f in fileInfos) {
                 string q = Query.Text.Trim().ToLower();
                 SaveRegistry("Query", q);
                 filePanel = new DisplayFile(f.FullName, this);
                 regex = new Regex(
                   q,
                   RegexOptions.IgnoreCase
                   | RegexOptions.Multiline
                   | RegexOptions.IgnorePatternWhitespace
                   | RegexOptions.Compiled
                   );
                 if (regex.IsMatch(filePanel.DisplayName) || regex.IsMatch(filePanel.Content)) {
                     if (_notes.ContainsKey(f.FullName) == false)
                         _notes.Add(f.FullName, filePanel);
                     NotesList.Controls.Add(filePanel);
                 }
             }
         }
         //Open_CommandLineArgs();
     }
 }