Example #1
0
        protected virtual void OnInvokeClicked(object sender, System.EventArgs e)
        {
            foreach (var child in outputsBox.Children)
            {
                outputsBox.Remove(child);
            }

            var arguments = new Dictionary <string, string> ();
            var children  = table.Children;

            for (var i = children.Length - 1; i > 0; i -= 2)
            {
                string value;
                var    child = children[i - 1];
                var    entry = child as Entry;
                if (entry != null)
                {
                    value = entry.Text;
                }
                else
                {
                    value = ((ComboBox)child).ActiveText;
                }
                arguments[((Label)children[i]).Text] = value;
            }

            inputsBox.Sensitive = false;
            invoke.Sensitive    = false;

            ThreadPool.QueueUserWorkItem(state => {
                try  {
                    var results = action.Invoke(arguments);
                    if (results == null)
                    {
                        return;
                    }
                    Application.Invoke((o, a) => {
                        foreach (var result in results)
                        {
                            var expander = new Expander(result.Key);
                            expander.Add(new Label(result.Value)
                            {
                                LineWrap = true, Selectable = true
                            });
                            outputsBox.PackStart(expander, false, false, 0);
                        }
                        outputsBox.ShowAll();
                        inputsBox.Sensitive = true;
                        invoke.Sensitive    = true;
                    });
                } catch (UpnpControlException exception) {
                    // TODO report error to the UI
                    Console.WriteLine("Upnp error: " + exception.UpnpError);
                }
            });
        }