/*
* Process Hacker
*
* Copyright (C) 2008 wj32
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Collections;
namespace ProcessHacker
{
///
/// Provides methods for loading and saving ListView column settings.
///
public static class ColumnSettings
{
///
/// Saves the column settings of the specified ListView to a string.
///
///
///
public static string SaveSettings(ListView lv)
{
string result = "";
try
{
foreach (ColumnHeader ch in lv.Columns)
{
result += ch.DisplayIndex.ToString() + "," + ch.Width.ToString() + "|";
}
}
catch
{ }
return result;
}
///
/// Loads column settings from a string to a ListView.
///
///
///
public static void LoadSettings(string settings, ListView lv)
{
string[] list = settings.Split('|');
try
{
for (int i = 0; i < list.Length; i++)
{
string[] s = list[i].Split(',');
lv.Columns[i].DisplayIndex = Int32.Parse(s[0]);
lv.Columns[i].Width = Int32.Parse(s[1]);
}
}
catch
{ }
}
}
}