Пример #1
0
 public AddExForm(actions action, fileContext file, Action<string[], string> onFinish)
   : this() {
   this.file = file; this.action = action; this.onFinish = onFinish;
   HomeBtn_Click(null, null);
   //new browserEx.browser(webBrowser, () => HomeBtn_Click(null, null));
 }
Пример #2
0
    void adjustFileContext(ref fileContext ctx) {
      if (actCtx != null && (DateTime.UtcNow - actCtx.created).TotalMilliseconds < 300) return; //zivotnost ctx je omezena na jednu user akci
      IVsMonitorSelection monSel = (IVsMonitorSelection)GetService(typeof(SVsShellMonitorSelection));
      IntPtr hierPtr; uint currentItemId; IVsMultiItemSelect multSel; IntPtr selPtr;
      int hr = monSel.GetCurrentSelection(out hierPtr, out currentItemId, out multSel, out selPtr);
      if (multSel != null || hierPtr == null) return; //multi selection nebo zadna selection
      IVsHierarchy selectedHierarchy = Marshal.GetObjectForIUnknown(hierPtr) as IVsHierarchy;
      if (selectedHierarchy == null) return;

      string currentDocument;
      selectedHierarchy.GetCanonicalName(VSConstants.VSITEMID_ROOT, out currentDocument);
      selectedHierarchy.GetCanonicalName(currentItemId, out currentDocument);

      if (Machines._rootDir != null && currentDocument.IndexOf(Machines._rootDir) != 0) publisherCtx = null; //context je neaktualni

      if (publisherCtx == null) {
        string rootDoc;
        selectedHierarchy.GetCanonicalName(VSConstants.VSITEMID_ROOT, out rootDoc);
        publisherCtx = new publisherContext(rootDoc);
      }
      fileContext.adjustFileContext(currentDocument, new vsFileContext { hierarchy = selectedHierarchy, itemId = currentItemId }, publisherCtx, ref ctx);
    }
Пример #3
0
 public static void saveHtmlData(fileContext ctx) {
   var html = getHtmFromTemplate(ctx);
   if (vsNetServer.log.hasError) return;
   SaveFileDialog saveDlg = new SaveFileDialog();
   saveDlg.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments);
   saveDlg.Filter = "Html file|*.htm";
   saveDlg.FilterIndex = 1;
   saveDlg.FileName = "page.htm";
   if (saveDlg.ShowDialog() == DialogResult.OK)
     File.WriteAllText(saveDlg.FileName, html);
 }
Пример #4
0
 public static void adjustFileContext(string fn, object vsNetHiearchy, publisherContext publ, ref fileContext ctx) {
   if (fn.EndsWith("\\")) { fn += "meta.xml"; if (!File.Exists(fn)) { ctx = null; return; } }
   fn = fn.ToLower();
   ctx = new fileContext(fn, vsNetHiearchy) { publ = publ };
 }
Пример #5
0
 //vybuduje HTML na klientovi za pomoci template. Template se vytvari pomoci getHtmlFromScratch, s promenou casti: %#%scriptData%#% a %#%hash%#%.
 public static string getHtmFromTemplate(fileContext ctx) {
   vsNetServer.log.clear();
   vsNetServer.log.vsNetForBrowseAction = true;
   //var log = new LoggerMemory(true) { isVsNet = true, vsNetForBrowseAction = true };
   var postData = vsNetServer.getPostDataStr(ctx, null, vsNetServer.log);
   var isMod = ctx.url.EndsWith("/");
   string hash = !isMod ? XExtension.Create("vsNet".ToLower(), "vsNetExModel".ToLower(), ctx.url).Aggregate((r, i) => r + "@" + i) : "";
   var tempFn = vsNetServer.resourcePath + "author/" + (isMod ? "modTemplate" : "exTemplate") + ".htm";
   var html = FormatNamedProps(File.ReadAllText(tempFn), key => {
     switch (key) {
       case "scriptData": return postData.ToString();
       case "hash": return hash;
       case "baseTagUrl": return vsNetConfig.AppSettings["webAppUrl"];
       default: throw new NotImplementedException();
     }
   });
   return html;
 }
Пример #6
0
 public static void getPublishProduct(Stream str, fileContext actCtx, string prodUrl, string globalPublisherDir, IEnumerable<Packager.Consts.file> files = null) {
   vsNetServer.log.clear();
   vsNetServer.log.vsNetGlobalPublisherDir = globalPublisherDir;
   //var log = new LoggerMemory(true) { isVsNet = true, vsNetGlobalPublisherDir = globalPublisherDir };
   var prod = new product {
     url = prodUrl,
     styleSheet = ex.stdStyle,
     line = actCtx.line,
     //defaultDictType = dictTypes.no,
     //defaultLocs = new Langs[] {Langs.en_gb},
     title = actCtx.actNode.title,
     type = actCtx.actNode.isType(runtimeType.test) ? runtimeType.product | runtimeType.test : runtimeType.product,
     Items = new data[] { new ptr(true, actCtx.url) { takeChilds = childMode.selfChild } }
   };
   getPostDataFilesZip(str, actCtx, prod, vsNetServer.log, files);
 }