How to Move Images with Arrow Keys in a Windows WPF App

In Image Processing applications it is sometimes necessary to move a selected image (or part of image) to place at a specific position. For example, it is applicable to Form Processing, where predefined templates of different forms exist. When you select an image and place a predefined template on top of the image, it may happen that the position of the image needs to be adjusted to align it with the template. In such cases, you can use keyboard arrow keys to move the image horizontally and/or vertically.

We are exploring the same in a Windows app built with .NET, C#, and WPF. We have found several ways of moving the image when the image control is placed within a Canvas. Canvas is used as a container in WPF, where you can place several controls, but this case is a bit different. Here the image control is not placed within a Canvas – a different container has been used to place the image.

To achieve the image movement functionality, the PreviewKeyDown event can be used for Image control. This event occurs when a key is pressed, while the focus is on the image control. So, the first part is over, i.e., connect the arrow keys with the image control. The next question is how to move the image? For this set the image control’s margin whenever a specific keyboard key is pressed. Here is some code to alter the margin for the image control.

private void OnPreviewKeyDown(object sender, KeyEventArgs e)




case Key.Left:

leftMargin -= 5;

e.Handled = true;


case Key.Right:

leftMargin += 5;

e.Handled = true;


case Key.Up:

topMargin -= 5;

e.Handled = true;


case Key.Down:

topMargin += 5;

e.Handled = true;



MessageBox.Show(“Invalid key pressed”);



this.image1.Margin = new Thickness(leftMargin,






In the above code, say the image control currently has the focus and you want to move the image to the left. For that just press the left arrow key. Then the PreviewKeyDown event is called and it comes to the Key.Left case, which decreases the left margin by 5. In effect, you will see the image move to the left. The movements toward right, top, and bottom also work the same way.

Please remember the following points:

  1. The image control must have focus.
  2. Set the KeyPressEventArgs.Handled property to TRUE – it will cancel the KeyPress event; otherwise, the image control will loose focus and the PreviewKeyDown event will not called on arrow key press.

Enjoy playing with images in a WPF application on Windows.

Why Backup Data and How to Backup on Windows – A Simple Solution


The most precious thing on your computer is the data. No, not the latest and greatest computer you have purchased recently. The most valuable asset on your computer is all the data stored on it, especially what you have created, collected, processed, organized for your work, learning, or even entertainment. Now here are some cold hard truth about data and the associated risks.

1. More than 95% computer users have experienced data loss in some point of their life.

2. Data loss cost US businesses $11.8 billion in 1998. 6% of all PCs will suffer an episode of data loss in any given year.

3. An article from Boston Computing, provides the following statistics:

      • 30% of all businesses that have a major fire go out of business within a year. 70% fail within five years.
      • 93% of companies that lost their data center for 10 days or more due to a disaster filed for bankruptcy within one year of the disaster.
      • 31% of PC users have lost all of their files due to events beyond their control.
      • Every week 140,000 hard drives crash in the United States.
      • A 2013 poll found that 30% of computer users had NEVER backed up their data.
      • According to a 2013 report, 55% of disaster-related downtime stems from hardware failure, 22% from human error, and 18% from software failure.
      • More than half (53%) of the SMB organizations surveyed revealed they do not conduct daily backups.
      • According to a survey of SMB organizations, 32% responded saying backup is not an efficient use of their time.
      • Simple drive recovery can cost between US$5,000-10,000 and still success is not guaranteed.

4. Refer to a USA Today 2006 News article.

5. Refer to an Information Week 2011 News article.

6. For many businesses, data is their lifeline. Data loss can make them to go out of business.

7. Accidental delete, virus attack, hacking, disk failure are some of the common reasons for data loss.

8. Fire, earthquake, storm, flood are some of the natural calamities which result into data loss.

As it shows above, data loss has been known and documented to be a major problem for long time — for about 20 years (definitely a lot more than that). The volume of problems has increased with growing ubiquity of computers among households and businesses. The widespread use of mobile devices has made the risk potential even higher. Add to that the recent rise in malware attacks and cyber-crimes, e.g., WannaCry, Petya, Bad Rabbit etc. It seems there is no end in sight for security breaches, information leaks, and data loss / damage. All this is scary. So, how to address such risks to your precious data? The best option is to practice “Safe Computing” (outlined below), and also take regular backups, which is a simple defense against data loss due any reason.

Here are a few basic points related to backup:
a) In case of a data loss, recovery of an earlier version (that is close to the latest) is the main reason for backup.
b) “Sync” vs. “Backup”: Sync is convenient and popular, but Backup is more robust, dependable, and legally compliant.
c) Network Attached Storage (NAS), especially with RAID, is a common and good backup medium.
d) Regular backup is a legal requirement for businesses in some countries.
e) Backup, preferably automated / scheduled, should be part of every business’s Disaster Recovery plan.

Backup is in general of two types — full and incremental.

  • Full backup saves all the files and folders selected for the backup. It generates a bigger archive and takes longer, but has the full data snapshot.
  • Incremental backup saves only the files that have changed or are new since the last backup (full or incremental). It’s smaller in size and less time to complete, but it depends on the last full backup and any incremental backups in between.

It is a good practice to take a full backup after a significant number of incremental backups. E.g., if incremental backup is taken every day, a full backup can be taken once every month.

Earlier restoration involved restoring the full backup, followed by differential backup, and then all the incremental backups – a tedious and time-consuming process indeed! Now all that can be achieved in a single step, such as “Structure Restore”.

Here are some trends / observations for the data management and backup area:

  • With the prevalence of offsite / cloud-based email services, on-site email servers are reducing and email backup is becoming less important.
  • Permission issues and PC unavailability are the biggest reasons for backup failure.
  • Automatic data backup is much better than manual backups as the latter takes extra time and can be forgotten or skipped under pressure.
  • A well-defined data retention policy is as important as the backup policy and arrangement.
  • In general a business should have a different backup and data retention policy for each of its departments.

For the sake of your business, it’s a must to follow the Safe Computing Principles

  1. Use legal and up-to-date Operating System and other software
  2. Use a reputed and current anti-virus / anti-malware software
  3. Install the latest released stable updates for all your software, especially the Operating System
  4. Use automatic / scheduled regular backups of all important data
  5. Be paranoid… OK, just be super careful — do not trust random email attachments, links in emails, unknown websites / tiny URLs etc.

Please refer to Ransomware (in Wikipedia), in particular the “Mitigation” section.

Our two other posts related to this may also be informative and helpful:

    1. How to Handle Ransomware Threat: Be Cautious and Backup Data
    2. How to Create a Folder Accessible to only a Specific User (Data Backup User)


SARANGSoft offers two software products for data backup on Windows:

    1. filexpertez for backup of individual Windows PCs and servers
    2. WinBackup Business for backup of all Windows PCs and servers in a Windows network (domain or workgroup)

SARANGSoft filexpertez is one of the first applications to
a) provide “Structure (one-click) Restore”, reducing the restore effort by up to 99%.
b) allow versioning of the backed up files.
c) enable backup to cloud as well as various local storage.
With the use of “Structure Restore”, the need for differential backup is almost eliminated.

SARANGSoft WinBackup Business performs decentralized backup with centralized control — providing best of both worlds.
a) The backup effort gets distributed across all the computers and is not imposed on a single computer. This results in more flexibility as well as faster backups.
b) The network remains clog-free as the files are not examined or transferred over the network.
c) Enables configuring multiple backups – use different backup specification for different computers or even for the same computer.
d) (Unlike many other backup products) Doesn’t force the users to put their files (to backup) in a single folder. Multiple folders on a user’s computer can be specified to backup.
e) No need to have a single folder-set apply to all computers. Specify a different folder-set to backup for every computer.
f) It’s a rare backup software that provides both Individual (flexible) and Common (easy to use) Selection of folders to backup — see more on that below.
g) Specify a different backup destination for each backup specification. It helps categorize the destination depending on backup contents or the department.
h) Get access to a number of important reports. Click on individual column headers within the reports to sort the data, toggle between ascending and descending order the same way.
i) To backup data locally (not accessible even to the administrator), set the backup destination to local storage media such as External USB Hard Disk / CD / DVD.

Individual Selection vs. Common Selection

Individual Selection
Specify a different folder-set for every computer to backup; not necessarily the same folder-set to backup for every computer.
Common Selection
(If Individual Selection is tedious) Specify a common folder-set for all the computers to backup.

NOTE: If there are permission issues in the network and you are unable to perform Individual Selection, you can still go for Common Selection of the folders to backup.
Individual Selection offers you flexibility, whereas Common Selection offers you ease of use. It’s you who decides what you want.

It is important to remember a few points about Backup Scheduling:

  • Use the same User Id to launch the “Admin Console” and configure backups as what was specified while installing WinBackup Business Server.
  • Scheduling may fail due to permission issues or unavailability of the remote agent computer. Use the ‘Failed Schedules’ report to retry scheduling at a more suitable time.
  • To re-schedule an existing backup, load it in ‘Manage Backup’, go to the schedule options page, modify the schedule, and click ‘Start’ on the Progress page.

CloudScape‘, bundled with WinBackup Business, helps upload backup archives to public cloud storage ‘Amazon AWS-S3’ and ‘Microsoft Azure’ for added resiliency and protection.
NOTE: The AWS and Azure accounts must be your own. SARANGSoft does NOT provide such accounts along with its backup products.

If you feel lost at any point, or do not find what you need, or for any other problem, use the context sensitive help on any topic by just pressing the ‘F1’ key on the keyboard or the ‘Help’ button on the toolbar.

Network Backup
There are two technology options for corporate level backup – push and pull.
a) Push mode backup: Backup agent runs on individual PCs to collect the files, packages, optionally compresses and encrypts, before sending to backup destination. It is more

  • Secure: data can be encrypted before sending over the network
  • Bandwidth Efficient: Data can be compressed before sending over the network
  • Faster: Backup effort is distributed across the workstations, thus achieving better overall throughput
  • Better Load Balanced: Backup effort is not put on a single machine and is distributed across multiple machines

b) Pull mode backup: Backup software pulls the data from individual PCs and then backs them up. All work is done by a single “Backup PC”.

WinBackup Business: Advanced Backup Options

  • Backup open files too (except on Windows XP, Windows Server 2003/2003-R2); no need to close files before backup.
  • Use Backup-on-the-Go for users who remain disconnected from office network for major part of the day (e.g., sales, field support team members etc).
  • Most backup applications fail to backup if the target computer is not in network at the scheduled backup time, but WinBackup Business backs up at the scheduled time to a local disk and automatically transfers the backup archives to backup destination when the computer is back in the network.
  • Configure for the powerful AES encryption for every backup, so that only the intended user can open the backup files.
  • Get email notification when the backup process completes on a computer.

WinBackup Business: Advanced Restore Options

  • Restore operation on a large archive can take quite some time. WinBackup Business can notify through email when restore is complete.
  • Restoration is decentralized, thereby enabling respective users to restore according to own requirements without bothering the administrator.
  • Restoration is made easy using Structure Restore. Restore the latest version of all the files in one go.
  • To restore an older version of a file, use the Restore Point functionality.
  • To restore all files created or modified on/before a certain date, use the Advanced Filtering option.

Backup is essential for computing. Some of the backup tools are hard to use, or inflexible, or expensive, or all of those. Now you have options that work well and do not cost much.

Why use Optical Character Recognition in Various Scenarios

What is OCR?
Good quality Optical Character Recognition (OCR) is an unquestionably effective tool for extracting textual content in machine readable and editable format from a digitized image. The following steps are involved in the process – from scanning a paper document to getting the textual content out of the scanned image.

1. Use a compatible good quality document scanner to scan a paper document into suitable electronic format, such as JPEG, TIFF, PNG, PDF etc.

2. Preprocess the scanned document for skew correction, noise removal, and some mathematical transformations.

3. Perform Line Segmentation from the processed document, i.e., segregate each line from the scanned document.

4. Perform Word Segmentation, i.e., segregate the words of each line from the previous step.

5. Perform Character Separation, i.e., separate the characters of the segregated words from the previous step.

6. Perform Character Recognition, i.e., recognize each of the above segregated characters by looking into the pattern. Once the pattern are recognized the corresponding textual character is obtained. The pattern recognition may involve different types of methods, such as statistical analysis, neural networks, structural matching etc.

7. From character to word, from word to line, and from line to the entire document becomes recognized and its textual version is obtained.

In short, this is the main process and objective of Optical Character Recognition (OCR).

There are different OCR products – some commercial and some open source, such as the widely used / known “Tesseract“, which is distributed as part of various types of product offerings from different companies. SARANGSoft offers a version of Tesseract as a free download from its website. It enhances the functionality of digipaper ( by adding the OCR functionality.

Different Types of OCR
OCR is available for different languages, including English. Several successful researches have already been done and are still going on. Sometimes a document may contain multiple languages (such as forms). In that case OCR become more complex. An OCR engine for one language, such as English, is not sufficient in that case. The output textual content also would show textual form of different languages / scripts. Hence, this is known as Muitisctipt OCR as opposed to Single Script OCR in the simpler case of only one language / script.

It is also important to keep in mind that the textual content may be in printed form, or in handwritten form, or both. Very few OCR tools are effective in recognizing handwritten text, and most OCR tools focus on and handle only printed documents.

Teeseract supports recognition of texts in multiple languages. However, our experience is more focused on the English language. From what we have noticed, Tesseract doesn’t handle mixture of languages too well.

No OCR tool can guarantee a 100% accurate output because of different reasons:

  1. A document might contains clean text or it can be a a bit fuzzy / unclear / noisy, especially if it’s an old document where the contents are fade. Unclear / noisy documents should be run through some preprocessing like color and brightness adjustment, noise removal, filtering etc. to improve its clarity. Cleaner the document, more accurate the OCR result.
  1. Documents in grid format (i.e., in rows and columns) may also cause problems in accurately recognizing the textual contents. At times some of the (printed) texts go across the gred cell boundaries, thereby being more prone to error during recognition.
  1. Scanning of the paper document is an important factor in the recognition process. If the document is shrunk or skewed by a significant level, the preprocessing may not always back the document in its actual form. This also often lead to inaccurate OCR results.
  1. Recognizing handwriting is always hard, especially it’s cursive, in which case special processing (including Neural Networks techniques) may be needed to recognize the characters from the flowing nature of the writing. Bad handwriting is hard to recognize (both by humans and machines).

In the business world, OCR can be used for long-term digital storage of important papers, such as invoices, financial statements, reports, legal documents, applications, permits etc., especially if the volume of such papers grows too much. In some organizations, there are dedicated staff members to manually enter the details from those paper documents into digital formats (e.g., spreadsheets) to collect the data and make it available for processing. Another reason for digitizing paper documents is safekeeping and organizing for the long-term storage. If the digitized documents are properly “tagged”, an added benefit is the ease and speed of retrieving those when needed. However, manual entry of data and/or manual tagging is both error-prone, time consuming, and often inconsistent between individuals. Also, any error in manually entering data can cause major problems for the organization. OCR can be a great help in reducing the use of manual steps in the overall digitization process. The textual content from the scanned document images can be extracted using OCR. Then those can be put into appropriate places, such as in database fields, rows and columns of spreadsheets, or as “tags” for the concerned documents. Please note the word “reduce” above – a lot organizations think that by using OCR they can completely get rid of the manual intervention, which is a bit too much to expect. As no OCR is 100% accurate, output of OCR needs to be manually verified as appropriate for the case. That means instead of “entering” every data item manually, there is need “check” the correctness of OCR-generated data. It’s not safe to blindly trust the OCR output in a lot of cases.

In Banking sector, OCR may be used to recognize check number, account number, bank name, routing number etc. In Educational sector, OCR may be able to help with form processing. In any domain OCR can be used as a part of the digitization process to extract textual content after the scanning and use the textual content as (secondary) tags to later identify the documents.

In short, though OCR reduces manual data entry, thereby saving time and reducing / avoiding errors to a good extent, at the same time keep in mind that OCR output should be carefully checked before using it any ciritical purposes.

2016: IT Security Challenges

A recently published report by Gartner & Raytheon (Dec-2015) makes some security predictions for the year 2016. The picture is not comforting at all. The already scary level of attacks by cyber criminals will rise even more because of the cyber terrorists (including the “Syrian Electronic Army” or SEA in short), who will be working in sync with ISIS and other such groups.

1.  The US Elections Cycle Will Drive Significant Themed Attacks: The level of use of social and online media for US Presidential election process will exceed all earlier instances. The candidates have started opening websites with their own profile and are regularly updating those with campaign schedules, time tables, issue-based debates etc. They are also using facebook, Twitter, Instagram etc. as campaign tools. A 2014 survey showed nearly 74% of US adults use social networking. According to a recent survey by Pew Research Center, nearly 92% of the Americans are on social media. Of them 96% adults read news on Presidential election there. They have less interest and trust in traditional media like TV, newspaper etc. The candidates also are paying more attention to their Ads in social media sites.
This will make things easier for the hackers and spammers. Pretending to campaign on behalf of some candidate(s), they will present attractive / interesting topics or use offers as bait to trap / cheat users visiting social media as well as push malware, spam etc. in their email / computer.

2.  The attack on Google, Bing etc. will reach an extremely high level. There will be attacks through facebook, Twitter “friend” / “connection”. Serious attacks like Highly Transient Web Threat (HTWT) will also happen.

3.  Addition of the GTLD system will provide new opportunities for attackers: The top ten botnets like “Cutwell”, “Rustock”, “Mega-D” etc. will become even more powerful and active. They have been spreading spam to about 100 million computers around the world, which is 88% of all the 100s of billions of spam sent daily. In 2016, it might grow by 15 times or more!
Since multinational corporations and marketing agencies are becoming increasingly dependent on online services and web-based systems, there is big growth in “cloud computing”. Now the cyber criminals / terrorists are making “cloud computing” systems as their major target.

4.  The cyber criminals will attack the “traditional customer authentication” methods used for online banking and financial transactions to steal funds from bank accounts. There will be tremendous rise in the “Man in the Browser” (MITB) Trojan attack incidents.

5.  The cyber terrorists will also attach in guise of lucrative offers in emails (possibly as attachments) with attractive topics, pictures, invites as well fake web links, so that you step into their trap to reveal important personal information.

6.  The criminals will also use “BlackHatSEO” to get the fake sites and/or links in front of you in search engine results by suppressing the genuine websites. For this they will use various SEO techniques, including paid SEO.

7.  Fake Advertisements in the name of reputed media houses will be used to inject virus into those organizations’ websites. The hackers and spammers will use the still-in-use outdated technologies, such as unsupported and unpatched old software.

8.  The tiny URLs used in facebook and Twitter are quite popular among users. Since those are easy to utilize, the criminals will target the tiny URLs to bring people to malware-ridden 100s of thousands of fake websites.
According to an estimate from a few years back by a security software firm, nearly 300,000 fake websites are launched EVERYDAY just to lure unsuspecting users and infect their computers with malware and virus.

9.  The cyber criminals are going to use “SQL Injection” attack against the famous multinational banks, commercial and marketing companies around the world, including USA. Along with that they will use Phishing (stealing data through browser / email), Vishing (stealing data via phone calls), Smishing (via SMS to mobile phones) attacks.

10. There will be major increase in the cyber terrorists’ use of “foreign language spam” as well as “identity theft” attacks to steal our “digital signatures” for online (commercial / legal / financial) activities.

The only protection is to be super-careful (being paranoid is OK), even for individuals, because our own personal finances can be ruined by such attacks. A whole lot of people have already been burnt by “ransomware” (a kind of malware). Phishing and Vishing are still going on, and people continue to fall for those. On the other hand, a lot of computer users are oblivious about upgrading their software — Operating Systems, Applications, Browsers etc., even if free upgrades are widely available. There are a lot of people who derive extra pleasure in using pirated software, without understanding how dangerous it is for THEMSELVES. The big software companies can afford to lose a couple of billions in lost revenue due to piracy, but a compromised computer can terribly affect an individual’s life or a small business. It really doesn’t cost much when it’s spread over the lifetime of a computer and software. However, some people still find it necessary to avoid paying the dues and lead a risky life. Also, some computer users indiscriminately download and install “free” software from the Internet. Is “free” a business model for anyone? Yes, there are some legitimate “free” (mostly open source) software organizations, but they are well known. Why use software from a random company that pops up in a Google search? Does anyone buy any other thing like that? In real life do you use an item handed out by a complete stranger? Hopefully not.

It’s important to practice “Safe Computing”:
a)  Use ONLY legitimate software
b)  Use RELIABLE anti-virus from a REPUTED company
c)  Regularly update / patch software
d)  Monitor network to detect intrusion / infection
e)  Take automatic backup of all important data

The challenges are grave. The threats are real. The repercussions can be devastating. It’s worth being extra careful.

Welcome to SARANGSoft New Blog

Welcome to our new blog. It took us a long time to transition from our earlier setup (website and blog) to this new version. Hopefully the blog will be better and more active from now on.

The goal of our blog is to share our thoughts, actions, findings (and more) with a wide audience. While working on various projects – building our own software products as well as developing custom software solutions for our customers, we come across different questions and challenges, which we sometimes solve by ourselves and at times depend on the wisdom shared by others like us in the industry. We know firsthand how much information-sharing helps, and we greatly appreciate that. In this day and age of collaboration and networking, we would like to put forward some of the hard lessons we learn as part of our work, so that others do not have to reinvent the same wheel or go through similar frustrations. We all win through sharing, because it goes both ways.

Our posts will be mostly technical in nature, but there will also be some business-related topics, because we are in “technology business”! We develop and use technology for business – to make those more capable and efficient. That’s where the value of technology is – enabling new possibilities, improving existing processes, and even identifying fresh opportunities.

We welcome all meaningful and relevant discussions, including constructive criticism, of our posts. The different viewpoints from all concerned will enrich all of us in various ways.