This is a preview version of Cyotek's blog and may be missing functionality and/or unstable. Please visit https://www.cyotek.com/blog for the current version of the blog.
If you encounter any problems using this preview site, please contact us with the details.

Converting colours between RGB and CMYK in C#

c# color rgb cmyk 2 Comments Downloads

In my previous articles on reading and writing colours from various palette/swatch formats, I left CMYK conversion as an exercise for the reader and only demonstrated RGB aspects. This article demonstrates how to convert colours in CMYK format to RGB and vice versa.

Unlike RGB which generally uses the range 0-255, most examples of CMYK I've seen use percentages instead, e.g. 37% cyan, 18% magenta, no yellow and 31% black. In this article I'm using the range 0-1 to describe the colours. (Just to be awkward, the demonstration front end uses 0-100 to make it more user friendly!)

Read More

Displaying text in an empty ListBox

c# winforms WM_PAINT listbox wm_erasebkgnd 3 Comments Downloads

While looking at ways of improving the UI of a dialog in an application, I wanted to display some status text in a ListBox control that was empty. The default Windows Forms ListBox (which uses the underlying native Win32 control) doesn't support this, but with a little effort we can extend the control.

When a Control receives either the WM_PAINT or WM_ERASEBKGND messages, it will check to see if the ControlStyles.UserPaint style is set. If set then the WM_PAINT message will cause the Paint event to be raised, and for WM_ERASEBKGND the PaintBackground event - but only if the the AllPaintingInWmPaint style is not set.

Read More

Using the MantisBT REST API when hosted on IIS

mantisbt iis https redirect 0 Comments

I'm currently in the process of moving our hosting services from one provider to another; although some parts of cyotek.com infrastructure runs on Microsoft Azure, a fair chunk uses more traditional hosting. Our MantisBT instance is one such service that I recently migrated.

Previously the instance was hosted on Linux, now it's on Windows. The initial migration seemed to have gone well and so I'd moved onto the next sub-domain on the list.

Read More

Updating AssemblyInfo.cs version information via batch file

c# jenkins teamcity assemblyinfo sed 0 Comments

Over a year ago I wrote how to build and publish NuGet packages via Jenkins in which I stated I would follow up with another article on modifying AssemblyInfo.cs via a batch file. Of course, I forgot to write that post. Recently I was adding a NuGet publish job to a TeamCity server which reminded me and therefore finally here is the article.

While both Jenkins and TeamCity include or have available plugins for updating AssemblyInfo.cs, they both suffer from the problem in that they can write a version into the file but they can't read from it first to derive a new value. However, if you simply want to set a full version from within either CI tool you can without having to bother with anything in this post. As I wish to combine part of the existing version with a CI supplied value, I need to look at alternatives.

Read More

Tools we use - 2017 edition

tools 0 Comments

Happy New Year! Once again it's that time for the list of software products I used throughout the past year. Although there's a fair few new entries, overall there's not a huge amount of change given Cyotek's current technology focus.

(This list has grown over time and could probably do with some form of better grouping and ordering. For now, categories are fairly ad-hoc and nothing is in any particular order)

Read More

Reading and writing 18-bit RGB VGA Palette (pal) files with C#

c# rgb color palette 18-bit 24-bit westwood dos 6-bit 8-bit 1 Comments Downloads

18-bit RGB palettes are an old format used by VGA displays of yesteryear (although interestingly Wikipedia states they are still used by many LCD monitors). These palettes use 6-bits for each of the red, green and blue channels and usually allowed a maximum of 256 colours from the 262,144 unique colours available.

Files using this format are usually quite recognisable, having the extension pal and a size of 768 bytes.

Read More

Redirecting to HTTPS when using IIS behind a load balancer

asp.net iis https redirect 0 Comments

Cyotek has a number of different websites powering various bits of our software and services. Some are Windows based using IIS, and some are Linux based using Apache. Internal servers are are directly accessed but external servers are behind load balancers. Almost all are using HTTPS now and have redirects in place to force the use of HTTPS over HTTP.

There are plenty of articles on the internet dealing how to use .htaccess files to perform redirects using Apache, and various articles on different methods of redirecting IIS or ASP.NET applications. However, there seems to be a slight gap when it comes to load balancers or reverse proxies. Depending on how the load balancer / reverse proxy (referred to as just load balancer for the rest of the article) operates, the secure connection may terminate at the load balancer, and so the web server ...

Read More

Installing the URL Rewrite module into Internet Information Services

iis rewrite web platform installer 0 Comments

For quite some time now Internet Information Services (IIS) has had an URL Rewriter component that you can optionally install. As one of my upcoming shorter posts mentions the use of it, I thought I'd better provide installation instructions separately rather than cluttering up that post.

Some versions of Internet Information Services Manager (IIS Manager) have a Start Page, as demonstrated in the below screenshot. All instructions on this post assume that on opening IIS Manager the user has selected the root server node in the tree if it wasn't already selected.

Read More

Upload data to blob storage with Azure Functions

c# azure blob 2 Comments

Some time ago I used a third party product which accepted data from client applications via a HTTP WCF service and saved this data as files on the local disk. A Windows service would then periodically poll for new files and load the data into a SQL Server database. This worked, as long as both the HTTP server and the loader service were on the same computer/network. As this wasn't suitable for my needs, the software vendor provided me with the source code for the WCF service and I modified this to store the...

Read More

Arranging items radially around a central point using C#

c# math diagram trigonometry 0 Comments Downloads

Recently I was looking for a way of display hierarchical information in a more compact form than the previous horizontal/vertical trees I was using. One of the concepts I looked into during this was the idea of arranging children radially around a central node.

This post discusses the sample project I created to explore the first part of this concept.

Read More