protected override async Task SerializeToStreamAsync(Stream stream, TransportContext context)
        {
            // First write out content to local file asynchronously
            string fileName = Guid.NewGuid().ToString("D");
            string filePath = Path.Combine(_outputPath, fileName);

            using (FileStream fStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None, BufferSize, useAsync: true))
            {
                await InnerContent.CopyToAsync(fStream);
            }

            // Now write out content to actual output stream
            await InnerContent.CopyToAsync(stream);

            // Invoke content processor so that it can process the content asynchonously
            try
            {
                await _contentProcessor(filePath);
            }
            finally
            {
                // We are done with the local file and can delete it.
                File.Delete(filePath);
            }
        }
Esempio n. 2
0
        public override IHtmlContent Render(IHtmlHelper html)
        {
            FillMissingAttributes();

            var expandableItem = new TagBuilder("li");

            if (InnerContent?.Any() ?? false)
            {
                expandableItem.AddCssClass("expandable");
            }
            expandableItem.AddCssClass("slider-menu-item");
            expandableItem.Attributes["id"] = $"{Caption.ToLower().Replace(" ", "_")}-submodels";

            var link = html.ActionLink(Caption.ToUpper(), Action, Controller, new { brandID = RouteValues });


            var subGroup = new TagBuilder("div");

            subGroup.AddCssClass("sub-group");

            subGroup.InnerHtml.AppendHtml(RenderSubmenuHeader(html));

            foreach (var model in InnerContent)
            {
                subGroup.InnerHtml.AppendHtml(model.Render(html));
            }

            expandableItem.InnerHtml.AppendHtml(link);
            expandableItem.InnerHtml.AppendHtml(subGroup);
            return(expandableItem);
        }
Esempio n. 3
0
        private void button4_Click(object sender, EventArgs e)
        {
            //Create CubinoteBLE
            CubinoteBLE SDK = new CubinoteBLE();

            //Create a solid line
            TextItem t1 = new TextItem(41);
            //Create print content with the solid line
            InnerContent inerContent = new InnerContent(t1);

            //Create a regular text and insert it into print content
            String   text = "Test Cubinote SDK";
            TextItem t2   = new TextItem(text, 1);

            inerContent.textList.Add(t2);

            //Create a big font, bold and underline text and insert it into print content
            TextItem t3 = new TextItem(text, 1);

            t3.underline = 130;
            t3.bold      = 1;
            t3.fontSize  = 2;
            inerContent.textList.Add(t3);

            //Create a QR code and insert it into print content
            String   qr = "Test QR Code";
            TextItem t4 = new TextItem(qr, 3);

            inerContent.textList.Add(t4);

            //Create a material and insert it into print content
            TextItem t5 = new TextItem(10);

            inerContent.textList.Add(t5);

            //Create a Monochrome bitmap and insert it into print content
            byte[]   pImage       = ImageToByte(Properties.Resources.after);
            String   base64String = Convert.ToBase64String(pImage, 0, pImage.Length);
            TextItem p1           = new TextItem(base64String, 5);

            inerContent.textList.Add(p1);

            //Create a dash line and insert it into print content
            TextItem t6 = new TextItem(42);

            inerContent.textList.Add(t6);

            //Create a Cubinote Logo and insert it into print content
            TextItem t7 = new TextItem(57);

            inerContent.textList.Add(t7);

            //Print the content
            String res = SDK.CubinoteBLE_Print_Content(comboBox1.Text, inerContent);

            textBox1.Clear();
            textBox1.Text = res;
        }
 protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)
 {
     if (SerializeToStreamAsyncCallback != null)
     {
         return(SerializeToStreamAsyncCallback(stream, context));
     }
     else if (InnerContent != null)
     {
         return(InnerContent.CopyToAsync(stream, context));
     }
     else
     {
         throw new InvalidOperationException("Construct with inner HttpContent or set SerializeToStreamCallback first.");
     }
 }
Esempio n. 5
0
        public override IHtmlContent Render(IHtmlHelper html)
        {
            FillMissingAttributes();

            var expandableItem = new TagBuilder("li");

            expandableItem.AddCssClass("expandable");
            expandableItem.Attributes["id"] = $"{Caption.ToLower()}-models";

            var link = html.ActionLink(Caption.ToUpper(), Action, Controller, new { brandID = RouteValues });

            expandableItem.InnerHtml.AppendHtml(link);

            if (InnerContent is null)
            {
                return(expandableItem);
            }

            var subPanel = new TagBuilder("div");

            subPanel.AddCssClass("sub-panel");

            if (InnerContent.Count == 1)
            {
                InnerContent.First().FillMissingAttributes();
                foreach (var model in InnerContent.First().InnerContent)
                {
                    subPanel.InnerHtml.AppendHtml(model.Render(html));
                }
            }
            else
            {
                foreach (var group in InnerContent)
                {
                    subPanel.InnerHtml.AppendHtml(group.Render(html));
                }
            }

            expandableItem.InnerHtml.AppendHtml(subPanel);

            return(expandableItem);
        }
Esempio n. 6
0
        public IActionResult Index(EditorViewModel editor)
        {
            var content = _noteSaverDbContext.InnerContents.FirstOrDefault();

            if (content != null)
            {
                content.InnerText = editor.Content;
            }
            else
            {
                content = new InnerContent()
                {
                    InnerText = editor.Content,
                    TabId     = 1,
                    UserId    = 1,
                };
                _noteSaverDbContext.InnerContents.Add(content);
            }

            _noteSaverDbContext.SaveChanges();

            return(View(editor));
        }
Esempio n. 7
0
 public IAsyncOperationWithProgress <ulong, ulong> WriteToStreamAsync(IOutputStream outputStream)
 {
     return(InnerContent.WriteToStreamAsync(outputStream));
 }
Esempio n. 8
0
 public bool TryComputeLength(out ulong length)
 {
     return(InnerContent.TryComputeLength(out length));
 }
Esempio n. 9
0
 public IAsyncOperationWithProgress <string, ulong> ReadAsStringAsync()
 {
     return(InnerContent.ReadAsStringAsync());
 }
Esempio n. 10
0
 public IAsyncOperationWithProgress <IInputStream, ulong> ReadAsInputStreamAsync()
 {
     return(InnerContent.ReadAsInputStreamAsync());
 }
Esempio n. 11
0
 public IAsyncOperationWithProgress <IBuffer, ulong> ReadAsBufferAsync()
 {
     return(InnerContent.ReadAsBufferAsync());
 }
Esempio n. 12
0
 public IAsyncOperationWithProgress <ulong, ulong> BufferAllAsync()
 {
     return(InnerContent.BufferAllAsync());
 }
Esempio n. 13
0
 public void Dispose()
 {
     InnerContent.Dispose();
 }
Esempio n. 14
0
 public TableNode(string element, TableNode inner)
     : this(new TagBuilder(element))
 {
     InnerContent.Add(inner);
 }
Esempio n. 15
0
        public override IHtmlContent Render(IHtmlHelper html)
        {
            FillMissingAttributes();

            var expandableItem = new TagBuilder("li");

            if (InnerContent?.Any() ?? false)
            {
                expandableItem.AddCssClass("expandable");
            }
            expandableItem.AddCssClass("slider-menu-item");
            expandableItem.Attributes["id"] = $"{Caption.ToLower()}-models";

            var link = html.ActionLink(Caption.ToUpper(), Action, Controller, new { brandID = RouteValues });

            expandableItem.InnerHtml.AppendHtml(link);

            if (InnerContent is null)
            {
                return(expandableItem);
            }

            var subPanel = new TagBuilder("div");

            subPanel.AddCssClass("sub-menu");

            var submodelsMenu = new TagBuilder("ul");

            submodelsMenu.AddCssClass("slider-menu-nav");

            if (InnerContent.Count == 1)
            {
                InnerContent.First().FillMissingAttributes();
                foreach (var model in InnerContent.First().InnerContent)
                {
                    submodelsMenu.InnerHtml.AppendHtml(model.Render(html));
                }
            }
            else
            {
                var innerContent = new List <MobileBrandSubgroupContent>();
                for (var i = InnerContent.Count - 1; i >= 0; i--)
                {
                    if (string.IsNullOrEmpty(InnerContent[i].Caption.Trim()))
                    {
                        InnerContent[i - 1].InnerContent.AddRange(InnerContent[i].InnerContent);
                        continue;
                    }
                    innerContent.Add(InnerContent[i]);
                }

                innerContent.Reverse();
                foreach (var group in innerContent)
                {
                    submodelsMenu.InnerHtml.AppendHtml(group.Render(html));
                }
            }

            subPanel.InnerHtml.AppendHtml(RenderSubmenuHeader(html));
            subPanel.InnerHtml.AppendHtml(submodelsMenu);
            expandableItem.InnerHtml.AppendHtml(subPanel);

            return(expandableItem);
        }