/// <summary> /// Здесь запускается аддон /// </summary> /// <param name="mainWindow">Главное окно Цирцеи</param> public override void Run(IMainWindow mainWindow) { this.mainWindow = mainWindow; this.data = Data.Load(); IBaseWindow activeWindow = mainWindow.ActiveIRCWindow; if (activeWindow is IServerWindow) { IServerWindow server = activeWindow as IServerWindow; this.data.Info.Server.Name = server.Server.Name; this.data.Info.Nick = new NickName(server.Nick); } else if (activeWindow is IChannelWindow) { IChannelWindow channelWindow2 = activeWindow as IChannelWindow; this.data.Info.Server.Name = channelWindow2.OwnerServerWindow.Server.Name; this.data.Info.Nick = new NickName(channelWindow2.OwnerServerWindow.Nick); this.data.Channel = channelWindow2.WindowName; } else if (activeWindow is IPrivateWindow) { IPrivateWindow privateWindow = activeWindow as IPrivateWindow; this.data.Info.Server.Name = privateWindow.OwnerServerWindow.Server.Name; this.data.Info.Nick = new NickName(privateWindow.OwnerServerWindow.Nick); } else { this.data.Info.Nick = new NickName(mainWindow.DefaultNick); } this.connectionForm = (ConnectionForm)this.mainWindow.CreateObject(AppDomain.CurrentDomain, typeof(ConnectionForm), this.data); if (this.connectionForm == null) { ManualClose(); return; } if (this.mainWindow.ShowDialog(connectionForm) == DialogResult.OK) { this.data = this.connectionForm.Data; this.serverWindow = mainWindow.OpenConnection(this.data.Info); this.serverWindow.Disposed += (sender, e) => ManualClose(); if (this.serverWindow.IsConnected) { this.mainWindow.RunCallback(new Special.Action(Futher)); } else { this.serverWindow.OnConnected += new EventHandler(serverWindow_OnConnected); this.serverWindow.Connect(); } } else { ManualClose(); } }
public RequestHandler(IServerWindow serverWindow, string codeSyncDirectory) { if (string.IsNullOrWhiteSpace(codeSyncDirectory)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(codeSyncDirectory)); } if (!Directory.Exists(codeSyncDirectory)) { throw new DirectoryNotFoundException("Code sync directory does not exist."); } _ServerWindow = serverWindow ?? throw new ArgumentNullException(nameof(serverWindow)); _CodeSyncDirectory = codeSyncDirectory; _InformationRegex = new Regex(@"^-- CodeSync: (\w+)"); }
public Program(IWebServer webServer, IServerWindow serverWindow) { _WebServer = webServer ?? throw new ArgumentNullException(nameof(webServer)); _ServerWindow = serverWindow ?? throw new ArgumentNullException(nameof(serverWindow)); }