Beispiel #1
0
        public MemHackMain()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // Set the ListViewItemSorter property to a new ListViewItemComparer object.
            procList.ListViewItemSorter = new ListViewItemComparer(1, SortOrder.Ascending);

            UpdateBackgrounds();

            procSelect.Enabled = false;

            updList = new UpdateListDelegate(UpdateList);

            UpdateList();
            UpdateList();	// The second call is for debugging any problems in this function.
            m_timer = new System.Threading.Timer(m_cb, this, 1000, 1000);
            this.procLocation.Text = Resources.Unknown;
            this.procSelect.Text = Resources.Select;
            this.label1.Text = Resources.RunningProgramsLabel;
            this.label2.Text = Resources.ProcessNameLabel;
            this.clmID.Text = Resources.ID;
            this.clmName.Text = Resources.Name;
            this.clmTitle.Text = Resources.Title;
            this.Text = Resources.MemoryHacker;
            (new ToolTip()).SetToolTip(this, Resources.ToolTip_MemHackDlg);
            (new ToolTip()).SetToolTip(this.procList, Resources.ToolTip_ProcessList);
            (new ToolTip()).SetToolTip(this.procSelect, Resources.ToolTip_SelectProcess);
            (new ToolTip()).SetToolTip(this.procLocation, Resources.ToolTip_ApplicationPath);
            (new ToolTip()).SetToolTip(this.nameList, Resources.ToolTip_FriendlyNames);

            this.procList.DoubleClick += new EventHandler(procList_DoubleClick);
        }
Beispiel #2
0
        delegate void UpdateListDelegate(); // used by Update function to create delegate to update sensor list

        private void Update(object sender, EventArgs e)
        {
            // This function will probably run in a different thread from the windows controls
            //  because it is registered as a callback function in the Glove Driver
            //  (see function chkUseCallback_CheckedChanged)
            // We can't just change controls from a different thread so we first have to
            //  check if an invoke is required or not...
            if (lstSensors.InvokeRequired)
            {
                // It's on a different thread, so use Invoke.
                UpdateListDelegate d = new UpdateListDelegate(UpdateList);
                try
                {
                    this.Invoke(d, new object[] { });
                }
                catch
                {
                }
            }
            else
            {
                tmrUpdate_Tick(this, EventArgs.Empty);
            }
        }
Beispiel #3
0
        internal static void UpdateList(ListAction action, ArrayList oldItems, ArrayList newItems, ObjectTypes objectType, int objectId, SystemEventTypes eventType, UpdateListDelegate fnUpdate, object context)
        {
            ArrayList add = new ArrayList();
            ArrayList del = new ArrayList();
            foreach (int id in newItems)
            {
                switch (action)
                {
                    case ListAction.Add:
                        if (!oldItems.Contains(id))
                            add.Add(id);
                        break;
                    case ListAction.Remove:
                        if (oldItems.Contains(id))
                            del.Add(id);
                        break;
                    case ListAction.Set:
                        if (oldItems.Contains(id))
                            oldItems.Remove(id);
                        else
                            add.Add(id);
                        break;
                }
            }

            if (action == ListAction.Set)
                del.AddRange(oldItems);

            using (DbTransaction tran = DbTransaction.Begin())
            {
                bool updated = false;

                foreach (int id in add)
                {
                    fnUpdate(true, objectType, objectId, id, context);
                    updated = true;
                }

                foreach (int id in del)
                {
                    fnUpdate(false, objectType, objectId, id, context);
                    updated = true;
                }

                if (updated)
                    SystemEvents.AddSystemEvents(eventType, objectId);

                tran.Commit();
            }
        }
Beispiel #4
0
        internal static void UpdateCategories(ListAction action, ListType type, int issueId, ArrayList categories, bool checkAccess)
        {
            if(checkAccess && !Incident.CanUpdate(issueId))
                throw new AccessDeniedException();

            ArrayList oldItems;
            SystemEventTypes eventType;
            UpdateListDelegate fnUpdate;

            switch(type)
            {
                case ListType.GeneralCategories:
                    eventType = SystemEventTypes.Issue_Updated_GeneralCategories;
                    oldItems = LoadGeneralCategories(issueId);
                    fnUpdate = new UpdateListDelegate(Common.ListUpdate);
                    break;
                case ListType.IssueCategories:
                    eventType = SystemEventTypes.Issue_Updated_IssueCategories;
                    oldItems = LoadIssueCategories(issueId);
                    fnUpdate = new UpdateListDelegate(ListUpdate);
                    break;
                default:
                    throw new Exception("Unknown category type.");
            }
            Common.UpdateList(action, oldItems, categories, OBJECT_TYPE, issueId, eventType, fnUpdate, type);
        }
Beispiel #5
0
 public bool Configure(ProcessInformation pinfo)
 {
     Text = System.String.Format(Resources.MemoryHackerFormatString, pinfo.ID, pinfo.Name, pinfo.FullPath);
     m_pm = ProcessModifier.Open((uint) pinfo.ID);
     if(m_pm == null)
         return false;
     UpdateList();
     UpdateList();	// The second call is for debugging any problems in this function.
     updList = new UpdateListDelegate(UpdateList);
     m_timer = new System.Threading.Timer(m_cb, this, 2000, 2000);
     return true;
 }
Beispiel #6
0
        private static void UpdateList(ListAction action, ListType type, int projectId, ArrayList items, bool checkAccess)
        {
            if(checkAccess)
                VerifyCanUpdate(projectId);

            ArrayList oldItems;
            SystemEventTypes eventType;
            UpdateListDelegate fnUpdate;

            switch(type)
            {
                case ListType.GeneralCategories:
                    eventType = SystemEventTypes.Project_Updated_GeneralCategories;
                    oldItems = LoadGeneralCategories(projectId);
                    fnUpdate = new UpdateListDelegate(Common.ListUpdate);
                    break;
                case ListType.ProjectCategories:
                    eventType = SystemEventTypes.Project_Updated_ProjectCategories;
                    oldItems = LoadProjectCategories(projectId);
                    fnUpdate = new UpdateListDelegate(ListUpdate);
                    break;
                case ListType.ProjectGroups:
                    eventType = SystemEventTypes.Project_Updated_ProjectGroups;
                    oldItems = LoadProjectGroups(projectId);
                    fnUpdate = new UpdateListDelegate(ListUpdate);
                    break;
                default:
                    throw new Exception("Unknown list type.");
            }
            Common.UpdateList(action, oldItems, items, OBJECT_TYPE, projectId, eventType, fnUpdate, type);
        }