Наследование: IDisposable, IConfiguration
Пример #1
0
    public void Run()
    {
        bool enabled = true;

            try
            {
                Songcast songcast = new Songcast("av.openhome.org", 522, 1, 1, 100, false, enabled, 99, this, this, this, "OpenHome", "http://www.openhome.org", "http://www.openhome.org", new byte[] { }, String.Empty);

                while (true)
                {
                    ConsoleKeyInfo key = Console.ReadKey(true);

                    if (key.KeyChar == 'q')
                    {
                        break;
                    }

                    if (key.KeyChar == 'a')
                    {
                        songcast.SetSubnet(43200);
                    }

                    if (key.KeyChar == 'e')
                    {
                        if (enabled)
                        {
                            enabled = false;
                        }
                        else
                        {
                            enabled = true;
                        }

                        songcast.SetEnabled(enabled);

                        continue;
                    }
                }

                songcast.Dispose();
            }
            catch (SongcastError e)
            {
                Console.WriteLine(e.Message);
            }
    }
Пример #2
0
        public void Start(string aDomain, string aManufacturer, string aManufacturerUrl, string aModelUrl, byte[] aImage, string aMimeType)
        {
            if (iSongcast != null)
            {
                return;
            }

            // songcast always starts disabled
            if (EventEnabledChanged != null)
            {
                EventEnabledChanged(this, EventArgs.Empty);
            }

            // create the songcast object
            uint ttl     = 4;
            bool enabled = false;
            uint preset  = 0;

            iSongcast = new OpenHome.Songcast.Songcast(aDomain, iPreferences.SelectedSubnetAddress, iPreferences.MulticastChannel,
                                                       ttl, LatencyMs, iPreferences.MulticastEnabled,
                                                       enabled, preset, iSongcastMonitor, iSongcastMonitor, iSongcastMonitor, iSongcastMonitor,
                                                       aManufacturer, aManufacturerUrl, aModelUrl, aImage, aMimeType);
        }
Пример #3
0
        public MainWindow()
        {
            InitializeComponent();

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(EventCurrentDomainUnhandledException);

            this.DataContext = this;

            iExtendedNotifyIcon             = new ExtendedNotifyIcon(Properties.Resources.Icon);
            iExtendedNotifyIcon.Click      += EventNotifyIconClick;
            iExtendedNotifyIcon.RightClick += EventNotifyIconRightClick;

            System.Windows.Forms.ContextMenu menu = new System.Windows.Forms.ContextMenu();

            System.Windows.Forms.MenuItem open = new System.Windows.Forms.MenuItem("Open", new EventHandler(EventContextMenuOpen));
            System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("Exit", new EventHandler(EventContextMenuExit));

            menu.MenuItems.Add(open);
            menu.MenuItems.Add(exit);

            iExtendedNotifyIcon.ContextMenu = menu;

            Left = SystemParameters.WorkArea.Width - LayoutRoot.Width - 10;
            Top  = SystemParameters.WorkArea.Height - LayoutRoot.Height - 2;

            iConfigurationWindow = new ConfigurationWindow();
            iMediaPlayerWindow   = new MediaPlayerWindow(iConfigurationWindow.Enabled, this);

            iConfigurationWindow.Left = Left;
            iConfigurationWindow.Top  = Top - iConfigurationWindow.LayoutRoot.Height + 1;

            iMediaPlayerWindow.Left = Left;
            iMediaPlayerWindow.Top  = Top - iMediaPlayerWindow.LayoutRoot.Height + 1;

            // Locate these storyboards and "cache" them - we only ever want to find these once for performance reasons
            iStoryBoardFadeIn             = (Storyboard)this.TryFindResource("storyBoardFadeIn");
            iStoryBoardFadeIn.Completed  += new EventHandler(EventStoryBoardFadeInCompleted);
            iStoryBoardFadeOut            = (Storyboard)TryFindResource("storyBoardFadeOut");
            iStoryBoardFadeOut.Completed += new EventHandler(EventStoryBoardFadeOutCompleted);

            this.Closing += EventWindowClosing;

            System.Drawing.Image image = OpenHome.Songcast.Properties.Resources.Icon.ToBitmap();

            MemoryStream stream = new MemoryStream();

            image.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);

            byte[] bytes = stream.ToArray();

            try
            {
                iSongcast = new Songcast("av.openhome.org", iConfigurationWindow.Subnet, iConfigurationWindow.Channel, iConfigurationWindow.Ttl, iConfigurationWindow.Latency, iConfigurationWindow.Multicast, iConfigurationWindow.Enabled, iConfigurationWindow.Preset, iMediaPlayerWindow.ReceiverList, iConfigurationWindow.SubnetList, this, "OpenHome", "http://www.openhome.org", "http://www.openhome.org", bytes, "image/bmp");
            }
            catch (SongcastError e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                App.Current.Shutdown(1);
            }

            iConfigurationWindow.SubnetChanged    += EventSubnetChanged;
            iConfigurationWindow.MulticastChanged += EventMulticastChanged;
            iConfigurationWindow.ChannelChanged   += EventMulticastChannelChanged;
            iConfigurationWindow.TtlChanged       += EventTtlChanged;
            iConfigurationWindow.LatencyChanged   += EventLatencyChanged;
            iConfigurationWindow.PresetChanged    += EventPresetChanged;

            bool value = iConfigurationWindow.Enabled;

            iMediaPlayerWindow.SetEnabled(value);

            Settings.Click  += new RoutedEventHandler(EventSettingsClick);
            Receivers.Click += new RoutedEventHandler(EventReceiversClick);

            this.Topmost = true;
            iConfigurationWindow.Topmost = true;
            iMediaPlayerWindow.Topmost   = true;
        }
Пример #4
0
        public MainWindow()
        {
            InitializeComponent();

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(EventCurrentDomainUnhandledException);

            this.DataContext = this;

            iExtendedNotifyIcon = new ExtendedNotifyIcon(Properties.Resources.Icon);
            iExtendedNotifyIcon.Click += EventNotifyIconClick;
            iExtendedNotifyIcon.RightClick += EventNotifyIconRightClick;

            System.Windows.Forms.ContextMenu menu = new System.Windows.Forms.ContextMenu();

            System.Windows.Forms.MenuItem open = new System.Windows.Forms.MenuItem("Open", new EventHandler(EventContextMenuOpen));
            System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("Exit", new EventHandler(EventContextMenuExit));

            menu.MenuItems.Add(open);
            menu.MenuItems.Add(exit);

            iExtendedNotifyIcon.ContextMenu = menu;

            Left = SystemParameters.WorkArea.Width - LayoutRoot.Width - 10;
            Top = SystemParameters.WorkArea.Height - LayoutRoot.Height - 2;

            iConfigurationWindow = new ConfigurationWindow();
            iMediaPlayerWindow = new MediaPlayerWindow(iConfigurationWindow.Enabled, this);

            iConfigurationWindow.Left = Left;
            iConfigurationWindow.Top = Top - iConfigurationWindow.LayoutRoot.Height + 1;

            iMediaPlayerWindow.Left = Left;
            iMediaPlayerWindow.Top = Top - iMediaPlayerWindow.LayoutRoot.Height + 1;

            // Locate these storyboards and "cache" them - we only ever want to find these once for performance reasons
            iStoryBoardFadeIn = (Storyboard)this.TryFindResource("storyBoardFadeIn");
            iStoryBoardFadeIn.Completed += new EventHandler(EventStoryBoardFadeInCompleted);
            iStoryBoardFadeOut = (Storyboard)TryFindResource("storyBoardFadeOut");
            iStoryBoardFadeOut.Completed += new EventHandler(EventStoryBoardFadeOutCompleted);

            this.Closing += EventWindowClosing;

            System.Drawing.Image image = OpenHome.Songcast.Properties.Resources.Icon.ToBitmap();

            MemoryStream stream = new MemoryStream();

            image.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);

            byte[] bytes = stream.ToArray();

            try
            {
                iSongcast = new Songcast("av.openhome.org", iConfigurationWindow.Subnet, iConfigurationWindow.Channel, iConfigurationWindow.Ttl, iConfigurationWindow.Latency, iConfigurationWindow.Multicast, iConfigurationWindow.Enabled, iConfigurationWindow.Preset, iMediaPlayerWindow.ReceiverList, iConfigurationWindow.SubnetList, this, "OpenHome", "http://www.openhome.org", "http://www.openhome.org", bytes, "image/bmp");
            }
            catch (SongcastError e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                App.Current.Shutdown(1);
            }

            iConfigurationWindow.SubnetChanged += EventSubnetChanged;
            iConfigurationWindow.MulticastChanged += EventMulticastChanged;
            iConfigurationWindow.ChannelChanged += EventMulticastChannelChanged;
            iConfigurationWindow.TtlChanged += EventTtlChanged;
            iConfigurationWindow.LatencyChanged += EventLatencyChanged;
            iConfigurationWindow.PresetChanged += EventPresetChanged;

            bool value = iConfigurationWindow.Enabled;

            iMediaPlayerWindow.SetEnabled(value);

            Settings.Click += new RoutedEventHandler(EventSettingsClick);
            Receivers.Click += new RoutedEventHandler(EventReceiversClick);

            this.Topmost = true;
            iConfigurationWindow.Topmost = true;
            iMediaPlayerWindow.Topmost = true;
        }