/[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 892 - (show annotations) (download)
Wed Sep 17 05:56:41 2014 UTC (6 years, 10 months ago) by william
File size: 4883 byte(s)
+ alot of dang work to force an icon to be shown on the docked panels
  ** when it was as simple as setting: DockPanel.ShowDocumentIcon to true

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 this.dpanel.SuspendLayout(true);
44 //ShowDocks();
45 string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig);
46 if (File.Exists(configFile))
47 {
48 try
49 {
50 this.dpanel.LoadFromXml(configFile, m_deserializeDockContent);
51
52 try
53 {
54 List<IDockContent> contents = this.dpanel.Contents.ToList();
55 if (contents != null)
56 {
57 foreach (IDockContent content in contents)
58 {
59 foreach (var plugin in this.UserPlugins)
60 {
61 if (plugin.DockContent.GetType().Name == content.GetType().Name)
62 {
63 plugin.DockHandler = content.DockHandler;
64 SetDockIcon(plugin);
65 }
66 }
67 }
68 }
69 }
70 catch (Exception ex)
71 {
72 throw ex;
73 }
74
75 }
76 catch (Exception)
77 {
78 ShowDocks();
79 }
80 }
81 else
82 {
83 ShowDocks();
84 }
85
86 this.dpanel.ResumeLayout(true, true);
87 }
88
89 private void SetDockIcon(IUserControlPlugin c) { c.SetIcon(Core.Properties.Resources.romcheater_icon); }
90 private void ShowDocks()
91 {
92 foreach (var plugin in this.UserPlugins)
93 {
94 SetDockIcon(plugin);
95 plugin.Show(this.dpanel);
96 }
97 }
98 private void FloatingUserControlDock_Deactivate(object sender, EventArgs e)
99 {
100 string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), DockPanelConfig);
101 if (m_bSaveLayout)
102 this.dpanel.SaveAsXml(configFile);
103 else if (File.Exists(configFile))
104 File.Delete(configFile);
105
106 foreach (var t in this.dpanel.Contents)
107 {
108 t.OnDeactivate(e);
109 }
110 }
111 private IDockContent GetContentFromPersistString(string persistString)
112 {
113 IDockContent content = null;
114 foreach (var plugin in this.UserPlugins)
115 {
116 string t = plugin.DockContent.GetType().ToString();
117 if (persistString == "RomCheater.RVACalculator.RVACalculatorDockControl" && t == "RomCheater.RVACheatList.RVACheatListDockControl")
118 {
119 // update from renameing RomCheater.RVACalculator to RomCheater.RVACheatList
120 content = plugin.DockContent;
121 break;
122 }
123 if (persistString == t)
124 {
125 content = plugin.DockContent;
126 break;
127 }
128 }
129 return content;
130 }
131
132 private void FloatingUserControlDock_FormClosing(object sender, FormClosingEventArgs e)
133 {
134 FloatingUserControlDock_Deactivate(e, new EventArgs());
135 }
136 }
137 }

  ViewVC Help
Powered by ViewVC 1.1.22