コード例 #1
0
ファイル: SidebarForm.cs プロジェクト: cmrazek/ProbeNpp
        private void InitializeFunctionList()
        {
            if (_file == null)
            {
                lstFunctions.Items.Clear();
                return;
            }

            TextFilter tf = new TextFilter(txtFunctionFilter.Text);

            lstFunctions.Items.Clear();

            foreach (Function func in _file.Functions)
            {
                if (tf.Match(func.Name))
                {
                    var lvi = lstFunctions.Items.Add(CreateFunctionLvi(func));
                }
            }
        }
コード例 #2
0
ファイル: SidebarForm.cs プロジェクト: cmrazek/ProbeNpp
        private void UpdateFunctionList()
        {
            if (_file == null)
            {
                lstFunctions.Items.Clear();
                return;
            }

            TextFilter tf = new TextFilter(txtFunctionFilter.Text);

            // Get a list of the functions, and where they are in the file now.
            FunctionParser fp = new FunctionParser();
            var parsedFuncs = fp.Parse(_plugin.GetText(_plugin.Start, _plugin.End)).ToArray();

            Action updateAction = () =>
            {
                var listFuncs = (from i in lstFunctions.Items.Cast<ListViewItem>() select i.Tag as Function).ToArray();
                var fileFuncs = _file.Functions.ToArray();

                var newFuncs = (from func in parsedFuncs where !_file.FunctionIdExists(func.Id) select func).ToArray();
                var updatedFuncs = (from func in parsedFuncs where _file.FunctionIdExists(func.Id) select _file.GetFunction(func.Id)).ToArray();
                var deletedFuncs = (from name in _file.FunctionIds where !parsedFuncs.Any(f => f.Id == name) select _file.GetFunction(name)).ToArray();

                lstFunctions.BeginUpdate();
                try
                {
                    foreach (var func in deletedFuncs)
                    {
                        func.LVI.Remove();
                        _file.RemoveFunction(func.Id);
                    }

                    foreach (var func in newFuncs)
                    {
                        var lvi = CreateFunctionLvi(func);
                        lstFunctions.Items.Add(lvi);
                        _file.AddFunction(func);
                    }

                    foreach (var func in updatedFuncs)
                    {
                        UpdateFunctionLvi(func.LVI, func, (from f in parsedFuncs where f.Id == func.Id select f).FirstOrDefault());
                    }
                }
                finally
                {
                    lstFunctions.EndUpdate();
                }
            };
            if (lstFunctions.InvokeRequired) lstFunctions.BeginInvoke(updateAction);
            else updateAction();
        }
コード例 #3
0
ファイル: SidebarForm.cs プロジェクト: cmrazek/ProbeNpp
 private void ApplyFileFilter()
 {
     TextFilter filter = new TextFilter(txtFileFilter.Text);
     lstFiles.BeginUpdate();
     lstFiles.Items.Clear();
     try
     {
         foreach (ProbeFile pf in _files)
         {
             if (filter.Match(pf.title))
             {
                 ListViewItem lvi = new ListViewItem(pf.title);
                 lvi.SubItems.Add(pf.dir);
                 lvi.Tag = pf;
                 lstFiles.Items.Add(lvi);
             }
         }
     }
     finally
     {
         lstFiles.EndUpdate();
     }
 }