Пример #1
0
        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {
            // get selected row and decide what to show/not to show
            Point       p       = gridControl1.PointToClient(Cursor.Position);
            GridHitInfo hitinfo = gridView1.CalcHitInfo(p);

            int[] selectedrows = gridView1.GetSelectedRows();
            if (hitinfo.InRow)
            {
                int grouplevel = gridView1.GetRowLevel((int)selectedrows.GetValue(0));
                if (grouplevel >= gridView1.GroupCount)
                {
                    //Console.WriteLine("In row");
                    if (gridView1.GetFocusedRow() is TransactionEntry)
                    {
                        TransactionEntry sh = (TransactionEntry)gridView1.GetFocusedRow();
                        if (sh.IsRolledBack)
                        {
                            rollForwardToolStripMenuItem.Enabled = true;
                            rolllBackToolStripMenuItem.Enabled   = false;
                        }
                        else
                        {
                            rollForwardToolStripMenuItem.Enabled = false;
                            rolllBackToolStripMenuItem.Enabled   = true;
                        }
                    }
                }
            }
        }
Пример #2
0
 private void CastNoteChangedEvent(TransactionEntry entry)
 {
     if (onNoteChanged != null)
     {
         onNoteChanged(this, new RollInformationEventArgs(entry));
     }
 }
Пример #3
0
 private void CastRollForwardEvent(TransactionEntry entry)
 {
     if (onRollForward != null)
     {
         onRollForward(this, new RollInformationEventArgs(entry));
     }
 }
Пример #4
0
 private void CastNoteChangedEvent(TransactionEntry entry)
 {
     if (onNoteChanged != null)
     {
         onNoteChanged(this, new RollInformationEventArgs(entry));
     }
 }
Пример #5
0
 private void CastRollBackEvent(TransactionEntry entry)
 {
     if (onRollBack != null)
     {
         onRollBack(this, new RollInformationEventArgs(entry));
     }
 }
Пример #6
0
 private void CastRollBackEvent(TransactionEntry entry)
 {
     if (onRollBack != null)
     {
         onRollBack(this, new RollInformationEventArgs(entry));
     }
 }
Пример #7
0
 private void UpdateButtons()
 {
     int[] selectedrows = gridView1.GetSelectedRows();
     if (selectedrows.Length == 0)
     {
         simpleButton3.Enabled = false;
         simpleButton4.Enabled = false;
     }
     else
     {
         if (gridView1.GetFocusedRow() is TransactionEntry)
         {
             TransactionEntry sh = (TransactionEntry)gridView1.GetFocusedRow();
             if (sh.IsRolledBack)
             {
                 simpleButton4.Enabled = true;
                 simpleButton3.Enabled = false;
             }
             else
             {
                 simpleButton4.Enabled = false;
                 simpleButton3.Enabled = true;
             }
         }
     }
 }
Пример #8
0
 private void CastRollForwardEvent(TransactionEntry entry)
 {
     if (onRollForward != null)
     {
         onRollForward(this, new RollInformationEventArgs(entry));
     }
 }
Пример #9
0
 public void AddToTransactionLog(TransactionEntry entry)
 {
     entry.TransactionNumber = _transCollection.Count + 1;
     _transCollection.Add(entry);
     //SaveTransactionLog();
     AddTransactionToFile(entry, true);
     //UpdateNumberOfTransActions();
     //UpdateChecksum();
 }
Пример #10
0
 public void AddToTransactionLog(TransactionEntry entry)
 {
     entry.TransactionNumber = _transCollection.Count + 1;
     _transCollection.Add(entry);
     //SaveTransactionLog();
     AddTransactionToFile(entry, true);
     //UpdateNumberOfTransActions();
     //UpdateChecksum();
 }
Пример #11
0
 private void simpleButton4_Click(object sender, EventArgs e)
 {
     // cast roll forward
     if (gridView1.GetFocusedRow() is TransactionEntry)
     {
         TransactionEntry sh = (TransactionEntry)gridView1.GetFocusedRow();
         CastRollForwardEvent(sh);
         gridView1.FocusedRowHandle++;
     }
 }
Пример #12
0
            public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
            {
                if (destType == typeof(string) && value is TransactionEntry)
                {
                    // Cast the value to an Employee type
                    TransactionEntry pp = (TransactionEntry)value;

                    return(pp.EntryDateTime.ToString() + ", " + pp.SymbolAddress + ", " + pp.SymbolLength);
                }
                return(base.ConvertTo(context, culture, value, destType));
            }
Пример #13
0
 public void SetEntryNote(TransactionEntry ChangedEntry)
 {
     foreach (TransactionEntry entry in _transCollection)
     {
         if (entry.TransactionNumber == ChangedEntry.TransactionNumber)
         {
             entry.Note = ChangedEntry.Note;
         }
     }
     SaveTransactionLog();
 }
Пример #14
0
 private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
 {
     // note was edited?
     if (e.Column.Name == gcNote.Name)
     {
         // save the transaction log again (and reload?)
         TransactionEntry sh = (TransactionEntry)gridView1.GetRow(e.RowHandle);
         //MessageBox.Show("You changed the note into: " + sh.Note);
         CastNoteChangedEvent(sh);
     }
 }
Пример #15
0
 private void simpleButton3_Click(object sender, EventArgs e)
 {
     // cast rollback
     if (gridView1.GetFocusedRow() is TransactionEntry)
     {
         TransactionEntry sh = (TransactionEntry)gridView1.GetFocusedRow();
         CastRollBackEvent(sh);
         // move the selected cursor one row up, if possible
         gridView1.FocusedRowHandle--;
     }
 }
Пример #16
0
        public void ReadTransactionFile()
        {
            _transCollection = new TransactionCollection();
            if (VerifyChecksum())
            {
                FileInfo   fi          = new FileInfo(m_fileName);
                Int32      _entryCount = readInt32FromFile(m_fileName, 4);
                FileStream fs          = new FileStream(m_fileName, FileMode.Open);
                fs.Seek(8, SeekOrigin.Begin);
                using (BinaryReader br = new BinaryReader(fs))
                {
                    //  byte[] allBytes = br.ReadBytes((int)fi.Length - 8);

                    //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after
                    for (int t = 0; t < _entryCount; t++)
                    {
                        Int32    transActionNumber = br.ReadInt32();
                        byte     isRolledBack      = br.ReadByte();
                        byte     day           = br.ReadByte();
                        byte     month         = br.ReadByte();
                        Int16    year          = br.ReadInt16();
                        byte     hour          = br.ReadByte();
                        byte     minute        = br.ReadByte();
                        byte     second        = br.ReadByte();
                        DateTime entryDateTime = new DateTime(year, Convert.ToInt16(month), Convert.ToInt16(day), Convert.ToInt16(hour), Convert.ToInt16(minute), Convert.ToInt16(second));
                        Int32    address       = br.ReadInt32();
                        Int16    NoteLength    = br.ReadInt16();
                        byte[]   notedata      = br.ReadBytes(NoteLength);
                        string   note          = string.Empty;
                        for (int i = 0; i < notedata.Length; i += 2)
                        {
                            string Hex = string.Empty;
                            Hex += Convert.ToChar(notedata[i]);
                            Hex += Convert.ToChar(notedata[i + 1]);
                            int value = Convert.ToInt32(Hex, 16);
                            note += Convert.ToChar(value);
                        }
                        Int16  length     = br.ReadInt16();
                        byte[] beforeData = br.ReadBytes(length);
                        byte[] afterData  = br.ReadBytes(length);
                        // read day
                        TransactionEntry entry = new TransactionEntry(entryDateTime, address, length, beforeData, afterData, isRolledBack, transActionNumber, note);
                        _transCollection.Add(entry);
                    }
                }
                fs.Close();
            }
        }
Пример #17
0
        private void rollForwardToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // cast rollforward event to the main form
            // and reload the list
            int[] selectedrows = gridView1.GetSelectedRows();
            int   grouplevel   = gridView1.GetRowLevel((int)selectedrows.GetValue(0));

            if (grouplevel >= gridView1.GroupCount)
            {
                //Console.WriteLine("In row");
                if (gridView1.GetFocusedRow() is TransactionEntry)
                {
                    TransactionEntry sh = (TransactionEntry)gridView1.GetFocusedRow();
                    CastRollForwardEvent(sh);
                }
            }
        }
Пример #18
0
        public void savedatatobinary(int address, int length, byte[] data, string filename, bool DoTransActionEntry, string note, EDCFileType type)
        {
            // depends on filetype (EDC16 is not reversed)
            if (type != EDCFileType.EDC16)
            {
                data = reverseEndian(data);
            }
            if (address > 0 && address < m_currentfilelength)
            {
                try
                {
                    byte[] beforedata = readdatafromfile(filename, address, length, type);

                    FileStream   fsi1 = File.OpenWrite(filename);
                    BinaryWriter bw1  = new BinaryWriter(fsi1);
                    fsi1.Position = address;
                    for (int i = 0; i < length; i++)
                    {
                        bw1.Write((byte)data.GetValue(i));
                    }
                    fsi1.Flush();
                    bw1.Close();
                    fsi1.Close();
                    fsi1.Dispose();

                    if (m_ProjectTransactionLog != null && DoTransActionEntry)
                    {
                        // depends on filetype (EDC16 is not reversed)
                        if (type != EDCFileType.EDC16)
                        {
                            data = reverseEndian(data);
                        }
                        TransactionEntry tentry = new TransactionEntry(DateTime.Now, address, length, beforedata, data, 0, 0, note);
                        m_ProjectTransactionLog.AddToTransactionLog(tentry);
                        if (m_CurrentWorkingProject != string.Empty)
                        {
                            m_ProjectLog.WriteLogbookEntry(LogbookEntryType.TransactionExecuted, GetSymbolNameByAddress(address) + " " + note);
                        }
                    }
                }
                catch (Exception E)
                {
                    frmInfoBox info = new frmInfoBox("Failed to write to binary. Is it read-only? Details: " + E.Message);
                }
            }
        }
Пример #19
0
        private void AddTransactionToFile(TransactionEntry entry, bool updateChecksum)
        {
            // append at the end of the file
            //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after
            AppendInt32ToFile(entry.TransactionNumber);
            AppendByteToFile(Convert.ToByte(entry.IsRolledBack)); // not rolled back
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Day));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Month));
            AppendInt16ToFile(Convert.ToInt16(entry.EntryDateTime.Year));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Hour));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Minute));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Second));
            AppendInt32ToFile(entry.SymbolAddress);
            AppendInt16ToFile(Convert.ToInt16(entry.Note.Length * 2));
            // now add double hex all characters
            for (int i = 0; i < entry.Note.Length; i++)
            {
                byte   curByte = Convert.ToByte(entry.Note[i]);
                string Hex     = curByte.ToString("X2");
                AppendByteToFile(Convert.ToByte(Hex[0]));
                AppendByteToFile(Convert.ToByte(Hex[1]));
            }
            AppendInt16ToFile(Convert.ToInt16(entry.SymbolLength));
            AppendDataToFile(entry.DataBefore);
            AppendDataToFile(entry.DataAfter);
            // update number of entries
            Int32 _entryCount = readInt32FromFile(m_fileName, 4);

            _entryCount++;

            if (updateChecksum)
            {
                writeInt32ToFile(m_fileName, 4, _entryCount);
                UpdateChecksum();
            }
            // update checksum
        }
Пример #20
0
        public TransactionCollection ReadTransactionFileVersion1(string filename)
        {
            TransactionCollection m_transCollection = new TransactionCollection();
            Int32      _entryCount = readInt32FromFile(filename, 4);
            FileStream fs          = new FileStream(filename, FileMode.Open);

            fs.Seek(8, SeekOrigin.Begin);
            using (BinaryReader br = new BinaryReader(fs))
            {
                //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after
                for (int t = 0; t < _entryCount; t++)
                {
                    Int32    transActionNumber = br.ReadInt32();
                    byte     isRolledBack      = br.ReadByte();
                    byte     day           = br.ReadByte();
                    byte     month         = br.ReadByte();
                    Int16    year          = br.ReadInt16();
                    byte     hour          = br.ReadByte();
                    byte     minute        = br.ReadByte();
                    byte     second        = br.ReadByte();
                    DateTime entryDateTime = new DateTime(year, Convert.ToInt16(month), Convert.ToInt16(day), Convert.ToInt16(hour), Convert.ToInt16(minute), Convert.ToInt16(second));
                    Int32    address       = br.ReadInt32();
                    Int16    length        = br.ReadInt16();
                    byte[]   beforeData    = br.ReadBytes(length);
                    byte[]   afterData     = br.ReadBytes(length);
                    // read day

                    TransactionEntry entry = new TransactionEntry(entryDateTime, address, length, beforeData, afterData, isRolledBack, transActionNumber, "");
                    m_transCollection.Add(entry);
                }
            }
            fs.Close();


            return(m_transCollection);
        }
Пример #21
0
        public void savedatatobinary(int address, int length, byte[] data, string filename, bool DoTransActionEntry, string note, EDCFileType type)
        {
            // depends on filetype (EDC16 is not reversed)
            if (type != EDCFileType.EDC16)
            {
                data = reverseEndian(data);
            }
            if (address > 0 && address < m_currentfilelength)
            {
                try
                {
                    byte[] beforedata = readdatafromfile(filename, address, length, type);

                    FileStream fsi1 = File.OpenWrite(filename);
                    BinaryWriter bw1 = new BinaryWriter(fsi1);
                    fsi1.Position = address;
                    for (int i = 0; i < length; i++)
                    {
                        bw1.Write((byte)data.GetValue(i));
                    }
                    fsi1.Flush();
                    bw1.Close();
                    fsi1.Close();
                    fsi1.Dispose();

                    if (m_ProjectTransactionLog != null && DoTransActionEntry)
                    {
                        // depends on filetype (EDC16 is not reversed)
                        if (type != EDCFileType.EDC16)
                        {
                            data = reverseEndian(data);
                        }
                        TransactionEntry tentry = new TransactionEntry(DateTime.Now, address, length, beforedata, data, 0, 0, note);
                        m_ProjectTransactionLog.AddToTransactionLog(tentry);
                        if (m_CurrentWorkingProject != string.Empty)
                        {
                            m_ProjectLog.WriteLogbookEntry(LogbookEntryType.TransactionExecuted, GetSymbolNameByAddress(address) + " " + note);
                        }
                    }

                }
                catch (Exception E)
                {
                    frmInfoBox info = new frmInfoBox("Failed to write to binary. Is it read-only? Details: " + E.Message);
                }
            }
        }
 public bool Contains(TransactionEntry value)
 {
     // If value is not of type Int16, this will return false.
     return (List.Contains(value));
 }
 public int Add(TransactionEntry value)
 {
     return (List.Add(value));
 }
 public void Remove(TransactionEntry value)
 {
     List.Remove(value);
 }
Пример #25
0
        public TransactionCollection ReadTransactionFileVersion1(string filename)
        {
            TransactionCollection m_transCollection = new TransactionCollection();
            Int32 _entryCount = readInt32FromFile(filename, 4);
            FileStream fs = new FileStream(filename, FileMode.Open);
            fs.Seek(8, SeekOrigin.Begin);
            using (BinaryReader br = new BinaryReader(fs))
            {
                //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after
                for (int t = 0; t < _entryCount; t++)
                {
                    Int32 transActionNumber = br.ReadInt32();
                    byte isRolledBack = br.ReadByte();
                    byte day = br.ReadByte();
                    byte month = br.ReadByte();
                    Int16 year = br.ReadInt16();
                    byte hour = br.ReadByte();
                    byte minute = br.ReadByte();
                    byte second = br.ReadByte();
                    DateTime entryDateTime = new DateTime(year, Convert.ToInt16(month), Convert.ToInt16(day), Convert.ToInt16(hour), Convert.ToInt16(minute), Convert.ToInt16(second));
                    Int32 address = br.ReadInt32();
                    Int16 length = br.ReadInt16();
                    byte[] beforeData = br.ReadBytes(length);
                    byte[] afterData = br.ReadBytes(length);
                    // read day

                    TransactionEntry entry = new TransactionEntry(entryDateTime, address, length, beforeData, afterData, isRolledBack, transActionNumber, "");
                    m_transCollection.Add(entry);
                }
            }
            fs.Close();

            return m_transCollection;
        }
Пример #26
0
 public RollInformationEventArgs(TransactionEntry entry)
 {
     this._entry = entry;
 }
Пример #27
0
 public bool Contains(TransactionEntry value)
 {
     // If value is not of type Int16, this will return false.
     return(List.Contains(value));
 }
Пример #28
0
 public void Remove(TransactionEntry value)
 {
     List.Remove(value);
 }
Пример #29
0
 public void Insert(int index, TransactionEntry value)
 {
     List.Insert(index, value);
 }
Пример #30
0
 public int IndexOf(TransactionEntry value)
 {
     return(List.IndexOf(value));
 }
Пример #31
0
 public int Add(TransactionEntry value)
 {
     return(List.Add(value));
 }
Пример #32
0
        public void ReadTransactionFile()
        {
            _transCollection = new TransactionCollection();
            if (VerifyChecksum())
            {
                FileInfo fi = new FileInfo(m_fileName);
                Int32 _entryCount = readInt32FromFile(m_fileName, 4);
                FileStream fs = new FileStream(m_fileName, FileMode.Open);
                fs.Seek(8, SeekOrigin.Begin);
                using (BinaryReader br = new BinaryReader(fs))
                {
                  //  byte[] allBytes = br.ReadBytes((int)fi.Length - 8);

                    //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after
                    for (int t = 0; t < _entryCount; t++)
                    {
                        Int32 transActionNumber = br.ReadInt32();
                        byte isRolledBack = br.ReadByte();
                        byte day = br.ReadByte();
                        byte month = br.ReadByte();
                        Int16 year = br.ReadInt16();
                        byte hour = br.ReadByte();
                        byte minute = br.ReadByte();
                        byte second = br.ReadByte();
                        DateTime entryDateTime = new DateTime(year, Convert.ToInt16(month), Convert.ToInt16(day), Convert.ToInt16(hour), Convert.ToInt16(minute), Convert.ToInt16(second));
                        Int32 address = br.ReadInt32();
                        Int16 NoteLength = br.ReadInt16();
                        byte[] notedata = br.ReadBytes(NoteLength);
                        string note = string.Empty;
                        for (int i = 0; i < notedata.Length; i += 2)
                        {
                            string Hex = string.Empty;
                            Hex += Convert.ToChar(notedata[i]);
                            Hex += Convert.ToChar(notedata[i + 1]);
                            int value = Convert.ToInt32(Hex, 16);
                            note += Convert.ToChar(value);
                        }
                        Int16 length = br.ReadInt16();
                        byte[] beforeData = br.ReadBytes(length);
                        byte[] afterData = br.ReadBytes(length);
                        // read day
                        TransactionEntry entry = new TransactionEntry(entryDateTime, address, length, beforeData, afterData, isRolledBack, transActionNumber, note);
                        _transCollection.Add(entry);
                    }
                }
                fs.Close();

            }
        }
Пример #33
0
 private void RollForwardOnFile(string file2Rollback, TransactionEntry entry)
 {
     FileInfo fi = new FileInfo(file2Rollback);
     int addressToWrite = entry.SymbolAddress;
     while (addressToWrite > fi.Length) addressToWrite -= (int)fi.Length;
     Tools.Instance.savedatatobinary(addressToWrite, entry.SymbolLength, entry.DataAfter, file2Rollback, false, Tools.Instance.m_currentFileType);
     VerifyChecksum(Tools.Instance.m_currentfile, false, false);
 }
Пример #34
0
 public RollInformationEventArgs(TransactionEntry entry)
 {
     this._entry = entry;
 }
 public int IndexOf(TransactionEntry value)
 {
     return (List.IndexOf(value));
 }
Пример #36
0
        private void RollForward(TransactionEntry entry)
        {
            int addressToWrite = entry.SymbolAddress;
            Tools.Instance.savedatatobinary(addressToWrite, entry.SymbolLength, entry.DataAfter, Tools.Instance.m_currentfile, false, Tools.Instance.m_currentFileType);
            VerifyChecksum(Tools.Instance.m_currentfile, false, false);
            if (Tools.Instance.m_ProjectTransactionLog != null)
            {
                Tools.Instance.m_ProjectTransactionLog.SetEntryRolledForward(entry.TransactionNumber);
            }
            if (Tools.Instance.m_CurrentWorkingProject != string.Empty)
            {

                Tools.Instance.m_ProjectLog.WriteLogbookEntry(LogbookEntryType.TransactionRolledforward, Tools.Instance.GetSymbolNameByAddress(entry.SymbolAddress) + " " + entry.Note + " " + entry.TransactionNumber.ToString());
            }

            UpdateRollbackForwardControls();
        }
 public void Insert(int index, TransactionEntry value)
 {
     List.Insert(index, value);
 }
Пример #38
0
        private void AddTransactionToFile(TransactionEntry entry, bool updateChecksum)
        {
            // append at the end of the file
            //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after
            AppendInt32ToFile(entry.TransactionNumber);
            AppendByteToFile(Convert.ToByte(entry.IsRolledBack)); // not rolled back
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Day));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Month));
            AppendInt16ToFile(Convert.ToInt16(entry.EntryDateTime.Year));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Hour));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Minute));
            AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Second));
            AppendInt32ToFile(entry.SymbolAddress);
            AppendInt16ToFile(Convert.ToInt16(entry.Note.Length * 2));
            // now add double hex all characters
            for (int i = 0; i < entry.Note.Length; i++)
            {
                byte curByte = Convert.ToByte(entry.Note[i]);
                string Hex = curByte.ToString("X2");
                AppendByteToFile(Convert.ToByte(Hex[0]));
                AppendByteToFile(Convert.ToByte(Hex[1]));
            }
            AppendInt16ToFile(Convert.ToInt16(entry.SymbolLength));
            AppendDataToFile(entry.DataBefore);
            AppendDataToFile(entry.DataAfter);
            // update number of entries
            Int32 _entryCount = readInt32FromFile(m_fileName, 4);
            _entryCount++;

            if (updateChecksum)
            {
                writeInt32ToFile(m_fileName, 4, _entryCount);
                UpdateChecksum();
            }
            // update checksum
        }
Пример #39
0
 public void SetEntryNote(TransactionEntry ChangedEntry)
 {
     foreach (TransactionEntry entry in _transCollection)
     {
         if (entry.TransactionNumber == ChangedEntry.TransactionNumber)
         {
             entry.Note = ChangedEntry.Note;
         }
     }
     SaveTransactionLog();
 }