コード例 #1
0
        private void CartesianChart_DataClick(object sender, ChartPoint chartpoint)
        {
            Console.WriteLine("clicked!");
            Random r = new Random();
            var    n = DataValues.Count;

            DataValues.Clear();
            DataValues.AddRange(new double[n].Select(_ => r.Next(60) / 1.0));
        }
コード例 #2
0
ファイル: DataStorage.cs プロジェクト: JustinGZJ/SMD
 public void Load(string FilePath = DEFAULT_PATH)
 {
     lock (_enable)
     {
         if (!File.Exists(FilePath))
         {
             return;
         }
         var str = File.ReadAllText(FilePath);
         try
         {
             var obj = JsonConvert.DeserializeObject <IEnumerable <VAR> >(str);
             DataValues.Clear();
             foreach (var a in obj)
             {
                 DataValues.Add(a);
             }
         }
         catch (Exception ex)
         {
             _events.PostError(ex);
         }
     }
 }
コード例 #3
0
        internal void Write(FileWriter writer)
        {
            _savedParamObjects.Clear();
            _savedParamLists.Clear();
            DataValues.Clear();
            StringValues.Clear();
            ObjListOffsets.Clear();
            ListOffsets.Clear();

            writer.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;

            writer.Write(Encoding.ASCII.GetBytes("AAMP"));
            writer.Write(Version);
            writer.Write(Endianness);

            long sizeOffset = writer.Position;

            writer.Write(0); //Write the file size later
            writer.Write(ParameterIOVersion);

            uint DataSectionSize   = 0;
            uint StringSectionSize = 0;
            uint UnkUintCount      = 0;

            writer.Write(AlignUp(ParameterIOType.Length + 1, 4));
            long totalCountOffset = writer.Position;

            writer.Write(TotalListCount);
            writer.Write(TotalObjCount);
            writer.Write(TotalParamCount);
            writer.Write(DataSectionSize);
            writer.Write(StringSectionSize);
            writer.Write(UnkUintCount);
            writer.Write(ParameterIOType, Syroot.BinaryData.BinaryStringFormat.ZeroTerminated);
            writer.Align(4);

            //Write the lists
            WriteList(writer, RootNode);

            //Save the data and offsets for lists
            for (int index = 0; index < _savedParamLists.Count; index++)
            {
                WriteListData(writer, _savedParamLists[index], ListOffsets[index]);
            }

            //Save objects from lists
            for (int index = 0; index < _savedParamLists.Count; index++)
            {
                ListOffsets[index][1].WriteOffsetU16(writer, (uint)writer.Position);
                foreach (var obj in _savedParamLists[index].paramObjects)
                {
                    WriteObject(writer, obj);
                }
            }

            while (_savedParamObjects.Count != 0)
            {
                WriteObjectData(writer, PopAt(_savedParamObjects, 0));
            }

            uint DataStart = (uint)writer.Position;

            foreach (var entry in DataValues)
            {
                foreach (var offset in entry.Value)
                {
                    if (IsBuffer(((ParamEntry)offset.data).ParamType))
                    {
                        writer.Write(0); //Save offset after the size of buffer
                        offset.WriteOffsetU24(writer, (uint)writer.Position, (ParamEntry)offset.data);
                        writer.Seek(-4, SeekOrigin.Current);
                    }
                    else
                    {
                        offset.WriteOffsetU24(writer, (uint)writer.Position, (ParamEntry)offset.data);
                    }
                }

                writer.Write(entry.Key);
                writer.Align(4);
            }

            uint DataEnd         = (uint)writer.Position;
            uint StringDataStart = (uint)writer.Position;

            int stringCount = 0;

            foreach (var entry in StringValues)
            {
                foreach (var offset in entry.Value)
                {
                    offset.WriteOffsetU24(writer, (uint)writer.Position, (ParamEntry)offset.data);
                    stringCount++;
                }

                writer.Write(entry.Key);

                do
                {
                    writer.Write((byte)0);
                }while (writer.Position % 4 != 0);
            }
            uint StringDataEnd = (uint)writer.Position;

            //Write data size
            writer.Seek(totalCountOffset, System.IO.SeekOrigin.Begin);

            writer.Write(TotalListCount);
            writer.Write(TotalObjCount);
            writer.Write(TotalParamCount);
            writer.Write(DataEnd - DataStart);
            writer.Write(StringDataEnd - StringDataStart);

            //Write end of file
            writer.Seek(sizeOffset, System.IO.SeekOrigin.Begin);
            uint FileSize = (uint)writer.BaseStream.Length;

            writer.Write(FileSize);

            writer.Close();
            writer.Dispose();
        }