Skip to content

Instantly share code, notes, and snippets.

View bjoerntx's full-sized avatar
👨‍💻
Building web apps

Bjoern Meyer bjoerntx

👨‍💻
Building web apps
View GitHub Profile
@bjoerntx
bjoerntx / index.aspx
Last active August 29, 2015 14:23
Reporting: Styling the DocumentViewer for ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs"
Inherits="tx_documentviewer_style.index" %>
<%@ Register assembly="TXDocumentServer, Version=22.0.800.500,
Culture=neutral, PublicKeyToken=6b83fe9a75cfb638"
namespace="TXTextControl.DocumentServer.Web" tagprefix="cc1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
@bjoerntx
bjoerntx / gist:4907fa77ffd698d902e4
Last active August 29, 2015 14:23
SQL to create table
CREATE TABLE [dbo].[Categories] (
[CategoryId] [int] NOT NULL IDENTITY,
[Name] [nvarchar](max),
CONSTRAINT [PK_dbo.Categories] PRIMARY KEY ([CategoryId])
)
CREATE TABLE [dbo].[Products] (
[ProductId] [int] NOT NULL IDENTITY,
[Name] [nvarchar](max),
[CategoryId] [int] NOT NULL,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@bjoerntx
bjoerntx / gist:6ae5a1c9da161c936e94
Last active August 29, 2015 14:25
DataSelector
// DataSelector
// description: This class loops through all merge blocks in a given template to check
// for sort keywords. The given referenced DataSet will be sorted.
//
// Parameters: dataSet of type DataSet, template as a byte[] array in the InternalUnicodeFormat
public class DataSelector
{
public byte[] Template { get; set; }
public DataSelector(DataSet dataSet, byte[] template)
private string sDataSource = "data.xml";
private string sTemplateFile = "template.tx";
private void mergeToolStripMenuItem_Click(object sender, EventArgs e)
{
// convert the XML file to a .NET DataSet
DataSet ds = new DataSet();
ds.ReadXml(sDataSource, XmlReadMode.Auto);
// create a new DataSelector instance
private void InsertWatermarkImages()
{
// remove all existing watermarks
RemoveWatermarkImages(textControl1);
foreach (TXTextControl.Page page in textControl1.GetPages())
{
// create a new watermark image
Bitmap bmp = CreateDraftImage();
private void RemoveWatermarkImages(TXTextControl.TextControl textControl)
{
// List of images to be deleted
List<TXTextControl.Image> lImagesToRemove =
new List<TXTextControl.Image>();
// loop through all images and check for the Name
foreach (TXTextControl.Image img in textControl1.Images)
{
// add watermark images to the List
private int iNumberOfPages = 1;
// update the watermarks if the number of pages are different
private void textControl1_Changed(object sender, EventArgs e)
{
if (textControl1.Pages > iNumberOfPages)
{
InsertWatermarkImages();
iNumberOfPages = textControl1.Pages;
}
// creates a new "DRAFT" sample image
private Bitmap CreateDraftImage()
{
string sText = "DRAFT";
Bitmap destination = new Bitmap(400, 400);
using (Graphics g = Graphics.FromImage(destination))
{
GraphicsUnit units = GraphicsUnit.Pixel;
/*----------------------------------------------------------
** MultipagePrintDocument class
**--------------------------------------------------------*/
class MultipagePrintDocument : PrintDocument
{
/*------------------------------------------------------
** Constructor
** description: Initializes the private data fields
**----------------------------------------------------*/
public MultipagePrintDocument(TXTextControl.TextControl textControl,