/[RomCheater]/trunk/RomCheater.Core/Docking/FloatingUserControlDock.cs
ViewVC logotype

Contents of /trunk/RomCheater.Core/Docking/FloatingUserControlDock.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 903 - (show annotations) (download)
Wed Sep 17 12:44:22 2014 UTC (7 years ago) by william
File size: 4929 byte(s)
+ fix some issues with numeric input controls not properly sizing themselves

1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 using WeifenLuo.WinFormsUI.Docking;
10 using RomCheater.Interfaces;
11 using System.IO;
12
13
14 namespace RomCheater.Core.Docking
15 {
16 public partial class FloatingUserControlDock : DockContent
17 {
18 const string DockPanelConfig = "RomCheater-UserControls-DockPanel.conf";
19 private bool m_bSaveLayout = true;
20 private DeserializeDockContent m_deserializeDockContent;
21 private List<IUserControlPlugin> userplugins;
22
23 public List<IUserControlPlugin> UserPlugins
24 {
25 get { return userplugins; }
26 set { userplugins = value; }
27 }
28 public FloatingUserControlDock()
29 {
30 InitializeComponent();
31 this.UserPlugins = new List<IUserControlPlugin>();
32 m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
33 }
34
35 //protected FloatingUserControlDock(List<IUserControlPlugin> plugins) : this()
36 //{
37 // this.UserPlugins = plugins;
38 //}
39
40
41 private void FloatingUserControlDock_Shown(object sender, EventArgs e)
42 {
43 if (this.DesignMode) { return; }
44 this.dpanel.SuspendLayout(true);
45 //ShowDocks();
46 string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig);
47 if (File.Exists(configFile))
48 {
49 try
50 {
51 this.dpanel.LoadFromXml(configFile, m_deserializeDockContent);
52
53 try
54 {
55 List<IDockContent> contents = this.dpanel.Contents.ToList();
56 if (contents != null)
57 {
58 foreach (IDockContent content in contents)
59 {
60 foreach (var plugin in this.UserPlugins)
61 {
62 if (plugin.DockContent.GetType().Name == content.GetType().Name)
63 {
64 plugin.DockHandler = content.DockHandler;
65 SetDockIcon(plugin);
66 }
67 }
68 }
69 }
70 }
71 catch (Exception ex)
72 {
73 throw ex;
74 }
75
76 }
77 catch (Exception)
78 {
79 ShowDocks();
80 }
81 }
82 else
83 {
84 ShowDocks();
85 }
86
87 this.dpanel.ResumeLayout(true, true);
88 }
89
90 private void SetDockIcon(IUserControlPlugin c) { c.SetIcon(Core.Properties.Resources.romcheater_icon); }
91 private void ShowDocks()
92 {
93 foreach (var plugin in this.UserPlugins)
94 {
95 SetDockIcon(plugin);
96 plugin.Show(this.dpanel);
97 }
98 }
99 private void FloatingUserControlDock_Deactivate(object sender, EventArgs e)
100 {
101 string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig);
102 if (m_bSaveLayout)
103 this.dpanel.SaveAsXml(configFile);
104 else if (File.Exists(configFile))
105 File.Delete(configFile);
106
107 foreach (var t in this.dpanel.Contents)
108 {
109 t.OnDeactivate(e);
110 }
111 }
112 private IDockContent GetContentFromPersistString(string persistString)
113 {
114 IDockContent content = null;
115 foreach (var plugin in this.UserPlugins)
116 {
117 string t = plugin.DockContent.GetType().ToString();
118 if (persistString == "RomCheater.RVACalculator.RVACalculatorDockControl" && t == "RomCheater.RVACheatList.RVACheatListDockControl")
119 {
120 // update from renameing RomCheater.RVACalculator to RomCheater.RVACheatList
121 content = plugin.DockContent;
122 break;
123 }
124 if (persistString == t)
125 {
126 content = plugin.DockContent;
127 break;
128 }
129 }
130 return content;
131 }
132
133 private void FloatingUserControlDock_FormClosing(object sender, FormClosingEventArgs e)
134 {
135 FloatingUserControlDock_Deactivate(e, new EventArgs());
136 }
137 }
138 }

  ViewVC Help
Powered by ViewVC 1.1.22