示例#1
0
        private void ExportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //ToolTipText is the full filename
            var menuItem = (ToolStripMenuItem)sender;
            var fileName = menuItem.ToolTipText;

            ExportFile.Export(fileName, menuItem.Tag as ExportData);
        }
示例#2
0
        public static string ReadLeicaDNA03(string[] files, string prjName, int RecNo, double iAngle)
        {
            ReadFile read = new ReadFile();
            OberveSheet sheet = new ReadDataFile.Model.OberveSheet();
            sheet.Lines = read.ReadTxtList(files);

            string exportname = string.Format("{0}工程水准观测记录{1}次", prjName, RecNo);
            string templateUrl = HttpContext.Current.Request.ApplicationPath + "/Template/DNA03_Template.xls";
            string exportUrl = HttpContext.Current.Request.ApplicationPath + "/Export/" + exportname + ".xls";
            string templetepath = HttpContext.Current.Server.MapPath(templateUrl);
            string exportpath =HttpContext.Current.Server.MapPath(exportUrl);

            OberveSheet.IAngle = iAngle;
            OberveSheet.PrjName = exportname;
            OberveSheet.RecordNo = RecNo;

            ExportFile ex = new ExportFile();
            ex.TemplateFilePath = templetepath;
            ex.ExportFilePath = exportpath;
            ex.Export(sheet);
            return exportname + ".xls";
        }
示例#3
0
        private void ExtractFiles(object sender, bool decompile)
        {
            TreeViewWithSearchResults.TreeViewPackageTag package = null;
            TreeNode selectedNode = null;

            // the context menu can come from a TreeView or a ListView depending on where the user clicked to extract
            // each option has a difference in where we can get the values to extract
            if (((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl is TreeView)
            {
                var tree = ((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl as TreeView;
                selectedNode = tree.SelectedNode;
                package      = tree.Tag as TreeViewWithSearchResults.TreeViewPackageTag;
            }
            else if (((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl is ListView)
            {
                var listView = ((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl as ListView;
                selectedNode = listView.SelectedItems[0].Tag as TreeNode;
                package      = listView.Tag as TreeViewWithSearchResults.TreeViewPackageTag;
            }

            if (selectedNode.Tag.GetType() == typeof(PackageEntry))
            {
                // We are a file
                var file     = selectedNode.Tag as PackageEntry;
                var fileName = file.GetFileName();

                package.Package.ReadEntry(file, out var output);

                if (decompile && fileName.EndsWith("_c", StringComparison.Ordinal))
                {
                    using var resource = new Resource();
                    using var memory   = new MemoryStream(output);

                    resource.Read(memory);

                    ExportFile.Export(fileName, new ExportData
                    {
                        Resource      = resource,
                        VrfGuiContext = new VrfGuiContext(null, package),
                    });

                    return;
                }

                var dialog = new SaveFileDialog
                {
                    InitialDirectory = Settings.Config.SaveDirectory,
                    Filter           = "All files (*.*)|*.*",
                    FileName         = fileName,
                };
                var userOK = dialog.ShowDialog();

                if (userOK == DialogResult.OK)
                {
                    Settings.Config.SaveDirectory = Path.GetDirectoryName(dialog.FileName);
                    Settings.Save();

                    using var stream = dialog.OpenFile();
                    stream.Write(output, 0, output.Length);
                }
            }
            else
            {
                //We are a folder
                var dialog = new FolderBrowserDialog();
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    var extractDialog = new ExtractProgressForm(package.Package, selectedNode, dialog.SelectedPath, decompile);
                    extractDialog.ShowDialog();
                }
            }
        }