Example #1
0
        private string GetFirstTextValueByAtFlag(AtFlags atFlag)
        {
            string ret     = string.Empty;
            var    compGrp = _element.ComponentGroup;

            for (int i = 0; i < compGrp.Count; i++)
            {
                var comp = compGrp[i] as IComponentHtml;
                if (comp == null)
                {
                    continue;
                }

                var disp = comp.DisplayAt;
                if (disp == atFlag)
                {
                    ret = comp.Text?.Value
                          ?.StripHtmlTags()
                          ?.DecodeHtml()
                          ?.Trim();
                }
            }

            return(ret ?? string.Empty);
        }
Example #2
0
        protected void Update(short left,
                              short top,
                              short width,
                              short height,
                              AtFlags displayAt,
                              ComponentFieldFlags flags)
        {
#if DEBUG_REGISTRIES
            LogTo.Debug("[{0}] Updating component",
                        GetType().Name);
#endif

            Left = SetValue(Left,
                            left,
                            nameof(Left),
                            ref flags);
            Top = SetValue(Top,
                           top,
                           nameof(Top),
                           ref flags);
            Width = SetValue(Width,
                             width,
                             nameof(Width),
                             ref flags);
            Height = SetValue(Height,
                              height,
                              nameof(Height),
                              ref flags);
            DisplayAt = SetValue(DisplayAt,
                                 displayAt,
                                 nameof(DisplayAt),
                                 ref flags);
        }
		public static Int32 FromAtFlags (AtFlags value)
		{
			Int32 rval;
			if (FromAtFlags (value, out rval) == -1)
				ThrowArgumentException (value);
			return rval;
		}
Example #4
0
        protected void Update(short left,
                              short top,
                              short right,
                              short bottom,
                              AtFlags displayAt,
                              ComponentFieldFlags flags)
        {
#if DEBUG
            //System.Diagnostics.Debug.WriteLine("[{0}] Updating component", new[] { this.GetType().Name });
#endif

            Left = SetValue(Left,
                            left,
                            nameof(Left),
                            ref flags);
            Top = SetValue(Top,
                           top,
                           nameof(Top),
                           ref flags);
            Right = SetValue(Right,
                             right,
                             nameof(Right),
                             ref flags);
            Bottom = SetValue(Bottom,
                              bottom,
                              nameof(Bottom),
                              ref flags);
            DisplayAt = SetValue(DisplayAt,
                                 displayAt,
                                 nameof(DisplayAt),
                                 ref flags);
        }
Example #5
0
        private ImageContent NewImageContent(string src, TemplateType type)
        {
            AtFlags displayAt = type == TemplateType.Question
        ? AtFlags.All
        : AtFlags.NonQuestion;

            if (!File.Exists(src))
            {
                return(null);
            }

            byte[] imageArray = File.ReadAllBytes(src);
            if (imageArray.IsNull() || !imageArray.Any())
            {
                return(null);
            }

            using (MemoryStream ms = new MemoryStream(imageArray))
            {
                Image image = Image.FromStream(ms);

                // Add to registry
                int regId = Svc.SM.Registry.Image.Add(new ImageWrapper(image), src);
                if (regId == -1)
                {
                    return(null);
                }

                return(new ImageContent(regId, displayAt: displayAt));
            }
        }
Example #6
0
 protected ContentBase(AtFlags displayAt,
                       VerticalAlignment verticalAlignment     = VerticalAlignment.Stretch,
                       HorizontalAlignment horizontalAlignment = HorizontalAlignment.Stretch,
                       Size size = default)
 {
     DisplayAt           = displayAt;
     VerticalAlignment   = verticalAlignment;
     HorizontalAlignment = horizontalAlignment;
     Size = size;
 }
        public static Int32 FromAtFlags(AtFlags value)
        {
            Int32 rval;

            if (FromAtFlags(value, out rval) == -1)
            {
                ThrowArgumentException(value);
            }
            return(rval);
        }
Example #8
0
        public XamlControlImage(int id,
                                IImage img,
                                AtFlags displayAt)
        {
            Id        = id;
            Image     = img;
            DisplayAt = displayAt;

            InitializeComponent();
        }
Example #9
0
 public ImageContent(int                 registryId,
                     ImageStretchMode    stretchType = ImageStretchMode.Proportional,
                     AtFlags             displayAt   = AtFlags.All,
                     VerticalAlignment   vAlignment  = VerticalAlignment.Stretch,
                     HorizontalAlignment hAlignment  = HorizontalAlignment.Stretch,
                     Size                size        = default)
   : base(displayAt,
          vAlignment,
          hAlignment,
          size)
 {
   RegistryId  = registryId;
   StretchType = stretchType;
 }
Example #10
0
 public TextContent(bool html,
                    string text,
                    AtFlags displayAt              = AtFlags.All,
                    VerticalAlignment vAlignment   = VerticalAlignment.Stretch,
                    HorizontalAlignment hAlignment = HorizontalAlignment.Stretch,
                    Size size = default)
     : this(html,
            text,
            Encoding.Unicode,
            displayAt,
            vAlignment,
            hAlignment,
            size)
 {
 }
Example #11
0
        public XamlControlHtml(int id,
                               string html,
                               AtFlags displayAt)
        {
            Id        = id;
            DisplayAt = displayAt;
            Html      = html;

            if (DesignerProperties.GetIsInDesignMode(this) == false && id != int.MinValue)
            {
                TextFilePath = WriteToFile(html);
            }

            InitializeComponent();
        }
Example #12
0
 public TextContent(bool html,
                    string text,
                    Encoding encoding,
                    AtFlags displayAt              = AtFlags.All,
                    VerticalAlignment vAlignment   = VerticalAlignment.Stretch,
                    HorizontalAlignment hAlignment = HorizontalAlignment.Stretch,
                    Size size = default)
     : base(displayAt,
            vAlignment,
            hAlignment,
            size)
 {
     Html     = html;
     Text     = text;
     Encoding = encoding;
 }
Example #13
0
        public XamlControlSound(int id,
                                ISound sound,
                                string text,
                                MediaPanelType panelType,
                                AtFlags playAt,
                                AtFlags displayAt)
        {
            Id        = id;
            Sound     = sound;
            Text      = text;
            Panel     = panelType;
            PlayAt    = playAt;
            DisplayAt = displayAt;

            DataContext = this;

            InitializeComponent();
        }
Example #14
0
 public SoundContent(int registryId,
                     string text = "",
                     MediaPanelType panelType       = MediaPanelType.Slider,
                     AtFlags playAt                 = AtFlags.ShowStates,
                     AtFlags displayAt              = AtFlags.All,
                     VerticalAlignment vAlignment   = VerticalAlignment.Stretch,
                     HorizontalAlignment hAlignment = HorizontalAlignment.Stretch,
                     Size size = default)
     : base(displayAt,
            vAlignment,
            hAlignment,
            size)
 {
     RegistryId = registryId;
     Text       = text;
     PanelType  = panelType;
     PlayAt     = playAt;
 }
Example #15
0
        protected ComponentBase(short left,
                                short top,
                                short right,
                                short bottom,
                                AtFlags displayAt)
        {
#if DEBUG
            //System.Diagnostics.Debug.WriteLine("[{0}] Creating component", new[] { this.GetType().Name });
#endif

            Left = SetValue(left,
                            nameof(Left));
            Top = SetValue(top,
                           nameof(Top));
            Right = SetValue(right,
                             nameof(Right));
            Bottom = SetValue(bottom,
                              nameof(Bottom));
            DisplayAt = SetValue(displayAt,
                                 nameof(DisplayAt));
        }
Example #16
0
        protected ComponentBase(short left,
                                short top,
                                short width,
                                short height,
                                AtFlags displayAt)
        {
#if DEBUG_REGISTRIES
            LogTo.Debug("[{0}] Creating component",
                        GetType().Name);
#endif

            Left = SetValue(left,
                            nameof(Left));
            Top = SetValue(top,
                           nameof(Top));
            Width = SetValue(width,
                             nameof(Width));
            Height = SetValue(height,
                              nameof(Height));
            DisplayAt = SetValue(displayAt,
                                 nameof(DisplayAt));
        }
		public static bool TryToAtFlags (Int32 value, out AtFlags rval)
		{
			return ToAtFlags (value, out rval) == 0;
		}
		private static extern int ToAtFlags (Int32 value, out AtFlags rval);
		public static bool TryFromAtFlags (AtFlags value, out Int32 rval)
		{
			return FromAtFlags (value, out rval) == 0;
		}
		private static extern int FromAtFlags (AtFlags value, out Int32 rval);
 private static extern int FromAtFlags(AtFlags value, out Int32 rval);
 public static bool TryFromAtFlags(AtFlags value, out Int32 rval)
 {
     return(FromAtFlags(value, out rval) == 0);
 }
 private static extern int ToAtFlags(Int32 value, out AtFlags rval);
 public static bool TryToAtFlags(Int32 value, out AtFlags rval)
 {
     return(ToAtFlags(value, out rval) == 0);
 }