Example #1
0
        private void SnapshotsListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (int i = 0; i < SnapshotsListBox.Items.Count; ++i)
            {
                SnapshotsListBox.SetItemChecked(i, false);
            }

            SnapshotsListBox.SetItemChecked(SnapshotsListBox.SelectedIndex, true);
            ActiveSnapshot = SnapshotsListBox.SelectedItem as Snapshot;
            RenameSnapshotButton.Enabled = ActiveSnapshot.Id != 0;
        }
Example #2
0
        private void RefreshSnapshots()
        {
            int selId = 0, selIndex = 0;

            if (SnapshotsListBox.CheckedItems.Count > 0)
            {
                selId = (SnapshotsListBox.CheckedItems[0] as Snapshot).Id;
            }

            SnapshotsListBox.Items.Clear();
            using (var session = Connection.DataEngine.OpenSession())
                using (var tx = session.BeginTransaction())
                {
                    var snapshots = session.CreateCriteria <Snapshot>()
                                    .AddOrder(NHibernate.Criterion.Order.Desc("TimeStamp"))
                                    .List <Snapshot>();
                    foreach (var snap in snapshots)
                    {
                        if (snap.Id == selId)
                        {
                            selIndex = SnapshotsListBox.Items.Count;
                        }

                        if (snap.Id == 0)
                        {
                            SnapshotsListBox.Items.Insert(0, snap);
                        }
                        else
                        {
                            SnapshotsListBox.Items.Add(snap);
                        }
                    }

                    tx.Commit();
                }

            SnapshotsListBox.SetItemChecked(selIndex, true);
            ActiveSnapshot = SnapshotsListBox.CheckedItems[0] as Snapshot;
        }