Changeset - 41381c24d35a
[Not reviewed]
default
0 13 1
Jason Maltzen - 7 years ago 2018-05-15 15:35:12
jason@hiddenachievement.com
Now supports all the interface sizes with a setting to select the current interface size. The initial screen size check now displays the detected resolution as a hint. The screen size check / interface size settings can now be updated after launch through File->Preferences. Capturing a reaction now includes a progress bar, and runs in a separate thread instead of silently blocking. The reaction status window under 'Help' now has options to disable ingredients to remove them from the list. NOTE: this also disables/enables those ingredients in the recipe generator as well. The list also updates as new reactions are recorded instead of requiring that it be closed and re-opened to update.
14 files changed with 1107 insertions and 480 deletions:
0 comments (0 inline, 0 general)
DesertPaintLab.csproj
Show inline comments
 
<?xml version="1.0" encoding="utf-8"?>
 
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
 
  <PropertyGroup>
 
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
 
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
 
    <ProjectGuid>{1A885212-5FD2-4EBF-A98F-3EB1491A1CBB}</ProjectGuid>
 
    <OutputType>WinExe</OutputType>
 
    <RootNamespace>DesertPaintLab</RootNamespace>
 
    <AssemblyName>DesertPaintLab</AssemblyName>
 
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
 
    <IsWebBootstrapper>false</IsWebBootstrapper>
 
    <PublishUrl>publish\</PublishUrl>
 
    <Install>true</Install>
 
    <InstallFrom>Disk</InstallFrom>
 
    <UpdateEnabled>false</UpdateEnabled>
 
    <UpdateMode>Foreground</UpdateMode>
 
    <UpdateInterval>7</UpdateInterval>
 
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
 
    <UpdatePeriodically>false</UpdatePeriodically>
 
    <UpdateRequired>false</UpdateRequired>
 
    <MapFileExtensions>true</MapFileExtensions>
 
    <AutorunEnabled>true</AutorunEnabled>
 
    <ApplicationRevision>0</ApplicationRevision>
 
    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
 
    <IsWebBootstrapper>false</IsWebBootstrapper>
 
    <UseApplicationTrust>false</UseApplicationTrust>
 
    <BootstrapperEnabled>true</BootstrapperEnabled>
 
  </PropertyGroup>
 
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
 
    <DebugSymbols>true</DebugSymbols>
 
    <DebugType>full</DebugType>
 
    <Optimize>false</Optimize>
 
    <OutputPath>bin\Debug</OutputPath>
 
    <DefineConstants>DEBUG</DefineConstants>
 
    <ErrorReport>prompt</ErrorReport>
 
    <WarningLevel>4</WarningLevel>
 
    <PlatformTarget>x86</PlatformTarget>
 
    <ConsolePause>false</ConsolePause>
 
    <additionalargs>/unsafe</additionalargs>
 
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
 
  </PropertyGroup>
...
 
@@ -69,32 +70,33 @@
 
  <ItemGroup>
 
    <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
 
    <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
 
    <Reference Include="System" />
 
    <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
 
    <Reference Include="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
 
    <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
 
    <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
 
    <Reference Include="System.IO.Compression.FileSystem" />
 
  </ItemGroup>
 
  <ItemGroup>
 
    <EmbeddedResource Include="gtk-gui\gui.stetic">
 
      <LogicalName>gui.stetic</LogicalName>
 
    </EmbeddedResource>
 
  </ItemGroup>
 
  <ItemGroup>
 
    <Compile Include="InterfaceSize.cs" />
 
    <Compile Include="gtk-gui\generated.cs" />
 
    <Compile Include="MainWindow.cs" />
 
    <Compile Include="Main.cs" />
 
    <Compile Include="AssemblyInfo.cs" />
 
    <Compile Include="PlayerProfile.cs" />
 
    <Compile Include="FirstRunDialog.cs" />
 
    <Compile Include="SelectProfileDialog.cs" />
 
    <Compile Include="NewProfileDialog.cs" />
 
    <Compile Include="PaintSwatch.cs" />
 
    <Compile Include="Palette.cs" />
 
    <Compile Include="PaintColor.cs" />
 
    <Compile Include="Reaction.cs" />
 
    <Compile Include="ReagentManager.cs" />
 
    <Compile Include="Reagent.cs" />
 
    <Compile Include="gtk-gui\MainWindow.cs" />
 
    <Compile Include="gtk-gui\DesertPaintLab.FirstRunDialog.cs" />
InterfaceSize.cs
Show inline comments
 
new file 100644
 
/*
 
 * Copyright (c) 2015, Jason Maltzen
 

	
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 
 of this software and associated documentation files (the "Software"), to deal
 
 in the Software without restriction, including without limitation the rights
 
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
 copies of the Software, and to permit persons to whom the Software is
 
 furnished to do so, subject to the following conditions:
 

	
 
 The above copyright notice and this permission notice shall be included in
 
 all copies or substantial portions of the Software.
 

	
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
 THE SOFTWARE.
 
*/
 

	
 
namespace DesertPaintLab
 
{
 
    public enum InterfaceSize
 
    {
 
        Tiny = 0,
 
        Small = 1,
 
        Medium = 2,
 
        Large = 3,
 
        Huge = 4
 
    }
 
}
...
 
\ No newline at end of file
MainWindow.cs
Show inline comments
...
 
@@ -18,528 +18,519 @@
 
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
 THE SOFTWARE.
 
*/
 

	
 
using System;
 
using System.IO;
 
using System.Collections.Generic;
 
using System.Text.RegularExpressions;
 
using Gtk;
 
using DesertPaintLab;
 

	
 
public partial class MainWindow : Gtk.Window
 
{
 
    const string APP_VERSION = "1.7.15";
 

	
 
	bool unsavedData = false;
 
	bool shouldShutDown = false;
 
	List<string> profileList = new List<string>();
 
	PlayerProfile profile = null;
 
	
 
	Gdk.Window rootWindow = null;
 
	Gdk.Pixbuf screenBuffer = null;
 
    bool unsavedData = false;
 
    bool shouldShutDown = false;
 
    List<string> profileList = new List<string>();
 
    PlayerProfile profile = null;
 

	
 
    Gdk.Window rootWindow = null;
 
    Gdk.Pixbuf screenBuffer = null;
 

	
 
    // views
 
    RecipeGeneratorView generatorView;
 
    SimulatorView simulatorView;
 
    CaptureView captureView;
 

	
 
	public bool ShouldShutDown
 
	{
 
		get
 
		{
 
			return shouldShutDown;
 
		}
 
	}
 
	
 
	public MainWindow () : base(Gtk.WindowType.Toplevel)
 
	{
 
    private ReactionStatusWindow _reactionStatusWindow;
 

	
 
    public bool ShouldShutDown
 
    {
 
        get
 
        {
 
            return shouldShutDown;
 
        }
 
    }
 

	
 
    public MainWindow() : base(Gtk.WindowType.Toplevel)
 
    {
 
        string appDataPath = FileUtils.AppDataPath;
 
		if (!System.IO.Directory.Exists(appDataPath))
 
		{
 
			System.IO.Directory.CreateDirectory(appDataPath);	
 
		}
 
		
 
		DirectoryInfo di = new DirectoryInfo(appDataPath);
 
		DirectoryInfo[] dirs = di.GetDirectories();
 
		foreach (DirectoryInfo dir in dirs)
 
		{
 
			if (dir.Name != "template")
 
			{
 
				profileList.Add(dir.Name);
 
			}
 
		}
 
        if (!System.IO.Directory.Exists(appDataPath))
 
        {
 
            System.IO.Directory.CreateDirectory(appDataPath);
 
        }
 

	
 
        DirectoryInfo di = new DirectoryInfo(appDataPath);
 
        DirectoryInfo[] dirs = di.GetDirectories();
 
        foreach (DirectoryInfo dir in dirs)
 
        {
 
            if (dir.Name != "template")
 
            {
 
                profileList.Add(dir.Name);
 
            }
 
        }
 

	
 
        string colorsPath = FileUtils.FindApplicationResourceFile("colors.txt");
 
        if (colorsPath == null)
 
        {
 
            // failed to find colors.txt file
 
            MessageDialog md = new MessageDialog(this, 
 
            MessageDialog md = new MessageDialog(this,
 
                DialogFlags.DestroyWithParent,
 
                MessageType.Error, ButtonsType.Close, 
 
                MessageType.Error, ButtonsType.Close,
 
                "Failed to find colors.txt file. Please check your installation.");
 
       
 

 
            md.Run();
 
            md.Destroy();
 
            Application.Quit();
 
        }
 
		Palette.Load(colorsPath);
 
        Palette.Load(colorsPath);
 

	
 
        string ingredientsPath = FileUtils.FindApplicationResourceFile("ingredients.txt");
 
        if (ingredientsPath == null)
 
        {
 
            // failed to find ingredients.txt file
 
            MessageDialog md = new MessageDialog(this, 
 
            MessageDialog md = new MessageDialog(this,
 
                DialogFlags.DestroyWithParent,
 
                MessageType.Error, ButtonsType.Close, 
 
                MessageType.Error, ButtonsType.Close,
 
                "Failed to find ingredients.txt file. Please check your installation.");
 
       
 

 
            md.Run();
 
            md.Destroy();
 
            Application.Quit();
 
        }
 
        ReagentManager.Load(ingredientsPath);
 
		
 
		Build();
 
		
 
		// get the root window
 
		rootWindow = Gdk.Global.DefaultRootWindow;
 

	
 
        Build();
 

	
 
		// get its width and height
 
        int detectedScreenWidth;
 
        int detectedScreenHeight;
 
		rootWindow.GetSize(out detectedScreenWidth, out detectedScreenHeight);
 
        int screenWidth = detectedScreenWidth;
 
        int screenHeight = detectedScreenHeight;
 
        int pixelMultiplier = 1;
 
        // get the root window
 
        rootWindow = Gdk.Global.DefaultRootWindow;
 

	
 
        if ( DesertPaintLab.AppSettings.Load() == true )
 
        {
 
            DesertPaintLab.AppSettings.Get("ScreenWidth", out screenWidth);
 
            DesertPaintLab.AppSettings.Get("ScreenHeight", out screenHeight);
 
            DesertPaintLab.AppSettings.Get("PixelMultiplier", out pixelMultiplier);
 
        }
 
        // get its width and height
 
        DesertPaintLab.AppSettings.Load();
 

	
 
        ShowPreferencesDialog();
 

	
 
        bool enableDebugMenu;
 
        DesertPaintLab.AppSettings.Get("EnableDebugMenu", out enableDebugMenu);
 
        this.DebugAction.Visible = enableDebugMenu;
 

	
 
		ScreenCheckDialog screenCheckDialog = new ScreenCheckDialog();
 
        // TODO: screenCheckDialog.DetectedWidth = detectedScreenWidth;
 
        // TODO: screenCheckDialog.DetectedHeight = detectedScreenHeight;
 
		screenCheckDialog.ScreenWidth = screenWidth;
 
		screenCheckDialog.ScreenHeight = screenHeight;
 
        screenCheckDialog.GamePixelWidth = pixelMultiplier;
 
		ResponseType resp = (ResponseType)screenCheckDialog.Run();
 
        screenWidth = screenCheckDialog.ScreenWidth;
 
        screenHeight = screenCheckDialog.ScreenHeight;
 
        pixelMultiplier = screenCheckDialog.GamePixelWidth;
 
		screenCheckDialog.Destroy();
 
        ReactionRecorder.Instance.OnReactionRecorded += OnReactionRecorded;
 

	
 
        if (!OpenProfile())
 
        {
 
            shouldShutDown = true;
 
        }
 

	
 
        DesertPaintLab.AppSettings.Set("ScreenWidth", screenWidth);
 
        DesertPaintLab.AppSettings.Set("ScreenHeight", screenHeight);
 
        DesertPaintLab.AppSettings.Set("PixelMultiplier", pixelMultiplier);
 
        DesertPaintLab.AppSettings.Save();
 

	
 
		screenBuffer = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, screenWidth, screenHeight);
 
	
 
        ReactionRecorder.Instance.SetPixelMultiplier(pixelMultiplier);
 

	
 
		if (!OpenProfile())
 
		{
 
			shouldShutDown = true;
 
		}
 
        if (!shouldShutDown)
 
        {
 
            captureView = new CaptureView(profile, screenBuffer);
 
            generatorView = new RecipeGeneratorView(profile);
 
            generatorView.SetStatus += OnStatusUpdate;
 
            generatorView.Started += OnGeneratorRunning;
 
            generatorView.Stopped += OnGeneratorStopped;
 
            simulatorView = new SimulatorView(profile);
 

	
 
        captureView = new CaptureView(profile, screenBuffer);
 
        generatorView = new RecipeGeneratorView(profile);
 
        generatorView.SetStatus += OnStatusUpdate;
 
        generatorView.Started += OnGeneratorRunning;
 
        generatorView.Stopped += OnGeneratorStopped;
 
        simulatorView = new SimulatorView(profile);
 

	
 
        contentContainer.Add(captureView);
 
        captureView.Show();
 
	}
 
            contentContainer.Add(captureView);
 
            captureView.Show();
 
        }
 
    }
 

	
 
	bool ConfirmedExit()
 
	{
 
		if (unsavedData)
 
		{
 
			MessageDialog md = new MessageDialog(this, 
 
	            DialogFlags.DestroyWithParent,
 
	            MessageType.Warning, ButtonsType.OkCancel, 
 
	            "Your last reaction was unsaved." +
 
	            "Are you sure you want to quit?");
 
	   
 
			ResponseType resp = (ResponseType)md.Run();
 
			md.Destroy();
 
			return (resp == ResponseType.Ok);
 
		}
 
		return true;
 
	}
 
    bool ConfirmedExit()
 
    {
 
        if (unsavedData)
 
        {
 
            MessageDialog md = new MessageDialog(this,
 
                DialogFlags.DestroyWithParent,
 
                MessageType.Warning, ButtonsType.OkCancel,
 
                "Your last reaction was unsaved." +
 
                "Are you sure you want to quit?");
 

	
 
            ResponseType resp = (ResponseType)md.Run();
 
            md.Destroy();
 
            return (resp == ResponseType.Ok);
 
        }
 
        return true;
 
    }
 

	
 
    protected void OnStatusUpdate(object sender, EventArgs args)
 
    {
 
        StatusUpdateEventArgs statusArgs = (StatusUpdateEventArgs)args;
 
        statusBar.Push(0, statusArgs.Status);
 
    }
 

	
 
    protected void OnGeneratorRunning(object sender, EventArgs args)
 
    {
 
        NewProfileAction.Sensitive = false;
 
        OpenProfileAction.Sensitive = false;
 
        ImportProfileAction.Sensitive = false;
 
        if (captureView != null)
 
        {
 
            captureView.DisableRecord();
 
        }
 
    }
 

	
 
    protected void OnGeneratorStopped(object sender, EventArgs args)
 
    {
 
        NewProfileAction.Sensitive = true;
 
        OpenProfileAction.Sensitive = true;
 
        ImportProfileAction.Sensitive = true;
 
        if (captureView != null)
 
        {
 
            captureView.EnableRecord();
 
        }
 
    }
 
	
 
	void SetProfileName(string name)
 
	{	
 
		profile = new PlayerProfile(name,
 

	
 
    void SetProfileName(string name)
 
    {
 
        profile = new PlayerProfile(name,
 
            System.IO.Path.Combine(FileUtils.AppDataPath, name));
 
	}
 
    }
 

	
 
    void ProfileChanged()
 
    {
 
        statusBar.Push(0, "Profile: " + profile.Name);
 
        Title  = "Desert Paint Lab - " + profile.Name;
 
        Title = "Desert Paint Lab - " + profile.Name;
 

	
 
        if (generatorView != null)
 
        {
 
            generatorView.Profile = profile;
 
        }
 
        if (simulatorView != null)
 
        {
 
            simulatorView.Profile = profile;
 
        }
 
        if (captureView != null)
 
        {
 
            captureView.Profile = profile;
 
        }
 
    }
 
	
 
	bool NewProfile()
 
	{
 
		bool newProfileCreated = false;
 
		bool duplicateName = false;
 
		NewProfileDialog newProfileDialog = new NewProfileDialog();
 
		ResponseType resp = (ResponseType)newProfileDialog.Run();
 
		if (resp == ResponseType.Ok)
 
		{
 
			// Make sure profile doesn't already exist.
 
			foreach (string profileName in profileList)
 
			{
 
				if (profileName.Equals(newProfileDialog.ProfileName))
 
				{
 
					MessageDialog md = new MessageDialog(this, 
 
	            		DialogFlags.DestroyWithParent,
 
	            		MessageType.Error, ButtonsType.Ok, 
 
	            		"That profile name already exists.");
 
					resp = (ResponseType)md.Run();
 
					md.Destroy();
 
					duplicateName = true;
 
					break;	
 
				}
 
			}
 
			
 
			if (!duplicateName)
 
			{
 
				// Set profile name.
 
				SetProfileName(newProfileDialog.ProfileName);
 
				
 

	
 
    bool NewProfile()
 
    {
 
        bool newProfileCreated = false;
 
        bool duplicateName = false;
 
        NewProfileDialog newProfileDialog = new NewProfileDialog();
 
        ResponseType resp = (ResponseType)newProfileDialog.Run();
 
        if (resp == ResponseType.Ok)
 
        {
 
            // Make sure profile doesn't already exist.
 
            foreach (string profileName in profileList)
 
            {
 
                if (profileName.Equals(newProfileDialog.ProfileName))
 
                {
 
                    MessageDialog md = new MessageDialog(this,
 
                        DialogFlags.DestroyWithParent,
 
                        MessageType.Error, ButtonsType.Ok,
 
                        "That profile name already exists.");
 
                    resp = (ResponseType)md.Run();
 
                    md.Destroy();
 
                    duplicateName = true;
 
                    break;
 
                }
 
            }
 

	
 
            if (!duplicateName)
 
            {
 
                // Set profile name.
 
                SetProfileName(newProfileDialog.ProfileName);
 

	
 
                newProfileCreated = profile.Initialize();
 
                if (!newProfileCreated)
 
                {
 
                    MessageDialog md = new MessageDialog(this, 
 
                    MessageDialog md = new MessageDialog(this,
 
                        DialogFlags.DestroyWithParent,
 
                        MessageType.Error, ButtonsType.Ok, 
 
                        MessageType.Error, ButtonsType.Ok,
 
                        "Failed to initialize profile: " + profile.LastError);
 
                    resp = (ResponseType)md.Run();
 
                    md.Destroy();
 
                    duplicateName = false;
 
                }
 
                ProfileChanged();
 
			}
 
		}
 
		newProfileDialog.Destroy();
 
		return newProfileCreated;
 
	}
 
	
 
	bool OpenProfile()
 
	{
 
		bool profileSelected = false;
 
		
 
		if (profileList.Count > 0)
 
		{
 
			SelectProfileDialog selectProfileDialog = new SelectProfileDialog();
 
			selectProfileDialog.ProfileList = profileList;
 
			ResponseType resp = (ResponseType)selectProfileDialog.Run();
 
			selectProfileDialog.Destroy();
 
			string selectedProfile = selectProfileDialog.SelectedProfile;
 
			if ((resp == ResponseType.Ok) && (selectedProfile.Length > 0)) 
 
				// Selected a profile.
 
			{
 
				SetProfileName(selectedProfile);
 
				profileSelected = true;
 
			}
 
			else if (resp == ResponseType.Accept) // New profile.
 
			{
 
				profileSelected = NewProfile();
 
			}
 
		}
 
		else
 
		{
 
			FirstRunDialog firstRunDialog = new FirstRunDialog();
 
			ResponseType resp = (ResponseType)firstRunDialog.Run();
 
			firstRunDialog.Destroy();
 
			if (resp == ResponseType.Ok) // New profile
 
			{
 
				profileSelected = NewProfile();
 
			}
 
			else if (resp == ResponseType.Accept) // Import
 
			{
 
				FileChooserDialog fileDialog =
 
					new FileChooserDialog("Select reactions.txt file.",
 
				    this, FileChooserAction.Open,
 
					Gtk.Stock.Cancel, ResponseType.Cancel,
 
		            Gtk.Stock.Open, ResponseType.Accept);
 
				resp = (ResponseType)fileDialog.Run();
 
				if (resp == ResponseType.Accept)
 
				{
 
					string fileName = fileDialog.Filename;
 
					string directory = fileDialog.CurrentFolder;
 
					if (fileName == "reactions.txt")
 
					{
 
						profileSelected = NewProfile();
 
						if (profileSelected)
 
						{
 
							profile.ImportFromPP(directory);
 
						}
 
					}
 
				}
 
			}
 
		}
 
		
 
		if (profileSelected)
 
		{
 
			bool ok = profile.Load();
 
            }
 
        }
 
        newProfileDialog.Destroy();
 
        return newProfileCreated;
 
    }
 

	
 
    bool OpenProfile()
 
    {
 
        bool profileSelected = false;
 

	
 
        if (profileList.Count > 0)
 
        {
 
            SelectProfileDialog selectProfileDialog = new SelectProfileDialog();
 
            selectProfileDialog.ProfileList = profileList;
 
            ResponseType resp = (ResponseType)selectProfileDialog.Run();
 
            selectProfileDialog.Destroy();
 
            string selectedProfile = selectProfileDialog.SelectedProfile;
 
            if ((resp == ResponseType.Ok) && (selectedProfile.Length > 0))
 
            // Selected a profile.
 
            {
 
                SetProfileName(selectedProfile);
 
                profileSelected = true;
 
            }
 
            else if (resp == ResponseType.Accept) // New profile.
 
            {
 
                profileSelected = NewProfile();
 
            }
 
        }
 
        else
 
        {
 
            FirstRunDialog firstRunDialog = new FirstRunDialog();
 
            ResponseType resp = (ResponseType)firstRunDialog.Run();
 
            firstRunDialog.Destroy();
 
            if (resp == ResponseType.Ok) // New profile
 
            {
 
                profileSelected = NewProfile();
 
            }
 
            else if (resp == ResponseType.Accept) // Import
 
            {
 
                FileChooserDialog fileDialog =
 
                    new FileChooserDialog("Select reactions.txt file.",
 
                    this, FileChooserAction.Open,
 
                    Gtk.Stock.Cancel, ResponseType.Cancel,
 
                    Gtk.Stock.Open, ResponseType.Accept);
 
                resp = (ResponseType)fileDialog.Run();
 
                if (resp == ResponseType.Accept)
 
                {
 
                    string fileName = fileDialog.Filename;
 
                    string directory = fileDialog.CurrentFolder;
 
                    if (fileName == "reactions.txt")
 
                    {
 
                        profileSelected = NewProfile();
 
                        if (profileSelected)
 
                        {
 
                            profile.ImportFromPP(directory);
 
                        }
 
                    }
 
                }
 
            }
 
        }
 

	
 
        if (profileSelected)
 
        {
 
            bool ok = profile.Load();
 

	
 
            if (ok)
 
            {
 
                ProfileChanged();
 
            }
 
            else
 
            {
 
                MessageDialog md = new MessageDialog(this, 
 
                MessageDialog md = new MessageDialog(this,
 
                    DialogFlags.DestroyWithParent,
 
                    MessageType.Error, ButtonsType.Ok, 
 
                    MessageType.Error, ButtonsType.Ok,
 
                    "Error loading profile: " + profile.LastError);
 

	
 
                md.Run();
 
                md.Destroy();
 
                profileSelected = false;
 
            }
 
		}
 
        }
 

	
 
        return profileSelected;
 
    }
 

	
 
		return profileSelected;
 
	}
 
	
 
	protected void OnDeleteEvent(object sender, DeleteEventArgs a)
 
	{
 
		if (ConfirmedExit())
 
		{
 
			a.RetVal = true;
 
			Application.Quit();
 
		}
 
		else
 
		{
 
			a.RetVal = false;
 
		}
 
	}
 
	
 
    protected void OnDeleteEvent(object sender, DeleteEventArgs a)
 
    {
 
        if (ConfirmedExit())
 
        {
 
            a.RetVal = true;
 
            Application.Quit();
 
        }
 
        else
 
        {
 
            a.RetVal = false;
 
        }
 
    }
 

	
 
    protected virtual void OnDebugScreenshot(object sender, System.EventArgs e)
 
    {
 
        int screenWidth, screenHeight;
 
        rootWindow.GetSize(out screenWidth, out screenHeight);
 
        DesertPaintLab.AppSettings.Get("ScreenWidth", out screenWidth);
 
        DesertPaintLab.AppSettings.Get("ScreenHeight", out screenHeight);
 
        Gdk.Image rootImage = rootWindow.GetImage(0, 0, screenWidth, screenHeight);
 
        screenBuffer.GetFromImage(rootImage, rootImage.Colormap, 0, 0, 0, 0, screenWidth, screenHeight);
 
        string screenshotDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
 
        string filename;
 
        int i = 0;
 
        do
 
        {
 
            ++i;
 
            filename = System.IO.Path.Combine(screenshotDir, String.Format("DesertPaintLab_{0}.png", i));
 
        } while (System.IO.File.Exists(filename));
 
        screenBuffer.Save(filename, "png");
 
    }
 

	
 
	protected virtual void OnNewProfile(object sender, System.EventArgs e)
 
	{
 
		if (unsavedData)
 
		{
 
			MessageDialog md = new MessageDialog(this, 
 
	            DialogFlags.DestroyWithParent,
 
	            MessageType.Warning, ButtonsType.OkCancel, 
 
	            "Your last reaction was unsaved." +
 
	            "Are you sure you want to lose your changes?");
 
	   
 
			ResponseType resp = (ResponseType)md.Run();
 
			md.Destroy();
 
			if (resp != ResponseType.Ok)
 
			{
 
				return;	
 
			}
 
		}
 
		
 
		if (NewProfile())
 
		{
 
			bool ok = profile.Load();
 
    protected virtual void OnNewProfile(object sender, System.EventArgs e)
 
    {
 
        if (unsavedData)
 
        {
 
            MessageDialog md = new MessageDialog(this,
 
                DialogFlags.DestroyWithParent,
 
                MessageType.Warning, ButtonsType.OkCancel,
 
                "Your last reaction was unsaved." +
 
                "Are you sure you want to lose your changes?");
 

	
 
            ResponseType resp = (ResponseType)md.Run();
 
            md.Destroy();
 
            if (resp != ResponseType.Ok)
 
            {
 
                return;
 
            }
 
        }
 

	
 
        if (NewProfile())
 
        {
 
            bool ok = profile.Load();
 
            if (ok)
 
            {
 
                ProfileChanged();
 
            }
 
            else
 
            {
 
                MessageDialog md = new MessageDialog(this,
 
                    DialogFlags.DestroyWithParent,
 
                    MessageType.Warning, ButtonsType.OkCancel,
 
                    "Failed to load profile: " + profile.LastError);
 
                md.Run();
 
                md.Destroy();
 
            }
 
        }
 
    }
 

	
 
    protected virtual void OnOpenProfile(object sender, System.EventArgs e)
 
    {
 
        bool profileSelected = false;
 
        SelectProfileDialog selectProfileDialog = new SelectProfileDialog();
 
        selectProfileDialog.ProfileList = profileList;
 
        ResponseType resp = (ResponseType)selectProfileDialog.Run();
 
        selectProfileDialog.Destroy();
 
        if (resp == ResponseType.Ok) // Selected a profile.
 
        {
 
            SetProfileName(selectProfileDialog.SelectedProfile);
 
            profileSelected = true;
 
        }
 
        else if (resp == ResponseType.Accept) // New profile.
 
        {
 
            profileSelected = NewProfile();
 
        }
 
        if (profileSelected)
 
        {
 
            bool ok = profile.Load();
 
            if (ok)
 
            {
 
                ProfileChanged();
 
            }
 
            else
 
            {
 
                MessageDialog md = new MessageDialog(this, 
 
                MessageDialog md = new MessageDialog(this,
 
                    DialogFlags.DestroyWithParent,
 
                    MessageType.Warning, ButtonsType.OkCancel, 
 
                    "Failed to load profile: " + profile.LastError);
 
                md.Run();
 
                md.Destroy();
 
            }
 
		}
 
	}
 
	
 
	protected virtual void OnOpenProfile(object sender, System.EventArgs e)
 
	{
 
		bool profileSelected = false;
 
		SelectProfileDialog selectProfileDialog = new SelectProfileDialog();
 
		selectProfileDialog.ProfileList = profileList;
 
		ResponseType resp = (ResponseType)selectProfileDialog.Run();
 
		selectProfileDialog.Destroy();
 
		if (resp == ResponseType.Ok) // Selected a profile.
 
		{
 
			SetProfileName(selectProfileDialog.SelectedProfile);
 
			profileSelected = true;
 
		}
 
		else if (resp == ResponseType.Accept) // New profile.
 
		{
 
			profileSelected = NewProfile();
 
		}
 
		if (profileSelected)
 
		{
 
			bool ok = profile.Load();
 
            if (ok)
 
            {
 
                ProfileChanged();
 
            }
 
            else
 
            {
 
                MessageDialog md = new MessageDialog(this, 
 
                    DialogFlags.DestroyWithParent,
 
                    MessageType.Warning, ButtonsType.OkCancel, 
 
                    MessageType.Warning, ButtonsType.OkCancel,
 
                    "Failed to load profile: " + profile.LastError);
 
                md.Run();
 
                md.Destroy();
 
            }
 
		}
 
	}
 
	
 
	protected virtual void OnAbout(object sender, System.EventArgs e)
 
	{
 
		AboutDialog aboutDialog = new AboutDialog();
 
        }
 
    }
 

	
 
    protected virtual void OnAbout(object sender, System.EventArgs e)
 
    {
 
        AboutDialog aboutDialog = new AboutDialog();
 

	
 
        aboutDialog.ProgramName = "Desert Paint Lab";
 
        aboutDialog.Version = APP_VERSION ;
 
        aboutDialog.Version = APP_VERSION;
 
        aboutDialog.Comments = "Desert Paint Lab paint reaction recorder for A Tale in the Desert";
 
        aboutDialog.Authors = new string [] {"Tess Snider", "Jason Maltzen"};
 
        aboutDialog.Authors = new string[] { "Tess Snider", "Jason Maltzen" };
 
        //aboutDialog.Website = "http://www.google.com/";
 
		aboutDialog.Run();
 
		aboutDialog.Destroy();
 
	}
 
	
 
	protected virtual void OnMenuExit (object sender, System.EventArgs e)
 
	{
 
		if (ConfirmedExit())
 
		{
 
			Application.Quit();
 
		}
 
	}
 
	
 
	protected virtual void OnExportToPracticalPaint(object sender, System.EventArgs e)
 
	{
 
		FileChooserDialog fileDialog =
 
			new FileChooserDialog("Select destination file.",
 
				    this, FileChooserAction.Save,
 
			        Gtk.Stock.Cancel, ResponseType.Cancel,
 
		            Gtk.Stock.Save, ResponseType.Accept);
 
		ResponseType resp = (ResponseType)fileDialog.Run();
 
		if (resp == ResponseType.Accept)
 
		{
 
			string fileName = fileDialog.Filename;
 
			string directory = fileDialog.CurrentFolder;
 
			profile.SaveToPP(System.IO.Path.Combine(directory, fileName));
 
		}
 
		fileDialog.Destroy();
 
	}
 
        aboutDialog.Run();
 
        aboutDialog.Destroy();
 
    }
 

	
 
    protected virtual void OnMenuExit(object sender, System.EventArgs e)
 
    {
 
        if (ConfirmedExit())
 
        {
 
            Application.Quit();
 
        }
 
    }
 

	
 
    protected virtual void OnExportToPracticalPaint(object sender, System.EventArgs e)
 
    {
 
        FileChooserDialog fileDialog =
 
            new FileChooserDialog("Select destination file.",
 
                    this, FileChooserAction.Save,
 
                    Gtk.Stock.Cancel, ResponseType.Cancel,
 
                    Gtk.Stock.Save, ResponseType.Accept);
 
        ResponseType resp = (ResponseType)fileDialog.Run();
 
        if (resp == ResponseType.Accept)
 
        {
 
            string fileName = fileDialog.Filename;
 
            string directory = fileDialog.CurrentFolder;
 
            profile.SaveToPP(System.IO.Path.Combine(directory, fileName));
 
        }
 
        fileDialog.Destroy();
 
    }
 

	
 
    protected void OnReactionRecorded(Reagent reagent1, Reagent reagent2, Reaction reaction)
 
    {
 
        if (_reactionStatusWindow != null)
 
        {
 
            _reactionStatusWindow.RefreshReactions();
 
        }
 
    }
 

	
 
    protected void OnReactionStatusDestroyed(object o, EventArgs args)
 
    {
 
        _reactionStatusWindow = null;
 
    }
 

	
 
    protected void OnShowReactionStatus(object sender, EventArgs e)
 
    {
 
        ReactionStatusWindow win = new ReactionStatusWindow(profile);
 
        win.Show();
 
        if (_reactionStatusWindow != null) return; // already open
 
        _reactionStatusWindow = new ReactionStatusWindow(profile);
 
        _reactionStatusWindow.Destroyed += new EventHandler(OnReactionStatusDestroyed);
 
        _reactionStatusWindow.Show();
 
    }
 

	
 
    protected void OnExportProfile(object sender, EventArgs e)
 
    {
 
        FileChooserDialog fileDialog =
 
            new FileChooserDialog("Select destination file.",
 
                    this, FileChooserAction.Save,
 
                    Gtk.Stock.Cancel, ResponseType.Cancel,
 
                    Gtk.Stock.Save, ResponseType.Accept);
 
        ResponseType resp = (ResponseType)fileDialog.Run();
 
        if (resp == ResponseType.Accept)
 
        {
 
            string fileName = fileDialog.Filename;
 
            string directory = fileDialog.CurrentFolder;
 
            string targetFile = System.IO.Path.Combine(directory, fileName);
 
            if (File.Exists(targetFile))
 
            {
 
                // prompt to overwrite
 
                MessageDialog md = new MessageDialog(this, 
 
                MessageDialog md = new MessageDialog(this,
 
                    DialogFlags.DestroyWithParent,
 
                    MessageType.Warning, ButtonsType.OkCancel, 
 
                    MessageType.Warning, ButtonsType.OkCancel,
 
                    "Overwrite file at " +
 
                    targetFile + "?");
 
       
 

 
                resp = (ResponseType)md.Run();
 
                md.Destroy();
 
                if (resp == ResponseType.Ok)
 
                {
 
                    File.Delete(targetFile);
 
                    profile.Export(targetFile);
 
                }
 
            }
 
            else
 
            {
 
                profile.Export(targetFile);
 
            }
 
        }
 
        fileDialog.Destroy();
 
    }
 

	
...
 
@@ -550,60 +541,60 @@ public partial class MainWindow : Gtk.Wi
 
                    this, FileChooserAction.Open,
 
                    Gtk.Stock.Cancel, ResponseType.Cancel,
 
                    Gtk.Stock.Open, ResponseType.Accept);
 
        ResponseType resp = (ResponseType)fileDialog.Run();
 
        if (resp == ResponseType.Accept)
 
        {
 
            string fileName = fileDialog.Filename;
 
            string directory = fileDialog.CurrentFolder;
 
            string targetFile = fileName;
 
            if (directory != null)
 
            {
 
                targetFile = System.IO.Path.Combine(directory, fileName);
 
            }
 
            if (Directory.Exists(profile.Directory))
 
            {
 
                // prompt to overwrite
 
                MessageDialog md = new MessageDialog(this, 
 
                MessageDialog md = new MessageDialog(this,
 
                    DialogFlags.DestroyWithParent,
 
                    MessageType.Warning, ButtonsType.OkCancel, 
 
                    MessageType.Warning, ButtonsType.OkCancel,
 
                    "Overwrite profile '" +
 
                    profile.Name + "'?");
 
       
 

 
                resp = (ResponseType)md.Run();
 
                md.Destroy();
 
                if (resp == ResponseType.Ok)
 
                {
 
                    Directory.Delete(profile.Directory, true);
 
                    profile.Import(targetFile);
 
                }
 
            }
 
            else
 
            {
 
                profile.Import(targetFile);
 
            }
 
            bool ok = profile.Load();
 
            if (ok)
 
            {
 
                ProfileChanged();
 
            }
 
            else
 
            {
 
                MessageDialog md = new MessageDialog(this, 
 
                MessageDialog md = new MessageDialog(this,
 
                    DialogFlags.DestroyWithParent,
 
                    MessageType.Warning, ButtonsType.OkCancel, 
 
                    MessageType.Warning, ButtonsType.OkCancel,
 
                    "Failed to load imported profile: " + profile.LastError);
 
                md.Run();
 
                md.Destroy();
 
            }
 
        }
 
        fileDialog.Destroy();
 
    }
 

	
 
    protected void OnExportRecipeListToWiki(object sender, EventArgs e)
 
    {
 
        Gtk.FileChooserDialog fileDialog =
 
            new Gtk.FileChooserDialog("Select destination file.",
 
                    (Gtk.Window)Toplevel, Gtk.FileChooserAction.Save,
 
                    Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
 
                    Gtk.Stock.Save, Gtk.ResponseType.Accept);
 
        Gtk.ResponseType resp = (Gtk.ResponseType)fileDialog.Run();
...
 
@@ -708,18 +699,78 @@ public partial class MainWindow : Gtk.Wi
 
        {
 
            simulatorView = new SimulatorView(profile);
 
        }
 
        if (simulatorView.Visible == false)
 
        {
 
            simulatorView.ResizeChildren();
 
            simulatorView.CheckResize();
 
            contentContainer.Add(simulatorView);
 
            simulatorView.Show();
 
        }
 
        CheckResize();
 
        // TODO: enable/disable menu options based on view
 
        NewProfileAction.Sensitive = true;
 
        OpenProfileAction.Sensitive = true;
 
        ImportProfileAction.Sensitive = true;
 
    }
 

	
 
    protected void ShowPreferencesDialog()
 
    {
 
        int detectedScreenWidth;
 
        int detectedScreenHeight;
 
        rootWindow.GetSize(out detectedScreenWidth, out detectedScreenHeight);
 
        int screenWidth = detectedScreenWidth;
 
        int screenHeight = detectedScreenHeight;
 
        int pixelMultiplier = 1;
 
        int interfaceSizeIndex = (int)(InterfaceSize.Small);
 

	
 
        DesertPaintLab.AppSettings.Get("ScreenWidth", out screenWidth);
 
        DesertPaintLab.AppSettings.Get("ScreenHeight", out screenHeight);
 
        DesertPaintLab.AppSettings.Get("PixelMultiplier", out pixelMultiplier);
 
        DesertPaintLab.AppSettings.Get("InterfaceSize", out interfaceSizeIndex);
 
        InterfaceSize interfaceSize = (InterfaceSize)interfaceSizeIndex;
 

	
 
        ScreenCheckDialog screenCheckDialog = new ScreenCheckDialog();
 
        screenCheckDialog.DetectedScreenWidth = detectedScreenWidth;
 
        screenCheckDialog.DetectedScreenHeight = detectedScreenHeight;
 
        screenCheckDialog.ScreenWidth = screenWidth;
 
        screenCheckDialog.ScreenHeight = screenHeight;
 
        screenCheckDialog.GamePixelWidth = pixelMultiplier;
 
        screenCheckDialog.InterfaceSize = interfaceSize;
 

	
 
        ResponseType resp = (ResponseType)screenCheckDialog.Run();
 

	
 
        screenWidth = screenCheckDialog.ScreenWidth;
 
        screenHeight = screenCheckDialog.ScreenHeight;
 
        pixelMultiplier = screenCheckDialog.GamePixelWidth;
 
        interfaceSize = screenCheckDialog.InterfaceSize;
 
        screenCheckDialog.Destroy();
 

	
 
        DesertPaintLab.AppSettings.Set("ScreenWidth", screenWidth);
 
        DesertPaintLab.AppSettings.Set("ScreenHeight", screenHeight);
 
        DesertPaintLab.AppSettings.Set("PixelMultiplier", pixelMultiplier);
 
        DesertPaintLab.AppSettings.Set("InterfaceSize", (int)interfaceSize);
 
        DesertPaintLab.AppSettings.Save();
 

	
 
        screenBuffer = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, screenWidth, screenHeight);
 

	
 
        ReactionRecorder.Instance.SetPixelMultiplier(pixelMultiplier);
 
        ReactionRecorder.Instance.SetInterfaceSize(interfaceSize);
 
    }
 

	
 
    protected void OnPreferences(object sender, EventArgs e)
 
    {
 
        ShowPreferencesDialog();
 

	
 
        int screenWidth = 1920;
 
        int screenHeight = 1080;
 
        int pixelMultiplier = 1;
 
        int interfaceSizeIndex = (int)(InterfaceSize.Small);
 

	
 
        DesertPaintLab.AppSettings.Get("ScreenWidth", out screenWidth);
 
        DesertPaintLab.AppSettings.Get("ScreenHeight", out screenHeight);
 
        DesertPaintLab.AppSettings.Get("PixelMultiplier", out pixelMultiplier);
 
        DesertPaintLab.AppSettings.Get("InterfaceSize", out interfaceSizeIndex);
 

	
 
        captureView.ScreenBuffer = screenBuffer;
 
    }
 
}
 

	
PlayerProfile.cs
Show inline comments
...
 
@@ -503,67 +503,73 @@ namespace DesertPaintLab
 
        {
 
            ExportWikiFormat(writer, this.recipes);
 
        }
 
        
 
        public void ExportWikiRibbons(TextWriter writer)
 
        {
 
            ExportWikiFormat(writer, this.ribbonRecipes);
 
        }
 
        
 
        public void ExportWikiFormat(TextWriter writer, SortedDictionary<string, PaintRecipe> recipeDict)
 
        {
 
            PaintRecipe recipe;
 
            List<KeyValuePair<string, string>> missing = new List<KeyValuePair<string, string>>();
 
            using (writer)
 
            {
 
                writer.WriteLine("{| class='wikitable sortable' border=\"1\" style=\"background-color:#DEB887;\"");
 
                writer.WriteLine("! Color !! Recipe !! Verified");    
 
                writer.WriteLine("! Color !! Recipe !! Missing Reactions? || Verified");
 
                foreach (PaintColor color in Palette.Colors)
 
                {
 
                    writer.WriteLine("|-");
 
                    string colorLine = "| ";
 
                    colorLine += "style=\"font-weight: bold; background-color: #" + color.Red.ToString("X2") + color.Green.ToString("X2") + color.Blue.ToString("X2") + ";";
 
                    float rPortion = color.Red / 255.0f;
 
                    float gPortion = color.Green / 255.0f;
 
                    float bPortion = color.Blue / 255.0f;
 
                    float maxColor = Math.Max(rPortion, Math.Max(gPortion, bPortion));
 
                    float minColor = Math.Min(rPortion, Math.Min(gPortion, bPortion));
 
                    float luminance = (maxColor - minColor) * 0.5f;
 
                    if (luminance < 0.5f)
 
                    {
 
                        // dark color gets light text
 
                        colorLine += " color: #FFFFFF;";
 
                    }
 
                    colorLine += "\" | " + color.Name + " || ";
 
                    if (recipeDict.TryGetValue(color.Name, out recipe))
 
                    {
 
                        foreach (PaintRecipe.RecipeIngredient ingredient in recipe.Ingredients)
 
                        {
 
                            colorLine += " " + ingredient.ToString();
 
                        }
 
                    } 
 
                    else
 
                    {
 
                        // no recipe
 
                    }
 
                    colorLine += " || ";
 
                    
 
                    if (recipe.CheckMissingReactions(ref missing) == false)
 
                    if (recipe.CheckMissingReactions(ref missing) == true)
 
                    {
 
                        colorLine += "Y";
 
                    }
 
                    else
 
                    {
 
                        colorLine += "N";
 
                    }
 

	
 
                    colorLine += " || N";
 
                    writer.WriteLine(colorLine);
 
                }
 
                writer.WriteLine("|}");
 
            }
 
        }
 
 
 
		public Reaction FindReaction(Reagent reagent1, Reagent reagent2)
 
		{
 
            return reactions.Find(reagent1, reagent2);
 
		}
 
		
 
		public void SetReaction(Reagent reagent1, Reagent reagent2, Reaction reaction)
 
		{
 
            reactions.Set(reagent1, reagent2, reaction);
 
		}
 

	
ReactionRecorder.cs
Show inline comments
...
 
@@ -15,127 +15,227 @@
 
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
 THE SOFTWARE.
 
*/
 

	
 
using System;
 
using System.IO;
 

	
 
namespace DesertPaintLab
 
{
 
    // ReactionRecorder - business logic for recording paint reactions
 
    public class ReactionRecorder
 
    {
 
        public delegate void CaptureProgressHandler(int x, int y);
 
        public CaptureProgressHandler OnCaptureProgress;
 

	
 
        const int COLOR_TOLERANCE = 3;
 

	
 
        const int DEFAULT_SWATCH_HEIGHT = 24; // including top and bottom borders
 
        const int DEFAULT_SWATCH_WIDTH = 260;
 
        const int DEFAULT_COLOR_BAR_WIDTH = 306;
 
        const int DEFAULT_RED_BAR_SPACING = 32;
 
        const int DEFAULT_GREEN_BAR_SPACING = 42;
 
        const int DEFAULT_BLUE_BAR_SPACING = 52;
 

	
 
        const int DEFAULT_SWATCH_TEST_WIDTH = 26; // width to test on ends of swatch (10% on either end)
 
        const InterfaceSize DEFAULT_INTERFACE_SIZE = InterfaceSize.Small;
 

	
 
        int swatchHeight = DEFAULT_SWATCH_HEIGHT;
 
        int swatchWidth = DEFAULT_SWATCH_WIDTH;
 
        int swatchTestWidth = DEFAULT_SWATCH_TEST_WIDTH;
 
        int colorBarWidth = DEFAULT_COLOR_BAR_WIDTH;
 
        int redBarSpacing = DEFAULT_RED_BAR_SPACING;
 
        int greenBarSpacing = DEFAULT_GREEN_BAR_SPACING;
 
        int blueBarSpacing = DEFAULT_BLUE_BAR_SPACING;
 
        public static readonly int[] SWATCH_HEIGHT = 
 
        {
 
            24, // tiny
 
            24, // small
 
            24, // medium
 
            24, // large
 
            24 // huge
 
        };
 
        public static readonly int[] SWATCH_WIDTH =
 
        {
 
            260, // tiny
 
            260, // small
 
            260, // medium
 
            274, // large
 
            304 // huge
 
        };
 
        public static readonly int[] COLOR_BAR_WIDTH =
 
        {
 
            306, // tiny
 
            306, // small
 
            306, // medium
 
            320, // large
 
            350 // huge
 
        };
 
        public static readonly int[] RED_BAR_SPACING =
 
        {
 
            32, // tiny
 
            32, // small
 
            32, // medium
 
            32, // large
 
            32 // huge
 
        };
 
        public static readonly int[] GREEN_BAR_SPACING =
 
        {
 
            42, // tiny
 
            42, // small
 
            42, // medium
 
            42, // large
 
            42 // huge
 
        };
 
        public static readonly int[] BLUE_BAR_SPACING =
 
        {
 
            52, // tiny
 
            52, // small
 
            52, // medium
 
            52, // large
 
            52 // huge
 
        };
 
        // width to test on ends of swatch (10% on either end)
 
        public static readonly int[] SWATCH_TEST_WIDTH =
 
        {
 
            26, // tiny
 
            26, // small
 
            26, // medium
 
            28, // large
 
            31  // huge
 
        };
 

	
 
        int swatchHeight = SWATCH_HEIGHT[(int)DEFAULT_INTERFACE_SIZE];
 
        int swatchWidth = SWATCH_WIDTH[(int)DEFAULT_INTERFACE_SIZE];
 
        int swatchTestWidth = SWATCH_TEST_WIDTH[(int)DEFAULT_INTERFACE_SIZE];
 
        int colorBarWidth = COLOR_BAR_WIDTH[(int)DEFAULT_INTERFACE_SIZE];
 
        int redBarSpacing = RED_BAR_SPACING[(int)DEFAULT_INTERFACE_SIZE];
 
        int greenBarSpacing = GREEN_BAR_SPACING[(int)DEFAULT_INTERFACE_SIZE];
 
        int blueBarSpacing = BLUE_BAR_SPACING[(int)DEFAULT_INTERFACE_SIZE];
 

	
 
        public int SwatchHeight {  get { return swatchHeight; } }
 
        public int SwatchWidth {  get { return swatchWidth; } }
 
        public int ColorBarWidth { get { return colorBarWidth;  } }
 
        public int RedBarSpacing {  get { return redBarSpacing; } }
 
        public int GreenBarSpacing { get { return greenBarSpacing; } }
 
        public int BlueBarSpacing {  get { return blueBarSpacing; } }
 

	
 
        // Current Status
 
        public bool IsCaptured { get; private set; }
 
        public int X { get; private set; }
 
        public int Y { get; private set; }
 
        public int ScreenWidth { get; private set; }
 
        public int ScreenHeight { get; private set; }
 
        public PaintColor RecordedColor { get; private set; }
 
        public int RedBarX { get; private set; }
 
        public int RedBarY { get; private set; }
 

	
 
        int pixelMultiplier = 1;
 
        InterfaceSize interfaceSize;
 

	
 
        bool firstRun = true;
 
        int lastSwatchX = -1;
 
        int lastSwatchY = -1;
 
        public int SwatchX { get { return lastSwatchX; } }
 
        public int SwatchY { get { return lastSwatchY; } }
 

	
 
        private static ReactionRecorder _instance;
 
        public static ReactionRecorder Instance
 
        {
 
            get {
 
                if (_instance == null)
 
                {
 
                    _instance = new ReactionRecorder();
 
                }
 
                return _instance;
 
            }
 
        }
 

	
 
        private StreamWriter _log;
 
        public StreamWriter Log
 
        {
 
            set
 
            {
 
                _log = value;
 
            }
 
        }
 
        public StreamWriter Log { get; set; }
 
        private void WriteLog(string format, params object[] args)
 
        {
 
            if (_log != null)
 
            if (Log != null)
 
            {
 
                _log.WriteLine(format, args);
 
                Log.WriteLine(format, args);
 
            }
 
        }
 

	
 
        public delegate void ReactionRecordedHandler(Reagent reagent1, Reagent reagent2, Reaction reaction);
 
        public ReactionRecordedHandler OnReactionRecorded;
 

	
 
        public ReactionRecorder()
 
        {
 
            this.pixelMultiplier = 1;
 
            swatchHeight = DEFAULT_SWATCH_HEIGHT * pixelMultiplier;
 
            swatchWidth = DEFAULT_SWATCH_WIDTH * pixelMultiplier;
 
            colorBarWidth = DEFAULT_COLOR_BAR_WIDTH * pixelMultiplier;
 
            redBarSpacing = DEFAULT_RED_BAR_SPACING * pixelMultiplier;
 
            greenBarSpacing = DEFAULT_GREEN_BAR_SPACING * pixelMultiplier;
 
            blueBarSpacing = DEFAULT_BLUE_BAR_SPACING * pixelMultiplier;
 
            swatchTestWidth = DEFAULT_SWATCH_TEST_WIDTH * pixelMultiplier;
 
            pixelMultiplier = 1;
 
            interfaceSize = DEFAULT_INTERFACE_SIZE;
 
            swatchHeight = SWATCH_HEIGHT[(int)interfaceSize] * pixelMultiplier;
 
            swatchWidth = SWATCH_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
            colorBarWidth = COLOR_BAR_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
            redBarSpacing = RED_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            greenBarSpacing = GREEN_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            blueBarSpacing = BLUE_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            swatchTestWidth = SWATCH_TEST_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
        }
 

	
 
        public ReactionRecorder(int pixelMultiplier)
 
        {
 
            this.pixelMultiplier = pixelMultiplier;
 
            swatchHeight = DEFAULT_SWATCH_HEIGHT * pixelMultiplier;
 
            swatchWidth = DEFAULT_SWATCH_WIDTH * pixelMultiplier;
 
            colorBarWidth = DEFAULT_COLOR_BAR_WIDTH * pixelMultiplier;
 
            redBarSpacing = DEFAULT_RED_BAR_SPACING * pixelMultiplier;
 
            greenBarSpacing = DEFAULT_GREEN_BAR_SPACING * pixelMultiplier;
 
            blueBarSpacing = DEFAULT_BLUE_BAR_SPACING * pixelMultiplier;
 
            swatchTestWidth = DEFAULT_SWATCH_TEST_WIDTH * pixelMultiplier;
 
            this.interfaceSize = DEFAULT_INTERFACE_SIZE;
 
            swatchHeight = SWATCH_HEIGHT[(int)interfaceSize] * pixelMultiplier;
 
            swatchWidth = SWATCH_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
            colorBarWidth = COLOR_BAR_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
            redBarSpacing = RED_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            greenBarSpacing = GREEN_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            blueBarSpacing = BLUE_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            swatchTestWidth = SWATCH_TEST_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
        }
 

	
 
        public ReactionRecorder(int pixelMultiplier, InterfaceSize interfaceSize)
 
        {
 
            this.pixelMultiplier = pixelMultiplier;
 
            this.interfaceSize = interfaceSize;
 
            swatchHeight = SWATCH_HEIGHT[(int)interfaceSize] * pixelMultiplier;
 
            swatchWidth = SWATCH_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
            colorBarWidth = COLOR_BAR_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
            redBarSpacing = RED_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            greenBarSpacing = GREEN_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            blueBarSpacing = BLUE_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            swatchTestWidth = SWATCH_TEST_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
        }
 

	
 
        private static bool IsPapyTexture(byte r, byte g, byte b)
 
        {
 
            // red between 208 and 244
 
            // green between 192 and 237
 
            // blue between 145 and 205
 
            return ((r > 0xD0) && (g >= 0xC0) && (b >= 0x91)) &&
 
                   ((r < 0xF4) && (g <= 0xED) && (b <= 0xCD));
 
        }
 

	
 
        public void SetPixelMultiplier(int pixelMultiplier)
 
        {
 
            swatchHeight    = DEFAULT_SWATCH_HEIGHT * pixelMultiplier;
 
            swatchWidth     = DEFAULT_SWATCH_WIDTH * pixelMultiplier;
 
            colorBarWidth   = DEFAULT_COLOR_BAR_WIDTH * pixelMultiplier;
 
            redBarSpacing   = DEFAULT_RED_BAR_SPACING * pixelMultiplier;
 
            greenBarSpacing = DEFAULT_GREEN_BAR_SPACING * pixelMultiplier;
 
            blueBarSpacing  = DEFAULT_BLUE_BAR_SPACING * pixelMultiplier;
 
            swatchTestWidth = DEFAULT_SWATCH_TEST_WIDTH * pixelMultiplier;
 
            this.pixelMultiplier = pixelMultiplier;
 

	
 
            swatchHeight = SWATCH_HEIGHT[(int)interfaceSize] * pixelMultiplier;
 
            swatchWidth      = SWATCH_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
            colorBarWidth    = COLOR_BAR_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
            redBarSpacing    = RED_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            greenBarSpacing  = GREEN_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            blueBarSpacing   = BLUE_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            swatchTestWidth  = SWATCH_TEST_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
        }
 

	
 
        public void SetInterfaceSize(InterfaceSize interfaceSize)
 
        {
 
            this.interfaceSize = interfaceSize;
 

	
 
            swatchHeight = SWATCH_HEIGHT[(int)interfaceSize] * pixelMultiplier;
 
            swatchWidth = SWATCH_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
            colorBarWidth = COLOR_BAR_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
            redBarSpacing = RED_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            greenBarSpacing = GREEN_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            blueBarSpacing = BLUE_BAR_SPACING[(int)interfaceSize] * pixelMultiplier;
 
            swatchTestWidth = SWATCH_TEST_WIDTH[(int)interfaceSize] * pixelMultiplier;
 
        }
 

	
 
        unsafe private void ColorAt(byte *pixBytes, int x, int y, int stride, out byte r, out byte g, out byte b)
 
        {
 
            int pixelStart = (y * stride) + (x * 3);
 
                    r = pixBytes[pixelStart];
 
                    g = pixBytes[pixelStart + 1];
 
                    b = pixBytes[pixelStart + 2];
 
        }
 

	
 
        private bool IsDarkPixel(int r, int g, int b)
 
        {
 
            return ((r < 0x46) && (g < 0x46) && (b < 0x47));
 
        }
 

	
 
        private bool IsColorMatch(byte test_r, byte test_g, byte test_b, byte target_r, byte target_g, byte target_b)
...
 
@@ -286,149 +386,171 @@ namespace DesertPaintLab
 
                colorMatch = true;
 
                for (int i = 2; i < swatchHeight - (2 * pixelMultiplier); ++i)
 
                {
 
                    otherPixelStart = pixelStart + (stride * i);
 
                    if (!IsColorMatch(pixel_r, pixel_g, pixel_b, pixBytes[otherPixelStart], pixBytes[otherPixelStart + 1], pixBytes[otherPixelStart + 2]))
 
                    {
 
                        colorMatch = false;
 
                        break;
 
                    }
 
                }
 

	
 
                if (colorMatch)
 
                {
 
                    // WE FOUND THE SWATCH!
 
                    // Now we know where the color bars are.
 
                    redPixelStart = pixelStart + (redBarSpacing * stride);
 
                    int redPixel = redPixelStart;
 
                    int redPixelCount = 0;
 
                    while ((pixBytes[redPixelStart] > 0x9F) &&
 
                           (pixBytes[redPixelStart + 1] < 0x62) &&
 
                           (pixBytes[redPixelStart + 2] < 0x62))
 
                    while ((pixBytes[redPixel] > 0x9F) &&
 
                           (pixBytes[redPixel + 1] < 0x62) &&
 
                           (pixBytes[redPixel + 2] < 0x62))
 
                    {
 
                        redPixelCount++;
 
                        // pixBytes[redPixelStart] = 0x00;
 
                        // pixBytes[redPixelStart + 1] = 0xFF;
 
                        // pixBytes[redPixelStart + 2] = 0xFF;
 
                        redPixelStart += 3;
 
                        // pixBytes[redPixel] = 0x00;
 
                        // pixBytes[redPixel + 1] = 0xFF;
 
                        // pixBytes[redPixel + 2] = 0xFF;
 
                        redPixel += 3;
 
                    }
 
                    WriteLog("Color {0}, {1}, {2} is no longer red at {3},{4}", pixBytes[redPixelStart], pixBytes[redPixelStart + 1], pixBytes[redPixelStart + 2], (redPixelStart % stride)/3, redPixelStart / stride);
 
                    WriteLog("Color {0}, {1}, {2} is no longer red at {3},{4}", pixBytes[redPixel], pixBytes[redPixel + 1], pixBytes[redPixel + 2], (redPixel % stride)/3, redPixel / stride);
 

	
 
                    reactedColor.Red = (byte)Math.Round((float)redPixelCount * 255f / (float)colorBarWidth);
 
                    int greenPixelStart = pixelStart + (greenBarSpacing * stride);
 

	
 
                    int greenPixelCount = 0;
 
                    while ((pixBytes[greenPixelStart] < 0x62) &&
 
                           (pixBytes[greenPixelStart + 1] > 0x9F) &&
 
                           (pixBytes[greenPixelStart + 2] < 0x62))
 
                    {
 
                        greenPixelCount++;
 
                        // pixBytes[greenPixelStart] = 0x00;
 
                        // pixBytes[greenPixelStart + 1] = 0xFF;
 
                        // pixBytes[greenPixelStart + 2] = 0xFF;
 
                        greenPixelStart += 3;
 
                    }
 
                    WriteLog("Color {0}, {1}, {2} is no longer green at pixel offset {3},{4}", pixBytes[greenPixelStart], pixBytes[greenPixelStart + 1], pixBytes[greenPixelStart + 2], (greenPixelStart % stride)/3, redPixelStart / stride);
 
                    WriteLog("Color {0}, {1}, {2} is no longer green at pixel offset {3},{4}", pixBytes[greenPixelStart], pixBytes[greenPixelStart + 1], pixBytes[greenPixelStart + 2], (greenPixelStart % stride)/3, greenPixelStart / stride);
 

	
 
                    reactedColor.Green = (byte)Math.Round((float)greenPixelCount * 255f / (float)colorBarWidth);
 
                    int bluePixelStart = pixelStart + (blueBarSpacing * stride);
 

	
 
                    int bluePixelCount = 0;
 
                    while ((pixBytes[bluePixelStart] < 0x62) &&
 
                        (pixBytes[bluePixelStart + 1] < 0x62) &&
 
                        (pixBytes[bluePixelStart + 2] > 0x9F))
 
                    {
 
                        bluePixelCount++;
 
                        // pixBytes[bluePixelStart] = 0x00;
 
                        // pixBytes[bluePixelStart + 1] = 0xFF;
 
                        // pixBytes[bluePixelStart + 2] = 0xFF;
 
                        bluePixelStart += 3;
 
                    }
 
                    WriteLog("Color {0}, {1}, {2} is no longer blue at pixel offset {3},{4}", pixBytes[bluePixelStart], pixBytes[bluePixelStart + 1], pixBytes[bluePixelStart + 2], (bluePixelStart % stride)/3, bluePixelStart / stride);
 

	
 
                    reactedColor.Blue = (byte)Math.Round((float)bluePixelCount * 255f / (float)colorBarWidth);
 
                    WriteLog("Found the color swatch at {0}, {1}. Color={2} Red={3}px Green={4}px Blue={5}px", x, y, reactedColor, redPixelCount, greenPixelCount, bluePixelCount);
 
                    return true;
 
                }
 
            }
 
            return false;
 
        }
 

	
 
        unsafe public bool CaptureReaction(byte* pixBytes, int screenshotWidth, int screenshotHeight, int stride, ref PaintColor reactedColor, ref int redPixelStart)
 
        unsafe public bool CaptureReaction(byte* pixBytes, int screenshotWidth, int screenshotHeight, int stride)
 
        {
 
            PaintColor reactedColor = new PaintColor();
 
            int redPixelStart = 0;
 
            ScreenWidth = screenshotWidth;
 
            ScreenHeight = screenshotHeight;
 

	
 
            IsCaptured = false;
 
            if (!firstRun)
 
            {
 
                // If this is not the first run, let's check the last location, to see if the UI is still there.
 
                if (TestPosition(lastSwatchX, lastSwatchY, pixBytes, screenshotWidth, screenshotHeight, stride, ref reactedColor, ref redPixelStart))
 
                {
 
                    IsCaptured = true;
 
                    RedBarX = (redPixelStart % stride) / 3;
 
                    RedBarY = redPixelStart / stride;
 
                    RecordedColor = reactedColor;
 
                    return true;
 
                }
 
                else
 
                {
 
                    firstRun = true;
 
                }
 
            }
 

	
 
            for (int x = 0; x < screenshotWidth - colorBarWidth; ++x)
 
            for (X = 0; X < screenshotWidth - colorBarWidth; ++X)
 
            {
 
                for (int y = 0; y < (screenshotHeight - (blueBarSpacing + 1)  /*53*/); ++y)
 
                for (int Y = 0; Y < (screenshotHeight - (blueBarSpacing + 10)  /*53*/); ++Y)
 
                {
 
                    if (TestPosition(x, y, pixBytes, screenshotWidth, screenshotHeight, stride, ref reactedColor, ref redPixelStart))
 
                    if (TestPosition(X, Y, pixBytes, screenshotWidth, screenshotHeight, stride, ref reactedColor, ref redPixelStart))
 
                    {
 
                        lastSwatchX = x;
 
                        lastSwatchY = y;
 
                        RedBarX = (redPixelStart % stride) / 3;
 
                        RedBarY = redPixelStart / stride;
 
                        RecordedColor = reactedColor;
 
                        lastSwatchX = X;
 
                        lastSwatchY = Y;
 
                        firstRun = false;
 
                        IsCaptured = true;
 
                        return true;
 
                    }
 
                    OnCaptureProgress?.Invoke(X, Y);
 
                }
 
            }
 
            return false;
 
        }
 

	
 
        public bool RecordReaction(PlayerProfile profile, PaintColor expectedColor, PaintColor reactedColor, Reagent[] reagents)
 
        {
 
            bool saved = false;
 
            int r, g, b;
 
            if (reagents[2] != null)
 
            {
 
                // A 3-reagent reaction.
 
                Reaction reaction1 = profile.FindReaction(reagents[0], reagents[1]);
 
                Reaction reaction2 = profile.FindReaction(reagents[0], reagents[2]);
 
                Reaction reaction3 = profile.FindReaction(reagents[1], reagents[2]);
 
                
 
                r = reactedColor.Red - expectedColor.Red;
 
                g = reactedColor.Green - expectedColor.Green;
 
                b = reactedColor.Blue - expectedColor.Blue;
 
                
 
                if (reaction2 == null)
 
                {
 
                    r = r - reaction1.Red - reaction3.Red;
 
                    g = g - reaction1.Green - reaction3.Green;
 
                    b = b - reaction1.Blue - reaction3.Blue;
 
                    profile.SetReaction(reagents[0], reagents[2], new Reaction(r, g, b));
 
                    Reaction reaction = new Reaction(r, g, b);
 
                    profile.SetReaction(reagents[0], reagents[2], reaction);
 
                    profile.Save();
 
                    saved = true;
 
                    OnReactionRecorded?.Invoke(reagents[0], reagents[2], reaction);
 
                }
 
                else if (reaction3 == null)
 
                {
 
                    r = r - reaction1.Red - reaction2.Red;
 
                    g = g - reaction1.Green - reaction2.Green;
 
                    b = b - reaction1.Blue - reaction2.Blue;
 
                    profile.SetReaction(reagents[1], reagents[2], new Reaction(r, g, b));
 
                    Reaction reaction = new Reaction(r, g, b);
 
                    profile.SetReaction(reagents[1], reagents[2], reaction);
 
                    profile.Save();
 
                    saved = true;
 
                }   
 
                    OnReactionRecorded?.Invoke(reagents[1], reagents[2], reaction);
 
                }
 
            }
 
            else if ((reagents[0] != null) && (reagents[1] != null))
 
            {
 
                // A 2-reagent reaction.
 
                r = reactedColor.Red - expectedColor.Red;
 
                g = reactedColor.Green - expectedColor.Green;
 
                b = reactedColor.Blue - expectedColor.Blue;
 
                profile.SetReaction(reagents[0], reagents[1], new Reaction(r, g, b));
 
                Reaction reaction = new Reaction(r, g, b);
 
                profile.SetReaction(reagents[0], reagents[1], reaction);
 
                profile.Save();
 
                saved = true;
 
                OnReactionRecorded?.Invoke(reagents[0], reagents[1], reaction);
 
            }
 
            return saved;
 
        }
 
    }
 
}
 

	
ReactionStatusWindow.cs
Show inline comments
 
using System;
 

	
 
namespace DesertPaintLab
 
{
 
    public partial class ReactionStatusWindow : Gtk.Window
 
    {
 
        //PlayerProfile profile;
 
        PlayerProfile _profile;
 

	
 
        Gtk.ListStore reagentListStore;
 

	
 
        public ReactionStatusWindow(PlayerProfile profile) : base(Gtk.WindowType.Toplevel)
 
        {
 
            //this.profile = profile;
 
            _profile = profile;
 
            this.Build();
 

	
 
            //Gtk.CellRendererText reagentColumnCell = new Gtk.CellRendererText();
 

	
 
            SetupReagentList();
 

	
 
            int count = 0;
 
            foreach (string name1 in ReagentManager.Names)
 
            {
 
                Reagent reagent1 = ReagentManager.GetReagent(name1);
 
                foreach (string name2 in ReagentManager.Names)
 
                {
 
                    if (name1.Equals(name2))
 
                    {
 
                        continue;
 
                    }
 
                    Reagent reagent2 = ReagentManager.GetReagent(name2);
 
                    Reaction reaction = profile.FindReaction(reagent1, reagent2);
 
                    if (reaction == null)
 
                    {
 
                        if (count == 0)
 
                        {
...
 
@@ -36,19 +40,132 @@ namespace DesertPaintLab
 
                        }
 
                        Gtk.Label label = new Gtk.Label(name1 + " + " + name2);
 
                        resultbox.PackStart(label, false, false, 0);
 

	
 
                        ++count;
 
                    }
 
                }
 
            }
 

	
 
            if (count == 0)
 
            {
 
                Gtk.Label header = new Gtk.Label("All reactions recorded!");
 
                resultbox.PackStart(header, false, false, 0);
 
            }
 
            ShowAll();
 
        }
 

	
 
        public void RefreshReactions()
 
        {
 
            while (resultbox.Children.Length > 0)
 
            {
 
                Gtk.Widget child = resultbox.Children[0];
 
                resultbox.Remove(child);
 
            }
 
            int count = 0;
 
            foreach (string name1 in ReagentManager.Names)
 
            {
 
                Reagent reagent1 = ReagentManager.GetReagent(name1);
 
                foreach (string name2 in ReagentManager.Names)
 
                {
 
                    if (name1.Equals(name2))
 
                    {
 
                        continue;
 
                    }
 
                    Reagent reagent2 = ReagentManager.GetReagent(name2);
 
                    if (!reagent1.Enabled || !reagent2.Enabled) continue;
 
                    Reaction reaction = _profile.FindReaction(reagent1, reagent2);
 
                    if (reaction == null)
 
                    {
 
                        if (count == 0)
 
                        {
 
                            Gtk.Label header = new Gtk.Label("Missing Reactions:");
 
                            resultbox.PackStart(header, false, false, 0);
 
                            Gtk.HSeparator sep = new Gtk.HSeparator();
 
                            resultbox.PackStart(sep, false, false, 0);
 
                        }
 
                        Gtk.Label label = new Gtk.Label(name1 + " + " + name2);
 
                        resultbox.PackStart(label, false, false, 0);
 

	
 
                        ++count;
 
                    }
 
                }
 
            }
 

	
 
            if (count == 0)
 
            {
 
                Gtk.Label header = new Gtk.Label("All reactions recorded!");
 
                resultbox.PackStart(header, false, false, 0);
 
            }
 
            ShowAll();
 
        }
 

	
 
        private void OnReagentToggled(object o, Gtk.ToggledArgs args)
 
        {
 
            Gtk.TreeIter iter;
 
            reagentListStore.GetIter(out iter, new Gtk.TreePath(args.Path));
 

	
 
            Reagent reagent = (Reagent)reagentListStore.GetValue(iter, 0);
 
            reagent.Enabled = !reagent.Enabled;
 
            // TODO: SaveReagentSettings();
 
            RefreshReactions();
 
        }
 

	
 
        // Reagent view handling
 
        private void RenderReagentToggle(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
 
        {
 
            Reagent reagent = (Reagent)model.GetValue(iter, 0);
 
            Gtk.CellRendererToggle toggle = (cell as Gtk.CellRendererToggle);
 
            toggle.Active = reagent.Enabled;
 
            toggle.Activatable = !reagent.IsCatalyst;
 
            toggle.Mode = reagent.IsCatalyst ? Gtk.CellRendererMode.Inert : Gtk.CellRendererMode.Activatable;
 
        }
 

	
 
        void SetupReagentList()
 
        {
 
            // initialize reagent list
 
            reagentListStore = new Gtk.ListStore(typeof(Reagent), typeof(string), typeof(Reagent), typeof(Reagent));
 
            foreach (string reagentName in ReagentManager.Names)
 
            {
 
                Reagent reagent = ReagentManager.GetReagent(reagentName);
 
                reagentListStore.AppendValues(reagent, reagentName); // , reagent, reagent);
 
            }
 

	
 
            // Add the columns to the TreeView
 
            Gtk.TreeViewColumn reagentEnabledColumn = new Gtk.TreeViewColumn();
 
            reagentEnabledColumn.Title = "Enabled";
 
            Gtk.CellRendererToggle reagentEnabledCell = new Gtk.CellRendererToggle();
 
            reagentEnabledCell.Activatable = true;
 
            reagentEnabledCell.Sensitive = true;
 
            reagentEnabledCell.Mode = Gtk.CellRendererMode.Activatable;
 
            reagentEnabledCell.Visible = true;
 
            reagentEnabledCell.Toggled += new Gtk.ToggledHandler(OnReagentToggled);
 
            reagentEnabledColumn.PackStart(reagentEnabledCell, true);
 
            //reagentEnabledColumn.AddAttribute(reagentEnabledCell, "active", 0);
 

	
 
            Gtk.TreeViewColumn reagentNameColumn = new Gtk.TreeViewColumn();
 
            reagentNameColumn.Title = "Ingredient";
 
            Gtk.CellRendererText reagentNameCell = new Gtk.CellRendererText();
 
            reagentNameCell.Mode = Gtk.CellRendererMode.Inert;
 
            reagentNameColumn.PackStart(reagentNameCell, true);
 
            reagentNameColumn.AddAttribute(reagentNameCell, "text", 1);
 
            reagentNameColumn.Expand = true;
 

	
 
            reagentListStore = new Gtk.ListStore(typeof(Reagent), typeof(string), typeof(Reagent), typeof(Reagent));
 
            foreach (string reagentName in ReagentManager.Names)
 
            {
 
                Reagent reagent = ReagentManager.GetReagent(reagentName);
 
                reagentListStore.AppendValues(reagent, reagentName); // , reagent, reagent);
 
            }
 

	
 
            reagentEnabledColumn.SetCellDataFunc(reagentEnabledCell, new Gtk.TreeCellDataFunc(RenderReagentToggle));
 

	
 
            // Assign the model to the TreeView
 
            reagentListView.Model = reagentListStore;
 
            reagentListView.Sensitive = true;
 

	
 
            reagentListView.AppendColumn(reagentEnabledColumn);
 
            reagentListView.AppendColumn(reagentNameColumn);
 
        }
 
    }
 
}
 

	
ScreenCheckDialog.cs
Show inline comments
...
 
@@ -37,35 +37,78 @@ namespace DesertPaintLab
 
				screenWidthEntry.Text = value.ToString(); 
 
			}
 
		}
 

	
 
		public int ScreenHeight
 
		{
 
			get
 
			{
 
				return int.Parse(screenHeightEntry.Text);	
 
			}	
 
			set
 
			{
 
				screenHeightEntry.Text = value.ToString();
 
			}
 
		}
 

	
 
		public int GamePixelWidth
 
        private int _detectedScreenWidth;
 
        private int _detectedScreenHeight;
 
        public int DetectedScreenWidth
 
        {
 
            get
 
            {
 
                return _detectedScreenWidth;
 
            }
 
            set
 
            {
 
                _detectedScreenWidth = value;
 
                detectedResolutionLabel.Text = string.Format("Detected: {0} x {1}", _detectedScreenWidth, _detectedScreenHeight);
 
            }
 
        }
 

	
 
        public int DetectedScreenHeight
 
        {
 
            get
 
            {
 
                return _detectedScreenHeight;
 
            }
 
            set
 
            {
 
                _detectedScreenHeight = value;
 
                detectedResolutionLabel.Text = string.Format("Detected: {0} x {1}", _detectedScreenWidth, _detectedScreenHeight);
 
            }
 
        }
 

	
 
        public int GamePixelWidth
 
		{
 
			get
 
			{
 
				return int.Parse(gamePixelWidthEntry.Text);	
 
			}	
 
			set
 
			{
 
				gamePixelWidthEntry.Text = value.ToString();
 
			}
 
		}
 

	
 
        public InterfaceSize InterfaceSize
 
        {
 
            get
 
            {
 
                InterfaceSize result = (InterfaceSize)interfaceSizeComboBox.Active;
 
                return result;
 
            }
 
            set
 
            {
 
                Gtk.TreeIter iter;
 
                interfaceSizeComboBox.Model.IterNthChild(out iter, (int)value);
 
                interfaceSizeComboBox.SetActiveIter(iter);
 
            }
 
        }
 

	
 
		public ScreenCheckDialog ()
 
		{
 
			this.Build ();
 
		}
 
	}
 
}
 

	
UI/CaptureView.cs
Show inline comments
 
using System;
 
using System.IO;
 
using System.Threading;
 

	
 
namespace DesertPaintLab
 
{
 
    [System.ComponentModel.ToolboxItem(true)]
 
    public partial class CaptureView : Gtk.Bin
 
    {
 

	
 
        Reagent[] reagents = new Reagent[3];
 
        PaintRecipe recipe = new PaintRecipe();
 

	
 
        PaintColor expectedColor = new PaintColor();
 
        PaintColor reactedColor = new PaintColor();
 

	
 
        PlayerProfile profile = null;
 

	
 
        Gdk.Pixbuf screenBuffer = null;
 

	
 
        Gtk.ThreadNotify notifyCaptureProgress;
 
        Gtk.ThreadNotify notifyCaptureComplete;
 

	
 
        bool recordEnabled = true;
 
        bool isCaptured = false;
 

	
 
        public CaptureView(PlayerProfile profile, Gdk.Pixbuf screenBuffer) : base()
 
        {
 
            this.profile = profile;
 
            this.screenBuffer = screenBuffer;
 

	
 
            this.Build();
 

	
 
            reagents[0] = null;
 
            reagents[1] = null;
 
            reagents[2] = null;
 

	
 
            if (unmodifiedSwatch != null)
 
            {
 
                unmodifiedSwatch.Clear();
 
            }
 
            if (reactionSwatch != null)
 
            {
 
                reactionSwatch.Clear();
 
            }
 

	
 
            PopulateDropDowns();
 
            recipe.Reactions = profile.Reactions;
 
        }
 

	
 
        public Gdk.Pixbuf ScreenBuffer
 
        {
 
            get { return screenBuffer; }
 
            set {
 
                if (screenBuffer != null)
 
                {
 
                    // TODO: free it up?
 
                }
 
                screenBuffer = value;
 
            }
 
        }
 

	
 
        public PlayerProfile Profile
 
        {
 
            set {
 
                profile = value;
 
                PopulateDropDowns();
 
                recipe.Reactions = profile.Reactions;
 
                UpdateIngredients();
 
                // TODO: reset views
 
            }
 
        }
 

	
 
        public void DisableRecord()
 
        {
 
            recordEnabled = false;
 
            recordButton.Sensitive = false;
 
        }
...
 
@@ -231,183 +247,265 @@ namespace DesertPaintLab
 
        
 
            expectedColor.Set(recipe.BaseColor);
 
            unmodifiedSwatch.Color = expectedColor;
 
            //SetExpectedColor(recipeColor.Red, recipeColor.Green, recipeColor.Blue);
 
            
 
            if (reactionKnown)
 
            {
 
                reactedColor.Set(recipe.ReactedColor);
 
                reactionSwatch.Color = reactedColor;
 
            }
 
            else
 
            {
 
                reactionSwatch.Clear(); 
 
            }
 
        }
 

	
 
        unsafe bool CaptureReactionColor()
 
        unsafe void BeginCapture()
 
        {
 
            // Take a screenshot.
 
            int screenWidth, screenHeight;
 
            bool debugScreenshot = false;
 
            captureButton.Sensitive = false;
 
            ingredient1ComboBox.Sensitive = false;
 
            ingredient2ComboBox.Sensitive = false;
 
            ingredient3ComboBox.Sensitive = false;
 
            clearReactionButton.Sensitive = false;
 

	
 
            progressBar.Show();
 
            recordButton.Hide();
 

	
 
            bool enableDebugMenu = false;
 
            Gdk.Window rootWindow = Gdk.Global.DefaultRootWindow;
 
            DesertPaintLab.AppSettings.Get("ScreenWidth", out screenWidth);
 
            DesertPaintLab.AppSettings.Get("ScreenHeight", out screenHeight);
 
            DesertPaintLab.AppSettings.Get("EnableDebugMenu", out enableDebugMenu);
 
            DesertPaintLab.AppSettings.Get("DebugScreenshot", out debugScreenshot);
 
            Gdk.Image rootImage = rootWindow.GetImage(0, 0, screenWidth, screenHeight);
 
            screenBuffer.GetFromImage(rootImage, rootImage.Colormap, 0, 0, 0, 0, screenWidth, screenHeight);
 
            rootImage.Unref();
 
            System.GC.Collect(); // really, clean up now
 
            //screenBuffer.GetFromDrawable(rootWindow,
 
            //  rootWindow.Colormap, 0, 0, 0, 0, screenWidth, screenHeight);
 
            int stride = screenBuffer.Rowstride;
 
            byte* pixBytes = (byte*)screenBuffer.Pixels;
 
            int redPixelStart = -1;
 

	
 
            StreamWriter log = null;
 
            if (enableDebugMenu)
 
            {
 
                string logfile = FileUtils.FindNumberedFile("DesertPaintLab_Capture", "log", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
 
                log = new StreamWriter(logfile);
 
                ReactionRecorder.Instance.Log = log;
 
            }
 
            isCaptured = ReactionRecorder.Instance.CaptureReaction(pixBytes, screenWidth, screenHeight, stride, ref reactedColor, ref redPixelStart);
 

	
 
            if (notifyCaptureProgress == null)
 
            {
 
                notifyCaptureProgress = new Gtk.ThreadNotify(new Gtk.ReadyEvent(NotifyCaptureProgress));
 
                notifyCaptureComplete = new Gtk.ThreadNotify(new Gtk.ReadyEvent(NotifyCaptureComplete));
 
            }
 

	
 
            this.reactionSwatch.Color = new PaintColor("Searching", "00", "00", "00");
 

	
 
            Thread thr = new Thread(new ThreadStart(this.CaptureReactionThread));
 
            thr.Priority = ThreadPriority.AboveNormal;
 
            thr.Start();
 
            //OnCaptureComplete(isCaptured, reactedColor, screenWidth, screenHeight, stride, redPixelStart);
 
        }
 

	
 
        unsafe private void CaptureReactionThread()
 
        {
 
            byte* pixBytes = (byte*)screenBuffer.Pixels;
 

	
 
            ReactionRecorder.Instance.OnCaptureProgress += OnCaptureProgress;
 
            ReactionRecorder.Instance.CaptureReaction(pixBytes, screenBuffer.Width, screenBuffer.Height, screenBuffer.Rowstride);
 
            ReactionRecorder.Instance.OnCaptureProgress -= OnCaptureProgress;
 

	
 
            notifyCaptureComplete.WakeupMain();
 
        }
 

	
 
        private void OnCaptureProgress(int x, int y)
 
        {
 
            notifyCaptureProgress.WakeupMain();
 
        }
 

	
 
        private void NotifyCaptureProgress()
 
        {
 
            // TODO: progress bar
 
            //ReactionRecorder.Instance.X;
 
            //ReactionRecorder.Instance.Y;
 
            progressBar.Fraction = ((double)(ReactionRecorder.Instance.X) / (double)(ReactionRecorder.Instance.ScreenWidth - ReactionRecorder.Instance.ColorBarWidth));
 
        }
 

	
 
        void OnCaptureComplete(bool isCaptured, PaintColor reactedColor, int swatchX, int swatchY)
 
        {
 
            int screenWidth = screenBuffer.Width;
 
            int screenHeight = screenBuffer.Height;
 
            int stride = screenBuffer.Rowstride;
 

	
 
            StreamWriter log = ReactionRecorder.Instance.Log;
 
            if (log != null)
 
            {
 
                log.Flush();
 
                log.Close();
 
                log = null;
 
                ReactionRecorder.Instance.Log = null;
 
            }
 

	
 
            bool enableDebugMenu = false;
 
            DesertPaintLab.AppSettings.Get("EnableDebugMenu", out enableDebugMenu);
 
            bool debugScreenshot = false;
 
            DesertPaintLab.AppSettings.Get("DebugScreenshot", out debugScreenshot);
 
            if (enableDebugMenu && debugScreenshot)
 
            {
 
                if (!isCaptured)
 
                {
 
                    // write out the whole screenshot on a failure to capture
 
                    string screenshotDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
 
                    string filename = FileUtils.FindNumberedFile("DesertPaintLab_Colormatch", "png", screenshotDir);
 
                    screenBuffer.Save(filename, "png");
 
                }
 
                else
 
                {
 
                    // record the swatch that was captured
 
                    // convert to pixel offset instead of byte
 
                    int redPixelStartX = (redPixelStart % stride) / 3;
 
                    int redPixelStartY = (redPixelStart / stride);
 
                    // write out the screenshot
 
                    string screenshotDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
 
                    string filename = FileUtils.FindNumberedFile("DesertPaintLab_Colormatch", "png", screenshotDir);
 
                    int captureAreaWidth = Math.Min(64, screenWidth - redPixelStartX + 64);
 
                    int captureAreaHeight = Math.Min(64, screenHeight - redPixelStartY + 64);
 
                    Gdk.Pixbuf outPixBuf = new Gdk.Pixbuf(screenBuffer, Math.Max(0, redPixelStartX - 32), Math.Max(0, redPixelStartY - 32), captureAreaWidth, captureAreaHeight);
 
                    int x = swatchX - 16;
 
                    int captureAreaWidth = ReactionRecorder.Instance.ColorBarWidth + 32;
 
                    captureAreaWidth = Math.Min(screenWidth - x, captureAreaWidth);
 
                    int y = swatchY - 16;
 
                    int captureAreaHeight = ReactionRecorder.Instance.BlueBarSpacing + 42;
 
                    captureAreaHeight = Math.Min(screenHeight - y, captureAreaHeight);
 

	
 
                    Gdk.Pixbuf outPixBuf = new Gdk.Pixbuf(screenBuffer, Math.Max(0, x), Math.Max(0, y), 
 
                        captureAreaWidth, captureAreaHeight);
 
                    //Gdk.Pixbuf outPixBuf = new Gdk.Pixbuf(screenBuffer, Math.Max(0, redPixelStartX), Math.Max(0, redPixelStartY),
 
                    //    ReactionRecorder.Instance.ColorBarWidth, ReactionRecorder.Instance.GreenBarSpacing - ReactionRecorder.Instance.RedBarSpacing);
 
                    //screenBuffer.Save(filename, "png");
 
                    outPixBuf.Save(filename, "png");
 
                }
 
            }
 
            //screenBuffer.Save("screenshot.png", "png");
 
            
 
            return isCaptured;
 
        }
 

	
 
        protected virtual void OnCapture(object sender, System.EventArgs e)
 
        {
 
            if (CaptureReactionColor())
 
            if (isCaptured)
 
            {
 
                string warning = "";
 
                if (reactedColor.Red == 0)
 
                {
 
                    warning = warning + "\nRed is too low.";
 
                }
 
                if (reactedColor.Green == 0)
 
                {
 
                    warning = warning + "\nGreen is too low.";  
 
                    warning = warning + "\nGreen is too low.";
 
                }
 
                if (reactedColor.Blue == 0)
 
                {
 
                    warning = warning + "\nBlue is too low.";   
 
                    warning = warning + "\nBlue is too low.";
 
                }
 
                if (reactedColor.Red == 255)
 
                {
 
                    warning = warning + "\nRed is too high.";
 
                }
 
                if (reactedColor.Green == 255)
 
                {
 
                    warning = warning + "\nGreen is too high."; 
 
                    warning = warning + "\nGreen is too high.";
 
                }
 
                if (reactedColor.Blue == 255)
 
                {
 
                    warning = warning + "\nBlue is too high.";  
 
                    warning = warning + "\nBlue is too high.";
 
                }
 
                
 

 
                if (warning.Length != 0)
 
                {
 
                    isCaptured = true;
 
                    Gtk.MessageDialog md = new Gtk.MessageDialog((Gtk.Window)Toplevel, 
 
                    Gtk.MessageDialog md = new Gtk.MessageDialog((Gtk.Window)Toplevel,
 
                    Gtk.DialogFlags.DestroyWithParent,
 
                    Gtk.MessageType.Error, Gtk.ButtonsType.Ok, 
 
                    Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
 
                    "Reaction clipped.  You will need to do a " +
 
                    "3-way reaction to test this pair.  Details: " +
 
                    warning);
 
           
 

 
                    md.Run();
 
                    md.Destroy();
 
                }
 
                else
 
                {
 
                    this.reactionSwatch.Color = reactedColor;
 
                    recordButton.Sensitive = recordEnabled;
 
                }
 

	
 
                captureButton.Sensitive = false;
 
            }
 
            else
 
            {
 
                Gtk.MessageDialog md = new Gtk.MessageDialog((Gtk.Window)Toplevel, 
 
                Gtk.MessageDialog md = new Gtk.MessageDialog((Gtk.Window)Toplevel,
 
                    Gtk.DialogFlags.DestroyWithParent,
 
                    Gtk.MessageType.Error, Gtk.ButtonsType.Ok, 
 
                    Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
 
                    "Pigment Lab dialog box NOT FOUND.  Please ensure " +
 
                    "that there is an unobstructed view of the dialog " +
 
                    "and that your interface size is set to 'small' " +
 
                    "when you press the Capture button.");
 
           
 

 
                md.Run();
 
                md.Destroy();   
 
                md.Destroy();
 
            }
 

	
 
            progressBar.Hide();
 
            recordButton.Show();
 

	
 
            ingredient1ComboBox.Sensitive = true;
 
            ingredient2ComboBox.Sensitive = true;
 
            ingredient3ComboBox.Sensitive = false;
 
            UpdateIngredients();
 
        }
 

	
 
        private void NotifyCaptureComplete()
 
        {
 
            OnCaptureComplete(
 
                ReactionRecorder.Instance.IsCaptured,
 
                ReactionRecorder.Instance.RecordedColor,
 
                ReactionRecorder.Instance.SwatchX,
 
                ReactionRecorder.Instance.SwatchY);
 
        }
 

	
 
        unsafe void CaptureReactionColor()
 
        {
 
            // Take a screenshot.
 
            int screenWidth, screenHeight;
 
            Gdk.Window rootWindow = Gdk.Global.DefaultRootWindow;
 
            DesertPaintLab.AppSettings.Get("ScreenWidth", out screenWidth);
 
            DesertPaintLab.AppSettings.Get("ScreenHeight", out screenHeight);
 
            Gdk.Image rootImage = rootWindow.GetImage(0, 0, screenWidth, screenHeight);
 
            screenBuffer.GetFromImage(rootImage, rootImage.Colormap, 0, 0, 0, 0, screenWidth, screenHeight);
 
            rootImage.Unref();
 
            System.GC.Collect(); // really, clean up now
 

	
 
            BeginCapture();
 
        }
 

	
 
        protected virtual void OnCapture(object sender, System.EventArgs e)
 
        {
 
            CaptureReactionColor();
 
        }
 
        
 
        protected virtual void OnRecord(object sender, System.EventArgs e)
 
        {
 
            if (ReactionRecorder.Instance.RecordReaction(profile, expectedColor, reactedColor, reagents))
 
            {
 
                recordButton.Sensitive = false;
 
            }
 
        }
 
        
 
        protected virtual void OnChangedIngredient1(object sender, System.EventArgs e)
 
        {
 
            UpdateIngredients();
 
        }
 
        
 
        protected virtual void OnChangedIngredient2(object sender, System.EventArgs e)
 
        {
 
            UpdateIngredients();
 
        }
 
        
 
        protected virtual void OnChangedIngredient3(object sender, System.EventArgs e)
 
        {
 
            UpdateIngredients();
 
    
 
        }
 
        
 
        protected void OnClearReaction(object sender, EventArgs e)
 
        {
 
            string reagentName1 = GetSelectedReagentName(1);
 
            string reagentName2 = GetSelectedReagentName(2);
 
            string reagentName3 = GetSelectedReagentName(3);
 

	
 
            if ((reagentName1 != null) && (reagentName2 != null) && (reagentName3 == null))
 
            {
 
                Reagent reagent1 = ReagentManager.GetReagent(reagentName1);
 
                Reagent reagent2 = ReagentManager.GetReagent(reagentName2);
 

	
 
                if (null != profile.FindReaction(reagent1, reagent2))
 
                {
 
                    Gtk.MessageDialog md = new Gtk.MessageDialog((Gtk.Window)Toplevel, 
gtk-gui/DesertPaintLab.CaptureView.cs
Show inline comments
...
 
@@ -45,33 +45,35 @@ namespace DesertPaintLab
 
		private global::Gtk.Button captureButton;
 
		
 
		private global::Gtk.Label unmodifiedLabel;
 
		
 
		private global::Gtk.Frame reactedColorFrame;
 
		
 
		private global::Gtk.Alignment GtkAlignment2;
 
		
 
		private global::Gtk.VBox vbox4;
 
		
 
		private global::DesertPaintLab.PaintSwatch reactionSwatch;
 
		
 
		private global::Gtk.Button recordButton;
 
		
 
		private global::Gtk.Label reactionLabel;
 

	
 
		protected virtual void Build ()
 
        private global::Gtk.ProgressBar progressBar;
 

	
 
        protected virtual void Build ()
 
		{
 
			global::Stetic.Gui.Initialize (this);
 
			// Widget DesertPaintLab.CaptureView
 
			global::Stetic.BinContainer.Attach (this);
 
			this.Name = "DesertPaintLab.CaptureView";
 
			// Container child DesertPaintLab.CaptureView.Gtk.Container+ContainerChild
 
			this.hbox1 = new global::Gtk.HBox ();
 
			this.hbox1.Name = "hbox1";
 
			this.hbox1.Spacing = 6;
 
			// Container child hbox1.Gtk.Box+BoxChild
 
			this.selectIngredientsFrame = new global::Gtk.Frame ();
 
			this.selectIngredientsFrame.Name = "selectIngredientsFrame";
 
			this.selectIngredientsFrame.BorderWidth = ((uint)(4));
 
			// Container child selectIngredientsFrame.Gtk.Container+ContainerChild
 
			this.GtkAlignment = new global::Gtk.Alignment (0F, 0F, 1F, 1F);
 
			this.GtkAlignment.Name = "GtkAlignment";
...
 
@@ -238,55 +240,66 @@ namespace DesertPaintLab
 
			this.GtkAlignment2.RightPadding = ((uint)(5));
 
			this.GtkAlignment2.BottomPadding = ((uint)(6));
 
			// Container child GtkAlignment2.Gtk.Container+ContainerChild
 
			this.vbox4 = new global::Gtk.VBox ();
 
			this.vbox4.WidthRequest = 120;
 
			this.vbox4.Name = "vbox4";
 
			this.vbox4.Spacing = 6;
 
			// Container child vbox4.Gtk.Box+BoxChild
 
			this.reactionSwatch = new global::DesertPaintLab.PaintSwatch ();
 
			this.reactionSwatch.WidthRequest = 120;
 
			this.reactionSwatch.HeightRequest = 120;
 
			this.reactionSwatch.Events = ((global::Gdk.EventMask)(256));
 
			this.reactionSwatch.Name = "reactionSwatch";
 
			this.vbox4.Add (this.reactionSwatch);
 
			global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.vbox4 [this.reactionSwatch]));
 
			w19.Position = 0;
 
			// Container child vbox4.Gtk.Box+BoxChild
 
			this.recordButton = new global::Gtk.Button ();
 

	
 
            this.progressBar = new global::Gtk.ProgressBar();
 
            this.progressBar.Name = "progressBar";
 
            this.vbox4.Add(this.progressBar);
 
            global::Gtk.Box.BoxChild wProgress = ((global::Gtk.Box.BoxChild)(this.vbox4[this.progressBar]));
 
            wProgress.PackType = ((global::Gtk.PackType)(1));
 
            wProgress.Position = 1;
 
            wProgress.Expand = false;
 
            wProgress.Fill = false;
 

	
 
            // Container child vbox4.Gtk.Box+BoxChild
 
            this.recordButton = new global::Gtk.Button ();
 
			this.recordButton.CanFocus = true;
 
			this.recordButton.Name = "recordButton";
 
			this.recordButton.UseUnderline = true;
 
			this.recordButton.Label = "Record";
 
			this.vbox4.Add (this.recordButton);
 
			global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.vbox4 [this.recordButton]));
 
			w20.Position = 1;
 
			w20.Position = 2;
 
			w20.Expand = false;
 
			w20.Fill = false;
 
			this.GtkAlignment2.Add (this.vbox4);
 
			this.reactedColorFrame.Add (this.GtkAlignment2);
 
			this.reactionLabel = new global::Gtk.Label ();
 
			this.reactionLabel.Name = "reactionLabel";
 
			this.reactionLabel.LabelProp = "<b>Reacted</b>";
 
			this.reactionLabel.UseMarkup = true;
 
			this.reactionLabel.Justify = ((global::Gtk.Justification)(2));
 
			this.reactedColorFrame.LabelWidget = this.reactionLabel;
 
			this.hbox1.Add (this.reactedColorFrame);
 
			global::Gtk.Box.BoxChild w23 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.reactedColorFrame]));
 
			w23.Position = 2;
 
			w23.Position = 3;
 
			w23.Expand = false;
 
			w23.Fill = false;
 
			this.Add (this.hbox1);
 
			if ((this.Child != null)) {
 
				this.Child.ShowAll ();
 
			}
 
			this.clearReactionButton.Hide ();
 
			this.Hide ();
 
            this.progressBar.Hide();
 
            this.Hide ();
 
			this.ingredient1ComboBox.Changed += new global::System.EventHandler (this.OnChangedIngredient1);
 
			this.ingredient2ComboBox.Changed += new global::System.EventHandler (this.OnChangedIngredient2);
 
			this.ingredient3ComboBox.Changed += new global::System.EventHandler (this.OnChangedIngredient3);
 
			this.clearReactionButton.Clicked += new global::System.EventHandler (this.OnClearReaction);
 
			this.captureButton.Clicked += new global::System.EventHandler (this.OnCapture);
 
			this.recordButton.Clicked += new global::System.EventHandler (this.OnRecord);
 
		}
 
	}
 
}
gtk-gui/DesertPaintLab.ReactionStatusWindow.cs
Show inline comments
 

	
 
// This file has been generated by the GUI designer. Do not modify.
 
namespace DesertPaintLab
 
{
 
	public partial class ReactionStatusWindow
 
	{
 
		private global::Gtk.ScrolledWindow scroller;
 
        private global::Gtk.HBox hbox1;
 

	
 
        private global::Gtk.Frame ingredientFrame;
 
        private global::Gtk.Alignment ingredientAlignment;
 

	
 
        private global::Gtk.ScrolledWindow scrolledwindow2;
 

	
 
        private global::Gtk.TreeView reagentListView;
 

	
 
        private global::Gtk.Label GtkLabel4;
 

	
 

	
 
        private global::Gtk.ScrolledWindow scroller;
 
		
 
		private global::Gtk.VBox resultbox;
 

	
 
		protected virtual void Build ()
 
		{
 
			global::Stetic.Gui.Initialize (this);
 
			// Widget DesertPaintLab.ReactionStatusWindow
 
			this.Name = "DesertPaintLab.ReactionStatusWindow";
 
			this.Title = "Reaction Status";
 
			this.WindowPosition = ((global::Gtk.WindowPosition)(4));
 
			// Container child DesertPaintLab.ReactionStatusWindow.Gtk.Container+ContainerChild
 
			this.scroller = new global::Gtk.ScrolledWindow ();
 

	
 
            this.hbox1 = new global::Gtk.HBox();
 
            this.hbox1.Name = "hbox1";
 
            this.hbox1.Spacing = 6;
 

	
 
            // Reagent list
 
            // Container child vbox8.Gtk.Box+BoxChild
 
            this.ingredientFrame = new global::Gtk.Frame();
 
            this.ingredientFrame.Name = "frame3";
 
            this.ingredientFrame.ShadowType = ((global::Gtk.ShadowType)(0));
 
            // Container child ingredientFrame.Gtk.Container+ContainerChild
 
            this.ingredientAlignment = new global::Gtk.Alignment(0F, 0F, 1F, 1F);
 
            this.ingredientAlignment.Name = "GtkAlignment1";
 
            this.ingredientAlignment.LeftPadding = ((uint)(12));
 
            // Container child GtkAlignment1.Gtk.Container+ContainerChild
 
            this.scrolledwindow2 = new global::Gtk.ScrolledWindow();
 
            this.scrolledwindow2.CanFocus = true;
 
            this.scrolledwindow2.Name = "scrolledwindow2";
 
            this.scrolledwindow2.ShadowType = ((global::Gtk.ShadowType)(1));
 
            // Container child scrolledwindow2.Gtk.Container+ContainerChild
 
            this.reagentListView = new global::Gtk.TreeView();
 
            this.reagentListView.WidthRequest = 240;
 
            this.reagentListView.CanFocus = true;
 
            this.reagentListView.Name = "reagentListView";
 
            this.scrolledwindow2.Add(this.reagentListView);
 
            this.ingredientAlignment.Add(this.scrolledwindow2);
 
            this.ingredientFrame.Add(this.ingredientAlignment);
 
            this.GtkLabel4 = new global::Gtk.Label();
 
            this.GtkLabel4.Name = "GtkLabel4";
 
            this.GtkLabel4.LabelProp = "<b>Ingredients</b>";
 
            this.GtkLabel4.UseMarkup = true;
 
            this.ingredientFrame.LabelWidget = this.GtkLabel4;
 
            this.hbox1.Add(this.ingredientFrame);
 
            global::Gtk.Box.BoxChild w0 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.ingredientFrame]));
 
            w0.Expand = false;
 
            w0.Fill = true;
 
            w0.Position = 0;
 

	
 

	
 
            // Container child DesertPaintLab.ReactionStatusWindow.Gtk.Container+ContainerChild
 
            this.scroller = new global::Gtk.ScrolledWindow ();
 
            this.scroller.WidthRequest = 300;
 
			this.scroller.CanFocus = true;
 
			this.scroller.Name = "scroller";
 
			this.scroller.ShadowType = ((global::Gtk.ShadowType)(1));
 
			// Container child scroller.Gtk.Container+ContainerChild
 
			global::Gtk.Viewport w1 = new global::Gtk.Viewport ();
 
			w1.ShadowType = ((global::Gtk.ShadowType)(0));
 
			// Container child GtkViewport.Gtk.Container+ContainerChild
 
			this.resultbox = new global::Gtk.VBox ();
 
			this.resultbox.Name = "resultbox";
 
			this.resultbox.Spacing = 6;
 
			w1.Add (this.resultbox);
 
			this.scroller.Add (w1);
 
			this.Add (this.scroller);
 
			if ((this.Child != null)) {
 
            this.hbox1.Add(this.scroller);
 
            global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.scroller]));
 
            w2.Expand = true;
 
            w2.Fill = true;
 
            w2.Position = 1;
 

	
 
            this.Add(this.hbox1);
 

	
 
            if ((this.Child != null)) {
 
				this.Child.ShowAll ();
 
			}
 
			this.DefaultWidth = 400;
 
			this.DefaultHeight = 300;
 
			this.Show ();
 
		}
 
	}
 
}
gtk-gui/DesertPaintLab.RecipeGeneratorView.cs
Show inline comments
...
 
@@ -177,33 +177,33 @@ namespace DesertPaintLab
 
			global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hbox7]));
 
			w8.Position = 1;
 
			w8.Expand = false;
 
			w8.Fill = false;
 
			// Container child vbox8.Gtk.Box+BoxChild
 
			this.hseparator3 = new global::Gtk.HSeparator ();
 
			this.hseparator3.Name = "hseparator3";
 
			this.vbox8.Add (this.hseparator3);
 
			global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.hseparator3]));
 
			w9.Position = 2;
 
			w9.Expand = false;
 
			w9.Fill = false;
 
			// Container child vbox8.Gtk.Box+BoxChild
 
			this.checkButtonRibbon = new global::Gtk.CheckButton ();
 
			this.checkButtonRibbon.CanFocus = true;
 
			this.checkButtonRibbon.Name = "checkButtonRibbon";
 
			this.checkButtonRibbon.Label = "Ribbon Recipes";
 
			this.checkButtonRibbon.Label = "Silk Ribbon Recipes";
 
			this.checkButtonRibbon.DrawIndicator = true;
 
			this.checkButtonRibbon.UseUnderline = true;
 
			this.vbox8.Add (this.checkButtonRibbon);
 
			global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.vbox8 [this.checkButtonRibbon]));
 
			w10.Position = 3;
 
			w10.Expand = false;
 
			w10.Fill = false;
 
			// Container child vbox8.Gtk.Box+BoxChild
 
			this.hbox4 = new global::Gtk.HBox ();
 
			this.hbox4.Name = "hbox4";
 
			this.hbox4.Spacing = 6;
 
			// Container child hbox4.Gtk.Box+BoxChild
 
			this.maxRecipeSpinButton = new global::Gtk.SpinButton (10, 100, 1);
 
			this.maxRecipeSpinButton.CanFocus = true;
 
			this.maxRecipeSpinButton.Name = "maxRecipeSpinButton";
 
			this.maxRecipeSpinButton.Adjustment.PageIncrement = 10;
gtk-gui/DesertPaintLab.ScreenCheckDialog.cs
Show inline comments
 

	
 
// This file has been generated by the GUI designer. Do not modify.
 
namespace DesertPaintLab
 
{
 
	public partial class ScreenCheckDialog
 
	{
 
		private global::Gtk.VBox vbox2;
 
		
 
		private global::Gtk.HBox hbox1;
 
		
 
		private global::Gtk.Label label1;
 
		
 
		private global::Gtk.Entry screenWidthEntry;
 

	
 
        private global::Gtk.Label detectedResolutionLabel;
 

	
 
        private global::Gtk.Entry screenWidthEntry;
 
		
 
		private global::Gtk.Entry screenHeightEntry;
 
		
 
		private global::Gtk.HBox hbox2;
 
		
 
		private global::Gtk.Label label2;
 
		
 
		private global::Gtk.Entry gamePixelWidthEntry;
 
		
 
		private global::Gtk.Button buttonOk;
 

	
 
        private global::Gtk.HBox hbox3;
 

	
 
        private global::Gtk.Label interfaceSizeLlabel;
 

	
 
        private global::Gtk.ComboBox interfaceSizeComboBox;
 

	
 
        private global::Gtk.Button buttonOk;
 

	
 
		protected virtual void Build ()
 
		{
 
			global::Stetic.Gui.Initialize (this);
 
			// Widget DesertPaintLab.ScreenCheckDialog
 
			this.Name = "DesertPaintLab.ScreenCheckDialog";
 
			this.Title = "Screen Check";
 
			this.WindowPosition = ((global::Gtk.WindowPosition)(4));
 
			this.Modal = true;
 
			this.BorderWidth = ((uint)(9));
 
			// Internal child DesertPaintLab.ScreenCheckDialog.VBox
 
			global::Gtk.VBox w1 = this.VBox;
 
			w1.Name = "dialog1_VBox";
 
			// Container child dialog1_VBox.Gtk.Box+BoxChild
 
			this.vbox2 = new global::Gtk.VBox ();
 
			this.vbox2.Name = "vbox2";
 
			this.vbox2.Spacing = 20;
 
			this.vbox2.BorderWidth = ((uint)(20));
 
			// Container child vbox2.Gtk.Box+BoxChild
 
			this.hbox1 = new global::Gtk.HBox ();
 

	
 
            // Container child vbox2.Gtk.Box+BoxChild
 
            this.hbox1 = new global::Gtk.HBox ();
 
			this.hbox1.Name = "hbox1";
 
			this.hbox1.Spacing = 20;
 
			this.hbox1.BorderWidth = ((uint)(10));
 
			// Container child hbox1.Gtk.Box+BoxChild
 
			this.label1 = new global::Gtk.Label ();
 
			this.label1.Name = "label1";
 
			this.label1.LabelProp = "Screen Resolution";
 
			this.hbox1.Add (this.label1);
 
			global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.label1]));
 
			w2.Position = 0;
 
			w2.Expand = false;
 
			w2.Fill = false;
 
            global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.label1]));
 
            w2.Position = 0;
 
            w2.Expand = false;
 
            w2.Fill = false;
 
			// Container child hbox1.Gtk.Box+BoxChild
 
			this.screenWidthEntry = new global::Gtk.Entry ();
 
			this.screenWidthEntry.WidthRequest = 50;
 
			this.screenWidthEntry.CanFocus = true;
 
			this.screenWidthEntry.Name = "screenWidthEntry";
 
			this.screenWidthEntry.IsEditable = true;
 
			this.screenWidthEntry.InvisibleChar = '●';
 
			this.hbox1.Add (this.screenWidthEntry);
 
			global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.screenWidthEntry]));
 
			w3.Position = 1;
 
			// Container child hbox1.Gtk.Box+BoxChild
 
			this.screenHeightEntry = new global::Gtk.Entry ();
 
			this.screenHeightEntry.WidthRequest = 50;
 
			this.screenHeightEntry.CanFocus = true;
 
			this.screenHeightEntry.Name = "screenHeightEntry";
 
			this.screenHeightEntry.IsEditable = true;
 
			this.screenHeightEntry.InvisibleChar = '●';
 
			this.hbox1.Add (this.screenHeightEntry);
 
			global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.screenHeightEntry]));
 
			w4.Position = 2;
 
			this.vbox2.Add (this.hbox1);
 
			global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox1]));
 
			w5.Position = 0;
 
			w5.Expand = false;
 
			w5.Fill = false;
 
			// Container child vbox2.Gtk.Box+BoxChild
 
			this.hbox2 = new global::Gtk.HBox ();
 

	
 
            // Container child vbox2.Gtk.Box+BoxChild
 
            this.detectedResolutionLabel = new global::Gtk.Label();
 
            this.detectedResolutionLabel.Name = "detectedResolutionLabel";
 
            this.detectedResolutionLabel.LabelProp = "Detected Screen Resolution: ??";
 
            this.vbox2.Add(this.detectedResolutionLabel);
 
            global::Gtk.Box.BoxChild wDR = ((global::Gtk.Box.BoxChild)(this.vbox2[this.detectedResolutionLabel]));
 
            wDR.Position =  1;
 
            wDR.Expand = false;
 
            wDR.Fill = false;
 

	
 
            // Container child vbox2.Gtk.Box+BoxChild
 
            this.hbox2 = new global::Gtk.HBox ();
 
			this.hbox2.Name = "hbox2";
 
			this.hbox2.Spacing = 20;
 
			this.hbox2.BorderWidth = ((uint)(10));
 
			// Container child hbox2.Gtk.Box+BoxChild
 
			this.label2 = new global::Gtk.Label ();
 
			this.label2.Name = "label2";
 
			this.label2.LabelProp = "Game Pixel Width in Screen Pixels";
 
			this.hbox2.Add (this.label2);
 
			global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.label2]));
 
			w6.Position = 0;
 
			w6.Expand = false;
 
			w6.Fill = false;
 
			// Container child hbox2.Gtk.Box+BoxChild
 
			this.gamePixelWidthEntry = new global::Gtk.Entry ();
 
			this.gamePixelWidthEntry.WidthRequest = 50;
 
			this.gamePixelWidthEntry.CanFocus = true;
 
			this.gamePixelWidthEntry.Name = "gamePixelWidthEntry";
 
			this.gamePixelWidthEntry.IsEditable = true;
 
			this.gamePixelWidthEntry.InvisibleChar = '●';
 
			this.hbox2.Add (this.gamePixelWidthEntry);
 
			global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.gamePixelWidthEntry]));
 
			w7.Position = 1;
 
			w7.Expand = false;
 
			w7.Fill = false;
 
			this.vbox2.Add (this.hbox2);
 
			global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox2]));
 
			w8.Position = 1;
 
			w8.Position = 2;
 
			w8.Expand = false;
 
			w8.Fill = false;
 
			w1.Add (this.vbox2);
 

	
 
            // Container child vbox2.Gtk.Box+BoxChild
 
            this.hbox3 = new global::Gtk.HBox();
 
            this.hbox3.Name = "hbox3";
 
            this.hbox3.Spacing = 20;
 
            this.hbox3.BorderWidth = ((uint)(10));
 
            // Container child hbox3.Gtk.Box+BoxChild
 
            this.interfaceSizeLlabel = new global::Gtk.Label();
 
            this.interfaceSizeLlabel.Name = "interfaceSizeLabel";
 
            this.interfaceSizeLlabel.LabelProp = "Interface Size";
 
            this.hbox3.Add(this.interfaceSizeLlabel);
 
            global::Gtk.Box.BoxChild interfaceSizeContainer = ((global::Gtk.Box.BoxChild)(this.hbox3[this.interfaceSizeLlabel]));
 
            interfaceSizeContainer.Position = 0;
 
            interfaceSizeContainer.Expand = false;
 
            interfaceSizeContainer.Fill = false;
 
            // Container child hbox2.Gtk.Box+BoxChild
 
            this.interfaceSizeComboBox = global::Gtk.ComboBox.NewText();
 
            this.interfaceSizeComboBox.Name = "interfaceSizeComboBox";
 
            this.hbox3.Add(this.interfaceSizeComboBox);
 
            global::Gtk.Box.BoxChild wInterfaceSize = ((global::Gtk.Box.BoxChild)(this.hbox2[this.interfaceSizeComboBox]));
 
            wInterfaceSize.Position = 1;
 
            this.vbox2.Add(this.hbox3);
 
            global::Gtk.Box.BoxChild wInterfaceSizeBox = ((global::Gtk.Box.BoxChild)(this.vbox2[this.hbox3]));
 
            wInterfaceSizeBox.Position = 0;
 
            wInterfaceSizeBox.Expand = false;
 
            wInterfaceSizeBox.Fill = false;
 

	
 
            // Fill interface size box
 
            interfaceSizeComboBox.Clear();
 

	
 
            Gtk.CellRendererText cell = new Gtk.CellRendererText();
 
            interfaceSizeComboBox.PackStart(cell, false);
 
            interfaceSizeComboBox.AddAttribute(cell, "text", 0);
 
            Gtk.ListStore store = new Gtk.ListStore(typeof(string));
 
            interfaceSizeComboBox.Model = store;
 
            store.AppendValues("Tiny");
 
            store.AppendValues("Small");
 
            store.AppendValues("Medium");
 
            store.AppendValues("Large");
 
            store.AppendValues("Huge");
 
            Gtk.TreeIter iter;
 
            interfaceSizeComboBox.Model.IterNthChild(out iter, 1);
 
            interfaceSizeComboBox.SetActiveIter(iter);
 

	
 
            w1.Add (this.vbox2);
 
			global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(w1 [this.vbox2]));
 
			w9.Position = 0;
 
			w9.Position = 3;
 
			// Internal child DesertPaintLab.ScreenCheckDialog.ActionArea
 
			global::Gtk.HButtonBox w10 = this.ActionArea;
 
			w10.Name = "dialog1_ActionArea";
 
			w10.Spacing = 10;
 
			w10.BorderWidth = ((uint)(5));
 
			w10.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
 
			// Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
 
			this.buttonOk = new global::Gtk.Button ();
 
			this.buttonOk.CanDefault = true;
 
			this.buttonOk.CanFocus = true;
 
			this.buttonOk.Name = "buttonOk";
 
			this.buttonOk.UseStock = true;
 
			this.buttonOk.UseUnderline = true;
 
			this.buttonOk.Label = "gtk-ok";
 
			this.AddActionWidget (this.buttonOk, -5);
 
			global::Gtk.ButtonBox.ButtonBoxChild w11 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w10 [this.buttonOk]));
 
			w11.Expand = false;
 
			w11.Fill = false;
 
			if ((this.Child != null)) {
 

	
 
            if ((this.Child != null)) {
 
				this.Child.ShowAll ();
 
			}
 
			this.DefaultWidth = 378;
 
			this.DefaultHeight = 245;
 
			this.Show ();
 
		}
 
	}
 
}
gtk-gui/MainWindow.cs
Show inline comments
...
 
@@ -31,34 +31,36 @@ public partial class MainWindow
 
	
 
	private global::Gtk.Action ExportRecipesAction;
 
	
 
	private global::Gtk.Action CopyRecipesToClipboardAction;
 
	
 
	private global::Gtk.Action ProfileAction;
 
	
 
	private global::Gtk.Action NewProfileAction;
 
	
 
	private global::Gtk.Action OpenProfileAction;
 
	
 
	private global::Gtk.Action ImportProfileAction;
 
	
 
	private global::Gtk.Action ExportProfileAction;
 
	
 
	private global::Gtk.Action ExportForPracticalPaintAction;
 
	
 
	private global::Gtk.VBox vbox1;
 

	
 
    private global::Gtk.Action PreferencesAction;
 

	
 
    private global::Gtk.VBox vbox1;
 
	
 
	private global::Gtk.MenuBar menu;
 
	
 
	private global::Gtk.Alignment contentContainer;
 
	
 
	private global::Gtk.Statusbar statusBar;
 

	
 
	protected virtual void Build ()
 
	{
 
		global::Stetic.Gui.Initialize (this);
 
		// Widget MainWindow
 
		this.UIManager = new global::Gtk.UIManager ();
 
		global::Gtk.ActionGroup w1 = new global::Gtk.ActionGroup ("Default");
 
		this.FileAction = new global::Gtk.Action ("FileAction", "_File", null, null);
 
		this.FileAction.ShortLabel = "_File";
 
		w1.Add (this.FileAction, "<Alt>f");
...
 
@@ -109,42 +111,45 @@ public partial class MainWindow
 
		w1.Add (this.ProfileAction, null);
 
		this.NewProfileAction = new global::Gtk.Action ("NewProfileAction", "New Profile", null, null);
 
		this.NewProfileAction.ShortLabel = "New Profile";
 
		w1.Add (this.NewProfileAction, null);
 
		this.OpenProfileAction = new global::Gtk.Action ("OpenProfileAction", "Open Profile", null, null);
 
		this.OpenProfileAction.ShortLabel = "Open Profile";
 
		w1.Add (this.OpenProfileAction, null);
 
		this.ImportProfileAction = new global::Gtk.Action ("ImportProfileAction", "Import Profile", null, null);
 
		this.ImportProfileAction.ShortLabel = "Import Profile";
 
		w1.Add (this.ImportProfileAction, null);
 
		this.ExportProfileAction = new global::Gtk.Action ("ExportProfileAction", "Export Profile", null, null);
 
		this.ExportProfileAction.ShortLabel = "Export Profile";
 
		w1.Add (this.ExportProfileAction, null);
 
		this.ExportForPracticalPaintAction = new global::Gtk.Action ("ExportForPracticalPaintAction", "Export for PracticalPaint", null, null);
 
		this.ExportForPracticalPaintAction.ShortLabel = "Export for PracticalPaint";
 
		w1.Add (this.ExportForPracticalPaintAction, null);
 
		this.UIManager.InsertActionGroup (w1, 0);
 
        this.PreferencesAction = new global::Gtk.Action("PreferencesAction", "Preferences", null, null);
 
        this.PreferencesAction.ShortLabel = "Preferences";
 
        w1.Add(this.PreferencesAction, null);
 
        this.UIManager.InsertActionGroup (w1, 0);
 
		this.AddAccelGroup (this.UIManager.AccelGroup);
 
		this.Name = "MainWindow";
 
		this.Title = "Desert Paint Lab";
 
		this.WindowPosition = ((global::Gtk.WindowPosition)(4));
 
		// Container child MainWindow.Gtk.Container+ContainerChild
 
		this.vbox1 = new global::Gtk.VBox ();
 
		this.vbox1.Name = "vbox1";
 
		// Container child vbox1.Gtk.Box+BoxChild
 
		this.UIManager.AddUiFromString ("<ui><menubar name='menu'><menu name='FileAction' action='FileAction'><menu name='ProfileAction' action='ProfileAction'><menuitem name='NewProfileAction' action='NewProfileAction'/><menuitem name='OpenProfileAction' action='OpenProfileAction'/><menuitem name='ImportProfileAction' action='ImportProfileAction'/><menuitem name='ExportProfileAction' action='ExportProfileAction'/><menuitem name='ExportForPracticalPaintAction' action='ExportForPracticalPaintAction'/></menu><menu name='RecipesAction' action='RecipesAction'><menuitem name='ExportRecipesAction' action='ExportRecipesAction'/><menuitem name='CopyRecipesToClipboardAction' action='CopyRecipesToClipboardAction'/></menu><separator/><menuitem name='ExitAction' action='ExitAction'/></menu><menu name='ViewAction' action='ViewAction'><menuitem name='CaptureAction' action='CaptureAction'/><menuitem name='SimulatorAction' action='SimulatorAction'/><menuitem name='RecipeGeneratorAction' action='RecipeGeneratorAction'/></menu><menu name='HelpAction' action='HelpAction'><menuitem name='AboutAction' action='AboutAction'/><menuitem name='ReactionStatusAction' action='ReactionStatusAction'/></menu><menu name='DebugAction' action='DebugAction'><menuitem name='ScreenshotAction' action='ScreenshotAction'/></menu></menubar></ui>");
 
		this.UIManager.AddUiFromString ("<ui><menubar name='menu'><menu name='FileAction' action='FileAction'><menu name='ProfileAction' action='ProfileAction'><menuitem name='NewProfileAction' action='NewProfileAction'/><menuitem name='OpenProfileAction' action='OpenProfileAction'/><menuitem name='ImportProfileAction' action='ImportProfileAction'/><menuitem name='ExportProfileAction' action='ExportProfileAction'/><menuitem name='ExportForPracticalPaintAction' action='ExportForPracticalPaintAction'/></menu><menu name='RecipesAction' action='RecipesAction'><menuitem name='ExportRecipesAction' action='ExportRecipesAction'/><menuitem name='CopyRecipesToClipboardAction' action='CopyRecipesToClipboardAction'/></menu><separator/><menuitem name='PreferencesAction' action='PreferencesAction'/><separator/><menuitem name='ExitAction' action='ExitAction'/></menu><menu name='ViewAction' action='ViewAction'><menuitem name='CaptureAction' action='CaptureAction'/><menuitem name='SimulatorAction' action='SimulatorAction'/><menuitem name='RecipeGeneratorAction' action='RecipeGeneratorAction'/></menu><menu name='HelpAction' action='HelpAction'><menuitem name='AboutAction' action='AboutAction'/><menuitem name='ReactionStatusAction' action='ReactionStatusAction'/></menu><menu name='DebugAction' action='DebugAction'><menuitem name='ScreenshotAction' action='ScreenshotAction'/></menu></menubar></ui>");
 
		this.menu = ((global::Gtk.MenuBar)(this.UIManager.GetWidget ("/menu")));
 
		this.menu.Name = "menu";
 
		this.vbox1.Add (this.menu);
 
		global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.menu]));
 
		w2.Position = 0;
 
		w2.Expand = false;
 
		w2.Fill = false;
 
		// Container child vbox1.Gtk.Box+BoxChild
 
		this.contentContainer = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F);
 
		this.contentContainer.Name = "contentContainer";
 
		this.contentContainer.LeftPadding = ((uint)(8));
 
		this.contentContainer.TopPadding = ((uint)(6));
 
		this.contentContainer.RightPadding = ((uint)(8));
 
		this.contentContainer.BottomPadding = ((uint)(5));
 
		this.vbox1.Add (this.contentContainer);
 
		global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.contentContainer]));
...
 
@@ -167,18 +172,19 @@ public partial class MainWindow
 
		this.Show ();
 
		this.DeleteEvent += new global::Gtk.DeleteEventHandler (this.OnDeleteEvent);
 
		this.AboutAction.Activated += new global::System.EventHandler (this.OnAbout);
 
		this.ExitAction.Activated += new global::System.EventHandler (this.OnMenuExit);
 
		this.ScreenshotAction.Activated += new global::System.EventHandler (this.OnDebugScreenshot);
 
		this.ReactionStatusAction.Activated += new global::System.EventHandler (this.OnShowReactionStatus);
 
		this.CaptureAction.Toggled += new global::System.EventHandler (this.OnSelectCaptureView);
 
		this.SimulatorAction.Toggled += new global::System.EventHandler (this.OnSelectSimulatorView);
 
		this.RecipeGeneratorAction.Toggled += new global::System.EventHandler (this.OnSelectRecipeGeneratorView);
 
		this.ExportRecipesAction.Activated += new global::System.EventHandler (this.OnExportRecipeListToWiki);
 
		this.CopyRecipesToClipboardAction.Activated += new global::System.EventHandler (this.OnCopyRecipeListToClipboard);
 
		this.NewProfileAction.Activated += new global::System.EventHandler (this.OnNewProfile);
 
		this.OpenProfileAction.Activated += new global::System.EventHandler (this.OnOpenProfile);
 
		this.ImportProfileAction.Activated += new global::System.EventHandler (this.OnImportProfile);
 
		this.ExportProfileAction.Activated += new global::System.EventHandler (this.OnExportProfile);
 
		this.ExportForPracticalPaintAction.Activated += new global::System.EventHandler (this.OnExportToPracticalPaint);
 
        this.PreferencesAction.Activated += new global::System.EventHandler(this.OnPreferences);
 
	}
 
}
gtk-gui/gui.stetic
Show inline comments
...
 
@@ -625,32 +625,44 @@ You can either import an existing Practi
 
                    <property name="Expand">False</property>
 
                    <property name="Fill">False</property>
 
                  </packing>
 
                </child>
 
                <child>
 
                  <placeholder />
 
                </child>
 
              </widget>
 
              <packing>
 
                <property name="Position">1</property>
 
                <property name="AutoSize">True</property>
 
                <property name="Expand">False</property>
 
                <property name="Fill">False</property>
 
              </packing>
 
            </child>
 
            <child>
 
              <widget class="Gtk.Label" id="detectedResolutionLabel">
 
                <property name="MemberName" />
 
                <property name="LabelProp" translatable="yes">Detected Resolution</property>
 
              </widget>
 
              <packing>
 
                <property name="Position">0</property>
 
                <property name="AutoSize">True</property>
 
                <property name="Expand">False</property>
 
                <property name="Fill">False</property>
 
              </packing>
 
            </child>
 
            <child>
 
              <placeholder />
 
            </child>
 
          </widget>
 
          <packing>
 
            <property name="Position">0</property>
 
            <property name="AutoSize">True</property>
 
          </packing>
 
        </child>
 
      </widget>
 
    </child>
 
    <child internal-child="ActionArea">
 
      <widget class="Gtk.HButtonBox" id="dialog1_ActionArea">
 
        <property name="MemberName" />
 
        <property name="Spacing">10</property>
 
        <property name="BorderWidth">5</property>
 
        <property name="Size">1</property>
...
 
@@ -1245,33 +1257,33 @@ You can either import an existing Practi
 
                </child>
 
                <child>
 
                  <widget class="Gtk.HSeparator" id="hseparator3">
 
                    <property name="MemberName" />
 
                  </widget>
 
                  <packing>
 
                    <property name="Position">2</property>
 
                    <property name="AutoSize">True</property>
 
                    <property name="Expand">False</property>
 
                    <property name="Fill">False</property>
 
                  </packing>
 
                </child>
 
                <child>
 
                  <widget class="Gtk.CheckButton" id="checkButtonRibbon">
 
                    <property name="MemberName" />
 
                    <property name="CanFocus">True</property>
 
                    <property name="Label" translatable="yes">Ribbon Recipes</property>
 
                    <property name="Label" translatable="yes">Silk Ribbon Recipes</property>
 
                    <property name="DrawIndicator">True</property>
 
                    <property name="HasLabel">True</property>
 
                    <property name="UseUnderline">True</property>
 
                    <signal name="Toggled" handler="OnRecipesToggled" />
 
                  </widget>
 
                  <packing>
 
                    <property name="Position">3</property>
 
                    <property name="AutoSize">True</property>
 
                    <property name="Expand">False</property>
 
                    <property name="Fill">False</property>
 
                  </packing>
 
                </child>
 
                <child>
 
                  <widget class="Gtk.HBox" id="hbox4">
 
                    <property name="MemberName" />
 
                    <property name="Spacing">6</property>
0 comments (0 inline, 0 general)