private void TakeSnapshot(bool userInitiated)
        {
            var snap = Snapshot.TakeSnapshot(userInitiated);

            lastForMonitorCount[snap.NumMonitors] = snap;
            m_snapshots.Add(snap);

            while (m_snapshots.Count > 10)
            {
                Snapshot toRemove = null;
                foreach (var sn in m_snapshots)
                {
                    if (sn.NumMonitors == snap.NumMonitors)
                    {
                        toRemove = sn;
                        break;
                    }
                }
                if (toRemove != null)
                {
                    m_snapshots.Remove(toRemove);
                }
                else
                {
                    break;
                }
            }

            UpdateRestoreChoicesInMenu();

            lastCount = snap.NumMonitors;

            WriteSnapshotList();
        }
Esempio n. 2
0
        private void TakeSnapshot(bool userInitiated)
        {
            Snapshot s1 = Snapshot.TakeSnapshot(userInitiated);

            m_snapshots.Add(s1);
            UpdateRestoreChoicesInMenu();
        }
Esempio n. 3
0
        private void trayIcon_MouseClick(object sender, MouseEventArgs e)
        {
            m_menuShownSnapshot          = Snapshot.TakeSnapshot(false);
            justNowToolStripMenuItem.Tag = m_menuShownSnapshot;

            // the context menu won't show by default on left clicks.  we're going to have to ask it to show up.
            if (e.Button == MouseButtons.Left)
            {
                try {
                    // try using reflection to get to the private ShowContextMenu() function...which really
                    // should be public but is not.
                    var showContextMenuMethod = trayIcon.GetType().GetMethod("ShowContextMenu",
                                                                             BindingFlags.NonPublic | BindingFlags.Instance);
                    showContextMenuMethod.Invoke(trayIcon, null);
                } catch (Exception) {
                    // something went wrong with out hack -- fall back to a shittier approach
                    trayMenu.Show(Cursor.Position);
                }
            }
        }
Esempio n. 4
0
        private void TakeSnapshot(string name)
        {
            Snapshot      s1 = Snapshot.TakeSnapshot(name);
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < fixed_snapshots.Count; i++)
            {
                if (fixed_snapshots[i].Name != null && fixed_snapshots[i].Name.Equals(name))
                {
                    fixed_snapshots.RemoveAt(i);
                    i--;
                }
                else
                {
                    sb.AppendLine(fixed_snapshots[i].ConvertToString());
                }
            }
            fixed_snapshots.Add(s1);
            sb.AppendLine(s1.ConvertToString());

            System.IO.File.WriteAllText(fPath, sb.ToString());
            UpdateRestoreChoicesInMenu();
        }