/// <summary>
        /// Lets the user choose a file to upload, and then transfers it
        /// </summary>
        /// <param name="owner">The owner form</param>
        /// <param name="con">The connection to use</param>
        /// <returns>A DialogResult object that indicates the upload result</returns>
        public static DialogResult UploadPackage(Form owner, IServerConnection con)
        {
            OpenFileDialog dlg = DialogFactory.OpenFile();
            //Mono does NOT like this one
            //dlg.AutoUpgradeEnabled = true;
            dlg.CheckFileExists = true;
            dlg.CheckPathExists = true;
            dlg.DefaultExt = ".mgp"; //NOXLATE
            dlg.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickMgp, "mgp") + "|" + //NOXLATE
                         string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickZip, "zip") + "|" + //NOXLATE
                         StringConstants.AllFilesFilter;
            dlg.FilterIndex = 0;
            dlg.Multiselect = false;
            dlg.ValidateNames = true;
            dlg.Title = Strings.UploadPackageDialogTitle;

            if (dlg.ShowDialog(owner) == DialogResult.OK)
            {
                var optDiag = new PackageUploadOptionDialog();
                optDiag.ShowDialog();
                if (optDiag.Method == PackageUploadMethod.Transactional)
                {
                    return UploadPackage(owner, con, dlg.FileName);
                }
                else
                {
                    return StartNonTransactionalUploadLoop(owner, con, dlg.FileName);
                }
            }
            else
                return DialogResult.Cancel;
        }
예제 #2
0
 private void lnkLoadImage_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     using (var open = DialogFactory.OpenFile())
     {
         open.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickPng, "png"); //NOXLATE
         if (open.ShowDialog() == DialogResult.OK)
         {
             byte[] content = File.ReadAllBytes(open.FileName);
             //HACK: Leaky Abstraction. The impl of IImageGraphic.Item returns a new instance
             //So these are not the same reference
             _imageInline.Content = content;
             if (_image.Item.Type == ImageType.Inline)
             {
                 _image.Item = _imageInline;
             }
             txtImageBase64.Text = Convert.ToBase64String(content);
             txtImageBase64.Tag  = content;
             using (var ms = new MemoryStream(content))
             {
                 Image img = Image.FromStream(ms);
                 symSizeX.Content = $"'{PxToMM(img.Width, 96).ToString(System.Globalization.CultureInfo.InvariantCulture)}'";  //NOXLATE
                 symSizeY.Content = $"'{PxToMM(img.Height, 96).ToString(System.Globalization.CultureInfo.InvariantCulture)}'"; //NOXLATE
             }
         }
     }
 }
        public override void Run()
        {
            var wb      = Workbench.Instance;
            var exp     = wb.ActiveSiteExplorer;
            var connMgr = ServiceRegistry.GetService <ServerConnectionManager>();
            var conn    = connMgr.GetConnection(exp.ConnectionName);

            using (var open = DialogFactory.OpenFile())
            {
                open.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickMgp, "mgp"); //NOXLATE
                if (open.ShowDialog(wb) == System.Windows.Forms.DialogResult.OK)
                {
                    var optDiag = new PackageUploadOptionDialog();
                    optDiag.ShowDialog();
                    DialogResult res;
                    if (optDiag.Method == PackageUploadMethod.Transactional)
                    {
                        res = PackageProgress.UploadPackage(wb,
                                                            conn,
                                                            open.FileName);
                    }
                    else
                    {
                        res = PackageProgress.StartNonTransactionalUploadLoop(wb, conn, open.FileName);
                    }
                    if (res == System.Windows.Forms.DialogResult.OK)
                    {
                        exp.RefreshModel(conn.DisplayName);
                    }
                }
            }
        }
 private void btnProviderTemplate_Click(object sender, EventArgs e)
 {
     using (var dlg = DialogFactory.OpenFile())
     {
         dlg.Title  = string.Format(Strings.LocateExecutable, "ProviderTemplate.exe");                                                  //NOXLATE
         dlg.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickExe, "exe"); //NOXLATE
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             txtProviderTemplateTool.Text = dlg.FileName;
         }
     }
 }
예제 #5
0
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     using (var open = DialogFactory.OpenFile())
     {
         open.InitialDirectory = Application.StartupPath;
         open.RestoreDirectory = true;
         open.Filter           = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickIni, "ini"); //NOXLATE
         if (open.ShowDialog() == DialogResult.OK)
         {
             LastIniPath = txtPlatformConfig.Text = open.FileName;
             UpdateLoginStatus();
         }
     }
 }
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     using (var dlg = DialogFactory.OpenFile())
     {
         dlg.InitialDirectory = Application.StartupPath;
         //WTF does this default to false??? Does MS not realize that changing directories
         //via this dialog absolutely screws up file/assembly loading from relative paths?
         dlg.RestoreDirectory = true;
         dlg.Filter           = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickIni, "ini"); //NOXLATE
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             LastIniPath = txtWebConfig.Text = dlg.FileName;
         }
     }
 }
예제 #7
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string filter = GetFilter();

            using (var dlg = DialogFactory.OpenFile())
            {
                dlg.Filter      = filter;
                dlg.Multiselect = true;
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    _lpt.AddFiles(dlg.FileNames);
                    OnResourceChanged();
                }
            }
        }
예제 #8
0
        public override void Run()
        {
            var wb      = Workbench.Instance;
            var exp     = wb.ActiveSiteExplorer;
            var connMgr = ServiceRegistry.GetService <ServerConnectionManager>();
            var conn    = connMgr.GetConnection(exp.ConnectionName);

            using (var open = DialogFactory.OpenFile())
            {
                open.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickMgp, "mgp"); //NOXLATE
                if (open.ShowDialog(wb) == System.Windows.Forms.DialogResult.OK)
                {
                    var dlg = new PackageEditorDialog(open.FileName, conn);
                    dlg.ShowDialog(wb);
                }
            }
        }
예제 #9
0
 public override IResource CreateItem(string startPoint, IServerConnection conn)
 {
     using (var dlg = DialogFactory.OpenFile())
     {
         dlg.Multiselect = true;
         dlg.Filter      = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickDwf, "dwf"); //NOXLATE
         if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             var proc = ObjectFactory.CreateLoadProcedure(LoadType.Dwf, dlg.FileNames);
             if (!string.IsNullOrEmpty(startPoint) && ResourceIdentifier.IsFolderResource(startPoint))
             {
                 proc.SubType.RootPath = startPoint;
                 proc.SubType.SpatialDataSourcesPath = startPoint;
                 proc.SubType.LayersPath             = startPoint;
             }
             return(proc);
         }
         return(null);
     }
 }
예제 #10
0
        private void btnLoadFile_Click(object sender, EventArgs e)
        {
            if (host == null)
            {
                return;
            }

            using (var picker = DialogFactory.OpenFile())
            {
                picker.Filter = "*.py|*.py"; //NOXLATE
                if (picker.ShowDialog() == DialogResult.OK)
                {
                    var con     = host.Console;
                    var cmdline = con.CommandLine;
                    con.WriteLine();
                    cmdline.ScriptScope.Engine.ExecuteFile(picker.FileName, cmdline.ScriptScope);
                    NewPrompt(con);
                }
            }
        }
예제 #11
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     using (var open = DialogFactory.OpenFile())
     {
         open.Multiselect = true;
         if (open.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 foreach (var fileName in open.FileNames)
                 {
                     UploadFile(fileName);
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(NestedExceptionMessageProcessor.GetFullMessage(ex), Strings.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
예제 #12
0
        public override void Run()
        {
            string exe = PropertyService.Get(ConfigProperties.RtMapInspectorPath, string.Empty);

            if (!File.Exists(exe))
            {
                using (var dlg = DialogFactory.OpenFile())
                {
                    dlg.Title  = string.Format(Strings.LocateExecutable, "RtMapInspector.exe");                                                    //NOXLATE
                    dlg.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickExe, "exe"); //NOXLATE
                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        exe = dlg.FileName;
                        PropertyService.Set(ConfigProperties.RtMapInspectorPath, exe);
                    }
                }
            }

            var procInfo = new ProcessStartInfo(exe);

            procInfo.WorkingDirectory = Path.GetDirectoryName(exe);
            var proc = Process.Start(procInfo);
        }
예제 #13
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            using (var open = DialogFactory.OpenFile())
            {
                open.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickXml, "xml"); //NOXLATE
                if (open.ShowDialog() == DialogResult.OK)
                {
                    listChangedDisabled = true;
                    try
                    {
                        var           cmds = _wl.ImportCustomCommands(open.FileName);
                        StringBuilder sb   = new StringBuilder();

                        foreach (var imported in cmds)
                        {
                            ICommand cmd = _wl.GetCommandByName(imported.ImportedName);
                            _commands.Add(new CommandDecorator(cmd));

                            if (imported.NameChanged)
                            {
                                sb.AppendLine(imported.ToString());
                            }
                        }

                        MessageBox.Show(string.Format(Strings.CustomCommandsImported, cmds.Length, open.FileName, sb.ToString()));
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, Strings.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        listChangedDisabled = false;
                    }
                }
            }
        }
예제 #14
0
        internal static void RunCooker(params string[] args)
        {
            string exe = PropertyService.Get(ConfigProperties.MgCookerPath, string.Empty); //NOXLATE

            if (!File.Exists(exe))
            {
                using (var dlg = DialogFactory.OpenFile())
                {
                    dlg.Title  = string.Format(Strings.LocateExecutable, "MgCooker.exe");                                                          //NOXLATE
                    dlg.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickExe, "exe"); //NOXLATE
                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        exe = dlg.FileName;
                        PropertyService.Set(ConfigProperties.MgCookerPath, exe);
                    }
                }
            }

            var procInfo = new ProcessStartInfo(exe);

            procInfo.WorkingDirectory = Path.GetDirectoryName(exe);
            procInfo.Arguments        = string.Join(" ", args); //NOXLATE
            var proc = Process.Start(procInfo);
        }