コード例 #1
0
 public string HtmlLTRB()
 {
     if (Dock == SMControlSelection.None)
     {
         return(SMRectangleArea.HtmlLTRB(RelativeArea));
     }
     return(HtmlDock());
 }
コード例 #2
0
ファイル: SMControlGroup.cs プロジェクト: gopa810/Rambha
        public bool ContainsControl(SMControl control)
        {
            SMRectangleArea cga = Area;
            SMRectangleArea ca  = control.Area;

            bool pr = cga.RelativeArea.Contains(ca.RelativeArea);

            return(pr ? ControlIsCompatible(control) : false);
        }
コード例 #3
0
 public static void Copy(SMRectangleArea source, SMRectangleArea target)
 {
     target.RelativeArea          = source.RelativeArea;
     target.Selected              = source.Selected;
     target.Dock                  = source.Dock;
     target.BackType              = source.BackType;
     target.BackgroundImage       = source.BackgroundImage;
     target.BackgroundImageOffset = source.BackgroundImageOffset;
     target.Screen                = source.Screen;
     target.DockModified          = source.DockModified;
 }
コード例 #4
0
 public SMRectangleArea(SMRectangleArea source)
 {
     if (source == null)
     {
         RelativeArea = Rectangle.Empty;
         Selected     = false;
         Dock         = SMControlSelection.None;
         DockModified = false;
     }
     else
     {
         Copy(source, this);
     }
 }
コード例 #5
0
        public static SMRectangleArea FromBytes(byte[] buffer)
        {
            SMRectangleArea area = null;

            using (MemoryStream ms = new MemoryStream(buffer))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    RSFileReader fr = new RSFileReader(br);
                    area = new SMRectangleArea();
                    area.Load(fr);
                }
            }
            return(area);
        }
コード例 #6
0
        public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
        {
            PrepareContent();
            bool   horz        = bHorizontal;
            string blockFormat = Font.HtmlString() + Paragraph.Html() + ContentPaddingHtml();
            string dimensions  = string.Format("height:{0}%;width:{1}%", horz ? 100 : 100 / texts.Count, horz ? 100 / texts.Count : 100);

            sbHtml.Append("<div ");
            sbHtml.AppendFormat(" id=\"c{0}\" ", this.Id);
            sbHtml.AppendFormat(" style ='display:flex;flex-direction:{1};position:absolute;z-index:{0};", zorder,
                                horz ? "row" : "column");
            SMRectangleArea area = this.Area;

            sbHtml.Append(area.HtmlLTRB());
            sbHtml.Append("'>\n");
            int i = 0;

            string[] radiustextH = { "15px 0px 0px 15px", "0px", "0px 15px 15px 0px" };
            string[] radiustextV = { "15px 15px 0px 0px", "0px", "0px 0px 15px 15px" };
            foreach (SelText si in texts)
            {
                int ridx = (i == 0 ? 0 : i == (texts.Count - 1) ? 2 : 1);
                sbHtml.AppendFormat("<div id=\"sel{0}_{2}\" class=\"csSelectN\" style='cursor:pointer;border-radius:{1};{3};' onclick=\"toogleSelectCtrl({0},{2})\">\n",
                                    Id, bHorizontal ? radiustextH[ridx] : radiustextV[ridx], i, dimensions);

                sbHtml.AppendFormat("<div class=\"vertCenter\" style='text-align:center'><div>\n");
                sbHtml.AppendFormat("{0}", si.text);
                sbHtml.AppendFormat("</div></div>");

                sbHtml.AppendFormat("</div>\n");
                i++;
            }
            //sbHtml.Append("background:lightyellow;border:1px solid black;'>");
            //sbHtml.Append("<b>" + GetType().Name + "</b><br>" + this.Text);
            sbHtml.Append("</div>\n");

            ctx.AppendToControlList("type", "select", "segments", texts.Count.ToString(), "correct", p_expectedSelection.ToString(),
                                    "id", Id.ToString(), "current", "0");
        }
コード例 #7
0
        public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
        {
            bool   horz        = (Orientation == SMTextDirection.Horizontal);
            string blockFormat = Font.HtmlString() + Paragraph.Html() + ContentPaddingHtml();

            sbCss.AppendFormat(".c{0}n {{ {1} {2} height:{3}%;width:{4}%; }}\n", Id, HtmlFormatColor(false), blockFormat,
                               horz ? 100 : 100 / Objects.Count, horz ? 100 / Objects.Count : 100);
//            sbCss.AppendFormat(".c{0}h {{ {1} {2} }}\n", Id, HtmlFormatColor(true), blockFormat);

            sbHtml.Append("<div ");
            sbHtml.AppendFormat(" id=\"c{0}\" ", this.Id);
            sbHtml.AppendFormat(" style ='display:flex;flex-direction:{1};position:absolute;z-index:{0};", zorder,
                                horz ? "row" : "column");
            SMRectangleArea area = this.Area;

            sbHtml.Append(area.HtmlLTRB());
            sbHtml.Append("'>\n");
            foreach (StringItem si in Objects)
            {
                sbHtml.AppendFormat("<div class=\"c{0}n\">\n", Id);
                if (si.IsText)
                {
                    sbHtml.AppendFormat("<div class=\"vertCenter\"><div>\n");
                    sbHtml.AppendFormat("{0}", si.Text);
                    sbHtml.AppendFormat("</div></div>");
                }
                else if (si.IsImage)
                {
                    sbHtml.AppendFormat("<img src=\"{0}\" style='object-fit:contain;width:100%;height:100%;'>",
                                        ctx.GetFileNameFromImage(si.Image.Image));
                }
                sbHtml.AppendFormat("</div>\n");
            }
            //sbHtml.Append("background:lightyellow;border:1px solid black;'>");
            //sbHtml.Append("<b>" + GetType().Name + "</b><br>" + this.Text);
            sbHtml.Append("</div>\n");
        }
コード例 #8
0
ファイル: SMDrawable.cs プロジェクト: gopa810/Rambha
        public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
        {
            sbHtml.Append("<div ");
            sbHtml.AppendFormat(" id=\"c{0}\" ", this.Id);
            sbHtml.AppendFormat(" style ='position:absolute;z-index:{0};", zorder);
            SMRectangleArea area = this.Area;

            sbHtml.Append(area.HtmlLTRB());
            sbHtml.Append("'>");

            DrawingContext dc = new DrawingContext();

            string[] lines = Drawings.Split('\r', '\n', ';');
            foreach (string line in lines)
            {
                string[] lp = line.Split(' ');
                if (lp.Length == 0)
                {
                    return;
                }
                if (lp[0] != "line")
                {
                    continue;
                }
                if (lp[1] == lp[3])
                {
                    sbHtml.AppendFormat("<div style='position:relative;top:{0}%;height:{1}%;left:{2}%;width:2;background:black;'></div>", lp[2], lp[4], lp[1]);
                }
                else if (lp[2] == lp[4])
                {
                    sbHtml.AppendFormat("<div style='position:relative;left:{0}%;width:{1}%;top:{2}%;height:2;background:black;'></div>", lp[1], lp[3], lp[2]);
                }
            }

            sbHtml.Append("</div>\n");
        }
コード例 #9
0
 public void Set(SMRectangleArea area)
 {
     Copy(area, this);
 }
コード例 #10
0
ファイル: SMConnection.cs プロジェクト: gopa810/Rambha
        public void Paint(MNPageContext context)
        {
            if (Source == null || Target == null)
            {
                return;
            }

            SMRectangleArea sa = Source.Area;
            SMRectangleArea ta = Target.Area;

            Rectangle rs = sa.GetBounds(context);
            Rectangle rt = ta.GetBounds(context);

            Point sc = Point.Empty;
            Point tc = Point.Empty;

            if (Source.DragLineAlign == SMDragLineAlign.Undef)
            {
                if (Source.NormalState.BorderStyle == SMBorderStyle.Elipse)
                {
                    sc = IntersectionPointLineElipse(rs, CenterPoint(rt));
                }
                else
                {
                    sc = IntersectionPointLineRect(rs, CenterPoint(rt));
                }
            }
            else if (Source.DragLineAlign == SMDragLineAlign.LeftRight)
            {
                if (rs.Left > rt.Right)
                {
                    sc = new Point(rs.Left, rs.Top + rs.Height / 2);
                }
                else
                {
                    sc = new Point(rs.Right, rs.Top + rs.Height / 2);
                }
            }
            else if (Source.DragLineAlign == SMDragLineAlign.TopBottom)
            {
                if (rs.Top > rt.Bottom)
                {
                    sc = new Point(rs.Left + rs.Width / 2, rs.Top);
                }
                else
                {
                    sc = new Point(rs.Left + rs.Width / 2, rs.Bottom);
                }
            }

            if (Target.DragLineAlign == SMDragLineAlign.LeftRight)
            {
                if (rs.Left < rt.Right)
                {
                    tc = new Point(rt.Left, rt.Top + rt.Height / 2);
                }
                else
                {
                    tc = new Point(rt.Right, rt.Top + rt.Height / 2);
                }
            }
            else if (Target.DragLineAlign == SMDragLineAlign.TopBottom)
            {
                if (rs.Top < rt.Bottom)
                {
                    tc = new Point(rt.Left + rt.Width / 2, rt.Top);
                }
                else
                {
                    tc = new Point(rt.Left + rt.Width / 2, rt.Bottom);
                }
            }
            else
            {
                if (Target.NormalState.BorderStyle == SMBorderStyle.Elipse)
                {
                    tc = IntersectionPointLineElipse(rt, CenterPoint(rs));
                }
                else
                {
                    tc = IntersectionPointLineRect(rt, CenterPoint(rs));
                }
            }


            switch (ConnectionStyle)
            {
            default:
                context.g.DrawLine(Pens.Black, sc, tc);
                break;
            }
        }
コード例 #11
0
ファイル: SMLabel.cs プロジェクト: gopa810/Rambha
        public override void Paint(MNPageContext context)
        {
            SMRectangleArea area   = this.Area;
            Rectangle       bounds = area.GetBounds(context);

            SMConnection conn = context.CurrentPage.FindConnection(this);

            if (conn != null)
            {
                UIStateHover = true;
            }


            bool b = UIStateHover;

            UIStateHover |= SwitchStatus;
            SMStatusLayout layout = PrepareBrushesAndPens();

            UIStateHover = b;

            Rectangle boundsA = bounds;

            boundsA.Y       = Math.Max(0, bounds.Top);
            boundsA.X       = Math.Max(0, bounds.Left);
            boundsA.Width   = Math.Min(context.PageWidth, bounds.Right);
            boundsA.Height  = Math.Min(context.PageHeight, bounds.Bottom);
            boundsA.Width  -= boundsA.X;
            boundsA.Height -= boundsA.Y;

            Rectangle textBounds = ContentPadding.ApplyPadding(boundsA);

            if (Text != null && Text.Contains("\\n"))
            {
                Text = Text.Replace("\\n", "\n");
            }
            string plainText = Text;
            MNReferencedAudioText runningText = null;

            if (Content != null)
            {
                plainText = null;
                if (Content is MNReferencedText)
                {
                    plainText = ((MNReferencedText)Content).Text;
                }
                else if (Content is MNReferencedAudioText)
                {
                    runningText = Content as MNReferencedAudioText;
                }
                else if (Content is MNReferencedSound)
                {
                    plainText = Text;
                }
            }

            if (plainText.StartsWith("$"))
            {
                plainText = Document.ResolveProperty(plainText.Substring(1));
            }

            Font usedFont = GetUsedFont();

            if (plainText != null)
            {
                Size      textSize = richText.MeasureString(context, plainText, textBounds.Width);
                Rectangle r        = Area.GetDockedRectangle(context.PageSize, textSize);
                if (Area.Dock != SMControlSelection.None)
                {
                    textBounds.X     = Area.RelativeArea.X + SMRectangleArea.PADDING_DOCK_LEFT;
                    textBounds.Y     = Area.RelativeArea.Y + SMRectangleArea.PADDING_DOCK_TOP;
                    textBounds.Width = Area.RelativeArea.Width - SMRectangleArea.PADDING_DOCK_LEFT
                                       - SMRectangleArea.PADDING_DOCK_RIGHT + 2;
                    textBounds.Height            = Area.RelativeArea.Height - SMRectangleArea.PADDING_DOCK_TOP - SMRectangleArea.PADDING_DOCK_BOTTOM + 2;
                    richText.Paragraph.VertAlign = SMVerticalAlign.Top;
                }

                if (Area.BackType == SMBackgroundType.None)
                {
                    DrawStyledBackground(context, layout, bounds);
                }
                else if (Area.BackType == SMBackgroundType.Solid)
                {
                    context.g.FillRectangle(SMGraphics.GetBrush(Page.BackgroundColor), r);
                }
                else if (Area.BackType == SMBackgroundType.Shadow && Area.BackgroundImage != null)
                {
                    context.g.DrawImage(Area.BackgroundImage,
                                        textBounds.X + Area.BackgroundImageOffset.X,
                                        textBounds.Y + Area.BackgroundImageOffset.Y);
                }

                if (Area.Dock == SMControlSelection.None)
                {
                    DrawStyledBorder(context, layout, bounds);
                }

                richText.DrawString(context, layout, textBounds);
            }
            else if (runningText != null)
            {
                DrawStyledBackground(context, layout, bounds);
                DrawStyledBorder(context, layout, bounds);

                Point curr  = new Point(textBounds.Left, textBounds.Top);
                int   index = 0;
                foreach (GOFRunningTextItem w in runningText.Words)
                {
                    Brush currBrush = (runningText.currentWord >= index ? Brushes.Red : tempForeBrush);
                    SizeF textSize  = context.g.MeasureString(w.Text, usedFont);
                    if (curr.X + textSize.Width > textBounds.Right)
                    {
                        curr.X  = textBounds.Left;
                        curr.Y += (int)textSize.Height;
                    }
                    context.g.DrawString(w.Text, usedFont, currBrush, curr);
                    curr.X += (int)textSize.Width;

                    index++;
                }
            }

            if (UIStateError == MNEvaluationResult.Incorrect && UIStateChecked)
            {
                if (Document.HasViewer)
                {
                    Document.Viewer.ScheduleCall(MNNotificationCenter.RectifyDelay, this, "clearCheck");
                }
            }

            // draw selection marks
            base.Paint(context);
        }