/// <summary> /// Shows the dialog /// </summary> /// <returns>True if the user presses OK else false</returns> public DialogResult ShowDialog(IntPtr hWndOwner) { bool flag; if (Environment.OSVersion.Version.Major >= 6) // if current OS is windows and version Vista or higher - then use extended dialogs { var r = new Reflector("System.Windows.Forms"); uint num = 0; var typeIFileDialog = r.GetType("FileDialogNative.IFileDialog"); var dialog = r.Call(ofd, "CreateVistaDialog"); r.Call(ofd, "OnBeforeVistaDialog", dialog); var options = (uint)r.CallAs(typeof(FileDialog), ofd, "GetOptions"); options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS"); r.CallAs(typeIFileDialog, dialog, "SetOptions", options); var pfde = r.New("FileDialog.VistaDialogEvents", ofd); var parameters = new[] { pfde, num }; r.CallAs2(typeIFileDialog, dialog, "Advise", parameters); num = (uint)parameters[1]; try { var num2 = (int)r.CallAs(typeIFileDialog, dialog, "Show", hWndOwner); flag = 0 == num2; } finally { r.CallAs(typeIFileDialog, dialog, "Unadvise", num); GC.KeepAlive(pfde); } } else // in another case - use standart dialog { using (var fbd = new FolderBrowserDialog { Description = Title, SelectedPath = InitialDirectory, ShowNewFolderButton = false, RootFolder = RootFolder }) { if (fbd.ShowDialog() != DialogResult.OK) { return(DialogResult.Cancel); } ofd.FileName = fbd.SelectedPath; flag = true; } } return(flag ? DialogResult.OK : DialogResult.Cancel); }
/// <summary> /// Shows the dialog /// </summary> /// <param name="hWndOwner">Handle of the control to be parent</param> /// <returns>True if the user presses OK else false</returns> public bool ShowDialog(IntPtr hWndOwner) { bool flag = false; if (Environment.OSVersion.Version.Major >= 6) { var r = new Reflector("System.Windows.Forms"); uint num = 0; Type typeIFileDialog = r.GetType("FileDialogNative.IFileDialog"); object dialog = r.Call(ofd, "CreateVistaDialog"); r.Call(ofd, "OnBeforeVistaDialog", dialog); uint options = (uint)r.CallAs(typeof(System.Windows.Forms.FileDialog), ofd, "GetOptions"); options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS"); r.CallAs(typeIFileDialog, dialog, "SetOptions", options); object pfde = r.New("FileDialog.VistaDialogEvents", ofd); object[] parameters = new object[] { pfde, num }; r.CallAs2(typeIFileDialog, dialog, "Advise", parameters); num = (uint)parameters[1]; try { int num2 = (int)r.CallAs(typeIFileDialog, dialog, "Show", hWndOwner); flag = 0 == num2; } finally { r.CallAs(typeIFileDialog, dialog, "Unadvise", num); GC.KeepAlive(pfde); } } else { using (var fbd = new FolderBrowserDialog()) { fbd.Description = this.Title; fbd.SelectedPath = this.InitialDirectory; fbd.ShowNewFolderButton = false; if (fbd.ShowDialog(new WindowWrapper(hWndOwner)) != DialogResult.OK) { return(false); } ofd.FileName = fbd.SelectedPath; flag = true; } } return(flag); }
/// <summary> /// Shows the dialog</summary> /// <param name="owner">Control to be parent</param> /// <returns>True if the user presses OK else false</returns> public DialogResult ShowDialog(IWin32Window owner) { DialogResult result; if (Environment.OSVersion.Version.Major >= 6) { var r = new Reflector("System.Windows.Forms"); uint num = 0; Type typeIFileDialog = r.GetType("FileDialogNative.IFileDialog"); object dialog = r.Call(m_ofd, "CreateVistaDialog"); r.Call(m_ofd, "OnBeforeVistaDialog", dialog); uint options = (uint)r.CallAs(typeof(FileDialog), m_ofd, "GetOptions"); options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS"); r.CallAs(typeIFileDialog, dialog, "SetOptions", options); object pfde = r.New("FileDialog.VistaDialogEvents", m_ofd); object[] parameters = new[] { pfde, num }; r.CallAs2(typeIFileDialog, dialog, "Advise", parameters); num = (uint)parameters[1]; try { int num2 = (int)r.CallAs(typeIFileDialog, dialog, "Show", owner == null ? IntPtr.Zero : owner.Handle); result = (0 == num2) ? DialogResult.OK : DialogResult.Cancel; } finally { r.CallAs(typeIFileDialog, dialog, "Unadvise", num); GC.KeepAlive(pfde); } } else { using (var fbd = new FolderBrowserDialog()) { fbd.Description = Description; fbd.SelectedPath = InitialDirectory; fbd.ShowNewFolderButton = false; result = fbd.ShowDialog(owner); if (result == DialogResult.OK) { m_ofd.FileName = fbd.SelectedPath; } } } return(result); }
public bool ShowDialog(IntPtr hWndOwner) { bool flag = false; if (Environment.OSVersion.Version.Major >= 6) { var r = new Reflector("System.Windows.Forms"); uint num = 0; Type typeIFileDialog = r.GetType("FileDialogNative.IFileDialog"); object dialog = r.Call(ofd, "CreateVistaDialog"); r.Call(ofd, "OnBeforeVistaDialog", dialog); uint options = (uint)r.CallAs(typeof(System.Windows.Forms.FileDialog), ofd, "GetOptions"); options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS"); r.CallAs(typeIFileDialog, dialog, "SetOptions", options); object pfde = r.New("FileDialog.VistaDialogEvents", ofd); object[] parameters = new object[] { pfde, num }; r.CallAs2(typeIFileDialog, dialog, "Advise", parameters); num = (uint)parameters[1]; try { int num2 = (int)r.CallAs(typeIFileDialog, dialog, "Show", hWndOwner); flag = 0 == num2; } finally { r.CallAs(typeIFileDialog, dialog, "Unadvise", num); GC.KeepAlive(pfde); } } else { using (var fbd = new FolderBrowserDialog()) { fbd.Description = this.Title; fbd.SelectedPath = this.InitialDirectory; fbd.ShowNewFolderButton = false; if (fbd.ShowDialog(new WindowWrapper(hWndOwner)) != DialogResult.OK) return false; ofd.FileName = fbd.SelectedPath; flag = true; } } return flag; }
public bool ShowDialog(IntPtr hWndOwner) { if ((Environment.OSVersion.Version.Major >= 6) && !this.UseOldDialog) { Reflector reflector = new Reflector("System.Windows.Forms"); uint num = 0; Type type = reflector.GetType("FileDialogNative.IFileDialog"); object obj2 = reflector.Call(this.ofd, "CreateVistaDialog", new object[0]); reflector.Call(this.ofd, "OnBeforeVistaDialog", new object[] {obj2}); uint num2 = (uint) reflector.CallAs(typeof (FileDialog), this.ofd, "GetOptions", new object[0]); num2 |= (uint) reflector.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS"); reflector.CallAs(type, obj2, "SetOptions", new object[] {num2}); object obj3 = reflector.New("FileDialog.VistaDialogEvents", new object[] {this.ofd}); object[] parameters = new object[] {obj3, num}; reflector.CallAs2(type, obj2, "Advise", parameters); num = (uint) parameters[1]; try { int num3 = (int) reflector.CallAs(type, obj2, "Show", new object[] {hWndOwner}); return (0 == num3); } finally { reflector.CallAs(type, obj2, "Unadvise", new object[] {num}); GC.KeepAlive(obj3); } } FolderBrowserDialogEx ex = new FolderBrowserDialogEx(); ex.Description = this.Title; ex.SelectedPath = this.InitialDirectory; ex.ShowNewFolderButton = true; ex.ShowEditBox = true; ex.ShowFullPathInEditBox = true; if (ex.ShowDialog(new WindowWrapper(hWndOwner)) != DialogResult.OK) { return false; } this.ofd.FileName = ex.SelectedPath; return true; }
private bool ShowDialog(IntPtr hWndOwner) { bool flag; if (Environment.OSVersion.Version.Major >= 6) { var r = new Reflector("System.Windows.Forms"); uint num = 0; var typeIFileDialog = r.GetType("FileDialogNative.IFileDialog"); var dialog = Reflector.Call(_ofd, "CreateVistaDialog"); Reflector.Call(_ofd, "OnBeforeVistaDialog", dialog); var options = (uint)Reflector.CallAs(typeof(FileDialog), _ofd, "GetOptions"); options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS"); Reflector.CallAs(typeIFileDialog, dialog, "SetOptions", options); var pfde = r.New("FileDialog.VistaDialogEvents", _ofd); var parameters = new[] { pfde, num }; Reflector.CallAs2(typeIFileDialog, dialog, "Advise", parameters); num = (uint)parameters[1]; try { var num2 = (int)Reflector.CallAs(typeIFileDialog, dialog, "Show", hWndOwner); flag = 0 == num2; } finally { Reflector.CallAs(typeIFileDialog, dialog, "Unadvise", num); GC.KeepAlive(pfde); } } else { var fbd = new FolderBrowserDialog { Description = Title, SelectedPath = InitialDirectory }; if (fbd.ShowDialog(new WindowWrapper(hWndOwner)) != DialogResult.OK) { return(false); } _ofd.FileName = fbd.SelectedPath; return(true); } return(flag); }
internal static void ExportRollup(TextWriter writer, IDictionary action, Hashtable opt, SPWeb web, Hashtable fht, string [] listColumns, string locale, Action <string, string> csvWrite, string sep) { string tmp, fieldName, colVal, mulSep = ProductPage.Config(ProductPage.GetContext(), "MultiSep"); object val, ds; int pos; bool filt = ((action ["filter"] is bool) && (bool)action ["filter"]); if (refl == null) { refl = new Reflector(Assembly.Load("roxority_PeopleZen, Version=1.0.0.0, Culture=neutral, PublicKeyToken=68349fdcd3484f01")); } foreach (string k in new ArrayList(opt.Keys)) { if (opt [k] is string) { opt [k] = HttpUtility.UrlDecode(opt [k] + string.Empty); } } if (filt && (fht == null) && opt.ContainsKey("f")) { fht = new Hashtable(); fht ["f"] = JSON.JsonDecode(HttpUtility.UrlDecode(opt ["f"] + string.Empty)); if (opt.ContainsKey("fa")) { fht ["fa"] = JSON.JsonDecode(HttpUtility.UrlDecode(opt ["fa"] + string.Empty)); } } using (IDisposable consumer = refl.New("roxority.Data.DataSourceConsumer", JsonSchemaManager.Bool(action ["nopg"], false) ? 0 : (int)opt ["ps"], (int)opt ["p"], "1".Equals(opt ["dty"]), "1".Equals(opt ["did"]), opt ["pr"] + string.Empty, (object)(tmp = (opt ["spn"] + string.Empty)), string.IsNullOrEmpty(tmp) ? null : (object)"1".Equals(opt ["sd"]), JsonSchemaManager.Bool(action ["notb"], false) ? string.Empty : (opt ["tpn"] + string.Empty), JsonSchemaManager.Bool(action ["notb"], false) ? string.Empty : opt ["tv"], (object)(tmp = (opt ["gpn"] + string.Empty)), string.IsNullOrEmpty(tmp) ? null : (object)"1".Equals(opt ["gd"]), "1".Equals(opt ["gb"]), "1".Equals(opt ["gs"]), web, opt ["dsid"] + string.Empty, null, filt ? fht : null, null, new List <Exception> ()) as IDisposable) { ds = refl.Get(consumer, "DataSource"); foreach (object crec in refl.Get(consumer, "List") as IEnumerable) { for (int i = 0; i < listColumns.Length; i++) { fieldName = ((pos = listColumns [i].IndexOf(':')) <= 0) ? (listColumns [i]) : (listColumns [i].Substring(0, pos)); val = refl.Call(crec, "Get", new Type [] { typeof(string), typeof(string), ds.GetType().BaseType }, new object [] { fieldName, string.Empty, ds }); colVal = GetExportValue(web, val, null, locale, ((fieldName.ToLowerInvariant().Contains("birthday") || fieldName.ToLowerInvariant().Contains("xxxhiredate")) && !string.IsNullOrEmpty(val + string.Empty)), mulSep); csvWrite(colVal, ((i == listColumns.Length - 1) ? "\r\n" : sep)); } } } }
/// <summary> /// Shows the dialog /// </summary> /// <param name="hWndOwner">Handle of the control to be parent</param> /// <returns>True if the user presses OK else false</returns> public bool ShowDialog(IntPtr hWndOwner) { bool flag = false; if (PlatformHelper.GetPlatform() == Platform.OsX || PlatformHelper.GetPlatform() == Platform.Linux || Environment.OSVersion.Version.Major < 6) { flag = FallBackToFolderBrowserDialog(hWndOwner); } else { var r = new Reflector("System.Windows.Forms"); uint num = 0; Type typeIFileDialog = r.GetType("FileDialogNative.IFileDialog"); if (typeIFileDialog == null) flag = FallBackToFolderBrowserDialog(hWndOwner); else { object dialog = r.Call(ofd, "CreateVistaDialog"); r.Call(ofd, "OnBeforeVistaDialog", dialog); uint options = (uint)r.CallAs(typeof(System.Windows.Forms.FileDialog), ofd, "GetOptions"); options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS"); r.CallAs(typeIFileDialog, dialog, "SetOptions", options); object pfde = r.New("FileDialog.VistaDialogEvents", ofd); object[] parameters = new object[] { pfde, num }; r.CallAs2(typeIFileDialog, dialog, "Advise", parameters); num = (uint)parameters[1]; try { int num2 = (int)r.CallAs(typeIFileDialog, dialog, "Show", hWndOwner); flag = 0 == num2; } finally { r.CallAs(typeIFileDialog, dialog, "Unadvise", num); GC.KeepAlive(pfde); } } } return flag; }
/// <summary> /// Shows the dialog /// </summary> /// <returns>True if the user presses OK else false</returns> public DialogResult ShowDialog(IntPtr hWndOwner) { bool flag; if (Environment.OSVersion.Version.Major >= 6) // if current OS is windows and version Vista or higher - then use extended dialogs { var r = new Reflector("System.Windows.Forms"); uint num = 0; var typeIFileDialog = r.GetType("FileDialogNative.IFileDialog"); var dialog = r.Call(ofd, "CreateVistaDialog"); r.Call(ofd, "OnBeforeVistaDialog", dialog); var options = (uint)r.CallAs(typeof(FileDialog), ofd, "GetOptions"); options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS"); r.CallAs(typeIFileDialog, dialog, "SetOptions", options); var pfde = r.New("FileDialog.VistaDialogEvents", ofd); var parameters = new[] { pfde, num }; r.CallAs2(typeIFileDialog, dialog, "Advise", parameters); num = (uint)parameters[1]; try { var num2 = (int)r.CallAs(typeIFileDialog, dialog, "Show", hWndOwner); flag = 0 == num2; } finally { r.CallAs(typeIFileDialog, dialog, "Unadvise", num); GC.KeepAlive(pfde); } } else // in another case - use standart dialog { using (var fbd = new FolderBrowserDialog { Description = Title, SelectedPath = InitialDirectory, ShowNewFolderButton = false, RootFolder = RootFolder }) { if (fbd.ShowDialog() != DialogResult.OK) return DialogResult.Cancel; ofd.FileName = fbd.SelectedPath; flag = true; } } return flag ? DialogResult.OK : DialogResult.Cancel; }
public static IDictionary GetControls(HttpContext context, Page page, string ownerID, string check, string siteUrl, Control parent) { string thisID, clickScript, fj = string.Empty; bool isSep1, isSep2, hasSep1, hasSep2, includeFilters = false, isPeop, origPage, doZones; int zoneCount; List <KeyValuePair <string, KeyValuePair <List <KeyValuePair <string, CamlOperator> >, bool> > > effectiveFilters = null; Type [] types = new Type [] { typeof(WebPartVerb) }, rollTypes = new Type [] { typeof(IDictionary) }; Type wpType; OrderedDictionary dict = new OrderedDictionary(), ctl, items = null, actionItem, actionItems = null; KeyValuePair <JsonSchemaManager, JsonSchemaManager> jsonMans; JsonSchemaManager.Schema ctlSchema, actSchema; WebPartManager wpMan = WebPartManager.GetCurrentWebPartManager(page); Reflector refl; SPList list; List <SystemWebPart> parts; IEnumerable <SystemWebPart> partsEnum; WebPartVerb wpVerb; using (ProductPage ppage = new ProductPage()) { jsonMans = JsonSchemaManager.TryGet(ppage, null, true, true, null); foreach (JsonSchemaManager jman in new JsonSchemaManager [] { jsonMans.Key, jsonMans.Value }) { if (jman != null) { if (((ctlSchema = jman.AllSchemas ["PrintControls"]) != null) && ((actSchema = jman.AllSchemas ["PrintActions"]) != null)) { foreach (IDictionary launcher in ctlSchema.Instances) { if (launcher != null) { if (JsonSchemaManager.Bool(launcher [check], true)) { ctl = MakeSubControl(ownerID + "_" + launcher ["id"], JsonSchemaManager.GetDisplayName(launcher, ctlSchema.Name, false), ctlSchema.GetInstanceDescription(launcher), string.Empty, siteUrl + "/_layouts/images/roxority_PrintZen/printer32.png", items = new OrderedDictionary()); foreach (IDictionary action in actSchema.Instances) { if (action != null) { items [thisID = (ctl ["id"] + "_" + action ["id"])] = actionItem = MakeSubControl(thisID, JsonSchemaManager.GetDisplayName(action, "PrintActions", false), ctlSchema.GetInstanceDescription(action), string.Empty, siteUrl + "/_layouts/images/lg_icxps.gif", actionItems = new OrderedDictionary()); hasSep1 = hasSep2 = isSep1 = isSep2 = false; zoneCount = -1; if (wpMan != null) { if (hasSep2 = hasSep1 = (JsonSchemaManager.Bool(launcher ["pp"], true) && !"n".Equals(action ["mpp"]))) { actionItems [thisID + "_pp"] = MakeSubControl(thisID + "_pp", ProductPage.GetProductResource("PrintPageContent"), ProductPage.GetProductResource("PrintPageContentDesc"), clickScript = PrintZenMenuItem.GetClickScript(context, ownerID, siteUrl, string.Empty, action, SPContext.Current.Web, false, false, null, null, true, false, null, null, Guid.Empty, null, page, false), siteUrl + "/_layouts/images/lg_icgen.gif", null); } if (JsonSchemaManager.Bool(launcher ["pw"], true) && ((partsEnum = ProductPage.TryEach <SystemWebPart> (wpMan.WebParts)) != null)) { parts = new List <SystemWebPart> (partsEnum); parts.Sort((wp1, wp2) => { WebPartZoneBase zone1, zone2; if ((wp1 == null) && (wp2 == null)) { return(0); } if (wp1 == null) { return(-1); } if (wp2 == null) { return(1); } if (((zone1 = wp1.Zone) == null) || ((zone2 = wp2.Zone) == null)) { return((wp1.ZoneIndex == wp2.ZoneIndex) ? wp1.TabIndex.CompareTo(wp2.TabIndex) : wp1.ZoneIndex.CompareTo(wp2.ZoneIndex)); } return((zone1.TabIndex == zone2.TabIndex) ? wp1.ZoneIndex.CompareTo(wp2.ZoneIndex) : zone1.TabIndex.CompareTo(zone2.TabIndex)); }); foreach (SystemWebPart wp in parts) { refl = new Reflector((wpType = wp.GetType()).Assembly); list = (("Microsoft.SharePoint.WebPartPages.XsltListViewWebPart".Equals(wpType.FullName) || (wp is ListViewWebPart)) ? ((wp is ListViewWebPart) ? (refl.Get(wp, "List") as SPList) : ((SPView)refl.Get(wp, "ContextView")).ParentList) : null); isPeop = ((wpType.FullName == "roxority_RollupZen.RollupWebPart") || (wpType.FullName == "roxority_PeopleZen.roxority_UserListWebPart")); if (IsPartSupported(action, wp, isPeop, list, out origPage)) { if (hasSep1 && !isSep1) { isSep1 = true; actionItems [thisID + "_sep1"] = null; } hasSep2 = true; if (isPeop && (!origPage) && ((wpVerb = refl.Call(wp, "GetPrintVerb", rollTypes, new object [] { action }) as WebPartVerb) != null)) { clickScript = wpVerb.ClientClickHandler + string.Empty; } else if ((list != null) && !origPage) { clickScript = string.Empty; PrintZenMenuItem.GetFilterInfo(action, "PrintActions", ref clickScript, wp, page, ref includeFilters, ref fj, ref effectiveFilters); if (string.IsNullOrEmpty(clickScript)) { clickScript = PrintZenMenuItem.GetClickScript(context, ownerID, siteUrl, string.Empty, action, SPContext.Current.Web, JsonSchemaManager.Bool(action ["view"], true), includeFilters, effectiveFilters, fj, true, false, list, null, ProductPage.GetGuid(refl.Get(wp, "ViewGuid") + string.Empty), PrintZenMenuItem.GetAllPageParams(context, true, null), parent, origPage); } } else { clickScript = PrintZenMenuItem.GetClickScript(context, ownerID, siteUrl, string.Empty, action, SPContext.Current.Web, false, false, null, null, true, false, null, null, ProductPage.GetGuid(wp.ID.Substring(2).Replace('_', '-')), PrintZenMenuItem.GetAllPageParams(context, true, null), parent, origPage); } actionItems [thisID + "_" + wp.ID] = MakeSubControl(thisID + "_" + wp.ID, wp.DisplayTitle, GetPartDesc(wp, refl), clickScript, siteUrl + "/_layouts/roxority_PrintZen/mash.tl.aspx?op=imgoverlay&backimg=" + HttpUtility.UrlEncode("/_layouts/images/roxority_PrintZen/printer32.png") + "&overlay=" + HttpUtility.UrlEncode(string.IsNullOrEmpty(wp.TitleIconImageUrl) ? (string.IsNullOrEmpty(wp.CatalogIconImageUrl) ? "/_layouts/images/itobject.gif" : wp.CatalogIconImageUrl) : wp.TitleIconImageUrl) + "&r=" + ppage.Rnd.Next(), null); } } } if (doZones = (JsonSchemaManager.Bool(launcher ["pz"], true) && (!"n".Equals(action ["mwz"])) && ((!JsonSchemaManager.Bool(launcher ["pp"], true)) || (((zoneCount = wpMan.Zones.Count) > 1))))) { if (zoneCount > 0) { zoneCount = 0; foreach (WebPartZoneBase zone in ProductPage.TryEach <WebPartZoneBase> (wpMan.Zones)) { if (zone.WebParts.Count > (JsonSchemaManager.Bool(launcher ["pw"], true) ? 1 : 0)) { zoneCount++; } } } } if (doZones && ((zoneCount < 0) || (zoneCount > 1))) { foreach (WebPartZoneBase zone in ProductPage.TryEach <WebPartZoneBase> (wpMan.Zones)) { if (zone.WebParts.Count > (JsonSchemaManager.Bool(launcher ["pw"], true) ? 1 : 0)) { if (hasSep2 && !isSep2) { isSep2 = true; actionItems [thisID + "_sep2"] = null; } clickScript = PrintZenMenuItem.GetClickScript(context, ownerID, siteUrl, string.Empty, action, SPContext.Current.Web, false, false, null, null, true, false, null, null, Guid.Empty, null, zone, false); actionItems [thisID + "_" + zone.ID] = MakeSubControl(thisID + "_" + zone.ID, ProductPage.GetProductResource("WebPartZone", zone.DisplayTitle), GetZoneDesc(zone), clickScript, siteUrl + "/_layouts/images/lg_icgen.gif", null); } } } } if (actionItems.Count == 0) { items.Remove(thisID); } } } if (items.Count > 0) { dict [launcher ["id"]] = ctl; } } if ((items != null) && (items.Count == 1)) { foreach (DictionaryEntry entry in actionItems) { items [entry.Key] = entry.Value; } items.RemoveAt(0); } } } } } } } return(dict); }
protected override void CreateChildControls() { string wpPageUrl, otherPartID = Request.QueryString ["wpid"], viewRawID, tmpCssClass = "c" + ProductPage.GuidLower(Guid.NewGuid(), false), propVal, nuPropVal, srcPageUrl = string.Empty; ProductPage.LicInfo li = ProductPage.LicInfo.Get(null); bool hasInvalidParams = false, isInvalidParam, isB = ProductPage.LicEdition(ctx, li, 2); int itemID = 0; object sm; XmlElement elem; Panel panel = HeaderWebParts; ArrayList filters = null; Hashtable fht = null; Guid viewID = Guid.Empty; SPLimitedWebPartManager wpMan = null; List <SystemWebPart> parts = new List <SystemWebPart> (); List <string> queryString = new List <string> (); TitleBarWebPart tbwp; SystemWebPart pwp; ctx = ProductPage.GetContext(); foreach (string k in Request.QueryString.AllKeys) { if (!string.IsNullOrEmpty(k)) { if (!(isInvalidParam = (k.StartsWith("FilterField", StringComparison.InvariantCultureIgnoreCase) || k.StartsWith("FilterValue", StringComparison.InvariantCultureIgnoreCase)))) { if (!isB) { foreach (string [] arr in new string [] [] { PrintZenMenuItem.CalendarParams, PrintZenMenuItem.FolderParams, PrintZenMenuItem.PageParams, PrintZenMenuItem.SortParams }) { if (isInvalidParam = (Array.IndexOf <string> (arr, k) >= 0)) { break; } } } } if (isInvalidParam) { hasInvalidParams = true; } else { queryString.Add(k + "=" + Server.UrlEncode(Request.QueryString [k])); if ((!"rpzopt".Equals(k, StringComparison.InvariantCultureIgnoreCase)) && !"r".Equals(k, StringComparison.InvariantCultureIgnoreCase)) { PhVals ["QueryString_" + k] = Request.QueryString [k]; } } } } if ((!string.IsNullOrEmpty(Request.QueryString ["t"])) && (Title != Request.QueryString ["t"])) { Title = Request.QueryString ["t"]; } if (hasInvalidParams) { Response.Redirect(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf('?')) + "?" + string.Join("&", queryString.ToArray()), true); } else if (!ProductPage.isEnabled) { MainWebPart.Controls.Add(new LiteralControl(ProductPage.GetResource("NotEnabled", "", ProductPage.GetTitle()))); } else { if ((!string.IsNullOrEmpty(viewRawID = Request.QueryString ["View"])) && !int.TryParse(viewRawID, out itemID)) { viewID = ProductPage.GetGuid(viewRawID); } if (ProductPage.LicEdition(ctx, li, 4)) { if (!string.IsNullOrEmpty(Request.QueryString ["fs"])) { filters = JSON.JsonDecode(Request.QueryString ["fs"]) as ArrayList; } if (!string.IsNullOrEmpty(Request.QueryString ["fj"])) { fht = JSON.JsonDecode(Request.QueryString ["fj"]) as Hashtable; } } foreach (IDictionary action in Actions) { if (Request.QueryString ["a"].Equals(action ["id"])) { try { if ((action ["sm"] is bool) && (bool)action ["sm"]) { if (!exAsmTried) { exAsmTried = true; try { exRefl = new Reflector(exAsm = Assembly.Load("System.Web.Extensions, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")); exType = exAsm.GetType("System.Web.UI.ScriptManager", false, true); } catch { } } if ((exRefl != null) && (exType != null) && (Form != null) && ((sm = exRefl.Call(exType, "GetCurrent", this)) == null)) { theLit.Controls.AddAt(0, (sm = exRefl.New(exType.FullName)) as Control); } } PhVals ["List_Title"] = string.Empty; PhVals ["Item_Title"] = string.Empty; PhVals ["View_Title"] = string.Empty; PhVals ["Context_Title"] = string.Empty; foreach (DictionaryEntry prop in action) { if (prop.Value is string) { PhVals ["PrintAction_" + prop.Key] = prop.Value + string.Empty; } } AutoPrint = PrintZenMenuItem.GetBool(action, "dp"); ShowPlaceholders = PrintZenMenuItem.GetBool(action, "sp"); ShowToolbar = PrintZenMenuItem.GetBool(action, "tb"); site = new SPSite(ctx.Site.ID); web = site.OpenWeb(ctx.Web.ID); if ((!string.IsNullOrEmpty(wpPageUrl = (action ["wp"] + string.Empty))) && ProductPage.LicEdition(ctx, li, 4)) { try { if ((wpPageUrl.StartsWith("http:", StringComparison.InvariantCultureIgnoreCase) || wpPageUrl.StartsWith("https:", StringComparison.InvariantCultureIgnoreCase)) && !wpPageUrl.StartsWith(web.Url.TrimEnd() + '/', StringComparison.InvariantCultureIgnoreCase)) { site2 = new SPSite(wpPageUrl); web2 = site2.OpenWeb(); } if ((wpMan = ((web2 == null) ? web : web2).GetLimitedWebPartManager(wpPageUrl, PersonalizationScope.Shared)) == null) { throw new Exception("xyz"); } } catch (Exception ex) { Errors.Add(new Exception(ProductPage.GetProductResource("WebPartPageNotFound", wpPageUrl.ToUpperInvariant()), "xyz".Equals(ex.Message) ? null : ex)); } } if (!isB) { panel.Controls.Add(new LiteralControl("<div class=\"" + tmpCssClass + "\">Powered by <b>SharePoint-Tools.net/PrintZen</b></div><style type=\"text/css\"> ." + tmpCssClass + " { text-align: center; font-size: " + new Random().Next(24, 37) + "px; display: none; padding-bottom: 12px; } @media print { div." + tmpCssClass + " { display: block !important; } } </style>")); } if (wpMan == null) { if (!string.IsNullOrEmpty(otherPartID)) { AddOtherWebPart(Request.QueryString ["l"], otherPartID); } else if (itemID > 0) { AddListFormWebPart(action, itemID); } else if (Guid.Empty.Equals(viewID) && !string.IsNullOrEmpty(viewRawID)) { if (isB) { AddPeopleWebPart(action, viewRawID, filters, fht); } } else { AddListViewWebPart(action, viewID, filters, fht); } } else { Placeholders = true; foreach (SystemWebPart wp in ProductPage.TryEach <SystemWebPart> (wpMan.WebParts, false, delegate(Exception ex) { Errors.Add(ex); }, true)) { if ((tbwp = wp as TitleBarWebPart) == null) { parts.Add(wp); } else { PhVals ["TitleBar_Caption"] = tbwp.HeaderCaption; PhVals ["TitleBar_Description"] = tbwp.HeaderDescription; PhVals ["TitleBar_Image"] = tbwp.Image; PhVals ["TitleBar_Title"] = tbwp.HeaderTitle; if (PrintZenMenuItem.GetBool(action, "st")) { parts.Add(tbwp); } } } parts.Sort((wp1, wp2) => { return(wp1.ZoneIndex.CompareTo(wp2.ZoneIndex)); }); foreach (SystemWebPart wp in parts) { if (("PRINTZEN_LIST_VIEW".Equals(wp.Title.Trim(), StringComparison.InvariantCultureIgnoreCase)) || ("PRINTZEN_TARGET".Equals(wp.Title.Trim(), StringComparison.InvariantCultureIgnoreCase))) { if (!string.IsNullOrEmpty(otherPartID)) { AddOtherWebPart(Request.QueryString ["l"], otherPartID); } else if (itemID > 0) { AddListFormWebPart(action, itemID); } else if (Guid.Empty.Equals(viewID) && !string.IsNullOrEmpty(viewRawID)) { if (isB) { AddPeopleWebPart(action, viewRawID, filters, fht); } } else { AddListViewWebPart(action, viewID, filters, fht); } panel = FooterWebParts; } else { try { InitWebPart(wp); panel.Controls.Add(wp); } catch (Exception ex) { Errors.Add(ex); } } } foreach (Panel p in new Panel [] { HeaderWebParts, MainWebPart, FooterWebParts }) { foreach (Control ctl in p.Controls) { if ((pwp = ctl as SystemWebPart) != null) { foreach (PropertyInfo propInfo in pwp.GetType().GetProperties()) { if (propInfo.CanRead && propInfo.CanWrite) { if (propInfo.PropertyType == typeof(string)) { try { propVal = propInfo.GetValue(pwp, null) as string; } catch { propVal = null; } if ((!string.IsNullOrEmpty(propVal)) && (propVal != (nuPropVal = Replace(propVal)))) { propInfo.SetValue(pwp, nuPropVal, null); } } else if (propInfo.PropertyType == typeof(XmlElement)) { try { elem = propInfo.GetValue(pwp, null) as XmlElement; } catch { elem = null; } if ((elem != null) && Replace(elem)) { try { propInfo.SetValue(pwp, elem, null); } catch { } } } } } } } } } break; } catch (Exception ex) { Errors.Add(ex); break; } } }
/// <summary> /// Shows the dialog /// </summary> /// <param name="hWndOwner">Handle of the control to be parent</param> /// <returns>True if the user presses OK else false</returns> public bool ShowDialog(IntPtr hWndOwner) { bool flag; // TODO: Find way to use Microsoft.Win32 Reflector r = new Reflector("System.Windows.Forms"); uint num = 0; Type typeIFileDialog = r.GetType("FileDialogNative.IFileDialog"); object dialog = r.Call(ofd, "CreateVistaDialog"); r.Call(ofd, "OnBeforeVistaDialog", dialog); uint options = (uint)r.CallAs(typeof(FileDialog), ofd, "GetOptions"); options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS"); r.CallAs(typeIFileDialog, dialog, "SetOptions", options); object pfde = r.New("FileDialog.VistaDialogEvents", ofd); object[] parameters = new object[] { pfde, num }; r.CallAs2(typeIFileDialog, dialog, "Advise", parameters); num = (uint)parameters[1]; try { int num2 = (int)r.CallAs(typeIFileDialog, dialog, "Show", hWndOwner); flag = 0 == num2; } finally { r.CallAs(typeIFileDialog, dialog, "Unadvise", num); GC.KeepAlive(pfde); } return flag; }