상속: IDebugDataAccess, IDisposable
 void ContextConnectionState(DebugContext ctx, System.Data.ConnectionState state)
 {
     this.Dispatcher.BeginInvoke((Action)delegate
     {
         txtStatus.Text = state.ToString();
     });
 }
 void ContextDebugLevel(DebugContext ctx, bool fullLogs)
 {
     this.Dispatcher.BeginInvoke((Action)delegate
     {
         chkFullLogs.IsChecked = fullLogs;
     });
 }
        void CtxRefreshAllIocs(DebugContext ctx)
        {
            this.Dispatcher.BeginInvoke((Action)delegate
            {
                lstChannels.Items.Clear();
                lstIocs.Items.Clear();

                foreach (var i in ctx.Iocs)
                {
                    lstIocs.Items.Add(new TextBlock { Text = i.Name });
                }
                lstIocs.SelectedIndex = -1;
            }, new object[] { });
        }
        void Start()
        {
            GatewayChooser dlg = new GatewayChooser();
            dlg.Owner = this;
            dlg.Gateway = (string)Properties.Settings.Default["StoredGateway"];
            if (dlg.ShowDialog() == false)
            {
                Application.Current.Shutdown();
            }
            Properties.Settings.Default["StoredGateway"] = dlg.Gateway;
            Properties.Settings.Default.Save();

            context = new DebugContext(dlg.Gateway);
            context.RefreshAllIocs += new RefreshAllDelegate(CtxRefreshAllIocs);
            context.NewIocChannel += new NewConnectionChannelDelegate(CtxNewIocChannel);
            context.DropIoc += new DropConnectionDelegate(CtxDropIoc);
            context.RefreshAllClients += new RefreshAllDelegate(ContextRefreshAllClients);
            context.NewClientChannel += new NewConnectionChannelDelegate(ContextNewClientChannel);
            context.DropClient += new DropConnectionDelegate(ContextDropClient);
            context.ConnectionState += new ContextConnectionDelegate(ContextConnectionState);
            context.DebugLog += new DebugLogDelegate(ContextDebugLog);
            context.NewName += new NewGatewayNameDelegate(ContextNewName);
            context.DebugLevel += new DebugLevelDelegate(ContextDebugLevel);
        }
        void CtxNewIocChannel(DebugContext ctx, string ioc, string channel)
        {
            this.Dispatcher.BeginInvoke((Action)delegate
            {
                bool iocIsKnown = lstIocs.Items.Cast<TextBlock>().Any(i => i.Text == ioc);
                if (!iocIsKnown)
                {
                    lstIocs.Items.Add(new TextBlock { Text = ioc });
                }

                if (lstIocs.SelectedIndex != -1 && ((TextBlock)lstIocs.SelectedItem).Text == ioc)
                {
                    lstChannels.Items.Add(new TextBlock { Text = channel });
                }
            });
        }
 void CtxDropIoc(DebugContext ctx, string ioc)
 {
     CtxRefreshAllIocs(ctx);
 }
        void ContextNewName(DebugContext ctx, string name)
        {
            this.Dispatcher.BeginInvoke((Action)delegate
            {
                if (epicsClient != null)
                {
                    foreach (var i in channels)
                    {
                        i.Dispose();
                    }
                    channels.Clear();
                    epicsClient.Dispose();
                }
                txtGatewayName.Text = name;

                epicsClient = new EpicsClient();
                epicsClient.Configuration.SearchAddress = (string)Properties.Settings.Default["StoredGateway"];

                foreach (var i in channelNames)
                {
                    EpicsChannel<string> channel = epicsClient.CreateChannel<string>(name + i);
                    channels.Add(channel);
                    channel.MonitorChanged += new EpicsDelegate<string>(ChannelMonitorChanged);
                }
            });
        }
        void ContextNewClientChannel(DebugContext ctx, string client, string channel)
        {
            this.Dispatcher.BeginInvoke((Action)delegate
            {
                bool cIsKnown = lstClients.Items.Cast<TextBlock>().Any(i => i.Text == client);

                if (!cIsKnown)
                    lstClients.Items.Add(new TextBlock { Text = client });

                if (lstClients.SelectedIndex != -1 && ((TextBlock)lstClients.SelectedItem).Text == client)
                {
                    lstClientsChannels.Items.Add(new TextBlock { Text = channel });
                }
            });
        }
 void ContextDropClient(DebugContext ctx, string host)
 {
     ContextRefreshAllClients(ctx);
 }