Программно-аппаратная система генерации сигналов с заданными параметрами

Дипломная работа - Компьютеры, программирование

Другие дипломы по предмету Компьютеры, программирование



>

using System.Linq;

using Commands;

using Common;

using Plugin;

///

/// TODO: Update summary.

///

public class UndoRedoService : NotifyableObject

{

///

///

///

private readonly Stack();

///

///

///

private readonly Stack();

///

///

///

private Stack();

///

///

///

private Stack();

///

///

///

public bool HasChanges

{

get

{

return !(this.originalUndoCommands.Count == this.undoCommands.Count &&

this.originalRedoCommands.Count == this.redoCommands.Count &&

this.originalUndoCommands.SequenceEqual(this.undoCommands) &&

this.originalRedoCommands.SequenceEqual(this.redoCommands));

}

}

///

///

///

public bool CanUndo

{

get

{

0;"> return this.undoCommands.Count > 0;

}

}

///

///

///

public bool CanRedo

{

get

{

0;"> return this.redoCommands.Count > 0;

}

}

///

///

///

public string UndoTitle

{

get

{

if (this.CanUndo)

{

return string.Format("Undo {0}", this.undoCommands.Peek().Title);

}

return null;

}

}

///

///

///

public string RedoTitle

{

get

{

if (this.CanRedo)

{

return string.Format("Redo {0}", this.redoCommands.Peek().Title);

}

return null;

}

}

///

///

///

///

public void Execute(IDesignerCommand command)

{

if (command == null)

{

return;

}

command.Execute();

this.undoCommands.Push(command);

this.redoCommands.Clear();

this.Update();

}

///

///

///

public void Undo()

{

if (!this.CanUndo)

{

return;

}

var command = this.undoCommands.Pop();

command.Undo();

this.redoCommands.Push(command);

this.Update();

}

///

///

///

public void Redo()

{

if (!this.CanRedo)

{

return;

}

var command = this.redoCommands.Pop();

command.Redo();

this.undoCommands.Push(command);

this.Update();

}

///

///

///

public void AcceptChanges()

{

(this.redoCommands);"> this.originalRedoCommands = new Stack(this.redoCommands);

(this.undoCommands);"> this.originalUndoCommands = new Stack(this.undoCommands);

}

///

///

///

private void Update()

{

this.Notify("UndoTitle");

this.Notify("RedoTitle");

}

}

}

Файл /Siglab/PluginService.csSiglab

{

using System;

using System.Collections.Generic;

using System.ComponentModel.Composition;

using System.ComponentModel.Composition.Hosting;

using System.IO;

using System.Linq;

using Plugin;

///

/// Plugin manager.

///

public class PluginService

{

public PluginService(string pluginDirectory)

{

this.PluginDirectory = pluginDirectory;

this.LoadPlugins();

}

[ImportMany]

public List Plugins

{

get;

protected set;

}

public string PluginDirectory

{

get;

private set;

}

public Plugin GetPlugin(string name)

{

n.Metadata.Name.Equals(name));"> var pluginFactory = this.Plugins.FirstOrDefault(n => n.Metadata.Name.Equals(name));

if (pluginFactory == null)

{

return null;

}

var plugin = pluginFactory.CreateExport().Value;

return plugin;

}

private void LoadPlugins()

{

var catalog = new AggregateCatalog();

var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this.PluginDirectory);

foreach (var directory in Directory.GetDirectories(path))

{

catalog.Catalogs.Add(new DirectoryCatalog(directory));

}

var container = new CompositionContainer(catalog);

container.ComposeParts(this);

}

}

}

Файл \Plugin\Plugin.cs\Plugin

{

using System;

using System.Collections.Generic;

using System.Windows;

using System.Windows.Controls;

using System.Xml.Linq;

///

/// Describes a plugin.

///

public abstract class Plugin : ISettings

{

private readonly List();

///

/// Initializes a new instance of the Plugin class.

///

protected Plugin()

{

this.Metadata = (PluginAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(PluginAttribute));

}

public List Ports

{

get

{

return this.ports;

}

}

///

/// Gets the metadata.

///

public PluginAttribute Metadata

{

get;

private set;

}

///

/// Gets or sets the view.

///

public UserControl View

{

get;

protected set;

}

///

/// Gets the name.

///

public string Name

{

get

{

return this.Metadata.Name;

}

}

///

/// Gets the library.

Copyright © 2008-2014 geum.ru   рубрикатор по предметам  рубрикатор по типам работ  пользовательское соглашение