/// <summary>
        /// Formats the GridView. Sets colours, spacing, locks the
        /// depth column, etc.
        /// </summary>
        private void FormatGrid()
        {
            for (int i = 0; i < properties.Count; i++)
            {
                // fixme - ugly hack to work around last column being very wide
                if (i != properties.Count - 1)
                {
                    grid.GetColumn(i).LeftJustification = false;
                }

                grid.GetColumn(i).HeaderLeftJustification = false;
                VariableProperty property = properties[i] as VariableProperty;
                if (!(property.Object is SoilCrop))
                {
                    continue;
                }

                SoilCrop crop       = property.Object as SoilCrop;
                int      index      = Apsim.Children(crop.Parent, typeof(SoilCrop)).IndexOf(crop);
                Color    foreground = ColourUtilities.ChooseColour(index);
                if (property.IsReadOnly)
                {
                    foreground = Color.Red;
                }

                grid.GetColumn(i).ForegroundColour = foreground;
                grid.GetColumn(i).MinimumWidth     = 70;
                grid.GetColumn(i).ReadOnly         = property.IsReadOnly;
            }
            grid.LockLeftMostColumns(1);
        }
Esempio n. 2
0
        /// <summary>
        /// Displays the colour information.
        /// </summary>
        /// <param name="targetControl">The target control.</param>
        /// <param name="showForeColourInformation">if set to <c>true</c> [show fore colour information].</param>
        /// <param name="controlDescription">The control description.</param>
        public static void DisplayColourInformation(Control targetControl, bool showForeColourInformation = false, string controlDescription = "", KryptonLabel output = null)
        {
            // Create a temporary tool tip
            ToolTip toolTipInformation = new ToolTip();

            ConversionMethods _conversionMethods = new ConversionMethods();

            if (showForeColourInformation && controlDescription != "")
            {
                toolTipInformation.SetToolTip(targetControl, $"{ controlDescription }\nBack Colour:\n\nARGB: ({ ColourUtilities.FormatColourARGBString(targetControl.BackColor)})\nRGB: ({ ColourUtilities.FormatColourRGBString(targetControl.BackColor) })\nHexadecimal Value: #{ _conversionMethods.ConvertRGBToHexadecimal(Convert.ToInt32(targetControl.BackColor.R), Convert.ToInt32(targetControl.BackColor.G), Convert.ToInt32(targetControl.BackColor.B)).ToUpper() }\nHue: { targetControl.BackColor.GetHue().ToString() }\nSaturation: { targetControl.BackColor.GetSaturation().ToString() }\nBrightness: { targetControl.BackColor.GetBrightness().ToString() }\n\nFore Colour:\nARGB: ({ ColourUtilities.FormatColourARGBString(targetControl.ForeColor)})\nRGB: ({ ColourUtilities.FormatColourRGBString(targetControl.ForeColor) })\nHexadecimal Value: #{ _conversionMethods.ConvertRGBToHexadecimal(Convert.ToInt32(targetControl.ForeColor.R), Convert.ToInt32(targetControl.ForeColor.G), Convert.ToInt32(targetControl.ForeColor.B)).ToUpper() }\nHue: { targetControl.BackColor.GetHue().ToString() }\nSaturation: { targetControl.BackColor.GetSaturation().ToString() }\nBrightness: { targetControl.BackColor.GetBrightness().ToString() }");

                output.Text = $"Colour values for: { controlDescription }, ARGB: ({ ColourUtilities.FormatColourARGBString(targetControl.BackColor) }), RGB: ({ ColourUtilities.FormatColourRGBString(targetControl.BackColor) })";
            }
            else if (showForeColourInformation)
            {
                toolTipInformation.SetToolTip(targetControl, $"Back Colour:\n\nARGB: ({ ColourUtilities.FormatColourARGBString(targetControl.BackColor)})\nRGB: ({ ColourUtilities.FormatColourRGBString(targetControl.BackColor) })\nHexadecimal Value: #{ _conversionMethods.ConvertRGBToHexadecimal(Convert.ToInt32(targetControl.BackColor.R), Convert.ToInt32(targetControl.BackColor.G), Convert.ToInt32(targetControl.BackColor.B)).ToUpper() }\n\nFore Colour:\nARGB: ({ ColourUtilities.FormatColourARGBString(targetControl.ForeColor)})\nRGB: ({ ColourUtilities.FormatColourRGBString(targetControl.ForeColor) })\nHexadecimal Value: #{ _conversionMethods.ConvertRGBToHexadecimal(Convert.ToInt32(targetControl.ForeColor.R), Convert.ToInt32(targetControl.ForeColor.G), Convert.ToInt32(targetControl.ForeColor.B)).ToUpper() }\nHue: { targetControl.BackColor.GetHue().ToString() }\nSaturation: { targetControl.BackColor.GetSaturation().ToString() }\nBrightness: { targetControl.BackColor.GetBrightness().ToString() }");

                output.Text = $"Colour values for: { controlDescription }, ARGB: ({ ColourUtilities.FormatColourARGBString(targetControl.BackColor) }), RGB: ({ ColourUtilities.FormatColourRGBString(targetControl.BackColor) })";
            }
            else if (controlDescription != "")
            {
                toolTipInformation.SetToolTip(targetControl, $"{ controlDescription }\nARGB: ({ ColourUtilities.FormatColourARGBString(targetControl.BackColor)})\nRGB: ({ ColourUtilities.FormatColourRGBString(targetControl.BackColor) })\nHexadecimal Value: #{ _conversionMethods.ConvertRGBToHexadecimal(Convert.ToInt32(targetControl.BackColor.R), Convert.ToInt32(targetControl.BackColor.G), Convert.ToInt32(targetControl.BackColor.B)).ToUpper() }");

                output.Text = $"Colour values for: { controlDescription }, ARGB: ({ ColourUtilities.FormatColourARGBString(targetControl.BackColor) }), RGB: ({ ColourUtilities.FormatColourRGBString(targetControl.BackColor) })";
            }
            else
            {
                toolTipInformation.SetToolTip(targetControl, $"ARGB: ({ ColourUtilities.FormatColourARGBString(targetControl.BackColor)})\nRGB: ({ ColourUtilities.FormatColourRGBString(targetControl.BackColor) })\nHexadecimal Value: #{ _conversionMethods.ConvertRGBToHexadecimal(Convert.ToInt32(targetControl.BackColor.R), Convert.ToInt32(targetControl.BackColor.G), Convert.ToInt32(targetControl.BackColor.B)).ToUpper() }\nHue: { targetControl.BackColor.GetHue().ToString() }\nSaturation: { targetControl.BackColor.GetSaturation().ToString() }\nBrightness: { targetControl.BackColor.GetBrightness().ToString() }");

                output.Text = $"Colour values for: { controlDescription }, ARGB: ({ ColourUtilities.FormatColourARGBString(targetControl.BackColor) }), RGB: ({ ColourUtilities.FormatColourRGBString(targetControl.BackColor) })";
            }
        }
Esempio n. 3
0
 private void kcmbSelectedColour_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (kcmbSelectedColour.Text == "Base Colour")
     {
         lblColourOutput.Text = $"{ ColourUtilities.FormatColourARGBString(pbxBaseColour.BackColor) }";
     }
 }
Esempio n. 4
0
        /// <summary>Writes documentation for this function by adding to the list of documentation tags.</summary>
        public override IEnumerable <ITag> Document()
        {
            DataTable table = new DataTable(Name);

            // Using the string datatype gives us control over how the numbers
            // are rendered, and allows for empty cells.
            if (XVariableName == null)
            {
                XVariableName = "X";
            }
            table.Columns.Add(XVariableName, typeof(string));
            table.Columns.Add(Parent.Name, typeof(string));
            for (int i = 0; i < Math.Max(X.Length, Y.Length); i++)
            {
                DataRow row = table.NewRow();
                row[0] = i <= X.Length - 1 ? X[i].ToString("F1") : "";
                row[1] = i <= Y.Length - 1 ? Y[i].ToString("F1") : "";
                table.Rows.Add(row);
            }
            yield return(new Table(table));

            var series = new APSIM.Shared.Graphing.Series[1];

            // fixme: colour
            series[0] = new LineSeries(Parent.Name, ColourUtilities.ChooseColour(4), false, X, Y, new Line(LineType.Solid, LineThickness.Normal), new Marker(MarkerType.None, MarkerSize.Normal, 1), XVariableName, Name);

            Axis xAxis = new Axis(XVariableName, AxisPosition.Bottom, false, false);
            Axis yAxis = new Axis(Parent.Name, AxisPosition.Left, false, false);

            var legend = new LegendConfiguration(LegendOrientation.Vertical, LegendPosition.TopLeft, true);

            yield return(new APSIM.Shared.Documentation.Graph(Parent.Name, series, xAxis, yAxis, legend));
        }
        private void PropagateColourSettingsArray()
        {
            _colourSettingsArray = new ArrayList();

            _colourSettingsArray.Add($"Base Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetBaseColour()) }");

            _colourSettingsArray.Add($"Dark Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetDarkestColour()) }");

            _colourSettingsArray.Add($"Middle Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetMediumColour()) }");

            _colourSettingsArray.Add($"Light Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetLightColour()) }");

            _colourSettingsArray.Add($"Lightest Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetLightestColour()) }");

            _colourSettingsArray.Add($"Border Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetBorderColour()) }");

            _colourSettingsArray.Add($"Disabled Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetDisabledControlColour()) }");

            _colourSettingsArray.Add($"Alternative Normal Text Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetAlternativeNormalTextColour()) }");

            _colourSettingsArray.Add($"Disabled Text Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetDisabledTextColour()) }");

            _colourSettingsArray.Add($"Normal Text Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetNormalTextColour()) }");

            _colourSettingsArray.Add($"Focused Text Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetFocusedTextColour()) }");

            _colourSettingsArray.Add($"Pressed Text Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetPressedTextColour()) }");

            _colourSettingsArray.Add($"Link Disabled Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetLinkDisabledColour()) }");

            _colourSettingsArray.Add($"Link Normal Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetLinkNormalColour()) }");

            _colourSettingsArray.Add($"Link Hover Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetLinkHoverColour()) }");

            _colourSettingsArray.Add($"Link Visited Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetLinkVisitedColour()) }");

            _colourSettingsArray.Add($"Custom Colour One: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetCustomColourOne()) }");

            _colourSettingsArray.Add($"Custom Colour Two: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetCustomColourTwo()) }");

            _colourSettingsArray.Add($"Custom Colour Three: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetCustomColourThree()) }");

            _colourSettingsArray.Add($"Custom Colour Four: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetCustomColourFour()) }");

            _colourSettingsArray.Add($"Custom Colour Five: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetCustomColourFive()) }");

            _colourSettingsArray.Add($"Custom Text Colour One: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetCustomTextColourOne()) }");

            _colourSettingsArray.Add($"Custom Text Colour Two: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetCustomTextColourTwo()) }");

            _colourSettingsArray.Add($"Custom Text Colour Three: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetCustomTextColourThree()) }");

            _colourSettingsArray.Add($"Custom Text Colour Four: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetCustomTextColourFour()) }");

            _colourSettingsArray.Add($"Custom Text Colour Five: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetCustomTextColourFive()) }");

            _colourSettingsArray.Add($"Menu Text Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetMenuTextColour()) }");

            _colourSettingsArray.Add($"Status Text Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetStatusStripTextColour()) }");
        }
Esempio n. 6
0
        /// <summary>Creates series definitions for the specified simulation.</summary>
        /// <param name="simulation">The simulation.</param>
        /// <param name="baseTitle">The base title.</param>
        /// <param name="baseFilter">The base filter.</param>
        /// <param name="colourIndex">The index into the colour palette.</param>
        /// <param name="definitions">The definitions to add to.</param>
        /// <param name="marker">The marker type.</param>
        /// <param name="line">The line type.</param>
        /// <param name="simulationNames">Simulation names to include in data.</param>
        private void CreateDefinitions(Simulation simulation, string baseTitle, string baseFilter, ref int colourIndex,
                                       ref MarkerType marker, LineType line,
                                       List <SeriesDefinition> definitions,
                                       string[] simulationNames)
        {
            List <IModel> zones = Apsim.Children(simulation, typeof(Zone));

            if (zones.Count > 1)
            {
                foreach (Zone zone in zones)
                {
                    string zoneFilter = baseFilter + " AND ZoneName = '" + zone.Name + "'";
                    definitions.Add(CreateDefinition(baseTitle + " " + zone.Name, zoneFilter,
                                                     ColourUtilities.ChooseColour(colourIndex),
                                                     marker, line,
                                                     simulationNames));
                    colourIndex++;
                }
            }
            else
            {
                definitions.Add(CreateDefinition(baseTitle, baseFilter,
                                                 ColourUtilities.ChooseColour(colourIndex),
                                                 marker, line,
                                                 simulationNames));
                colourIndex++;
            }

            if (colourIndex >= ColourUtilities.Colours.Length)
            {
                colourIndex = 0;
                marker      = IncrementMarker(marker);
            }
        }
Esempio n. 7
0
        private void kbtnGenerate_Click(object sender, EventArgs e)
        {
            //ColourUtilities.GenerateColourShades(pbxBaseColour.BackColor, pbxDarkColour, pbxMiddleColour, pbxLightColour, pbxLightestColour);

            ColourUtilities.GenerateColourShades(cpbBaseColourPreview.BackColor, cpbDarkestColourPreview, cpbMiddleColourPreview, cpbLightColourPreview, cpbLightestColourPreview);

            kbtnExport.Enabled = true;
        }
Esempio n. 8
0
        /// <summary>Called by the graph presenter to get a list of all actual series to put on the graph.</summary>
        /// <param name="definitions">A list of definitions to add to.</param>
        /// <param name="storage">Storage service</param>
        /// <param name="simulationsFilter">Unused simulation names filter.</param>
        public void GetSeriesToPutOnGraph(IStorageReader storage, List <SeriesDefinition> definitions, List <string> simulationsFilter = null)
        {
            stats.Clear();
            equationColours.Clear();

            int checkpointNumber = 0;

            foreach (var checkpointName in storage.CheckpointNames)
            {
                // Get all x/y data
                List <double> x = new List <double>();
                List <double> y = new List <double>();
                foreach (SeriesDefinition definition in definitions)
                {
                    if (definition.CheckpointName == checkpointName)
                    {
                        if (definition.X is double[] && definition.Y is double[])
                        {
                            x.AddRange(definition.X as IEnumerable <double>);
                            y.AddRange(definition.Y as IEnumerable <double>);
                        }
                    }
                }

                if (ForEachSeries)
                {
                    // Display a regression line for each series.
                    int numDefinitions = definitions.Count;
                    for (int i = 0; i < numDefinitions; i++)
                    {
                        if (definitions[i].X is double[] && definitions[i].Y is double[])
                        {
                            PutRegressionLineOnGraph(definitions, definitions[i].X, definitions[i].Y, definitions[i].Colour, null);
                            equationColours.Add(definitions[i].Colour);
                        }
                    }
                }
                else
                {
                    var regresionLineName = "Regression line";
                    if (checkpointName != "Current")
                    {
                        regresionLineName = "Regression line (" + checkpointName + ")";
                    }

                    // Display a single regression line for all data.
                    PutRegressionLineOnGraph(definitions, x, y, ColourUtilities.ChooseColour(checkpointNumber), regresionLineName);
                    equationColours.Add(ColourUtilities.ChooseColour(checkpointNumber));
                }

                if (showOneToOne)
                {
                    Put1To1LineOnGraph(definitions, x, y);
                }

                checkpointNumber++;
            }
        }
Esempio n. 9
0
        private void kbtnFileExport_Click(object sender, EventArgs e)
        {
            if (kmtxtFilePath.Text != "")
            {
                FileCreator fileCreator = new FileCreator();

                fileCreator.WriteColourFile("A:\\Test Colour.txt", ColourUtilities.FormatColourARGBString(pbxDarkColour.BackColor), ColourUtilities.FormatColourARGBString(pbxMiddleColour.BackColor), ColourUtilities.FormatColourARGBString(pbxLightColour.BackColor), ColourUtilities.FormatColourARGBString(pbxLightestColour.BackColor));
            }
        }
Esempio n. 10
0
        /// <summary>Calculate / create a directed graph from model</summary>
        public void CalculateDirectedGraph()
        {
            if (directedGraphInfo == null)
            {
                directedGraphInfo = new DirectedGraph();
            }

            directedGraphInfo.Begin();

            bool needAtmosphereNode = false;

            foreach (NutrientPool pool in Apsim.Children(this, typeof(NutrientPool)))
            {
                directedGraphInfo.AddNode(pool.Name, ColourUtilities.ChooseColour(3), Color.Black);

                foreach (CarbonFlow cFlow in Apsim.Children(pool, typeof(CarbonFlow)))
                {
                    foreach (string destinationName in cFlow.destinationNames)
                    {
                        string destName = destinationName;
                        if (destName == null)
                        {
                            destName           = "Atmosphere";
                            needAtmosphereNode = true;
                        }
                        directedGraphInfo.AddArc(null, pool.Name, destName, Color.Black);
                    }
                }
            }

            foreach (Solute solute in Apsim.Children(this, typeof(Solute)))
            {
                directedGraphInfo.AddNode(solute.Name, ColourUtilities.ChooseColour(2), Color.Black);
                foreach (NFlow nitrogenFlow in Apsim.Children(solute, typeof(NFlow)))
                {
                    string destName = nitrogenFlow.destinationName;
                    if (destName == null)
                    {
                        destName           = "Atmosphere";
                        needAtmosphereNode = true;
                    }
                    directedGraphInfo.AddArc(null, nitrogenFlow.sourceName, destName, Color.Black);
                }
            }

            if (needAtmosphereNode)
            {
                directedGraphInfo.AddTransparentNode("Atmosphere");
            }


            directedGraphInfo.End();
        }
Esempio n. 11
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            New();

            ColourUtilities.PropagateBasePaletteModes(kcmbBasePaletteMode);

            _colourSettingsManager.ResetSettings(_debugMode);

            if (_useCircularPictureBoxes)
            {
                ShowCircularPreviewBoxes(false);
            }
        }
        private void PropagateColourSettingsArray()
        {
            _colourSettingsArray = new ArrayList();

            _colourSettingsArray.Add($"Base Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetBaseColour()) }");

            _colourSettingsArray.Add($"Dark Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetDarkestColour()) }");

            _colourSettingsArray.Add($"Middle Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetMediumColour()) }");

            _colourSettingsArray.Add($"Light Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetLightColour()) }");

            _colourSettingsArray.Add($"Lightest Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetLightestColour()) }");

            _colourSettingsArray.Add($"Border Colour: { ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetBorderColour()) }");
        }
Esempio n. 13
0
        private void InitialiseWindow()
        {
            New();

            _mostRecentlyUsedFileManager = new MostRecentlyUsedFileManager(recentPaletteDefinitionsToolStripMenuItem, "Palette Editor", MyOwnRecentPaletteFileGotClicked_Handler, MyOwnRecentPaletteFilesGotCleared_Handler);

            ColourUtilities.PropagateBasePaletteModes(kcmbBasePaletteMode);

            _colourSettingsManager.ResetToDefaults();

            if (UseCircularPictureBoxes)
            {
                ShowCircularPreviewBoxes(_globalBooleanSettingsManager.GetUseCircularPictureBoxes());
            }

            TextExtra = $"(Build: { _currentVersion.Build.ToString() } - experimental)";
        }
Esempio n. 14
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            New();

            _mostRecentlyUsedFileManager = new MostRecentlyUsedFileManager(recentPaletteDefinitionsToolStripMenuItem, "Palette Editor", MyOwnRecentPaletteFileGotClicked_Handler, MyOwnRecentPaletteFilesGotCleared_Handler);

            ColourUtilities.PropagateBasePaletteModes(kcmbBasePaletteMode);

            _colourSettingsManager.ResetSettings(DebugMode);

            if (UseCircularPictureBoxes)
            {
                ShowCircularPreviewBoxes(_globalBooleanSettingsManager.GetUseCircularPictureBoxes());
            }

            TextExtra = $"(Build: { _currentVersion.Build.ToString() })";
        }
        /// <summary>
        /// Updates the colour palette.
        /// </summary>
        /// <param name="useCircularPictureBoxes">if set to <c>true</c> [use circular picture boxes].</param>
        private void UpdateColourPalette(bool useCircularPictureBoxes)
        {
            if (useCircularPictureBoxes)
            {
                kgbPreviewPane.Visible = false;

                kgbCircularColourPreviewPane.Visible = true;

                ColourUtilities.GrabColourDefinitions(cbxBaseColourPreview, cbxDarkColourPreview, cbxMiddleColourPreview, cbxLightColourPreview, cbxLightestColourPreview, cbxBorderColourPreview, cbxAlternativeNormalTextColourPreview, cbxNormalTextColourPreview, cbxDisabledTextColourPreview, cbxFocusedTextColourPreview, cbxPressedTextColourPreview, cbxDisabledColourPreview, cbxLinkNormalColourPreview, cbxLinkFocusedColourPreview, cbxLinkHoverColourPreview, cbxLinkVisitedColourPreview, cbxCustomColourOnePreview, cbxCustomColourTwoPreview, cbxCustomColourThreePreview, cbxCustomColourFourPreview, cbxCustomColourFivePreview, cbxCustomTextColourOnePreview, cbxCustomTextColourTwoPreview, cbxCustomTextColourThreePreview, cbxCustomTextColourFourPreview, cbxCustomTextColourFivePreview, cbxMenuTextColourPreview, cbxStatusTextColourPreview, cbxRibbonTabTextColourPreview);
            }
            else
            {
                kgbPreviewPane.Visible = true;

                kgbCircularColourPreviewPane.Visible = false;

                ColourUtilities.GrabColourDefinitions(pbxBaseColour, pbxDarkColour, pbxMiddleColour, pbxLightColour, pbxLightestColour, pbxBorderColourPreview, pbxAlternativeNormalTextColour, pbxNormalTextColourPreview, pbxDisabledTextColourPreview, pbxFocusedTextColourPreview, pbxPressedTextColourPreview, pbxDisabledColourPreview, pbxLinkNormalColourPreview, pbxLinkFocusedColourPreview, pbxLinkHoverColourPreview, pbxLinkVisitedColourPreview, pbxCustomColourOnePreview, pbxCustomColourTwoPreview, pbxCustomColourThreePreview, pbxCustomColourFourPreview, pbxCustomColourFivePreview, pbxCustomTextColourOnePreview, pbxCustomTextColourTwoPreview, pbxCustomTextColourThreePreview, pbxCustomTextColourFourPreview, pbxCustomTextColourFivePreview, pbxMenuTextColourPreview, pbxStatusTextColourPreview, pbxRibbonTabTextColourPreview);
            }
        }
Esempio n. 16
0
        private static void AddAnnotation(List <Annotation> annotations, List <object> x, Color baseColour, Dictionary <string, Color> colourMap, int startIndex, string startName, int i)
        {
            var bar = new LineAnnotation();

            if (colourMap.ContainsKey(startName))
            {
                bar.colour = colourMap[startName];
            }
            else
            {
                bar.colour = ColourUtilities.ChangeColorBrightness(baseColour, colourMap.Count * 0.2);
                colourMap.Add(startName, bar.colour);
            }
            bar.type            = LineType.Dot;
            bar.x1              = x[startIndex];
            bar.y1              = double.MinValue;
            bar.x2              = x[i - 1];
            bar.y2              = double.MaxValue;
            bar.InFrontOfSeries = false;
            bar.ToolTip         = startName;
            annotations.Add(bar);
        }
Esempio n. 17
0
        private APSIM.Shared.Documentation.Graph CreateGraph(uint indent = 0)
        {
            // fixme - this is basically identical to what we've got in the linear interp code.
            var    series = new APSIM.Shared.Graphing.Series[1];
            string xName  = "Average Temperature (°C)";
            string yName  = Name;

            series[0] = new APSIM.Shared.Graphing.LineSeries("Weighted temperature value",
                                                             ColourUtilities.ChooseColour(4),
                                                             false,
                                                             XYPairs.X,
                                                             XYPairs.Y,
                                                             new APSIM.Shared.Graphing.Line(APSIM.Shared.Graphing.LineType.Solid, APSIM.Shared.Graphing.LineThickness.Normal),
                                                             new APSIM.Shared.Graphing.Marker(APSIM.Shared.Graphing.MarkerType.None, APSIM.Shared.Graphing.MarkerSize.Normal, 1),
                                                             xName,
                                                             yName
                                                             );
            var xAxis  = new APSIM.Shared.Graphing.Axis(xName, APSIM.Shared.Graphing.AxisPosition.Bottom, false, false);
            var yAxis  = new APSIM.Shared.Graphing.Axis(yName, APSIM.Shared.Graphing.AxisPosition.Left, false, false);
            var legend = new APSIM.Shared.Graphing.LegendConfiguration(APSIM.Shared.Graphing.LegendOrientation.Vertical, APSIM.Shared.Graphing.LegendPosition.TopLeft, true);

            return(new APSIM.Shared.Documentation.Graph(Name, series, xAxis, yAxis, legend));
        }
Esempio n. 18
0
        /// <summary>
        /// Graph the specified simulation, looking for zones.
        /// </summary>
        /// <param name="model">The model where the graph sits.</param>
        /// <param name="ourDefinitions">The list of series definitions to add to.</param>
        private void GraphSimulation(IModel model, List <SeriesDefinition> ourDefinitions)
        {
            Simulation parentSimulation = Apsim.Parent(this, typeof(Simulation)) as Simulation;

            List <IModel> zones = Apsim.Children(model, typeof(Zone));

            if (zones.Count > 1)
            {
                int colourIndex = 0;
                foreach (Zone zone in zones)
                {
                    string filter = string.Format("SimulationName='{0}' and ZoneName='{1}'", parentSimulation.Name, zone.Name);
                    ourDefinitions.Add(CreateDefinition(zone.Name, filter, ColourUtilities.ChooseColour(colourIndex), Marker, Line,
                                                        new string[] { parentSimulation.Name }));
                    colourIndex++;
                }
            }
            else
            {
                string filter = string.Format("SimulationName='{0}'", parentSimulation.Name);
                ourDefinitions.Add(CreateDefinition(Name, filter, Colour, Marker, Line,
                                                    new string[] { parentSimulation.Name }));
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MainView(ViewBase owner = null) : base(owner)
        {
            MasterView      = this;
            numberOfButtons = 0;
            Builder builder = BuilderFromResource("ApsimNG.Resources.Glade.MainView.glade");

            window1         = (Window)builder.GetObject("window1");
            progressBar     = (ProgressBar)builder.GetObject("progressBar");
            statusWindow    = (TextView)builder.GetObject("StatusWindow");
            stopButton      = (Button)builder.GetObject("stopButton");
            notebook1       = (Notebook)builder.GetObject("notebook1");
            notebook2       = (Notebook)builder.GetObject("notebook2");
            vbox1           = (VBox)builder.GetObject("vbox1");
            vbox2           = (VBox)builder.GetObject("vbox2");
            hpaned1         = (HPaned)builder.GetObject("hpaned1");
            hbox1           = (HBox)builder.GetObject("hbox1");
            mainWidget      = window1;
            window1.Icon    = new Gdk.Pixbuf(null, "ApsimNG.Resources.apsim logo32.png");
            listButtonView1 = new ListButtonView(this);
            listButtonView1.ButtonsAreToolbar = true;

            vbox1.PackEnd(listButtonView1.MainWidget, true, true, 0);
            listButtonView2 = new ListButtonView(this);
            listButtonView2.ButtonsAreToolbar = true;
            vbox2.PackEnd(listButtonView2.MainWidget, true, true, 0);
            hpaned1.PositionSet = true;
            hpaned1.Child2.Hide();
            hpaned1.Child2.NoShowAll = true;

            notebook1.SetMenuLabel(vbox1, LabelWithIcon(indexTabText, "go-home"));
            notebook2.SetMenuLabel(vbox2, LabelWithIcon(indexTabText, "go-home"));

            notebook1.SwitchPage += OnChangeTab;
            notebook2.SwitchPage += OnChangeTab;

            notebook1.GetTabLabel(notebook1.Children[0]).Name = "selected-tab";

            hbox1.HeightRequest = 20;

            TextTag tag = new TextTag("error");

            // Make errors orange-ish in dark mode.
            if (Utility.Configuration.Settings.DarkTheme)
            {
                tag.ForegroundGdk = Utility.Colour.ToGdk(ColourUtilities.ChooseColour(1));
            }
            else
            {
                tag.Foreground = "red";
            }
            statusWindow.Buffer.TagTable.Add(tag);
            tag = new TextTag("warning");
            // Make warnings yellow in dark mode.
            if (Utility.Configuration.Settings.DarkTheme)
            {
                tag.ForegroundGdk = Utility.Colour.ToGdk(ColourUtilities.ChooseColour(7));
            }
            else
            {
                tag.Foreground = "brown";
            }
            statusWindow.Buffer.TagTable.Add(tag);
            tag                      = new TextTag("normal");
            tag.Foreground           = "blue";
            statusWindow.Visible     = false;
            stopButton.Image         = new Gtk.Image(new Gdk.Pixbuf(null, "ApsimNG.Resources.MenuImages.Delete.png", 12, 12));
            stopButton.ImagePosition = PositionType.Right;
            stopButton.Image.Visible = true;
            stopButton.Clicked      += OnStopClicked;
            window1.DeleteEvent     += OnClosing;

            // If font is null, or font family is null, or font size is 0, fallback
            // to the default font (on windows only).
            Pango.FontDescription f = null;
            if (!string.IsNullOrEmpty(Utility.Configuration.Settings.FontName))
            {
                f = Pango.FontDescription.FromString(Utility.Configuration.Settings.FontName);
            }
            if (ProcessUtilities.CurrentOS.IsWindows && (string.IsNullOrEmpty(Utility.Configuration.Settings.FontName) ||
                                                         f.Family == null ||
                                                         f.Size == 0))
            {
                // Default font on Windows is Segoe UI. Will fallback to sans if unavailable.
                Utility.Configuration.Settings.FontName = Pango.FontDescription.FromString("Segoe UI 11").ToString();
            }

            // Can't set font until widgets are initialised.
            if (!string.IsNullOrEmpty(Utility.Configuration.Settings.FontName))
            {
                Pango.FontDescription font = Pango.FontDescription.FromString(Utility.Configuration.Settings.FontName);
                ChangeFont(font);
            }

            //window1.ShowAll();
            if (ProcessUtilities.CurrentOS.IsMac)
            {
                InitMac();
                //Utility.Configuration.Settings.DarkTheme = Utility.MacUtilities.DarkThemeEnabled();
            }

            if (!ProcessUtilities.CurrentOS.IsLinux)
            {
                RefreshTheme();
            }

#if NETCOREAPP
            LoadStylesheets();
#endif
        }
Esempio n. 20
0
 /// <summary>Set visual aspects (colour, line type, marker type) of the series definition.</summary>
 /// <param name="seriesDefinition">The definition to paint.</param>
 public void Paint(SeriesDefinition seriesDefinition)
 {
     seriesDefinition.Colour = ColourUtilities.ChangeColorBrightness(seriesDefinition.Colour, seriesDefinition.ColourModifier);
     seriesDefinition.Line   = lineType;
     seriesDefinition.Marker = markerType;
 }
Esempio n. 21
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The underlying model we are to use</param>
        /// <param name="view">The underlying view we are to attach to</param>
        /// <param name="explorerPresenter">Our parent explorerPresenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.model = model as Model;
            this.view  = view as IProfileView;
            profileGrid.Attach(model, this.view.ProfileGrid, explorerPresenter);
            this.explorerPresenter = explorerPresenter;

            this.view.ShowView(false);

            // Setup the property presenter and view. Hide the view if there are no properties to show.
            this.propertyPresenter = new PropertyPresenter();
            this.propertyPresenter.Attach(this.model, this.view.PropertyGrid, this.explorerPresenter);

            // Create a list of profile (array) properties. Create a table from them and
            // hand the table to the profile grid.
            this.FindAllProperties(this.model);

            // Populate the grid
            this.PopulateGrid();

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource(model.GetType().Name + "Graph");

            if (this.graph == null)
            {
                this.view.ShowGraph(false);
            }
            else
            {
                this.parentForGraph = this.model.Parent as IModel;
                if (this.parentForGraph != null)
                {
                    this.parentForGraph.Children.Add(this.graph);
                    this.graph.Parent = this.parentForGraph;
                    this.view.ShowGraph(true);
                    int padding = (this.view as ProfileView).MainWidget.Allocation.Width / 2 / 2;
                    this.view.Graph.LeftRightPadding = padding;
                    this.graphPresenter = new GraphPresenter();
                    for (int col = 0; col < this.propertiesInGrid.Count; col++)
                    {
                        VariableProperty property   = this.propertiesInGrid[col];
                        string           columnName = property.Description;

                        // crop colours
                        if (property.CropName != null && columnName.Contains("LL"))
                        {
                            Series cropLLSeries = new Series();
                            cropLLSeries.Name         = columnName;
                            cropLLSeries.Colour       = ColourUtilities.ChooseColour(this.graph.Children.Count);
                            cropLLSeries.Line         = LineType.Solid;
                            cropLLSeries.Marker       = MarkerType.None;
                            cropLLSeries.Type         = SeriesType.Scatter;
                            cropLLSeries.ShowInLegend = true;
                            cropLLSeries.XAxis        = Axis.AxisType.Top;
                            cropLLSeries.YAxis        = Axis.AxisType.Left;
                            cropLLSeries.YFieldName   = "[Soil].DepthMidPoints";
                            cropLLSeries.XFieldName   = "[" + (property.Object as Model).Name + "]." + property.Name;
                            cropLLSeries.Parent       = this.graph;

                            this.graph.Children.Add(cropLLSeries);
                        }
                    }

                    this.graphPresenter.Attach(this.graph, this.view.Graph, this.explorerPresenter);
                }
            }

            // Trap the invoking of the ProfileGrid 'CellValueChanged' event so that
            // we can save the contents.
            this.view.ProfileGrid.CellsChanged += this.OnProfileGridCellValueChanged;

            // Trap the right click on column header so that we can potentially put
            // units on the context menu.
            this.view.ProfileGrid.GridColumnClicked += this.OnGridColumnClicked;

            // Trap the model changed event so that we can handle undo.
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;

            this.view.ShowView(true);
        }
        private void CustomColours_Load(object sender, EventArgs e)
        {
            ColourUtilities.PropagateStandardColours(kcmbNormalTextColour);

            ColourUtilities.PropagateSystemColours(kcmbNormalTextSystemColours);
        }
Esempio n. 23
0
        /// <summary>Calculate / create a directed graph from model</summary>
        public void CalculateDirectedGraph()
        {
            DirectedGraph oldGraph = directedGraphInfo;

            if (directedGraphInfo == null)
            {
                directedGraphInfo = new DirectedGraph();
            }

            directedGraphInfo.Begin();

            bool needAtmosphereNode = false;

            foreach (NutrientPool pool in this.FindAllChildren <NutrientPool>())
            {
                Point location = default(Point);
                Node  oldNode;
                if (oldGraph != null && pool.Name != null && (oldNode = oldGraph.Nodes.Find(f => f.Name == pool.Name)) != null)
                {
                    location = oldNode.Location;
                }
                directedGraphInfo.AddNode(pool.Name, ColourUtilities.ChooseColour(3), Color.Black, location);

                foreach (CarbonFlow cFlow in pool.FindAllChildren <CarbonFlow>())
                {
                    foreach (string destinationName in cFlow.destinationNames)
                    {
                        string destName = destinationName;
                        if (destName == null)
                        {
                            destName           = "Atmosphere";
                            needAtmosphereNode = true;
                        }

                        location = default(Point);
                        Arc oldArc;
                        if (oldGraph != null && pool.Name != null && (oldArc = oldGraph.Arcs.Find(f => f.SourceName == pool.Name && f.DestinationName == destName)) != null)
                        {
                            location = oldArc.Location;
                        }

                        directedGraphInfo.AddArc(null, pool.Name, destName, Color.Black, location);
                    }
                }
            }

            foreach (Solute solute in this.FindAllChildren <Solute>())
            {
                directedGraphInfo.AddNode(solute.Name, ColourUtilities.ChooseColour(2), Color.Black);
                foreach (NFlow nitrogenFlow in solute.FindAllChildren <NFlow>())
                {
                    string destName = nitrogenFlow.destinationName;
                    if (destName == null)
                    {
                        destName           = "Atmosphere";
                        needAtmosphereNode = true;
                    }
                    directedGraphInfo.AddArc(null, nitrogenFlow.sourceName, destName, Color.Black);
                }
            }

            if (needAtmosphereNode)
            {
                directedGraphInfo.AddTransparentNode("Atmosphere");
            }


            directedGraphInfo.End();
        }
Esempio n. 24
0
 /// <summary>A static setter function for colour from an index.</summary>
 /// <param name="definition">The series definition to change.</param>
 /// <param name="index">The colour index into the colour palette.</param>
 public static void SetColour(SeriesDefinition definition, int index)
 {
     definition.Colour = ColourUtilities.ChangeColorBrightness(ColourUtilities.Colours[index], definition.ColourModifier);
 }
        public override void Draw(BufferContainer buffer)
        {
            //ClearArea(buffer);

            var hero   = Game.Hero;
            var actors = Game.CurrentStage.Actors;

            var foreGroundColour = hero.Appearance.ForeGroundColor == null ? ConsoleColor.White : ColourUtilities.ConvertToConsoleColor(hero.Appearance.ForeGroundColor);
            var backGroundColour = hero.Appearance.BackGroundColor == null ? ConsoleColor.Black : ColourUtilities.ConvertToConsoleColor(hero.Appearance.BackGroundColor);

            int lineCounter = 0;

            WriteAt(buffer, 0, lineCounter++, "Visible Creatures:", ConsoleColor.DarkYellow, backGroundColour);

            WriteAt(buffer, 0, lineCounter, hero.Appearance.Glyph, foreGroundColour, backGroundColour);
            WriteAt(buffer, 2, lineCounter, Game.Hero.Name);
            WriteAt(buffer, 22, lineCounter, $"({hero.Position.x},{hero.Position.y})");
            WriteAt(buffer, 32, lineCounter++, $"{hero.Health.Current}/{hero.Health.Max}");


            foreach (var actor in actors)
            {
                if (actor is Monster)
                {
                    var monster = actor as Monster;

                    if (Option.ShowAll)
                    {
                        foreGroundColour = monster.Appearance.ForeGroundColor == null
                            ? ConsoleColor.White
                            : ColourUtilities.ConvertToConsoleColor(monster.Appearance.ForeGroundColor);
                        backGroundColour = monster.Appearance.BackGroundColor == null
                            ? ConsoleColor.Black
                            : ColourUtilities.ConvertToConsoleColor(monster.Appearance.BackGroundColor);

                        WriteAt(buffer, 0, lineCounter, " ".PadRight(MaxWidth, ' '), ConsoleColor.White,
                                ConsoleColor.Black);

                        if (monster.Appearance.Glyph.Length > 1)
                        {
                            Debugger.Break();
                        }

                        WriteAt(buffer, 0, lineCounter, monster.Appearance.Glyph, foreGroundColour, backGroundColour);
                        WriteAt(buffer, 2, lineCounter, monster.NounText);
                        WriteAt(buffer, 22, lineCounter, $"({monster.Position.x},{monster.Position.y})");
                        WriteAt(buffer, 32, lineCounter, $"{monster.Health.Current}/{monster.Health.Max}");

                        lineCounter++;
                    }
                    else
                    {
                        if (!Game.CurrentStage.Shadows[monster.Position.x, monster.Position.y].IsInShadow)
                        {
                            foreGroundColour = monster.Appearance.ForeGroundColor == null
                                ? ConsoleColor.White
                                : ColourUtilities.ConvertToConsoleColor(monster.Appearance.ForeGroundColor);
                            backGroundColour = monster.Appearance.BackGroundColor == null
                                ? ConsoleColor.Black
                                : ColourUtilities.ConvertToConsoleColor(monster.Appearance.BackGroundColor);

                            WriteAt(buffer, 0, lineCounter, " ".PadRight(MaxWidth, ' '), ConsoleColor.White,
                                    ConsoleColor.Black);

                            if (monster.Appearance.Glyph.Length > 1)
                            {
                                Debugger.Break();
                            }

                            WriteAt(buffer, 0, lineCounter, monster.Appearance.Glyph, foreGroundColour, backGroundColour);
                            WriteAt(buffer, 2, lineCounter, monster.NounText);
                            WriteAt(buffer, 22, lineCounter, $"({monster.Position.x},{monster.Position.y})");
                            WriteAt(buffer, 32, lineCounter, $"{monster.Health.Current}/{monster.Health.Max}");

                            lineCounter++;
                        }
                    }
                }
            }
        }
 private void ColourInformation_Load(object sender, EventArgs e)
 {
     AddColourDetails("Base", ColourUtilities.FormatColourRGBString(_colourSettingsManager.GetBaseColour()));
 }
Esempio n. 27
0
        private void tmrAutomateColourSwatchValues_Tick(object sender, EventArgs e)
        {
            //ColourUtilities.GenerateColourShades(pbxBaseColour.BackColor, pbxDarkColour, pbxMiddleColour, pbxLightColour, pbxLightestColour);

            ColourUtilities.GenerateColourShades(cpbBaseColourPreview.BackColor, cpbDarkestColourPreview, cpbMiddleColourPreview, cpbLightColourPreview, cpbLightestColourPreview);
        }
Esempio n. 28
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The underlying model we are to use</param>
        /// <param name="view">The underlying view we are to attach to</param>
        /// <param name="explorerPresenter">Our parent explorerPresenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.model = model as Model;
            this.view  = view as IProfileView;
            profileGrid.Attach(model, this.view.ProfileGrid, explorerPresenter);
            this.explorerPresenter = explorerPresenter;

            this.view.ShowView(false);

            // Setup the property presenter and view. Hide the view if there are no properties to show.
            this.propertyPresenter = new PropertyPresenter();
            this.propertyPresenter.Attach(this.model, this.view.PropertyGrid, this.explorerPresenter);
            propertyPresenter.ScalarsOnly = true;
            // Populate the grid
            this.PopulateGrid();

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource("WaterGraph");
            graph.Name = "";
            if (this.graph == null)
            {
                this.view.ShowGraph(false);
            }
            else
            {
                // The graph's series contain many variables such as [Soil].LL. We now replace
                // these relative paths with absolute paths.
                foreach (Series series in graph.FindAllChildren <Series>())
                {
                    series.XFieldName  = series.XFieldName?.Replace("[Soil]", this.model.Parent.FullPath);
                    series.X2FieldName = series.X2FieldName?.Replace("[Soil]", this.model.Parent.FullPath);
                    series.YFieldName  = series.YFieldName?.Replace("[Soil]", this.model.Parent.FullPath);
                    series.Y2FieldName = series.Y2FieldName?.Replace("[Soil]", this.model.Parent.FullPath);
                }

                this.parentForGraph = this.model.Parent as IModel;
                if (this.parentForGraph != null)
                {
                    // Don't add the graph as a child of the soil. This causes problems
                    // (see bug #4622), and adding the soil as a parent is sufficient.
                    this.graph.Parent = this.parentForGraph;
                    this.view.ShowGraph(true);
                    int padding = (this.view as ProfileView).MainWidget.Allocation.Width / 2 / 2;
                    this.view.Graph.LeftRightPadding = padding;
                    this.graphPresenter = new GraphPresenter();
                    for (int i = 0; i < this.profileGrid.Properties.Length; i++)
                    {
                        string columnName = profileGrid.Properties[i].Name;

                        if (columnName.Contains("\r\n"))
                        {
                            StringUtilities.SplitOffAfterDelimiter(ref columnName, "\r\n");
                        }

                        // crop colours
                        if (columnName.Contains("LL"))
                        {
                            if (profileGrid.Properties[i].Object is SoilCrop)
                            {
                                string soilCropName = (profileGrid.Properties[i].Object as SoilCrop).Name;
                                string cropName     = soilCropName.Replace("Soil", "");
                                columnName = cropName + " " + columnName;
                            }

                            Series cropLLSeries = new Series();
                            cropLLSeries.Name         = columnName;
                            cropLLSeries.Colour       = ColourUtilities.ChooseColour(this.graph.Children.Count);
                            cropLLSeries.Line         = LineType.Solid;
                            cropLLSeries.Marker       = MarkerType.None;
                            cropLLSeries.Type         = SeriesType.Scatter;
                            cropLLSeries.ShowInLegend = true;
                            cropLLSeries.XAxis        = Axis.AxisType.Top;
                            cropLLSeries.YAxis        = Axis.AxisType.Left;
                            cropLLSeries.YFieldName   = (parentForGraph is Soil ? parentForGraph.FullPath : "[Soil]") + ".Physical.DepthMidPoints";
                            cropLLSeries.XFieldName   = ((profileGrid.Properties[i].Object as IModel)).FullPath + "." + profileGrid.Properties[i].Name;
                            //cropLLSeries.XFieldName = ((property.Object as Model)).FullPath + "." + property.Name;
                            cropLLSeries.Parent = this.graph;

                            this.graph.Children.Add(cropLLSeries);
                        }
                    }

                    this.graph.LegendPosition = Graph.LegendPositionType.RightTop;
                    explorerPresenter.ApsimXFile.Links.Resolve(graphPresenter);
                    this.graphPresenter.Attach(this.graph, this.view.Graph, this.explorerPresenter);
                    graphPresenter.LegendInsideGraph = false;
                }
            }

            // Trap the model changed event so that we can handle undo.
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;

            this.view.ShowView(true);
        }
Esempio n. 29
0
        private void DrawItems(BufferContainer buffer, int x, int y, List <Item> items, StorageLocation current, StorageLocation target, bool isActive = false)
        {
            var i = 0;

            foreach (var item in items)
            {
                var alphabet = "abcdefghijklmnopqrstuvwxyz";
                var itemY    = i + y;

                var borderColor = ConsoleColor.DarkGray;
                var letterColor = ConsoleColor.DarkGray;
                var textColor   = ConsoleColor.DarkGray;
                var priceColor  = ConsoleColor.DarkGray;
                var glyphColor  = ConsoleColor.DarkGray;
                var attackColor = ConsoleColor.DarkGray;
                var armourColor = ConsoleColor.DarkGray;

                var enabled = true;

                if (isActive)
                {
                    switch (target)
                    {
                    case StorageLocation.Equipment:
                    {
                        var command = new EquipItemCommand();
                        var canUse  = command.CanSelect(item);
                        if (canUse)
                        {
                            borderColor = ConsoleColor.Gray;
                            letterColor = ConsoleColor.Yellow;
                            textColor   = item == null ? ConsoleColor.Gray : ConsoleColor.White;
                            priceColor  = ConsoleColor.DarkYellow;
                            glyphColor  = item == null
                                        ? ConsoleColor.Gray
                                        : ColourUtilities.ConvertToConsoleColor(item.Appearance.ForeGroundColor);
                            attackColor = ConsoleColor.Yellow;
                            armourColor = ConsoleColor.Green;
                        }
                        break;
                    }

                    case StorageLocation.Crucible:
                    {
                        var canUse = false;
                        if (item != null)
                        {
                            canUse = CanUseItemInRecipe(item);
                        }
                        if (canUse)
                        {
                            borderColor = ConsoleColor.Gray;
                            letterColor = ConsoleColor.Yellow;
                            textColor   = item == null ? ConsoleColor.Gray : ConsoleColor.White;
                            priceColor  = ConsoleColor.DarkYellow;
                            glyphColor  = item == null
                                        ? ConsoleColor.Gray
                                        : ColourUtilities.ConvertToConsoleColor(item.Appearance.ForeGroundColor);
                            attackColor = ConsoleColor.Yellow;
                            armourColor = ConsoleColor.Green;
                        }
                        break;
                    }

                    default:
                    {
                        borderColor = ConsoleColor.Gray;
                        letterColor = ConsoleColor.Yellow;
                        textColor   = item == null ? ConsoleColor.Gray : ConsoleColor.White;
                        priceColor  = ConsoleColor.DarkYellow;
                        glyphColor  = item == null
                                    ? ConsoleColor.Gray
                                    : ColourUtilities.ConvertToConsoleColor(item.Appearance.ForeGroundColor);
                        attackColor = ConsoleColor.Yellow;
                        armourColor = ConsoleColor.Green;
                        break;
                    }
                    }
                }

                WriteAt(buffer, x, itemY, " )                                               ", borderColor);
                WriteAt(buffer, x, itemY, alphabet[i].ToString(), letterColor);

                if (item == null)
                {
                    // what is the location?
                    if (current == StorageLocation.Equipment)
                    {
                        var text = ((EquipementSlot)i) + " slot is empty";
                        WriteAt(buffer, x + 3, itemY, text, textColor);
                    }
                }
                else
                {
                    if (enabled)
                    {
                        WriteAt(buffer, x + 3, itemY, item.Appearance.Glyph, glyphColor);
                    }

                    var text = item.NounText;
                    if (text.Length > 32)
                    {
                        text = text.Substring(0, 29) + "...";
                    }
                    WriteAt(buffer, x + 5, itemY, text, textColor);

                    // TODO: Eventually need to handle equipment that gives both an armor and attack bonus.
                    if (item.attack != null)
                    {
                        DrawStat(buffer, x, itemY, "»", item.attack.AverageDamage, attackColor, attackColor, enabled);
                    }
                    else if (item.armor != 0)
                    {
                        DrawStat(buffer, x, itemY, "•", item.armor, armourColor, armourColor, enabled);
                    }

                    if (item.price != 0)
                    {
                        var price = PriceString(item.price);
                        WriteAt(buffer, x + 49 - price.Length, itemY, price, priceColor);
                    }
                }

                // Increment the item counter
                i++;
            }

            // If this is the crucible then maybe a recipe has been completed.
            if (current == StorageLocation.Crucible)
            {
                if (completeRecipe != null)
                {
                    i++;
                    i++;

                    var textColour = ConsoleColor.Yellow;
                    if (isActive)
                    {
                        textColour = ConsoleColor.DarkGray;
                    }
                    var csv = string.Join(", ", completeRecipe.Produces.ToArray());
                    WriteAt(buffer, 0, y + i++, $"This recipe {csv}!", textColour);
                    WriteAt(buffer, 0, y + i++, "Press[Space] to forge item!", textColour);
                }
            }
        }
        private void kbtnSaveColour_Click(object sender, EventArgs e)
        {
            if (klstCustomColourSelector.SelectedItem.ToString() == "Border Colour")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.BORDERCOLOUR, pbxColourPreview.BackColor);

                //if (_globalBooleanSettingsManager.GetDisableListItem())
                //{

                //}
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Alternative Normal Text Colour")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.ALTERNATIVENORMALTEXTCOLOUR, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Normal Text Colour")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.NORMALTEXTCOLOUR, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Disabled Text Colour")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.DISABLEDTEXTCOLOUR, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Focused Text Colour")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.FOCUSEDTEXTCOLOUR, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Pressed Text Colour")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.PRESSEDTEXTCOLOUR, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Link Normal Text Colour")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.LINKNORMALTEXTCOLOUR, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Link Hover Text Colour")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.LINKHOVERTEXTCOLOUR, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Link Visited Text Colour")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.LINKVISITEDTEXTCOLOUR, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Disabled Control Colour")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.DISABLEDCONTROLCOLOUR, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Custom Colour One")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.CUSTOMCOLOURONE, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Custom Colour Two")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.CUSTOMCOLOURTWO, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Custom Colour Three")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.CUSTOMCOLOURTHREE, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Custom Colour Four")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.CUSTOMCOLOURFOUR, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Custom Colour Five")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.CUSTOMCOLOURFIVE, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Menu Text Colour")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.MENUTEXTCOLOUR, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Custom Text Colour One")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.CUSTOMTEXTCOLOURONE, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Custom Text Colour Two")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.CUSTOMTEXTCOLOURTWO, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Custom Text Colour Three")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.CUSTOMTEXTCOLOURTHREE, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Custom Text Colour Four")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.CUSTOMTEXTCOLOURFOUR, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Custom Text Colour Five")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.CUSTOMTEXTCOLOURFIVE, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Status Text Colour")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.STATUSTEXTCOLOUR, pbxColourPreview.BackColor);
            }
            else if (klstCustomColourSelector.SelectedItem.ToString() == "Ribbon Tab Text Colour")
            {
                ColourUtilities.DefineCustomColour(MiscellaneousColourDefinitions.RIBBONTABTEXTCOLOUR, pbxColourPreview.BackColor);
            }

            kbtnSaveColour.Enabled = false;
        }