Skip to content

Commit

Permalink
Merging in ASP.Net work
Browse files Browse the repository at this point in the history
  • Loading branch information
codekaizen committed Sep 12, 2008
1 parent 819f11d commit 41edd64
Show file tree
Hide file tree
Showing 738 changed files with 151,571 additions and 480 deletions.
15 changes: 0 additions & 15 deletions Common.msbuild

This file was deleted.

93 changes: 93 additions & 0 deletions Demos/SharpMapWinFormsDemo/ActionCommandHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

/*
* This file is part of SharpMapMapViewer
* SharpMapMapViewer is free software © 2008 Newgrove Consultants Limited,
* http://www.newgrove.com; you can redistribute it and/or modify it under the terms
* of the current GNU Lesser General Public License (LGPL) as published by and
* available from the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA: http://fsf.org/
* This program is distributed without any warranty;
* without even the implied warranty of merchantability or fitness for purpose.
* See the GNU Lesser General Public License for the full details.
*
* Author: John Diss 2008
*
*/

using System;
using MapViewer.Commands;

namespace MapViewer
{
public class ActionCommandHandler
: CommandHandlerBase
{
public ActionCommandHandler()
: this(null, null)
{
}

public ActionCommandHandler(ICommand command)
: this(command, null)
{
}

public ActionCommandHandler(Action action)
: this(null, action)
{
}

public ActionCommandHandler(ICommand command, Action action)
: base(command)
{
Action = action;
}

public Action Action { get; set; }

public override void HandleCommand()
{
if (Action != null)
Action();
}
}

public class ActionCommandHandler<TEventArgs>
: CommandHandlerBase<TEventArgs>
where TEventArgs : CommandEventArgs
{
public ActionCommandHandler()
: this(null, null)
{
}

public ActionCommandHandler(ICommand<TEventArgs> command)
: this(command, null)
{
}

public ActionCommandHandler(Action<TEventArgs> action)
: this(null, action)
{
}

public ActionCommandHandler(ICommand<TEventArgs> command, Action<TEventArgs> action)
: base(command)
{
Action = action;
}

public Action<TEventArgs> Action { get; set; }

public override void HandleCommand(TEventArgs args)
{
if (Action != null)
Action(args);
}

public override void HandleCommand()
{
throw new InvalidOperationException();
}
}
}
39 changes: 39 additions & 0 deletions Demos/SharpMapWinFormsDemo/Commands/ButtonCommandSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This file is part of SharpMapMapViewer
* SharpMapMapViewer is free software © 2008 Newgrove Consultants Limited,
* http://www.newgrove.com; you can redistribute it and/or modify it under the terms
* of the current GNU Lesser General Public License (LGPL) as published by and
* available from the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA: http://fsf.org/
* This program is distributed without any warranty;
* without even the implied warranty of merchantability or fitness for purpose.
* See the GNU Lesser General Public License for the full details.
*
* Author: John Diss 2008
*
*/
using System;
using System.Windows.Forms;

namespace MapViewer.Commands
{
public class ButtonCommandSource
: CommandControlSourceBase<Button>
{
protected override void WireControl(Button control)
{
control.Click += control_Click;
}

private void control_Click(object sender, EventArgs e)
{
if (Command != null)
Command.FireCommand();
}

protected override void UnwireControl(Button control)
{
control.Click -= control_Click;
}
}
}
62 changes: 62 additions & 0 deletions Demos/SharpMapWinFormsDemo/Commands/Command.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* This file is part of SharpMapMapViewer
* SharpMapMapViewer is free software © 2008 Newgrove Consultants Limited,
* http://www.newgrove.com; you can redistribute it and/or modify it under the terms
* of the current GNU Lesser General Public License (LGPL) as published by and
* available from the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA: http://fsf.org/
* This program is distributed without any warranty;
* without even the implied warranty of merchantability or fitness for purpose.
* See the GNU Lesser General Public License for the full details.
*
* Author: John Diss 2008
*
*/
using System;

namespace MapViewer.Commands
{
public class Command : ICommand
{
protected readonly string _name;
private bool _enabled = true;

public Command(string name)
{
_name = name;
}

#region ICommand Members

public event EventHandler CommandFired;

public bool Enabled
{
get { return _enabled; }
set
{
if (_enabled != value)
{
_enabled = value;
if (EnabledChanged != null)
EnabledChanged(this, EventArgs.Empty);
}
}
}

public void FireCommand()
{
if (CommandFired != null)
CommandFired(this, EventArgs.Empty);
}

public event EventHandler EnabledChanged;

public string Name
{
get { return _name; }
}

#endregion
}
}
133 changes: 133 additions & 0 deletions Demos/SharpMapWinFormsDemo/Commands/CommandComponentSourceBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
* This file is part of SharpMapMapViewer
* SharpMapMapViewer is free software © 2008 Newgrove Consultants Limited,
* http://www.newgrove.com; you can redistribute it and/or modify it under the terms
* of the current GNU Lesser General Public License (LGPL) as published by and
* available from the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA: http://fsf.org/
* This program is distributed without any warranty;
* without even the implied warranty of merchantability or fitness for purpose.
* See the GNU Lesser General Public License for the full details.
*
* Author: John Diss 2008
*
*/
using System;
using System.ComponentModel;

namespace MapViewer.Commands
{
public abstract class CommandComponentSourceBase<TComponent>
: ICommandComponentSource<TComponent>
where TComponent : IComponent
{
private ICommand _command;
private TComponent _component;
protected CommandEnabledChangedDelegate<TComponent> _enabledChangedAction;

protected CommandComponentSourceBase()
{
_enabledChangedAction = DefaultEnabledChangedAction();
}

protected CommandComponentSourceBase(ICommand command)
: this(default(TComponent), command)
{
}

protected CommandComponentSourceBase(TComponent component)
: this(component, null)
{
}

protected CommandComponentSourceBase(TComponent component, ICommand command)
: this()
{
Command = command;
Component = component;
}

private CommandEnabledChangedDelegate<TComponent> CommandEnabledChangedAction
{
get { return _enabledChangedAction; }
set { _enabledChangedAction = value; }
}

#region ICommandComponentSource<TComponent> Members

public ICommand Command
{
get { return _command; }
set
{
if (_command != null)
_command.EnabledChanged -= CommandEnabledChanged;
if (value != null)
{
_command = value;
_command.EnabledChanged += CommandEnabledChanged;
}
}
}

public TComponent Component
{
get { return _component; }
set
{
if (!Equals(_component, default(TComponent)))
UnwireComponent(_component);
if (!Equals(value, default(TComponent)))
{
_component = value;
WireComponent(_component);
CommandEnabledChanged(null, null);
}
}
}

#endregion

protected abstract CommandEnabledChangedDelegate<TComponent> DefaultEnabledChangedAction();

internal void CommandEnabledChanged(object sender, EventArgs e)
{
if (!Equals(Component, default(TComponent)) && Command != null)
CommandEnabledChangedAction(Component, Command.Enabled);
}

protected abstract void WireComponent(TComponent component);
protected abstract void UnwireComponent(TComponent component);
}

public abstract class CommandComponentSourceBase<TComponent, TEventArgs>
: CommandComponentSourceBase<TComponent>, ICommandComponentSource<TComponent, TEventArgs>
where TComponent : IComponent
where TEventArgs : CommandEventArgs
{
public CommandComponentSourceBase(ICommand<TEventArgs> command)
: this(default(TComponent), command)
{
}

public CommandComponentSourceBase(TComponent component)
: this(component, null)
{
}

public CommandComponentSourceBase(TComponent component, ICommand<TEventArgs> command)
: base(component, command)
{
}

#region ICommandComponentSource<TComponent,TEventArgs> Members

public new ICommand<TEventArgs> Command
{
get { return (ICommand<TEventArgs>) base.Command; }
set { base.Command = value; }
}

#endregion
}
}
Loading

0 comments on commit 41edd64

Please sign in to comment.