Exemplo n.º 1
0
        public override void Preview()
        {
            //Save the current resource to another session copy
            string resId  = $"Session:{this.EditorService.SessionID}//Preview{Guid.NewGuid()}.{this.Resource.ResourceType.ToString()}"; //NOXLATE
            string xml    = this.XmlContent;
            var    resSvc = this.EditorService.CurrentConnection.ResourceService;

            try
            {
                using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(xml)))
                {
                    resSvc.SetResourceXmlData(resId, ms);
                }
            }
            catch (Exception ex)
            {
                XmlContentErrorDialog.CheckAndHandle(ex, xml, false);
            }

            //Copy any resource data
            var previewCopy = resSvc.GetResource(resId);
            var conn        = _edSvc.CurrentConnection;

            this.Resource.CopyResourceDataTo(conn, previewCopy);
            var previewer = ResourcePreviewerFactory.GetPreviewer(conn.ProviderName);

            if (previewer != null)
            {
                previewer.Preview(previewCopy, this.EditorService);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Previews this resource
        /// </summary>
        public virtual void Preview()
        {
            var conn = this.EditorService.CurrentConnection;

            _svc.PrePreviewProcess();
            var previewer = ResourcePreviewerFactory.GetPreviewer(conn.ProviderName);

            if (previewer != null)
            {
                previewer.Preview(this.Resource, this.EditorService, _svc.PreviewLocale);
            }
        }
Exemplo n.º 3
0
 private void btnPreview_Click(object sender, EventArgs e)
 {
     if (SyncXml())
     {
         var previewer = ResourcePreviewerFactory.GetPreviewer(_conn.ProviderName);
         if (previewer != null)
         {
             previewer.Preview(_svc.GetEditedResource(), _svc);
         }
         else
         {
             MessageBox.Show(string.Format(Strings.NoRegisteredPreviewerForProvider, _conn.ProviderName));
         }
     }
 }
        public override void Run()
        {
            ResourceService.RegisterNeutralImages(Properties.Resources.ResourceManager);
            ResourceService.RegisterNeutralStrings(Strings.ResourceManager);

            if (!Platform.IsRunningOnMono)
            {
                ResourcePreviewerFactory.RegisterPreviewer(LocalConnection.PROVIDER_NAME, new LocalPreviewer());

                System.Windows.Forms.Application.ApplicationExit += new EventHandler(OnAppExit);
            }
            else
            {
                LoggingService.Info("Skipping local connection provider registration because I am guessing we're running Mono on Linux/Mac"); //LOCALIZEME
            }
        }
        public override void Run()
        {
            ResourceService.RegisterNeutralImages(Properties.Resources.ResourceManager);
            ResourceService.RegisterNeutralStrings(Strings.ResourceManager);

            Workbench.WorkbenchInitialized += (sender, e) =>
            {
                PreviewSettings.UseAjaxViewer   = PropertyService.Get(ConfigProperties.PreviewViewerType, "AJAX") == "AJAX"; //NOXLATE
                PreviewSettings.UseLocalPreview = PropertyService.Get(ConfigProperties.UseLocalPreview, ConfigProperties.DefaultUseLocalPreview);

                var urlLauncher = ServiceRegistry.GetService <UrlLauncherService>();
                var vcMgr       = ServiceRegistry.GetService <ViewContentManager>();
                ResourcePreviewerFactory.RegisterPreviewer("Maestro.Http", new LocalMapPreviewer(new DefaultResourcePreviewer(urlLauncher), urlLauncher, vcMgr)); //NOXLATE
                ResourcePreviewerFactory.RegisterPreviewer("Maestro.Rest", new LocalMapPreviewer(new DefaultResourcePreviewer(urlLauncher), urlLauncher, vcMgr)); //NOXLATE
                //A stub previewer does nothing, but will use local map previews for applicable resources if the configuration
                //property is set
                ResourcePreviewerFactory.RegisterPreviewer("Maestro.LocalNative", new LocalMapPreviewer(new StubPreviewer(), urlLauncher, vcMgr)); //NOXLATE

                ServiceRegistry.GetService <NewItemTemplateService>().InitUserTemplates();
                var wb = Workbench.Instance;

                Themes.CurrentTheme = Props.Get <string>(ConfigProperties.SelectedTheme, ConfigProperties.DefaultSelectedTheme);
                var themeToApply = Themes.Get(Themes.CurrentTheme);
                if (themeToApply != null)
                {
                    wb.ApplyTheme(themeToApply);
                }

                wb.FormClosing += new System.Windows.Forms.FormClosingEventHandler(OnWorkbenchClosing);
                wb.Text         = "MapGuide Maestro"; //NOXLATE

                if (Props.Get(ConfigProperties.ShowMessages, true))
                {
                    vcMgr.OpenContent <MessageViewer>(ViewRegion.Bottom);
                }

                if (Props.Get(ConfigProperties.ShowOutboundRequests, true))
                {
                    vcMgr.OpenContent <OutboundRequestViewer>(ViewRegion.Bottom);
                }

                LoginCommand.RunInternal(true);
            };
        }
Exemplo n.º 6
0
        /// <summary>
        /// Launches a preview of the given open resource
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="resourceId"></param>
        /// <param name="locale"></param>
        public void PreviewResource(IServerConnection conn, string resourceId, string locale)
        {
            Action action = () =>
            {
                var siteExp = this.MainWindow.ActiveSiteExplorer;
                var omgr    = ServiceRegistry.GetService <OpenResourceManager>();
                IEditorViewContent openEd = null;
                foreach (var ed in omgr.OpenEditors)
                {
                    if (ed.EditorService.CurrentConnection == conn && ed.EditorService.ResourceID == resourceId)
                    {
                        openEd = ed;
                        break;
                    }
                }
                if (openEd != null)
                {
                    var previewer = ResourcePreviewerFactory.GetPreviewer(conn.ProviderName);
                    if (previewer != null)
                    {
                        previewer.Preview(openEd.Resource, openEd.EditorService, locale);
                    }
                    else
                    {
                        throw new Exception(string.Format(Strings.Error_NoPreviewer, conn.ProviderName));
                    }
                }
                else
                {
                    throw new Exception(string.Format(Strings.Error_NoOpenEditor, resourceId));
                }
            };

            if (this.MainWindow.InvokeRequired)
            {
                this.MainWindow.Invoke(action);
            }
            else
            {
                action();
            }
        }
Exemplo n.º 7
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.SetCompatibleTextRenderingDefault(false);

            //Init the Maestro connection registry with additional providers from ConnectionProviders.xml
            ConnectionProviderRegistry.InitRegistry();

            //Register previewers
            var urlLauncher = new OurUrlLauncher();

            ResourcePreviewerFactory.RegisterPreviewer("Maestro.Http", new LocalMapPreviewer(new DefaultResourcePreviewer(urlLauncher), urlLauncher, null)); //NOXLATE
            //A stub previewer does nothing, but will use local map previews for applicable resources if the configuration
            //property is set
            ResourcePreviewerFactory.RegisterPreviewer("Maestro.LocalNative", new LocalMapPreviewer(new StubPreviewer(), urlLauncher, null)); //NOXLATE

            //Can't use this code, it requires a call to MgdPlatform.Initialize which we can't call indirectly :(

            /*
             * //Try to tap into mg-desktop coordinate system services if possible
             * try
             * {
             *  var provEntry = ConnectionProviderRegistry.FindProvider("Maestro.Local"); //NOXLATE
             *  if (provEntry != null)
             *  {
             *      string path = provEntry.AssemblyPath;
             *      Assembly asm = Assembly.LoadFrom(path); //NOXLATE
             *      if (asm != null)
             *      {
             *          Type mpuType = asm.GetType("OSGeo.MapGuide.MaestroAPI.Native.LocalNativeMpuCalculator"); //NOXLATE
             *          Type catType = asm.GetType("OSGeo.MapGuide.MaestroAPI.Native.LocalNativeCoordinateSystemCatalog"); //NOXLATE
             *
             *          if (mpuType != null && catType != null)
             *          {
             *              IMpuCalculator calc = (IMpuCalculator)Activator.CreateInstance(mpuType);
             *              ICoordinateSystemCatalog csCatalog = (ICoordinateSystemCatalog)Activator.CreateInstance(catType);
             *
             *              CsHelper.DefaultCalculator = calc;
             *              CsHelper.DefaultCatalog = csCatalog;
             *              Debug.WriteLine("Using mg-desktop coordinate system services where possible");
             *          }
             *      }
             *  }
             *  else
             *  {
             *      Debug.WriteLine("No mg-desktop coordinate system services to tap into. Using default services");
             *  }
             * }
             * catch (Exception ex)
             * {
             * }
             */

            var login = new Login.LoginDialog();

            if (login.ShowDialog() == DialogResult.OK)
            {
                var conn = login.Connection;

                //TODO: Validate connection capabilities
                Application.Run(new MainForm(conn));
            }
        }