private static void ProcessDiagramsLinkShapes(Diagram diagram, List<NodeShape> allShapes, LayoutInfo info)
        {
            foreach (LinkShape shape in diagram.LinkShapes)
            {
                if (allShapes.Contains(shape.FromShape) &&
                    allShapes.Contains(shape.ToShape))
                {
                    LinkShapeInfo lInfo = new LinkShapeInfo(info.Store);
                    lInfo.ElementId = shape.Element.Id;
                    lInfo.SourceElementId = shape.FromShape.Element.Id;
                    lInfo.TargetElementId = shape.ToShape.Element.Id;
                    lInfo.LinkDomainClassId = shape.Element.GetDomainClass().Id;

                    lInfo.SourceLocation = shape.SourceAnchor.GetRelativeLocation();
                    lInfo.TargetLocation = shape.TargetAnchor.GetRelativeLocation();

                    lInfo.RoutingMode = shape.RoutingMode;
                    lInfo.EdgePoints = ConvertToRelativeEdgePoints(shape.EdgePoints, shape.SourceAnchor.AbsoluteLocation);

                    info.LinkShapeInfos.Add(lInfo);
                }
            }

            foreach (Diagram d in diagram.IncludedDiagrams)
                ProcessDiagramsLinkShapes(d, allShapes, info);
        }
    /// <summary>
    /// Initializes this layout binding control.
    /// </summary>
    private void Initialize()
    {
        // Initialize source layout controls
        ltrSourceLayoutIcon.Text = PortalHelper.GetIconHtml(SourceLayout.LayoutThumbnailGUID, ValidationHelper.GetString(SourceLayout.LayoutIconClass, PortalHelper.DefaultPageLayoutIconClass));
        SourceLayoutDisplayNameLabel.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(SourceLayout.LayoutDisplayName));

        // Initialize target layout controls
        TargetLayout = DeviceProfileLayoutInfoProvider.GetTargetLayoutInfo(DeviceProfile, SourceLayout);
        if (TargetLayout != null)
        {
            ltrTargetLayoutIcon.Text = PortalHelper.GetIconHtml(TargetLayout.LayoutThumbnailGUID, ValidationHelper.GetString(TargetLayout.LayoutIconClass, PortalHelper.DefaultPageLayoutIconClass));
            TargetLayoutDisplayNameLabel.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(TargetLayout.LayoutDisplayName));
        }
        else
        {
            ltrTargetLayoutIcon.Text = PortalHelper.GetIconHtml(Guid.Empty, "icon-question-circle empty-device-layout-mapping");
            TargetLayoutDisplayNameLabel.Text = HTMLHelper.HTMLEncode(GetString("device_profile.layoutmapping.sethint"));
        }

        // Initialize script to open target layout selection dialog
        string baseUrl = URLHelper.ResolveUrl("~/CMSModules/DeviceProfile/Pages/SelectLayout.aspx");
        string url = String.Format("{0}?deviceProfileId={1:D}&sourceLayoutId={2:D}&targetLayoutId={3:D}", baseUrl, DeviceProfile.ProfileID, SourceLayout.LayoutId, TargetLayout != null ? TargetLayout.LayoutId : 0);
        string script = String.Format("modalDialog('{0}', 'SelectLayout', '1000', '785', null)", URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url)));
        TargetLayoutItemControl.Attributes.Add("onclick", script);

        btnDelete.ToolTip = GetString("device_profile.layoutmapping.unset");
        btnDelete.OnClientClick = "$cmsj.Event(event).stopPropagation(); Client_UnsetTargetLayout({sourceLayoutId:" + SourceLayout.LayoutId.ToString("D") + "}); return false;";
    }
    private void Initialize()
    {
        // Initialize source layout controls
        SourceLayoutThumbnail.AlternateText = HTMLHelper.HTMLEncode(GetString("device_profile.layoutmapping.sourcelayoutthumbalt"));
        SourceLayoutThumbnail.ImageUrl = GetLayoutThumbnailUrl(SourceLayout);
        SourceLayoutDisplayNameLabel.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(SourceLayout.LayoutDisplayName));

        // Initialize target layout controls
        TargetLayoutThumbnail.AlternateText = HTMLHelper.HTMLEncode(GetString("device_profile.layoutmapping.targetlayoutthumbalt"));
        TargetLayout = DeviceProfileLayoutInfoProvider.GetTargetLayoutInfo(DeviceProfile, SourceLayout);
        if (TargetLayout != null)
        {
            TargetLayoutThumbnail.ImageUrl = GetLayoutThumbnailUrl(TargetLayout);
            TargetLayoutDisplayNameLabel.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(TargetLayout.LayoutDisplayName));
        }
        else
        {
            TargetLayoutThumbnail.ImageUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/no_target_layout.png");
            TargetLayoutDisplayNameLabel.Text = HTMLHelper.HTMLEncode(GetString("device_profile.layoutmapping.sethint"));
        }

        // Initialize script to open target layout selection dialog
        string baseUrl = URLHelper.ResolveUrl("~/CMSModules/DeviceProfile/Pages/SelectLayout.aspx");
        string url = String.Format("{0}?deviceProfileId={1:D}&sourceLayoutId={2:D}&targetLayoutId={3:D}", baseUrl, DeviceProfile.ProfileID, SourceLayout.LayoutId, TargetLayout != null ? TargetLayout.LayoutId : 0);
        string script = String.Format("modalDialog('{0}', 'SelectLayout', '1000', '785', null)", URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url)));
        TargetLayoutItemControl.Attributes.Add("onclick", script);
    }
        public DiagramModelMergeOptions(LayoutInfo info, Guid elementId, Guid domainClassId, Guid shapeDomainClassId)
        {
            // save layout info as string
            this.LayoutInfoString = DiagramsDSLSerializationHelper.Instance.ConvertLayoutInfoToString(info);
            info.Delete();

            this.ElementId = elementId;
            this.DomainClassId = domainClassId;
            this.ShapeDomainClassId = shapeDomainClassId;
        }
Exemplo n.º 5
0
		private bool m_nextUpstreamSegWsOnly; // toggle for whether to try whitespace-only or no-ws for next upstream seg.

		public ParaBuilder(ParaBox para, LayoutInfo layoutInfo)
		{
			m_para = para;
			m_layoutInfo = layoutInfo;
			m_renderRuns = para.Source.RenderRuns;
			m_gapTop = m_para.GapTop(layoutInfo);
			m_gapLeft = m_para.GapLeading(layoutInfo); // Todo RTL.
			m_gapRight = m_para.GapTrailing(layoutInfo);
			m_surroundWidth = m_para.SurroundWidth(layoutInfo);
			m_surroundHeight = m_para.SurroundHeight(layoutInfo);
		}
    private string GetLayoutThumbnailUrl(LayoutInfo layout)
    {
        string relativeUrl = null;
        if (layout.LayoutThumbnailGUID != Guid.Empty)
        {
            relativeUrl =  layout.Generalized.GetThumbnailUrl(0, 0, 64);
        }
        else
        {
            relativeUrl = GetImageUrl("Objects/CMS_Layout/notavailable.png");
        }

        return URLHelper.ResolveUrl(relativeUrl);
    }
Exemplo n.º 7
0
 void UpdateInfo(LayoutInfo li)
 {
     if (li.PlainText == null)
         return;
     if (li.Font != null) {
         NSDictionary dict = NSDictionary.FromObjectsAndKeys (
             new object[] { li.Font },
             new object[] { NSAttributedString.FontAttributeName }
         );
         li.Text = new NSAttributedString (li.PlainText, dict);
     } else {
         li.Text = new NSAttributedString (li.PlainText);
     }
 }
Exemplo n.º 8
0
    /// <summary>
    /// Creates layout. Called when the "Create layout" button is pressed.
    /// </summary>
    private bool CreateLayout()
    {
        // Create new layout object
        LayoutInfo newLayout = new LayoutInfo();

        // Set the properties
        newLayout.LayoutDisplayName = "My new layout";
        newLayout.LayoutCodeName = "MyNewLayout";
        newLayout.LayoutDescription = "This is layout created by API Example";
        newLayout.LayoutCode = "<cc1:CMSWebPartZone ID=\"zoneLeft\" runat=\"server\" />";

        // Save the layout
        LayoutInfoProvider.SetLayoutInfo(newLayout);

        return true;
    }
        public static LayoutInfo CreateLayoutInfo(NodeShape shapeElement, Diagram diagram)
        {
            // create new layout
            List<NodeShape> allShapes = new List<NodeShape>();
            LayoutInfo l = new LayoutInfo(shapeElement.Store);
            l.HostElementId = shapeElement.Element.Id;
            l.Size = shapeElement.Size;

            foreach (NodeShape shape in shapeElement.Children)
            {
                allShapes.Add(shape);
                l.ChildrenInfos.Add(CreateNodeShapeInfo(shape, allShapes));
            }

            ProcessDiagramsLinkShapes(diagram, allShapes, l);
            return l;
        }
 void Read()
 {
     Hashtable tb = new Hashtable();
     ParseData(table, tb);
     foreach (DictionaryEntry t in tb)
     {
         LayoutInfo info = new LayoutInfo();
         LayoutInfoKey key = new LayoutInfoKey();
         Hashtable value = (Hashtable)t.Value;
         info.Chapter = ParseTableValueToInt(value["Chapter"]);
         key.Chapter = info.Chapter;
         info.Level = ParseTableValueToInt(value["Level"]);
         key.Level = info.Level;
         info.Star1 = ParseTableValueToInt(value["Star1"]);
         info.Star2 = ParseTableValueToInt(value["Star2"]);
         info.Star3 = ParseTableValueToInt(value["Star3"]);
         info.OpenStar = ParseTableValueToInt(value["OpenStar"]);
         info.Cost = ParseTableValueToInt(value["Cost"]);
         mCardDictionary.Add(key, info);
     }
 }
        public string ConvertLayoutInfoToString(LayoutInfo info)
        {
            string result = String.Empty;

            Microsoft.VisualStudio.Modeling.SerializationResult serializationResult = new Microsoft.VisualStudio.Modeling.SerializationResult();
            DomainXmlSerializerDirectory directory = this.GetDirectory(info.Store);
            System.Text.Encoding encoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
            Microsoft.VisualStudio.Modeling.SerializationContext serializationContext = new SerializationContext(directory, "", serializationResult);
            this.InitializeSerializationContext(info.Partition, serializationContext, false);

            global::System.IO.MemoryStream newFileContent = new global::System.IO.MemoryStream();
            global::System.Xml.XmlWriterSettings settings = DiagramsDSLSerializationHelper.Instance.CreateXmlWriterSettings(serializationContext, false, encoding);
            using (global::System.Xml.XmlWriter writer = global::System.Xml.XmlWriter.Create(newFileContent, settings))
            {
                DomainClassXmlSerializer rootSerializer = directory.GetSerializer(LayoutInfo.DomainClassId);
                
                RootElementSettings rootElementSettings = new RootElementSettings();
                rootElementSettings.SchemaTargetNamespace = "http://schemas.microsoft.com/dsltools/DiagramsDSL";
                rootElementSettings.Version = new global::System.Version("1.0.0.0");

                // Carry out the normal serialization.
                rootSerializer.Write(serializationContext, info, writer, rootElementSettings);
            }

            char[] chars = encoding.GetChars(newFileContent.GetBuffer());

            // search the open angle bracket and trim off the Byte Of Mark.
            result = new string(chars);
            int indexPos = result.IndexOf('<');
            if (indexPos > 0)
            {
                // strip off the leading Byte Of Mark.
                result = result.Substring(indexPos);
            }

            // trim off trailing 0s.
            result = result.TrimEnd('\0');

            return result;
        }
Exemplo n.º 12
0
		public void PrepareDivFixupMap()
		{
			var styles = new AssembledStyles();
			var div = new FixedSizeDiv(styles, 27, 37);
			var root = new FixedSizeRoot(styles, 49, 59);
			var block = new BlockBox(styles, Color.Red, 6000, 8000);
			div.AddBox(block);
			root.AddBox(div);
			div.Left = 5;
			div.Top = 7;
			block.Left = 10;
			block.Top = 20;
			var transform = new LayoutInfo(0, 0, 72, 72, 1000, m_gm.VwGraphics, new MockRendererFactory());
			block.Layout(transform);
			//Assert.AreEqual(6, block.Width); // sanity check: we made it 4000 mp wide at 72 dpi, that's 4 points at one point per dot
			var map = block.PrepareFixupMap();
			var invalidRect = map[block];
			Assert.AreEqual(new Rectangle(5 + 10 - 2, 7 + 20 - 2, 6 + 4, 8 + 4), invalidRect);
			invalidRect = map[div];
			Assert.AreEqual(new Rectangle(5 - 2, 7 - 2, 27 + 4, 37 + 4), invalidRect);
			invalidRect = map[root];
			Assert.AreEqual(new Rectangle(- 2, - 2, 49 + 4, 59 + 4), invalidRect);
		}
Exemplo n.º 13
0
    /// <summary>
    /// Initializes header action control.
    /// </summary>
    private void InitializeHeaderActions(LayoutInfo li)
    {
        // Header actions
        string[,] actions = new string[4, 11];

        // Save button
        actions[0, 0] = HeaderActions.TYPE_SAVEBUTTON;
        actions[0, 1] = GetString("General.Save");
        actions[0, 5] = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
        actions[0, 6] = "save";
        actions[0, 8] = "true";

        if (SettingsKeyProvider.UsingVirtualPathProvider)
        {
            // CheckOut
            actions[1, 0]  = HeaderActions.TYPE_SAVEBUTTON;
            actions[1, 1]  = GetString("General.CheckOutToFile");
            actions[1, 5]  = GetImageUrl("CMSModules/CMS_Content/EditMenu/checkout.png");
            actions[1, 6]  = "checkout";
            actions[1, 10] = "false";

            // CheckIn
            actions[2, 0]  = HeaderActions.TYPE_SAVEBUTTON;
            actions[2, 1]  = GetString("General.CheckInFromFile");
            actions[2, 5]  = GetImageUrl("CMSModules/CMS_Content/EditMenu/checkin.png");
            actions[2, 6]  = "checkin";
            actions[2, 10] = "false";

            // UndoCheckOut
            actions[3, 0]  = HeaderActions.TYPE_SAVEBUTTON;
            actions[3, 1]  = GetString("General.UndoCheckout");
            actions[3, 2]  = "return confirm(" + ScriptHelper.GetString(GetString("General.ConfirmUndoCheckOut")) + ");";
            actions[3, 5]  = GetImageUrl("CMSModules/CMS_Content/EditMenu/undocheckout.png");
            actions[3, 6]  = "undocheckout";
            actions[3, 10] = "false";
        }

        if (li != null)
        {
            if (li.LayoutCheckedOutByUserID > 0)
            {
                // Checked out by current machine
                if (li.LayoutCheckedOutMachineName.ToLower() == HTTPHelper.MachineName.ToLower())
                {
                    actions[2, 10] = "true";
                }
                if (CMSContext.CurrentUser.UserSiteManagerAdmin)
                {
                    actions[3, 10] = "true";
                }
            }
            else
            {
                actions[1, 10] = "true";
            }
        }

        this.CurrentMaster.HeaderActions.LinkCssClass     = "ContentSaveLinkButton";
        this.CurrentMaster.HeaderActions.ActionPerformed += new CommandEventHandler(HeaderActions_ActionPerformed);
        this.CurrentMaster.HeaderActions.Actions          = actions;
    }
Exemplo n.º 14
0
		public override void Layout(LayoutInfo transform)
		{
			var builder = new ParaBuilder(this, transform);
			builder.FullLayout();
		}
        private void updateLayout(Control control, List <Control> revalidatedControls)
        {
            LayoutInfo lastLayoutInfo = control.lastLayoutInfo;

            // работаем с родительским элементом управления
            if (control.Parent != null)
            {
                bool needUpdateParentLayout = true;
                // если размер текущего контрола не изменился, то состояние ревалидации не распространяется
                // вверх по дереву элементов, и мы переходим к работе с дочерними элементами
                // в противном случае мы добавляем родительский элемент в конец очереди ревалидации, и
                // возвращаем управление
                if (lastLayoutInfo.validity != LayoutValidity.Nothing)
                {
                    control.Measure(lastLayoutInfo.measureArgument);
//                    if (lastLayoutInfo.unclippedDesiredSize == control.layoutInfo.unclippedDesiredSize) {
                    if (checkDesiredSizeNotChangedRecursively(control))
                    {
                        needUpdateParentLayout = false;
                    }
                }
                if (needUpdateParentLayout)
                {
                    // mark the parent control for invalidation too and enqueue them
                    control.Parent.Invalidate();
                    // мы можем закончить с этим элементом, поскольку мы уже добавили
                    // в конец очереди его родителя, и мы все равно вернемся к нему в след. раз
                    return;
                }
            }
            // работаем с дочерними элементами управления
            // вызываем для текущего контрола Measure&Arrange с последними значениями аргументов
            if (lastLayoutInfo.validity == LayoutValidity.Nothing && control.Parent != null)
            {
                throw new InvalidOperationException("Assertion failed.");
            }
            // rootElement - особый случай
            if (control.Parent == null)
            {
                if (control != RootElement)
                {
                    throw new InvalidOperationException("Control has no parent but is not known rootElement.");
                }
                control.Measure(RootElementRect.Size);
                control.Arrange(RootElementRect);
            }
            else
            {
                control.Measure(lastLayoutInfo.measureArgument);
                control.Arrange(lastLayoutInfo.renderSlotRect);
            }
            // update render buffers of current control and its children
            RenderingBuffer buffer     = getOrCreateBufferForControl(control);
            RenderingBuffer fullBuffer = getOrCreateFullBufferForControl(control);
            // replace buffers if control has grown
            LayoutInfo layoutInfo = control.layoutInfo;

            if (layoutInfo.renderSize.width > buffer.Width || layoutInfo.renderSize.height > buffer.Height)
            {
                buffer               = new RenderingBuffer(layoutInfo.renderSize.width, layoutInfo.renderSize.height);
                fullBuffer           = new RenderingBuffer(layoutInfo.renderSize.width, layoutInfo.renderSize.height);
                buffers[control]     = buffer;
                fullBuffers[control] = fullBuffer;
            }
            buffer.Clear();
            if (control.RenderSize.Width != 0 && control.RenderSize.Height != 0)
            {
                control.Render(buffer);
            }
            // проверяем дочерние контролы - если их layoutInfo не изменился по сравнению с последним,
            // то мы можем взять их последний renderBuffer без обновления и применить к текущему контролу
            fullBuffer.CopyFrom(buffer);
            IList <Control> children = control.Children;

            foreach (Control child in children)
            {
                if (child.Visibility == Visibility.Visible)
                {
                    RenderingBuffer fullChildBuffer = processControl(child, revalidatedControls);
                    fullBuffer.ApplyChild(fullChildBuffer, child.ActualOffset,
                                          child.RenderSize,
                                          child.RenderSlotRect, child.LayoutClip);
                }
                else
                {
                    // чтобы следующий Invalidate перезаписал lastLayoutInfo
                    if (child.SetValidityToRender())
                    {
                        revalidatedControls.Add(child);
                    }
                }
            }

            // Save overlappingRect for each control child
            refreshChildrenLastOverlappedRects(control, false);

            if (control.SetValidityToRender())
            {
                revalidatedControls.Add(control);
            }
            addControlToRenderingUpdatedList(control);
        }
Exemplo n.º 16
0
        public void SetWidth(object backend, double value)
        {
            LayoutInfo li = (LayoutInfo)backend;

            li.Width = value;
        }
    /// <summary>
    /// Shows warning if there is wrong web part zone count set.
    /// </summary>
    private void HandleWebpartZonesCountWarning()
    {
        if (actualLayoutInfo == null)
        {
            actualLayoutInfo = EditedObject as LayoutInfo;
        }
        FormEngineUserControl zonesCountControl = EditFormLayout.FieldControls["layoutzonecount"];
        if ((actualLayoutInfo == null) || (zonesCountControl == null) || (!zonesCountControl.Visible))
        {
            return;
        }

        // Handle difference between counted and entered number of web part zones
        if (actualLayoutInfo.LayoutZoneCountAutomatic != actualLayoutInfo.LayoutZoneCount)
        {
            string msg = (actualLayoutInfo.LayoutZoneCount >= 0) ? String.Format(ResHelper.GetString("pagelayout.webpartzonescountnotmatch"), actualLayoutInfo.LayoutZoneCount, actualLayoutInfo.LayoutZoneCountAutomatic) : ResHelper.GetString("pagelayout.webpartzonescountmissing");
            ShowWarning(msg, null, null);
        }
    }
Exemplo n.º 18
0
        public override void SetWidth(object backend, double value)
        {
            LayoutInfo li = (LayoutInfo)backend;

            li.Width = value < 0 ? null : (float?)value;
        }
Exemplo n.º 19
0
 public QuaternionCurveLayout(LayoutInfo info)
 {
 }
Exemplo n.º 20
0
        public override void SetText(object backend, string text)
        {
            LayoutInfo li = (LayoutInfo)backend;

            li.Text = text == null ? String.Empty : text.Replace("\r\n", "\n");
        }
Exemplo n.º 21
0
        public override void SetFont(object backend, Font font)
        {
            LayoutInfo li = (LayoutInfo)backend;

            li.Font = ((FontData)ApplicationContext.Toolkit.GetSafeBackend(font)).Font;
        }
    /// <summary>
    /// Ensures the template from the selection and returns the template ID.
    /// </summary>
    /// <param name="documentName">Document name for the ad-hoc template</param>
    /// <param name="nodeGuid">Owner node GUID in case of ad-hoc template</param>
    /// <param name="errorMessage">Returns the error message</param>
    public PageTemplateInfo EnsureTemplate(string documentName, Guid nodeGuid, ref string errorMessage)
    {
        bool cloneAsAdHoc = false;
        bool masterOnly   = false;

        PageTemplateInfo templateInfo = null;

        // Template selection
        if (radUseTemplate.Checked)
        {
            // Template page
            int templateId = ValidationHelper.GetInteger(templateSelector.SelectedItem, 0);
            if (templateId > 0)
            {
                // Get the template and check if it should be cloned
                templateInfo = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);
                if (templateInfo != null)
                {
                    cloneAsAdHoc = templateInfo.PageTemplateCloneAsAdHoc || IsWireframe;
                }
            }
            else
            {
                errorMessage = GetString("NewPage.TemplateError");
            }
        }
        else if (radInherit.Checked)
        {
            // Inherited page
        }
        else if (radCreateBlank.Checked || radCreateEmpty.Checked)
        {
            // Create custom template info for the page
            templateInfo = new PageTemplateInfo(true);

            if (radCreateBlank.Checked)
            {
                // Blank page with layout
                int layoutId = ValidationHelper.GetInteger(layoutSelector.SelectedItem, 0);
                if (layoutId > 0)
                {
                    templateInfo.LayoutID = layoutId;

                    // Copy layout to selected template
                    if (chkLayoutPageTemplate.Checked)
                    {
                        templateInfo.LayoutID = 0;
                        LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(layoutId);
                        if (li != null)
                        {
                            templateInfo.PageTemplateLayout     = li.LayoutCode;
                            templateInfo.PageTemplateLayoutType = li.LayoutType;
                        }
                        else
                        {
                            errorMessage = GetString("NewPage.LayoutError");
                        }
                    }
                }
                else
                {
                    errorMessage = GetString("NewPage.LayoutError");
                }
            }
            else if (radCreateEmpty.Checked)
            {
                // Empty template
                templateInfo.LayoutID = 0;
                if (IsWireframe)
                {
                    templateInfo.PageTemplateLayout = "<cms:CMSWebPartZone ZoneID=\"zoneA\" runat=\"server\" Wireframe=\"true\" />";
                }
                else
                {
                    templateInfo.PageTemplateLayout = "<cms:CMSWebPartZone ZoneID=\"zoneA\" runat=\"server\" />";
                }

                templateInfo.PageTemplateLayoutType = LayoutTypeEnum.Ascx;
            }

            if (String.IsNullOrEmpty(errorMessage))
            {
                cloneAsAdHoc = true;
                masterOnly   = true;
            }
        }

        if (cloneAsAdHoc)
        {
            // Prepare ad-hoc template name
            string displayName = "Ad-hoc: " + documentName;

            // Create ad-hoc template
            templateInfo = PageTemplateInfoProvider.CloneTemplateAsAdHoc(templateInfo, displayName, CMSContext.CurrentSiteID, Guid.Empty);

            // Set inherit only master
            if (masterOnly)
            {
                templateInfo.InheritPageLevels = "\\";
            }

            PageTemplateInfoProvider.SetPageTemplateInfo(templateInfo);

            if (CMSContext.CurrentSite != null)
            {
                PageTemplateInfoProvider.AddPageTemplateToSite(templateInfo.PageTemplateId, CMSContext.CurrentSiteID);
            }
        }

        // Assign owner node GUID
        if ((templateInfo != null) && !templateInfo.IsReusable)
        {
            templateInfo.PageTemplateNodeGUID = nodeGuid;
        }

        // Reload the template selector in case of error
        if (!String.IsNullOrEmpty(errorMessage))
        {
            if (radUseTemplate.Checked)
            {
                templateSelector.ReloadData();
            }
        }

        return(templateInfo);
    }
Exemplo n.º 23
0
 public bool ValidateLayout(LayoutInfo layoutInfo)
 {
     return(DockPanel.RootRegion.Validate(layoutInfo));
 }
Exemplo n.º 24
0
        public override void SetTrimming(object backend, TextTrimming value)
        {
            LayoutInfo li = (LayoutInfo)backend;

            li.TextTrimming = value;
        }
Exemplo n.º 25
0
    /// <summary>
    /// Initializes header action control.
    /// </summary>
    private void InitializeHeaderActions(LayoutInfo li)
    {
        // Header actions
        string[,] actions = new string[4, 11];

        // Save button
        actions[0, 0] = HeaderActions.TYPE_SAVEBUTTON;
        actions[0, 1] = GetString("General.Save");
        actions[0, 5] = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
        actions[0, 6] = "save";
        actions[0, 8] = "true";

        if (SettingsKeyProvider.UsingVirtualPathProvider)
        {
            // CheckOut
            actions[1, 0] = HeaderActions.TYPE_SAVEBUTTON;
            actions[1, 1] = GetString("General.CheckOutToFile");
            actions[1, 5] = GetImageUrl("CMSModules/CMS_Content/EditMenu/checkout.png");
            actions[1, 6] = "checkout";
            actions[1, 10] = "false";

            // CheckIn
            actions[2, 0] = HeaderActions.TYPE_SAVEBUTTON;
            actions[2, 1] = GetString("General.CheckInFromFile");
            actions[2, 5] = GetImageUrl("CMSModules/CMS_Content/EditMenu/checkin.png");
            actions[2, 6] = "checkin";
            actions[2, 10] = "false";

            // UndoCheckOut
            actions[3, 0] = HeaderActions.TYPE_SAVEBUTTON;
            actions[3, 1] = GetString("General.UndoCheckout");
            actions[3, 2] = "return confirm(" + ScriptHelper.GetString(GetString("General.ConfirmUndoCheckOut")) + ");";
            actions[3, 5] = GetImageUrl("CMSModules/CMS_Content/EditMenu/undocheckout.png");
            actions[3, 6] = "undocheckout";
            actions[3, 10] = "false";
        }

        if (li != null)
        {
            if (li.LayoutCheckedOutByUserID > 0)
            {
                // Checked out by current machine
                if (li.LayoutCheckedOutMachineName.ToLower() == HTTPHelper.MachineName.ToLower())
                {
                    actions[2, 10] = "true";
                }
                if (CMSContext.CurrentUser.UserSiteManagerAdmin)
                {
                    actions[3, 10] = "true";
                }
            }
            else
            {
                actions[1, 10] = "true";
            }
        }

        this.CurrentMaster.HeaderActions.LinkCssClass = "ContentSaveLinkButton";
        this.CurrentMaster.HeaderActions.ActionPerformed += new CommandEventHandler(HeaderActions_ActionPerformed);
        this.CurrentMaster.HeaderActions.Actions = actions;
    }
Exemplo n.º 26
0
        public override void SetHeight(object backend, double value)
        {
            LayoutInfo li = (LayoutInfo)backend;

            li.Height = value < 0 ? null : (float?)value;
        }
Exemplo n.º 27
0
        public void SetHeight(object backend, double value)
        {
            LayoutInfo li = (LayoutInfo)backend;

            li.Heigth = value;
        }
Exemplo n.º 28
0
        public override void SetTrimming(object backend, TextTrimming textTrimming)
        {
            LayoutInfo li = (LayoutInfo)backend;

            li.TextTrimming = textTrimming;
        }
Exemplo n.º 29
0
 public void ApplyLayout(LayoutInfo layoutInfo)
 {
     MutateWithLockThenRaiseEvents(diagramMutator => diagramMutator.ApplyLayout(layoutInfo));
 }
Exemplo n.º 30
0
        public override void SetAlignment(object backend, Alignment alignment)
        {
            LayoutInfo li = (LayoutInfo)backend;

            li.TextAlignment = alignment;
        }
        private void SetErrors(object target, IList <object> errors, bool isClear)
        {
            var hasErrors = errors.Count != 0;

            if (TryGetEntryField != null)
            {
                target = TryGetEntryField(target);
            }

            var nativeObject = target as INativeObject;

            if (!nativeObject.IsAlive())
            {
                return;
            }
            var uiView = target as UIView;

            if (uiView != null && ErrorBorderWidth > 0)
            {
                if (hasErrors)
                {
                    LayoutInfo.Save(uiView, target);
                    uiView.Layer.BorderColor  = ErrorBorderColor.CGColor;
                    uiView.Layer.BorderWidth  = ErrorBorderWidth;
                    uiView.Layer.CornerRadius = CornerRadius;
                    uiView.ClipsToBounds      = true;
                }
                else
                {
                    LayoutInfo.Restore(uiView, target);
                }
            }

            var textField = target as UITextField;

            if (textField != null && ErrorImage != null && textField.Superview != null)
            {
                ErrorButton         errorButton;
                UITextFieldViewMode mode = hasErrors ? UITextFieldViewMode.Always : UITextFieldViewMode.Never;
                if (RightErrorImagePosition)
                {
                    textField.RightViewMode = mode;
                    errorButton             = textField.RightView as ErrorButton;
                    if (isClear)
                    {
                        textField.RightView = null;
                    }
                    else if (errorButton == null)
                    {
                        errorButton         = CreateErrorButton(textField);
                        textField.RightView = errorButton;
                    }
                }
                else
                {
                    textField.LeftViewMode = mode;
                    errorButton            = textField.LeftView as ErrorButton;
                    if (isClear)
                    {
                        textField.LeftView = null;
                    }
                    else if (errorButton == null)
                    {
                        errorButton        = CreateErrorButton(textField);
                        textField.LeftView = errorButton;
                    }
                }

                if (isClear)
                {
                    if (errorButton != null)
                    {
                        errorButton.ClearBindingsRecursively(true, true);
                        errorButton.DisposeEx();
                    }
                }
                else
                {
                    errorButton.SetErrors(errors);
                }
            }
        }
Exemplo n.º 32
0
        public override Size GetSize(object backend)
        {
            LayoutInfo li = (LayoutInfo)backend;

            return(li.GetSize().ToXwtSize());
        }
Exemplo n.º 33
0
 private static bool CanMoveTo(LayoutInfo info, int x, int y, Node[] reflow,
     int count, List<Decorator> decorators)
 {
     throw new Exception("Not Yet Implemented");
 }
Exemplo n.º 34
0
        public override double GetBaseline(object backend)
        {
            LayoutInfo li = (LayoutInfo)backend;

            return(li.GetBaseLine());
        }
Exemplo n.º 35
0
		public override void Layout(LayoutInfo transform)
		{
			LastLayoutTransform = transform;
			Height = 5; // arbitrary non-zero value to indicate a layout has occurred.
		}
Exemplo n.º 36
0
        public override double GetMeanline(object backend)
        {
            LayoutInfo li = (LayoutInfo)backend;

            return(GetBaseline(backend) - li.Font.XHeight / 2);
        }
Exemplo n.º 37
0
		/// <summary>
		/// Redo the layout of the paragraph given the Source changes indicated in the given details.
		/// </summary>
		/// <param name="details"></param>
		private void Relayout(SourceChangeDetails details)
		{
			// We would prefer to keep both sources intact, but we can't just do Source = details.NewSource,
			// because there is currently no way to change the Source of existing segments we may want to reuse.
			Source.Copyfrom(details.NewSource);
			var oldHeight = Height;
			var oldWidth = Width;
			using (var gh = Root.Site.DrawingInfo)
			{
				// Enhance JohnT: margins: need to adjust MaxWidth for margins and padding of containing boxes.
				var info = new LayoutInfo(ChildTransformFromRootTransform(gh.Transform), Root.LastLayoutInfo.MaxWidth,
					gh.VwGraphics, Root.LastLayoutInfo.RendererFactory);
				var builder = new ParaBuilder(this, info);
				using (var lcb = new LayoutCallbacks(Root))
				{
					builder.Relayout(details, lcb);
					if (Height != oldHeight || Width != oldWidth)
						RelayoutParents(gh);
				}
			}
		}
Exemplo n.º 38
0
        internal static void Draw(CGContextBackend ctx, object layout, double x, double y)
        {
            LayoutInfo li = (LayoutInfo)layout;

            li.Draw(ctx.Context, ctx.CurrentStatus.GlobalColor, x, y);
        }
Exemplo n.º 39
0
    protected void Page_Load(object sender, EventArgs e)
    {
        lbCodeName.Text                   = GetString("Administration-PageLayout_New.LayoutCodeName");
        lbLayoutDisplayName.Text          = GetString("Administration-PageLayout_New.LayoutDisplayName");
        lbLayoutDescription.Text          = GetString("Administration-PageLayout_New.LayoutDescription");
        lbLayoutCode.Text                 = GetString("Administration-PageLayout_New.LayoutCode");
        rfvLayoutDisplayName.ErrorMessage = GetString("Administration-PageLayout_New.ErrorEmptyLayoutDisplayName");
        rfvLayoutCode.ErrorMessage        = GetString("Administration-PageLayout_New.ErrorEmptyLayoutCode");
        rfvCodeName.ErrorMessage          = GetString("Administration-PageLayout_New.ErrorEmptyLayoutCodeName");
        lblType.Text = GetString("PageLayout.Type");

        string lang = DataHelper.GetNotEmpty(SettingsHelper.AppSettings["CMSProgrammingLanguage"], "C#");

        ltlDirectives.Text = "&lt;%@ Control Language=\"" + lang + "\" ClassName=\"Simple\" Inherits=\"CMS.PortalControls.CMSAbstractLayout\" %&gt;<br />&lt;%@ Register Assembly=\"CMS.PortalControls\" Namespace=\"CMS.PortalControls\" TagPrefix=\"cc1\" %&gt;";

        if (this.drpType.Items.Count == 0)
        {
            drpType.Items.Add(new ListItem(GetString("TransformationType.Ascx"), TransformationTypeEnum.Ascx.ToString()));
            drpType.Items.Add(new ListItem(GetString("TransformationType.Html"), TransformationTypeEnum.Html.ToString()));
        }

        if (EditedObject != null)
        {
            li = EditedObject as LayoutInfo;
            if (!RequestHelper.IsPostBack())
            {
                // Load the form
                LoadData();
            }
        }
        else
        {
            if (tbCodeName.Text == "")
            {
                // default layout code content
                tbLayoutCode.Text = "<cms:CMSWebPartZone ID=\"zoneCenter\" runat=\"server\" />";
            }
        }


        // Gets page layout info of specified 'layoutid'
        if (li != null)
        {
            lblUploadFile.Text = GetString("Administration-PageLayout_New.PageLayoutThumbnail");

            UploadFile.ObjectID   = li.LayoutId;
            UploadFile.Category   = MetaFileInfoProvider.OBJECT_CATEGORY_THUMBNAIL;
            UploadFile.ObjectType = PortalObjectType.PAGELAYOUT;

            this.plcFile.Visible = true;
        }

        InitializeHeaderActions(li);

        if (Request.QueryString["saved"] != null && Request.QueryString["saved"] == "1")
        {
            lblInfo.Visible = true;
            lblInfo.Text    = GetString("General.ChangesSaved");

            // Reload header if changes were saved
            ScriptHelper.RefreshTabHeader(Page, null);
        }

        if (li == null)
        {
            string layouts       = GetString("Administration-PageLayout_New.NewLayout");
            string title         = GetString("Administration-PageLayout_New.Title");
            string image         = GetImageUrl("Objects/CMS_Layout/new.png");
            string currentLayout = GetString("Administration-PageLayout_New.CurrentLayout");

            breadcrumbs[0, 0] = layouts;
            breadcrumbs[0, 1] = ResolveUrl("PageLayout_List.aspx");
            breadcrumbs[0, 2] = "";
            breadcrumbs[1, 0] = currentLayout;
            breadcrumbs[1, 1] = "";
            breadcrumbs[1, 2] = "";

            this.CurrentMaster.Title.Breadcrumbs   = breadcrumbs;
            this.CurrentMaster.Title.TitleText     = title;
            this.CurrentMaster.Title.TitleImage    = image;
            this.CurrentMaster.Title.HelpTopicName = "newedit_page_layout";
            this.CurrentMaster.Title.HelpName      = "helpTopic";
        }

        this.plcCssLink.Visible = String.IsNullOrEmpty(txtLayoutCSS.Text.Trim());
    }
Exemplo n.º 40
0
    /// <summary>
    /// Gets and bulk updates layouts. Called when the "Get and bulk update layouts" button is pressed.
    /// Expects the CreateLayout method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateLayouts()
    {
        // Prepare the parameters
        string where = "LayoutCodeName LIKE N'MyNewLayout%'";

        // Get the data
        DataSet layouts = LayoutInfoProvider.GetLayouts(where, null);
        if (!DataHelper.DataSourceIsEmpty(layouts))
        {
            // Loop through the individual items
            foreach (DataRow layoutDr in layouts.Tables[0].Rows)
            {
                // Create object from DataRow
                LayoutInfo modifyLayout = new LayoutInfo(layoutDr);

                // Update the properties
                modifyLayout.LayoutDisplayName = modifyLayout.LayoutDisplayName.ToUpper();

                // Save the changes
                LayoutInfoProvider.SetLayoutInfo(modifyLayout);
            }

            return true;
        }

        return false;
    }
Exemplo n.º 41
0
    protected void Page_Load(object sender, EventArgs e)
    {
        lbCodeName.Text = GetString("Administration-PageLayout_New.LayoutCodeName");
        lbLayoutDisplayName.Text = GetString("Administration-PageLayout_New.LayoutDisplayName");
        lbLayoutDescription.Text = GetString("Administration-PageLayout_New.LayoutDescription");
        lbLayoutCode.Text = GetString("Administration-PageLayout_New.LayoutCode");
        rfvLayoutDisplayName.ErrorMessage = GetString("Administration-PageLayout_New.ErrorEmptyLayoutDisplayName");
        rfvLayoutCode.ErrorMessage = GetString("Administration-PageLayout_New.ErrorEmptyLayoutCode");
        rfvCodeName.ErrorMessage = GetString("Administration-PageLayout_New.ErrorEmptyLayoutCodeName");
        lblType.Text = GetString("PageLayout.Type");

        string lang = DataHelper.GetNotEmpty(SettingsHelper.AppSettings["CMSProgrammingLanguage"], "C#");
        ltlDirectives.Text = "&lt;%@ Control Language=\"" + lang + "\" ClassName=\"Simple\" Inherits=\"CMS.PortalControls.CMSAbstractLayout\" %&gt;<br />&lt;%@ Register Assembly=\"CMS.PortalControls\" Namespace=\"CMS.PortalControls\" TagPrefix=\"cc1\" %&gt;";

        if (this.drpType.Items.Count == 0)
        {
            drpType.Items.Add(new ListItem(GetString("TransformationType.Ascx"), TransformationTypeEnum.Ascx.ToString()));
            drpType.Items.Add(new ListItem(GetString("TransformationType.Html"), TransformationTypeEnum.Html.ToString()));
        }

        if (EditedObject != null)
        {
            li = EditedObject as LayoutInfo;
            if (!RequestHelper.IsPostBack())
            {
                // Load the form
                LoadData();
            }
        }
        else
        {
            if (tbCodeName.Text == "")
            {
                // default layout code content
                tbLayoutCode.Text = "<cms:CMSWebPartZone ID=\"zoneCenter\" runat=\"server\" />";
            }
        }

        // Gets page layout info of specified 'layoutid'
        if (li != null)
        {
            lblUploadFile.Text = GetString("Administration-PageLayout_New.PageLayoutThumbnail");

            UploadFile.ObjectID = li.LayoutId;
            UploadFile.Category = MetaFileInfoProvider.OBJECT_CATEGORY_THUMBNAIL;
            UploadFile.ObjectType = PortalObjectType.PAGELAYOUT;

            this.plcFile.Visible = true;
        }

        InitializeHeaderActions(li);

        if (Request.QueryString["saved"] != null && Request.QueryString["saved"] == "1")
        {
            lblInfo.Visible = true;
            lblInfo.Text = GetString("General.ChangesSaved");

            // Reload header if changes were saved
            ScriptHelper.RefreshTabHeader(Page, null);
        }

        if (li == null)
        {
            string layouts = GetString("Administration-PageLayout_New.NewLayout");
            string title = GetString("Administration-PageLayout_New.Title");
            string image = GetImageUrl("Objects/CMS_Layout/new.png");
            string currentLayout = GetString("Administration-PageLayout_New.CurrentLayout");

            breadcrumbs[0, 0] = layouts;
            breadcrumbs[0, 1] = ResolveUrl("PageLayout_List.aspx");
            breadcrumbs[0, 2] = "";
            breadcrumbs[1, 0] = currentLayout;
            breadcrumbs[1, 1] = "";
            breadcrumbs[1, 2] = "";

            this.CurrentMaster.Title.Breadcrumbs = breadcrumbs;
            this.CurrentMaster.Title.TitleText = title;
            this.CurrentMaster.Title.TitleImage = image;
            this.CurrentMaster.Title.HelpTopicName = "newedit_page_layout";
            this.CurrentMaster.Title.HelpName = "helpTopic";
        }

        this.plcCssLink.Visible = String.IsNullOrEmpty(txtLayoutCSS.Text.Trim());
    }
Exemplo n.º 42
0
        private void ChangeKeyboardLayout(int index)
        {
            nIcon.Icon = mainIcon;

            try
            {
                if (!engines.ContainsKey(LastClientHandle))
                {
                    engines[LastClientHandle] = new LayoutInfo(index, new KeyMagicDotNet.KeyMagicEngine());
                }
                else if (index == 0 && engines[LastClientHandle].index == 0)
                {
                    index = LastKeyboardLayoutIndex;
                    engines[LastClientHandle] = new LayoutInfo(index, new KeyMagicDotNet.KeyMagicEngine());
                }
                else if (index == 0)
                {
                    Properties.Settings.Default.LastKeyboardLayoutIndex = LastKeyboardLayoutIndex = engines[LastClientHandle].index;
                    engines[LastClientHandle] = new LayoutInfo(0, null);
                }
                else if (engines[LastClientHandle].index != index)
                {
                    engines[LastClientHandle] = new LayoutInfo(index, new KeyMagicDotNet.KeyMagicEngine());
                }
                else if (engines[LastClientHandle].index == index)
                {
                    Debug.WriteLine(string.Format("engines[LastClientHandle].index == index # {0} == {1}", engines[LastClientHandle].index, index));
                    engines[LastClientHandle] = new LayoutInfo(0, null);
                    index = 0;
                }

                keyEventHandler.Engine = engines[LastClientHandle].engine;

                Debug.WriteLine(engines[LastClientHandle]);

                if (index != 0 && keyEventHandler.Engine != null)
                {
                    String fileName = ActiveKeyboardList[index].file;
                    bool success = keyEventHandler.Engine.LoadKeyboardFile(GetSaveKeyboardPath(fileName));
                    Debug.Assert(success == true, "Failed to load keyboard layout.");

                    SetKeyboardIcon(fileName);
                }

                SoftKeyboardEngine = keyEventHandler.Engine;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.StackTrace);
            }
        }
Exemplo n.º 43
0
    /// <summary>
    /// Saves the layout.
    /// </summary>
    /// <returns>Returns true if successful</returns>
    private bool SaveLayout()
    {
        string codeName = tbCodeName.Text.Trim();

        // Find out whether required fields are not empty
        string result = new Validator()
            .NotEmpty(codeName, GetString("Administration-PageLayout_New.ErrorEmptyLayoutCodeName"))
            .NotEmpty(tbLayoutDisplayName.Text, GetString("Administration-PageLayout_New.ErrorEmptyLayoutDisplayName"))
            .NotEmpty(tbLayoutCode.Text.Trim(), GetString("Administration-PageLayout_New.ErrorEmptyLayoutCode"))
            .IsCodeName(codeName, GetString("general.invalidcodename"))
            .Result;

        if (result == "")
        {
            if (li == null)
            {
                li = new LayoutInfo();
            }

            li.LayoutCodeName = codeName;
            li.LayoutDisplayName = tbLayoutDisplayName.Text.Trim();
            li.LayoutDescription = tbLayoutDescription.Text;
            li.LayoutType = LayoutInfoProvider.GetLayoutTypeEnum(this.drpType.SelectedValue);

            if (li.LayoutCheckedOutByUserID <= 0)
            {
                li.LayoutCode = tbLayoutCode.Text;
                li.LayoutCSS = txtLayoutCSS.Text;
            }

            try
            {
                LayoutInfoProvider.SetLayoutInfo(li);
                lblInfo.Visible = true;
                lblInfo.Text = GetString("General.ChangesSaved");
                breadcrumbs[1, 0] = li.LayoutDisplayName;
            }
            catch (Exception ex)
            {
                lblInfo.Visible = false;
                lblError.Visible = true;
                lblError.Text = ex.Message.Replace("%%name%%", li.LayoutCodeName);
                return false;
            }

            layoutId = li.LayoutId;

            UploadFile.ObjectID = layoutId;
            UploadFile.UploadFile();

            return !UploadFile.SavingFailed;
        }
        else
        {
            lblError.Text = result;
            lblError.Visible = true;
            return false;
        }
    }
Exemplo n.º 44
0
		/// <summary>
		/// Given three groups of words, sets up the mock engine so that the first line is a single segment consisting of the first three words of the first group;
		/// the second line contains the remaining word of the first group; then two words (in another WS) from the second group;
		/// the third line contains the rest of the second group;
		/// the last line contains the third group.
		/// For now it has some assumptions about the number of words in each group. Typically the correspond to the static variables with similar names.
		/// </summary>
		/// <param name="firstGroupWords"></param>
		/// <param name="secondGroupWords"></param>
		/// <param name="thirdGroupWords"></param>
		/// <param name="engine"></param>
		internal static void SetupMockEngineForThreeStringsPara(string[] firstGroupWords, string[] secondGroupWords, string[] thirdGroupWords,
			LayoutInfo layoutArgs)
		{
			string contents1 = AssembleStrings(firstGroupWords);
			string contents2 = AssembleStrings(secondGroupWords);
			string contents3 = AssembleStrings(thirdGroupWords);
			int totalLength = contents1.Length + contents2.Length + contents3.Length;
			var factory = (MockRendererFactory) layoutArgs.RendererFactory;
			var engine1 = new MockRenderEngine();
			factory.SetRenderer(s_simpleStringWs, engine1);
			var engine2 = new MockRenderEngine();
			factory.SetRenderer(s_secondGroupWs, engine2);

			int lenFirstSeg = SumStringLengths(s_simpleStringWords, 0, 3);
			engine1.AddMockSeg(0, contents1.Length, lenFirstSeg, s_widthFirstMockSeg, s_simpleStringWs,
							  LgEndSegmentType.kestMoreLines);
			// Asked to break the rest of the first WS run we answer a segment with the last word, and indicate that we broke at a ws boundary.
			engine1.AddMockSeg(lenFirstSeg, contents1.Length, SumStringLengths(firstGroupWords, 3, 4),
							  s_widthSecondLineFirstMockSeg, s_simpleStringWs, LgEndSegmentType.kestWsBreak);
			// Asked to break at the start of the second WS run we answer a segment with two more words (in the other writing system). This continues and completes the second line.
			engine2.AddMockSeg(contents1.Length, contents1.Length + contents2.Length, SumStringLengths(secondGroupWords, 0, 2),
							  s_widthSecondLineSecondMockSeg, s_secondGroupWs, LgEndSegmentType.kestMoreLines);
			// Asked to break after that we answer a segment with the rest of the second string. This makes the third line.
			engine2.AddMockSeg(contents1.Length + SumStringLengths(secondGroupWords, 0, 2), contents1.Length + contents2.Length, SumStringLengths(secondGroupWords, 2, 5),
							  s_widthThirdLineMockSeg, s_secondGroupWs, LgEndSegmentType.kestWsBreak);
			// Asked to put more on that third line, nothing fits.
			engine1.FailOnPartialLine(contents1.Length + contents2.Length, totalLength);
			// Asked to make a new (fourth) line, all the last string fits.
			engine1.AddMockSeg(contents1.Length + contents2.Length, totalLength, contents3.Length,
							  s_widthFourthLineMockSeg, s_secondGroupWs, LgEndSegmentType.kestNoMore);
		}
Exemplo n.º 45
0
 public LayoutInfo(Rect NewRect, float NewBaseline, int NewNChar, List<List<List<LayoutInfo>>> NewBounds)
 {
     this = new LayoutInfo();
     this.Rect = NewRect;
     this.Baseline = NewBaseline;
     this.nChar = NewNChar;
     this.Bounds = NewBounds;
 }
Exemplo n.º 46
0
    /// <summary>
    /// Save button is clicked.
    /// </summary>
    protected void SaveAction(object sender, EventArgs e)
    {
        // Check permissions
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.Design", "Design.EditLayout"))
        {
            RedirectToUIElementAccessDenied("CMS.Design", "Design.EditLayout");
        }

        // New device profile
        int newDeviceProfileId = deviceProfileId;

        if (newDeviceProfileId == 0)
        {
            newDeviceProfileId = ValidationHelper.GetInteger(ucNewDeviceProfile.Value, 0);
        }

        if (newDeviceProfileId == 0)
        {
            // Show error - select device profile first
            ShowError(GetString("devicelayout.selectdeviceprofile.error"));
            rbtnDevice.Checked = true;
            return;
        }

        PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);

        if ((pti != null) && (newDeviceProfileId > 0))
        {
            string         layoutCode = null;
            string         layoutCSS  = null;
            int            layoutId   = 0;
            LayoutTypeEnum layoutType = LayoutTypeEnum.Ascx;

            if (rbtnDevice.Checked)
            {
                // Copy from device
                int selectedDeviceProfileId = ValidationHelper.GetInteger(ucDeviceProfile.Value, 0);
                if (selectedDeviceProfileId > 0)
                {
                    // Existing device profile
                    PageTemplateDeviceLayoutInfo selectedDeviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(templateId, selectedDeviceProfileId);
                    if (selectedDeviceLayout != null)
                    {
                        layoutId   = selectedDeviceLayout.LayoutID;
                        layoutCode = selectedDeviceLayout.LayoutCode;
                        layoutCSS  = selectedDeviceLayout.LayoutCSS;
                        layoutType = selectedDeviceLayout.LayoutType;
                    }
                }
                else
                {
                    // Default device
                    layoutType = pti.PageTemplateLayoutType;

                    if (pti.LayoutID > 0)
                    {
                        layoutId = pti.LayoutID;
                    }
                    else
                    {
                        layoutCode = pti.PageTemplateLayout;
                        layoutCSS  = pti.PageTemplateCSS;
                    }
                }
            }
            else if (rbtnLayout.Checked)
            {
                // Use existing layout
                int        selectedLayoutId = ValidationHelper.GetInteger(ucLayout.Value, 0);
                LayoutInfo selectedLayout   = LayoutInfoProvider.GetLayoutInfo(selectedLayoutId);
                if (selectedLayout != null)
                {
                    layoutType = selectedLayout.LayoutType;

                    if (chkCopy.Checked)
                    {
                        // Copy layout code
                        layoutCode = selectedLayout.LayoutCode;
                        layoutCSS  = selectedLayout.LayoutCSS;
                    }
                    else
                    {
                        // Copy layout id
                        layoutId = selectedLayoutId;
                    }
                }
            }
            else if (rbtnEmptyLayout.Checked)
            {
                layoutCode = "<cms:CMSWebPartZone ZoneID=\"zoneA\" runat=\"server\" />";
            }

            PageTemplateDeviceLayoutInfo deviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(templateId, newDeviceProfileId);

            if (deviceLayout == null)
            {
                // Create a new device profile layout object
                deviceLayout = new PageTemplateDeviceLayoutInfo();
                deviceLayout.PageTemplateID = templateId;
                deviceLayout.ProfileID      = newDeviceProfileId;
            }

            // Modify the device profile layout object with updated values
            deviceLayout.LayoutID   = layoutId;
            deviceLayout.LayoutType = layoutType;
            deviceLayout.LayoutCode = layoutCode;
            deviceLayout.LayoutCSS  = layoutCSS;

            // Save the device profile layout object
            PageTemplateDeviceLayoutInfoProvider.SetTemplateDeviceLayoutInfo(deviceLayout);
            UIContext.EditedObject = deviceLayout;
            CMSObjectManager.CheckOutNewObject(Page);

            // Register refresh page scripts
            ScriptHelper.RegisterStartupScript(this, typeof(string), "deviceLayoutSaved", "if (wopener) { wopener.location.replace(wopener.location); } CloseDialog();", true);
        }
    }
Exemplo n.º 47
0
		public override void Layout(LayoutInfo transform)
		{
			Height = Segment.get_Height(IchMin, transform.VwGraphics);
			Width = Segment.get_Width(IchMin, transform.VwGraphics);
			m_ascent = Segment.get_Ascent(IchMin, transform.VwGraphics);
		}
Exemplo n.º 48
0
		static CTFrame CreateFrame (LayoutInfo li)
		{
			if (string.IsNullOrEmpty (li.Text))
				return null;

			using (CTFramesetter framesetter = new CTFramesetter (CreateAttributedString (li))) {
				CGPath path = new CGPath ();
				bool ellipsize = li.Width.HasValue && li.TextTrimming == TextTrimming.WordElipsis;
				path.AddRect (new RectangleF (0, 0, li.Width.HasValue && !ellipsize ? li.Width.Value : float.MaxValue, li.Height ?? float.MaxValue));

				return framesetter.GetFrame (new NSRange (0, li.Text.Length), path, null);
			}
		}
Exemplo n.º 49
0
        public override void AddAttribute(object backend, TextAttribute attribute)
        {
            LayoutInfo li = (LayoutInfo)backend;

            li.AddAttribute(attribute);
        }
        private RenderingBuffer processControl(Control control, List <Control> revalidatedControls)
        {
            RenderingBuffer buffer     = getOrCreateBufferForControl(control);
            RenderingBuffer fullBuffer = getOrCreateFullBufferForControl(control);
            //
            LayoutInfo lastLayoutInfo = control.lastLayoutInfo;
            LayoutInfo layoutInfo     = control.layoutInfo;

            //
            control.Measure(lastLayoutInfo.measureArgument);
            control.Arrange(lastLayoutInfo.renderSlotRect);
            // if lastLayoutInfo eq layoutInfo we can use last rendered buffer
//            if (layoutInfo.Equals(lastLayoutInfo) && lastLayoutInfo.validity == LayoutValidity.Render) {
            if (checkRenderingWasNotChangedRecursively(control))
            {
                if (control.SetValidityToRender())
                {
                    revalidatedControls.Add(control);
                }
                return(fullBuffer);
            }
            // replace buffers if control has grown
            if (layoutInfo.renderSize.width > buffer.Width || layoutInfo.renderSize.height > buffer.Height)
            {
                buffer               = new RenderingBuffer(layoutInfo.renderSize.width, layoutInfo.renderSize.height);
                fullBuffer           = new RenderingBuffer(layoutInfo.renderSize.width, layoutInfo.renderSize.height);
                buffers[control]     = buffer;
                fullBuffers[control] = fullBuffer;
            }
            // otherwise we should assemble full rendered buffer using childs
            buffer.Clear();
            if (control.RenderSize.Width != 0 && control.RenderSize.Height != 0)
            {
                control.Render(buffer);
            }
            //
            fullBuffer.CopyFrom(buffer);
            foreach (Control child in control.Children)
            {
                if (child.Visibility == Visibility.Visible)
                {
                    RenderingBuffer fullChildBuffer = processControl(child, revalidatedControls);
                    fullBuffer.ApplyChild(fullChildBuffer, child.ActualOffset,
                                          child.RenderSize, child.RenderSlotRect, child.LayoutClip);
                }
                else
                {
                    // чтобы следующий Invalidate для этого контрола
                    // перезаписал lastLayoutInfo
                    if (child.SetValidityToRender())
                    {
                        revalidatedControls.Add(child);
                    }
                }
            }

            // Save overlappingRect for each control child
            refreshChildrenLastOverlappedRects(control, false);

            if (control.SetValidityToRender())
            {
                revalidatedControls.Add(control);
            }
            return(fullBuffer);
        }
Exemplo n.º 51
0
        public override void ClearAttributes(object backend)
        {
            LayoutInfo li = (LayoutInfo)backend;

            li.ClearAttributes();
        }
Exemplo n.º 52
0
        public override int GetIndexFromCoordinates(object backend, double x, double y)
        {
            LayoutInfo li = (LayoutInfo)backend;

            return((int)li.GetIndexFromCoordinates(x, y));
        }
Exemplo n.º 53
0
 static void InvalidateFramesetter(LayoutInfo li)
 {
     if (li.Framesetter != null) {
         li.Framesetter.Dispose ();
         li.Framesetter = null;
     }
     if (!string.IsNullOrEmpty (li.Text))
         li.Framesetter = new CTFramesetter (CreateAttributedString (li));
 }
Exemplo n.º 54
0
        public static void ApplyLayout(NodeShape shapeElement, Diagram diagram, LayoutInfo layout)
        {
            // apply layout
            shapeElement.Size = layout.Size;

            // children
            foreach (NodeShape shape in shapeElement.Children)
            {
                ProcessNodeShape(shape, layout.ChildrenInfos);
            }

            RestoreLinkShapes(diagram, layout.LinkShapeInfos);

        }
Exemplo n.º 55
0
		static NSAttributedString CreateAttributedString (LayoutInfo li, string overrideText = null)
		{
			NSDictionary dict;
			if (li.Font != null) {
				dict = NSDictionary.FromObjectsAndKeys (
					new object[] { li.Font, new NSNumber (true) },
					new object[] { CTStringAttributeKey.Font, CTStringAttributeKey.ForegroundColorFromContext }
				);
			} else {
				dict = NSDictionary.FromObjectsAndKeys (
					new object[] { new NSNumber (true) },
					new object[] { CTStringAttributeKey.ForegroundColorFromContext }
				);
			}
			return new NSAttributedString (overrideText ?? li.Text, dict);
		}
 public abstract int GetSpan(LayoutInfo layoutInfo);
Exemplo n.º 57
0
        public override Point GetCoordinateFromIndex(object backend, int index)
        {
            LayoutInfo li = (LayoutInfo)backend;

            return(li.GetCoordinateFromIndex(index).ToXwtPoint());
        }
Exemplo n.º 58
0
        public static void Draw(object ctx, object layout, double x, double y)
        {
            LayoutInfo li = (LayoutInfo)layout;

            li.Text.DrawString(new System.Drawing.PointF((float)x, (float)y));
        }
Exemplo n.º 59
0
			public override void Layout(LayoutInfo transform)
			{
				LastLayoutInfo = transform;
				base.Layout(transform);
			}
Exemplo n.º 60
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        bool editingEnabled = true;

        LayoutInfo       li  = this.PagePlaceholder.LayoutInfo;
        PageTemplateInfo pti = this.PagePlaceholder.PageTemplateInfo;

        // Layout save button script
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "LayoutSave", ScriptHelper.GetScript(
                                                   "function SaveDocument() { layoutChanged = true; " + this.Page.ClientScript.GetPostBackEventReference(this.btnSaveLayout, "") + "; } \n"
                                                   ));

        string tmpLayoutCode = "";
        int    tmpCheckUser  = 0;
        string tmpMachine    = "";
        string tmpFilename   = "";
        string tmpLayoutUrl  = "";
        string layoutUrl     = "";

        LayoutTypeEnum layoutType = LayoutTypeEnum.Ascx;

        if (li != null)
        {
            tmpLayoutCode = li.LayoutCode;

            tmpCheckUser = li.LayoutCheckedOutByUserID;
            tmpMachine   = li.LayoutCheckedOutMachineName;
            tmpFilename  = li.LayoutCheckedOutFilename;
            tmpLayoutUrl = LayoutInfoProvider.GetLayoutUrl(li.LayoutCodeName, null, li.LayoutType);

            layoutUrl  = tmpLayoutUrl;
            layoutType = li.LayoutType;
        }

        // Get layout information
        if ((li == null) && (pti != null))
        {
            tmpLayoutCode = pti.PageTemplateLayout;

            tmpCheckUser = pti.PageTemplateLayoutCheckedOutByUserID;
            tmpMachine   = pti.PageTemplateLayoutCheckedOutMachineName;
            tmpFilename  = pti.PageTemplateLayoutCheckedOutFileName;

            layoutUrl  = PageTemplateInfoProvider.GetLayoutUrl(pti.CodeName, null, pti.PageTemplateLayoutType);
            layoutType = pti.PageTemplateLayoutType;

            if (pti.IsReusable)
            {
                tmpLayoutUrl = PageTemplateInfoProvider.GetLayoutUrl(pti.CodeName, null, pti.PageTemplateLayoutType);
            }
            else
            {
                tmpLayoutUrl = PageTemplateInfoProvider.GetAdhocLayoutUrl(pti.CodeName, null, pti.PageTemplateLayoutType);
            }
        }

        if (!RequestHelper.IsPostBack())
        {
            drpType.SelectedIndex = (layoutType == LayoutTypeEnum.Html ? 1 : 0);

            this.txtLayout.Text = tmpLayoutCode;
        }

        this.plcUndoCheckOut.Visible = false;
        this.plcCheckOut.Visible     = false;
        this.plcCheckIn.Visible      = false;

        // Check checked-out status
        if (tmpCheckUser > 0)
        {
            this.txtLayout.ReadOnly = true;

            string   username = null;
            UserInfo ui       = UserInfoProvider.GetUserInfo(tmpCheckUser);
            if (ui != null)
            {
                username = HTMLHelper.HTMLEncode(ui.FullName);
            }

            // Checked out by current machine
            if ((HttpContext.Current != null) && (tmpMachine.ToLower() == HTTPHelper.MachineName.ToLower()))
            {
                this.plcCheckIn.Visible = true;

                this.lblCheckOutInfo.Text = String.Format(ResHelper.GetString("PageLayout.CheckedOut", culture), HttpContext.Current.Server.MapPath(tmpFilename));
            }
            else
            {
                this.lblCheckOutInfo.Text = String.Format(ResHelper.GetString("PageLayout.CheckedOutOnAnotherMachine", culture), HTMLHelper.HTMLEncode(tmpMachine), HTMLHelper.HTMLEncode(username));
            }
            //this.lblCheckOutInfo.Text = String.Format(ResHelper.GetString("PageLayout.CheckedOutOnAnotherMachine"), li.LayoutCheckedOutMachineName, username);

            if (user.IsGlobalAdministrator)
            {
                this.plcUndoCheckOut.Visible = true;
            }
        }
        else
        {
            if (HttpContext.Current != null)
            {
                this.lblCheckOutInfo.Text = String.Format(ResHelper.GetString("PageLayout.CheckOutInfo", culture), HttpContext.Current.Server.MapPath(tmpLayoutUrl));
            }
            this.plcCheckOut.Visible = true;
            this.txtLayout.ReadOnly  = false;
        }

        bool isAscx = (this.drpType.SelectedValue.ToLower() == "ascx");

        this.btnSaveLayout.Visible = !isAscx || SettingsKeyProvider.UsingVirtualPathProvider;

        // Disable items when virtual path provider is disabled
        if (isAscx && !SettingsKeyProvider.UsingVirtualPathProvider && (pti != null))
        {
            this.lblVirtualInfo.Text     = String.Format(ResHelper.GetString("TemplateLayout.VirtualPathProviderNotRunning", culture), PageTemplateInfoProvider.GetLayoutUrl(pti.CodeName, null));
            this.plcVirtualInfo.Visible  = true;
            this.pnlCheckOutInfo.Visible = false;

            editingEnabled = false;
        }

        string info = null;

        // Setup the information and code type
        if (isAscx)
        {
            txtLayout.Editor.Language = LanguageEnum.ASPNET;
            txtLayout.UseAutoComplete = false;

            info = ResHelper.GetString("Administration-PageLayout_New.Hint", culture);

            // Check the edit code permission
            if (!user.IsAuthorizedPerResource("CMS.Design", "EditCode"))
            {
                editingEnabled = false;
                info           = ResHelper.GetString("EditCode.NotAllowed", culture);
            }
        }
        else
        {
            txtLayout.Editor.Language = LanguageEnum.HTMLMixed;
            txtLayout.UseAutoComplete = true;

            info = ResHelper.GetString("EditLayout.HintHtml", culture);
        }

        if (!String.IsNullOrEmpty(lblLayoutInfo.Text))
        {
            lblLayoutInfo.Text += "&nbsp;&nbsp;";
        }

        lblLayoutInfo.Text += info;

        this.lblLayoutInfo.Visible = (this.lblLayoutInfo.Text != "");

        this.txtLayout.ReadOnly = !editingEnabled;
        this.plcActions.Visible = editingEnabled;

        // Disable editor for layout or template checked out
        if (li != null)
        {
            if (li.LayoutCheckedOutByUserID > 0)
            {
                txtLayout.ReadOnly = true;
            }
        }
        else if (pti != null)
        {
            if (pti.PageTemplateLayoutCheckedOutByUserID > 0)
            {
                txtLayout.ReadOnly = true;
            }
        }
    }