3
// Copyright (C) 2009 GNOME Do
5
// This program is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program. If not, see <http://www.gnu.org/licenses/>.
20
using System.Collections.Generic;
25
using Docky.Interface;
27
namespace Docky.Core.Default
31
public class PainterService : IPainterService
35
ICollection<IDockPainter> painters;
37
#region IPainterService implementation
39
public event EventHandler PainterHideRequest;
40
public event EventHandler PainterShowRequest;
42
public void RegisterPainter (IDockPainter painter)
44
painters.Add (painter);
45
painter.ShowRequested += HandleShowRequested;
46
painter.HideRequested += HandleHideRequested;
49
void HandleHideRequested(object sender, EventArgs e)
51
IDockPainter painter = sender as IDockPainter;
52
if (painter == null || PainterHideRequest == null)
55
PainterHideRequest (sender, e);
58
void HandleShowRequested(object sender, EventArgs e)
60
IDockPainter painter = sender as IDockPainter;
61
if (painter == null || PainterShowRequest == null)
64
PainterShowRequest (sender, e);
69
public PainterService ()
71
painters = new List<IDockPainter> ();
74
#region IDisposable implementation
76
public void Dispose ()
78
DockServices.UnregisterService (this);
80
foreach (IDockPainter painter in painters) {
81
painter.ShowRequested -= HandleShowRequested;
82
painter.HideRequested -= HandleHideRequested;