Esempio n. 1
0
    /// <summary>
    /// Generates the addable snap2.
    /// </summary>
    /// <param name="dockingId">The docking id.</param>
    /// <param name="controlInfo">The control info.</param>
    /// <returns></returns>
    private Snap GenerateAddableSnap2(string dockingId, Mediachase.Cms.Controls.DynamicControlInfo controlInfo)
    {
        if (CMSContext.Current.ControlPlaces == string.Empty)
        {
            return(null);
        }

        Snap snap = new Snap();

        snap.DockingContainers = CMSContext.Current.ControlPlaces;

        snap.DockingStyle            = SnapDockingStyleType.TransparentRectangle;
        snap.MustBeDocked            = true;
        snap.CollapseDuration        = 300;
        snap.ExpandDuration          = 300;
        snap.AutoPostBackOnDock      = true;
        snap.CurrentDockingContainer = dockingId;
        snap.Dock += new Snap.DockEventHandler(Snap_Dock);

        //Control control = Mediachase.Cms.Controls.DynamicControlFactory.Create(this.Page, controlInfo.UID);

        Panel panel = new Panel();
        Label label = new Label();
        Image image = new Image();

        if (!string.IsNullOrEmpty(controlInfo.IconPath))
        {
            image.ImageUrl = Mediachase.Commerce.Shared.CommerceHelper.GetAbsolutePath(controlInfo.IconPath);
            image.Height   = 16;
            image.Width    = 16;
            panel.Controls.Add(image);
        }
        label.Text = controlInfo.Title;

        panel.ID = "cntrl" + (Guid.NewGuid().ToString()).Replace("-", string.Empty);
        panel.Controls.Add(label);

        SnapContent content = new SnapContent();

        content.Controls.Add(panel);
        snap.Content = content;
        //snap.Content = panel;

        //DV: 2007-09-12
        snap.Attributes.Add("ControlUID", controlInfo.Uid);

        _oldSnapArray.Add(new OldSnapInfo(snap, snap.CurrentDockingContainer, snap.CurrentDockingIndex));

        DockingTemp.Controls.Add(snap);

        string javaString = "";

        //javaString += "RecordAddedControl('add','" + isModified.ClientID + "','" + snap.ClientID;
        //javaString += "','" + panel.ClientID + "','" + controlInfo.Uid + "','" + controlInfo.AdapterPath + "');";
        javaString += " var __sh=$find('SnapHolder1_Snap'); if(__sh!=null) {__sh.RecordAddedControl('add','" + isModified.ClientID + "','" + snap.ClientID + "','" + panel.ClientID + "','" + controlInfo.Uid + "','" + controlInfo.AdapterPath + "');}";
        //    snap.Attributes.Add("onmouseup", "alert('begin');" + javaString + ";RecordNewDN();alert('end')");
        panel.Attributes.Add("onmousedown", snap.ClientID + ".StartDragging(event);" + javaString + " if(__sh!=null) __sh.RecordNewDN();");

        return(snap);
    }
Esempio n. 2
0
        /// <summary>
        /// Creates the specified page.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="controlUid">The control uid.</param>
        /// <returns></returns>
        public static Control Create(TemplateControl page, string controlUid)
        {
            if (page == null)
            {
                throw new ArgumentNullException("page");
            }

            if (controlUid == null)
            {
                throw new ArgumentNullException("controlUid");
            }

            Initialize();
            Control retVal = null;

            // Load Control Info
            DynamicControlInfo info = GetControlInfo(controlUid);

            if (info == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Invalid control Uid '{0}'", controlUid), "controlUid");
            }

            // Try Load Control
            if (!string.IsNullOrEmpty(info.Path))
            {
                retVal = page.LoadControl(CreateControlVirtualPath(info.Path));
            }
            else if (!string.IsNullOrEmpty(info.Type))
            {
                retVal = (Control)AssemblyUtil.LoadObject(info.Type);
            }

            // Try Load Adapter
            if (retVal != null && (!string.IsNullOrEmpty(info.AdapterPath) || !string.IsNullOrEmpty(info.AdapterType)))
            {
                Control adapter = null;

                if (!string.IsNullOrEmpty(info.Path))
                {
                    adapter = page.LoadControl(CreateControlVirtualPath(info.AdapterPath));
                }
                else if (!string.IsNullOrEmpty(info.Type))
                {
                    adapter = (Control)AssemblyUtil.LoadObject(info.AdapterType);
                }

                if (adapter != null)
                {
                    // Add Control to adapter
                    adapter.Controls.Add(retVal);

                    // Return adapter
                    retVal = adapter;
                }
            }

            return(retVal);
        }
Esempio n. 3
0
        /// <summary>
        /// Loads all controls from given directory and its subdirectories.
        /// </summary>
        /// <param name="structureVirtualPath">The structure virtual path.</param>
        /// <returns></returns>
        public static DynamicControlInfo[] Load(string structureVirtualPath)
        {
            List <DynamicControlInfo> list = new List <DynamicControlInfo>();

            string structurePath           = HostingEnvironment.MapPath(structureVirtualPath);
            IList <FileResolverItem> files = FileResolver.GetFiles(structurePath, ControlsDir + Path.DirectorySeparatorChar + "Configs", "*.config", null);

            foreach (FileResolverItem file in files)
            {
                string controlDir = Path.GetDirectoryName(file.FilePath);

                if (!String.IsNullOrEmpty(controlDir))
                {
                    string configsDir           = Path.DirectorySeparatorChar + ConfigDir;
                    string tempControlDirString = controlDir.EndsWith(Convert.ToString(Path.DirectorySeparatorChar)) ? controlDir.Substring(0, controlDir.Length - 1) : controlDir;
                    if (controlDir.EndsWith(configsDir, true, CultureInfo.InvariantCulture))
                    {
                        controlDir = controlDir.Substring(0, controlDir.LastIndexOf(configsDir));
                    }
                }

                DynamicControlInfo dci = McXmlSerializer.GetObjectFromFile <DynamicControlInfo>(file.FilePath);

                if (string.IsNullOrEmpty(dci.Uid))
                {
                    dci.Uid = Path.GetFileNameWithoutExtension(file.FilePath);
                }
                dci.AdapterPath      = MakeVirtualPath(structurePath, structureVirtualPath, controlDir, dci.AdapterPath);
                dci.IconPath         = MakeVirtualPath(structurePath, structureVirtualPath, controlDir, dci.IconPath);
                dci.Path             = MakeVirtualPath(structurePath, structureVirtualPath, controlDir, dci.Path);
                dci.PropertyPagePath = MakeVirtualPath(structurePath, structureVirtualPath, controlDir, dci.PropertyPagePath);

                list.Add(dci);
            }

            return(list.ToArray());
        }