// Created with MonoDevelop
//
//    QuickStep: Acquire, view and identify spectra 
//    Copyright (C) 2017 Thomas Klose & Torsten Schache, Hiperscan GmbH Dresden, Germany
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.


using System;
using Glade;
using Gtk;

using Hiperscan.GtkExtensions.Compiler;


namespace Hiperscan.GtkExtensions.Widgets
{
	
	public enum ShortOSVersion
	{
		Windows,
		Linux,
	}
	
	public class ExtToolTip
	{
		[Widget] Gtk.Window main_window = null;

		
		private ShortOSVersion OSPlatform {get;set;}
		
		public ExtToolTip()
		{
			switch(Environment.OSVersion.Platform)
			{
			case PlatformID.Win32NT:
			case PlatformID.Win32S:
			case PlatformID.Win32Windows:
			case PlatformID.WinCE:
			case PlatformID.Xbox:
				this.OSPlatform = ShortOSVersion.Windows;
				break;
				
			default:
				this.OSPlatform = ShortOSVersion.Linux;
				break;
			}
			
			this.Build();
			this.main_window.ShowAll();
		}
		
		private void Build()
		{
			Glade.XML gui = new Glade.XML(null, "GtkExtensions.ExtToolTip.ExtToolTip.glade", "main_window", "Hiperscan");
			gui.Autoconnect(this);
			this.main_window.DefaultWidth = 457;
			this.main_window.DefaultHeight = 237;
			this.main_window.ExposeEvent += this.OnExposeEvent;
		}
		
		private void OnExposeEvent(object sender, ExposeEventArgs e)
		{
			GenericGraphicCompiler translator = null;
			if (this.OSPlatform == ShortOSVersion.Windows)
				translator = new SystemDrawingGraphicCompiler(Gtk.DotNet.Graphics.FromDrawable(e.Event.Window, true));
			else
				 translator = new MonoCairoGraphicCompiler(Gdk.CairoHelper.Create(e.Event.Window));
			
			GraphicsShapeArc arc = new GraphicsShapeArc(new GraphicsPoint(100, 100), 100, 0, 90);
			arc.IsClosed = true;
			arc.Brush = new GraphicsSolidColorBrush();
			arc.Pen = new GraphicsPen(GraphicsColors.Red);
			arc.Pen.LineWidth = 3;
			
			GraphicsCompiler graphic_compiler = new GraphicsCompiler(arc, translator);
			graphic_compiler.TraverseVisualTree();	
			translator.Dispose();
			
		}
		
		private GraphicsGroup VisualTreeRoot {get;set;}
		


	}
}

