Пример #1
0
        public Result OnStartup(UIControlledApplication application)
        {
            _instance    = this;
            _application = application;

            try
            {
                _serviceHost = new ServiceHost(typeof(SockeyeService), new Uri("net.pipe://localhost/mcneel/sockeyeserver/1/server"));
            }
            catch
            {
                TaskDialog.Show("Sockeye", "Failed to create Sockeye service host.");
                throw;
            }

            try
            {
                _serviceHost.AddServiceEndpoint(typeof(ISockeyeService), new NetNamedPipeBinding(), "pipe");
            }
            catch
            {
                TaskDialog.Show("Sockeye", "Failed to create Sockeye service end point.");
                throw;
            }

            try
            {
                ServiceDebugBehavior debugBehavior = _serviceHost.Description.Behaviors.Find <ServiceDebugBehavior>();
                if (null == debugBehavior)
                {
                    debugBehavior = new ServiceDebugBehavior();
                    debugBehavior.IncludeExceptionDetailInFaults = true;
                    _serviceHost.Description.Behaviors.Add(debugBehavior);
                }
                else
                {
                    debugBehavior.IncludeExceptionDetailInFaults = true;
                }
            }
            catch
            {
                TaskDialog.Show("Sockeye", "Failed to create Sockeye service debug behavior.");
                throw;
            }

            try
            {
                _serviceHost.Open();
            }
            catch
            {
                TaskDialog.Show("Sockeye", "Failed to open Sockeye service.");
                throw;
            }

            RibbonPanel ribbonPanel = application.CreateRibbonPanel(_assemblyTitle);

            PushButton pushButton = ribbonPanel.AddItem(new PushButtonData(
                                                            _assemblyTitle, _assemblyTitle, _assemblyLocation, "SockeyeServer.Commands.CmdAbout")) as PushButton;

            Bitmap logo = SockeyeServer.Properties.Resources.Logo_32_32;

            BitmapSource bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(
                logo.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

            pushButton.LargeImage = bitmapSource;
            pushButton.Image      = bitmapSource;

            return(Result.Succeeded);
        }
Пример #2
0
        public Result OnStartup(UIControlledApplication application)
        {
            _instance = this;
              _application = application;

              try
              {
            _serviceHost = new ServiceHost(typeof(SockeyeService), new Uri("net.pipe://localhost/mcneel/sockeyeserver/1/server"));
              }
              catch
              {
            TaskDialog.Show("Sockeye", "Failed to create Sockeye service host.");
            throw;
              }

              try
              {
            _serviceHost.AddServiceEndpoint(typeof(ISockeyeService), new NetNamedPipeBinding(), "pipe");
              }
              catch
              {
            TaskDialog.Show("Sockeye", "Failed to create Sockeye service end point.");
            throw;
              }

              try
              {
            ServiceDebugBehavior debugBehavior = _serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>();
            if (null == debugBehavior)
            {
              debugBehavior = new ServiceDebugBehavior();
              debugBehavior.IncludeExceptionDetailInFaults = true;
              _serviceHost.Description.Behaviors.Add(debugBehavior);
            }
            else
            {
              debugBehavior.IncludeExceptionDetailInFaults = true;
            }
              }
              catch
              {
            TaskDialog.Show("Sockeye", "Failed to create Sockeye service debug behavior.");
            throw;
              }

              try
              {
            _serviceHost.Open();
              }
              catch
              {
            TaskDialog.Show("Sockeye", "Failed to open Sockeye service.");
            throw;
              }

              RibbonPanel ribbonPanel = application.CreateRibbonPanel(_assemblyTitle);

              PushButton pushButton = ribbonPanel.AddItem(new PushButtonData(
            _assemblyTitle, _assemblyTitle, _assemblyLocation, "SockeyeServer.Commands.CmdAbout")) as PushButton;

              Bitmap logo = SockeyeServer.Properties.Resources.Logo_32_32;

              BitmapSource bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(
            logo.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

              pushButton.LargeImage = bitmapSource;
              pushButton.Image = bitmapSource;

              return Result.Succeeded;
        }