//******************************************************************************** /// <summary> /// /// </summary> /// <param name="c"></param> /// <returns></returns> /// <created>UPh,27.12.2007</created> /// <changed>UPh,27.12.2007</changed> //******************************************************************************** static internal void RestorePosition(SplitContainer c) { int max = 0; if (c.Orientation == Orientation.Horizontal) { max = c.Height; } else { max = c.Width; } if (max <= 1) { return; } string strPos = PlProfile.GetString("Pos", MakeControlName(c)); int pos; if (!Int32.TryParse(strPos, out pos) || pos < 0 || pos > 10000) { return; } c.SplitterDistance = (pos * max) / 10000; }
//******************************************************************************** /// <summary> /// /// </summary> /// <param name="form"></param> /// <param name="refform"></param> /// <returns></returns> /// <created>UPh,27.12.2007</created> /// <changed>UPh,27.12.2007</changed> //******************************************************************************** static void SavePosition(Form form, Form refform) { if (form.WindowState == FormWindowState.Minimized || form.WindowState == FormWindowState.Maximized) { return; } int x = form.Left; int y = form.Top; int cx = form.Width; int cy = form.Height; StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0},{1},{2},{3}", x, y, cx, cy); // Immer möglichst die relative Position mit abspeichern if (form.Parent == null && refform != null && refform.WindowState != FormWindowState.Minimized) { int dx = x - refform.Left; int dy = y - refform.Top; sb.AppendFormat(",{0},{1}", dx, dy); } PlProfile.WriteString("Pos", form.Name, sb.ToString()); }
//******************************************************************************** /// <summary> /// Save the list to the profile, see PlProfile.SetProfileName() /// </summary> /// <returns></returns> /// <created>UPh,16.03.2007</created> /// <changed>UPh,16.03.2007</changed> //******************************************************************************** internal void Save() { int count = m_Items.Count; PlProfile.WriteInt(m_Section, "Count", count); for (int i = 0; i < count; i++) { PlProfile.WriteString(m_Section, Convert.ToString(i), m_Items[i]); } }
//******************************************************************************** /// <summary> /// /// </summary> /// <param name="c"></param> /// <returns></returns> /// <created>UPh,27.12.2007</created> /// <changed>UPh,27.12.2007</changed> //******************************************************************************** static void SavePosition(ListView c) { StringBuilder strPos = new StringBuilder(); for (int i = 0; i < c.Columns.Count; i++) { if (i > 0) { strPos.Append(","); } strPos.AppendFormat("{0}", c.Columns[i].Width); } PlProfile.WriteString("Pos", MakeControlName(c), strPos.ToString()); }
//******************************************************************************** /// <summary> /// /// </summary> /// <param name="c"></param> /// <returns></returns> /// <created>UPh,27.12.2007</created> /// <changed>UPh,27.12.2007</changed> //******************************************************************************** static internal void RestorePosition(ListView c) { string strPos = PlProfile.GetString("Pos", MakeControlName(c)); int[] arr = GetIntArray(strPos); if (arr == null) { return; } if (arr.Length != c.Columns.Count) { return; } for (int i = 0; i < arr.Length; i++) { c.Columns[i].Width = arr[i]; } }
//******************************************************************************** /// <summary> /// Initializes data and loads RecentList from profile /// </summary> /// <param name="section"></param> /// <param name="maxsize"></param> /// <returns></returns> /// <created>UPh,16.03.2007</created> /// <changed>UPh,16.03.2007</changed> //******************************************************************************** private void Initialize(string section, int maxsize) { m_Items = new List <string>(); m_MaxSize = maxsize; m_Section = section; // Lade aus demProfil int count = PlProfile.GetInt(m_Section, "Count"); for (int i = 0; i < count; i++) { string value = PlProfile.GetString(section, Convert.ToString(i)); if (value == "") { continue; } m_Items.Add(value); } }
//******************************************************************************** /// <summary> /// /// </summary> /// <param name="c"></param> /// <returns></returns> /// <created>UPh,27.12.2007</created> /// <changed>UPh,27.12.2007</changed> //******************************************************************************** static void SavePosition(SplitContainer c) { int max = 0; if (c.Orientation == Orientation.Horizontal) { max = c.Height; } else { max = c.Width; } if (max <= 1) { return; } int percent = (c.SplitterDistance * 10000) / max; PlProfile.WriteString("Pos", MakeControlName(c), percent.ToString()); }
//******************************************************************************** /// <summary> /// /// </summary> /// <param name="form"></param> /// <param name="refform"></param> /// <returns></returns> /// <created>UPh,27.12.2007</created> /// <changed>UPh,27.12.2007</changed> //******************************************************************************** static internal void RestorePosition(Form form, Form refform) { string strPos = PlProfile.GetString("Pos", form.Name); int[] arr = GetIntArray(strPos); if (arr == null) { return; } if (arr.Length != 4 && arr.Length != 6) { return; } int left = arr[0]; int top = arr[1]; int width = arr[2]; int height = arr[3]; if (form.Parent == null && arr.Length == 6 && refform != null && refform.WindowState != FormWindowState.Minimized) { int dx = arr[4]; int dy = arr[5]; left = refform.Left + dx; top = refform.Top + dy; } form.Left = left; form.Top = top; if (form.FormBorderStyle == FormBorderStyle.Sizable || form.FormBorderStyle == FormBorderStyle.SizableToolWindow) { form.Width = width; form.Height = height; } MakeVisible(form); }