<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Third Party &#8211; Xojo Programming Blog</title>
	<atom:link href="https://blog.xojo.com/tag/third-party/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.xojo.com</link>
	<description>Blog about the Xojo programming language and IDE</description>
	<lastBuildDate>Tue, 18 Apr 2023 17:57:50 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Heatmaps with the Monkeybread ChartDirector Plugin</title>
		<link>https://blog.xojo.com/2021/07/13/heatmaps-with-monkeybread-chartdirector-plugin/</link>
		
		<dc:creator><![CDATA[Stefanie Juchmes]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 15:00:00 +0000</pubDate>
				<category><![CDATA[Guest Post]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XDC]]></category>
		<category><![CDATA[Charts]]></category>
		<category><![CDATA[Monkeybread Software]]></category>
		<category><![CDATA[OmegaBundle]]></category>
		<category><![CDATA[Third Party]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=8804</guid>

					<description><![CDATA[In this blog post I want to show you how to build a heatmap as a representative for other diagrams. In order to complete this project you'll the MBS Xojo ChartDirector Plugin, conveniently included in the Omegabundle. A heat map is a grid of fields...]]></description>
										<content:encoded><![CDATA[
<p>In this blog post I want to show you how to build a heatmap. In order to complete this project you&#8217;ll need the <a href="https://www.xojo.com/store/addons/MBS.php">MBS Xojo ChartDirector Plugin</a>, conveniently included in the <a href="http://omegabundle.net/">Omegabundle</a> right now.</p>



<p>A heatmap is a grid of fields that can have different sizes and colors. Heatmaps are often used to analyze website user behavior. Each area is assigned a color, and heat maps let you see the high and the low of that area. They often look like the image of a thermal camera, which is where the name comes from. Of course, a heatmap can also be used for displaying different temperatures, as its name so aptly describes. In this example we want to do that. We have the monthly mean temperature for a city for the last 10 years and we want to display this temperature by colors in a heatmap. </p>



<h2 class="wp-block-heading">The Data</h2>



<p>To do this, we first create an array in which we write the years we have and an array with the individual month names: The information in these arrays will be needed later for the labelling of the axes. </p>



<p>In order to be able to display values in a diagram, we want to write the values into a single array with all the months following with their values. We will combine the values as follow:&nbsp;</p>



<pre class="wp-block-preformatted">Array( Jan ( 0 ) … Jan ( 9 ) , Feb ( 0 ) … Feb ( 9 ) , Mar ( 0 ) … , … Dec ( 9 ) )</pre>



<p>We start with the January values and append the other months behind it. We can highlight special parts of the heatmap by adding a star, a polygon or a cross of any color to the area.&nbsp;</p>



<h2 class="wp-block-heading">Creating the Heatmap</h2>



<p>Now we come to the creation of the actual diagram. We create an area 600 x 500 pixels in size; on this area we will later draw our chart and the legend. To do this, we create an instance of the class&nbsp;<a href="https://www.monkeybreadsoftware.net/class-cdxychartmbs.shtml">CDXYChartMBS</a>&nbsp;and pass the size in the parameters.&nbsp;</p>



<pre class="wp-block-preformatted">Dim c As New CDXYChartMBS(600, 500)</pre>



<p>Above the chart, with addTitle, we can add a title that describes our chart. Our chart should be on an area of 400 x 400 pixels and have a distance of 80 pixels from the top edge. The background color, as well as the grid color is transparent.&nbsp;</p>



<pre class="wp-block-preformatted">Dim p As CDPlotAreaMBS = c.setPlotArea(80, 80, 400, 400, -1, -1, CDBaseChartMBS.kTransparent, CDBaseChartMBS.kTransparent)</pre>



<p>Now our symbol for minimum temperature is added. The minimum temperature is a small circle in a light blue color. In the addScatterLayer method we first specify the X and Y coordinate arrays as parameters then the title that will later be displayed in the legend next to the diagram and the shape of the symbol. Here we use PolygonShape. The number in the brackets behind the shape indicates the number of sides of the polygon. If this is 0, we see a circle. Then in the parameters follows the size of the symbol and the color. The structure is the same for other marks.</p>



<pre class="wp-block-preformatted">Call c.addScatterLayer(symbolX, symbolY, "Min value", CDBaseChartMBS.PolygonShape(0), 15, &amp;hc6e2ff)</pre>



<p>Now we create the heatmap with the method addDiscreteHeatMapLayer. It should have a size of 10 x 12 cells. 10 cells on the x axis and 12 cells on the y axis. In the parameters we first specify the array with the data and then the amount of cells on the x axis. For this we have to determined the array size of the array of the years. The cell amount for y axis is automatically determined from the amount of data. </p>



<pre class="wp-block-preformatted">Dim layer As CDDiscreteHeatMapLayerMBS = c.addDiscreteHeatMapLayer(zData, xLabels_size)</pre>



<p>We now set the labels for the axes. With the method setLabels we specify the text. With the method xAxis.setLabelStyle we specify the font and the font color. The label should be rotated by 90 degrees on the x axis so that it is easier to read. With setLabelOffset we set the distance of the text to the grid border. With a value of 0, the text would be on the left or upper edges of the cell and not in the middle. With setXAxisOnTop we indicate that the text of the x axis should be above the diagram. </p>



<p>The setting of the y axis labels is similar</p>



<pre class="wp-block-preformatted">Call c.xAxis.setLabels(xLabels) 
Call c.xAxis.setLabelStyle("Arial Bold", 10, CDBaseChartMBS.kTextColor, 90) c.xAxis.setColors(CDBaseChartMBS.kTransparent, CDBaseChartMBS.kTextColor) 
c.xAxis.setLabelOffset(0.25) 
c.setXAxisOnTop 

Call c.yAxis.setLabels(yLabels) 
Call c.yAxis.setLabelStyle("Arial Bold", 10) c.yAxis.setColors(CDBaseChartMBS.kTransparent, CDBaseChartMBS.kTextColor) 
c.yAxis.setLabelOffset(0.25) 
c.yAxis.setReverse</pre>



<p>Now we want to specify the individual colors for the value ranges. For this we create a new array. In this array we first enter the lower limit of the temperature that the color should describe, then the color value in hexadecimal followed by the uppermost value. The uppermost value is at the same time the lowermost value of the next color, so we don&#8217;t enter it twice, but give directly the next color. Our values all have a distance of 3 degrees. Afterwards we create the array colorLabels, which describes the text for our legend</p>



<pre class="wp-block-preformatted">Dim colorScale() As Double = Array(0.0, &amp;h104E8B, 0.0, &amp;h00BFFF, 3.0, &amp;h7FFFD4, 6.0, &amp;hFFFF00, 9.0, &amp;hFFC125, 12.00, &amp;hFF7F00, 15.00, &amp;hff4500, 18.00, &amp;hcd0000, 21.00,&amp;h8B0000, 21.10) 
Dim colorLabels() As String = Array("&lt;0.0", "0.0-3.0", "3.1-6.0", "6.1-9.0", "9.1-12.0", "12.1-15.0", "15.1-18.0", "18.1-21.0", „>21.0“)</pre>



<p>We then apply the colors with colorAxis.setColorScale on the layer level.</p>



<pre class="wp-block-preformatted">layer.colorAxis.setColorScale(colorScale)</pre>



<p>We place the legend 20 pixels to the right of the diagram. We use the font Arial Bold in size 10. With setKeySize we set the size of the legend boxes and with setKeySpacing the vertical distance between the individual legend entries.</p>



<pre class="wp-block-preformatted">Dim b As CDLegendBoxMBS = c.addLegend(p.getRightX + 20, p.getTopY, True, "Arial Bold", 10) 
b.setBackground(CDBaseChartMBS.kTransparent, CDBaseChartMBS.kTransparent) 
b.setKeySize(15, 15) 
b.setKeySpacing(0, 8) 
b.addText("Temp in °C“)</pre>



<p>For the colors we use a trick, we read only the colors from the array that contains the color values and the temperature ranges by looking only at every second value. With the method addKey we then add the tag with the name and the extracted color.&nbsp;</p>



<pre class="wp-block-preformatted">For i As Integer = colorLabels_size - 1 DownTo 0 
 Dim n As Integer = colorScale(i * 2 + 1) 
 b.addKey(colorLabels(i), n) 
Next</pre>



<p>With the method makeChartPicture we get our diagram as picture:</p>



<pre class="wp-block-preformatted">pic = c.makeChartPicture</pre>



<p>And you can show this picture as backdrop to better draw it with the paint event. If you use MakeChart with PDF type as parameter, you can get a PDF file to embed in a PDF page as vector graphics.</p>



<p>Then we can run the program and see our heatmap. You can then continue to work with this heatmap according to your own preferences. The final heat map looks like this:</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="758" src="https://blog.xojo.com/wp-content/uploads/2021/07/tempheatmap-1024x758.jpg" alt="" class="wp-image-8808" srcset="https://blog.xojo.com/wp-content/uploads/2021/07/tempheatmap-1024x758.jpg 1024w, https://blog.xojo.com/wp-content/uploads/2021/07/tempheatmap-300x222.jpg 300w, https://blog.xojo.com/wp-content/uploads/2021/07/tempheatmap-768x568.jpg 768w, https://blog.xojo.com/wp-content/uploads/2021/07/tempheatmap-1536x1136.jpg 1536w, https://blog.xojo.com/wp-content/uploads/2021/07/tempheatmap.jpg 1668w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>As I mentioned at the beginning of this post, you&#8217;ll need the <a href="https://www.monkeybreadsoftware.de/xojo/plugin-chartdirector.shtml">MBS Xojo ChartDirector Plugin</a> which you can purchase on the MonkeyBread Software website; or, at the moment, it&#8217;s included in super the <a href="http://omegabundle.net/">Omegabundle</a> deal. Besides ChartDirector, Omegabundle includes a ton of other tools for the sensational price of 399.99$. For example, you also get a DynaPDF Starter license with which you can use to write the chart into a PDF file. If you want to attend the Xojo Developer Conference 2022 in London and meet us, Omegabundle includes a discount of 100$ for the conference! Read articles from the Xdev developer magazine on the way to the conference, because it&#8217;s also included in the bundle! Have a look at the <a href="http://omegabundle.net/">Omegabundle</a>. It&#8217;s worth it. I hope you enjoy the heatmap!</p>



<p><em>Stefanie Juchmes studies computer science at the University of Bonn. She came in touch with Xojo due to the work of her brother-in-law and got a junior developer position in early 2019 at <a rel="noreferrer noopener" href="https://www.monkeybreadsoftware.de/xojo/" target="_blank">Monkeybread Software.</a> You may have also read her articles in <a rel="noreferrer noopener" href="http://www.xdevmag.com/" target="_blank">Xojo Developer Magazine</a>. </em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Pump Up Your Xojo Development</title>
		<link>https://blog.xojo.com/2021/05/03/the-xojo-extras-store/</link>
		
		<dc:creator><![CDATA[Dana Brown]]></dc:creator>
		<pubDate>Mon, 03 May 2021 09:12:00 +0000</pubDate>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[AprendeXojo]]></category>
		<category><![CDATA[Monkeybread Software]]></category>
		<category><![CDATA[Ohanaware]]></category>
		<category><![CDATA[Third Party]]></category>
		<category><![CDATA[xDev Magazine]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=7746</guid>

					<description><![CDATA[During this week's May Sale all Xojo licenses and everything in the Xojo Extras Store are discounted 20%! What kind of deals and extras are out there? Let's check them out! There are 5 categories of Xojo Extras: Developer Tools, User Interface, Database, Distribution and Learning.]]></description>
										<content:encoded><![CDATA[
<p>During this week&#8217;s May Sale all Xojo licenses and everything in the Xojo Extras Store are discounted 20%! What kind of deals and extras are out there? Let&#8217;s check them out. There are 5 categories of Xojo Extras: Developer Tools, User Interface, Database, Distribution and Learning.</p>



<h2 class="wp-block-heading"><strong>Developer Tools</strong></h2>



<p><strong>piDog DataView</strong> is a fast and flexible list viewer and includes one year of updates.</p>



<p><strong>Markdown Parser</strong> for Xojo is a class that allows you to implement the ability to parse Markdown source text into HTML + the provided CSS styles, so it can be presented on the fly over an HTML control for its use &#8220;as-is&#8221;, as a starting point for invoices, reports, templates or document conversion. </p>



<p>If you don&#8217;t have anything from Monkeybread Software, then this is a great deal for you! Everything is 20% off from the <strong>Complete Plugin Set</strong>, which includes 54,000+ functions, to <strong>DynaPDF</strong> for creating and editing PDF documents and more.</p>



<p><strong>Mime Parser</strong> is a class for parsing emails.</p>



<p>The <strong>OMP Plugin</strong> allows you to easily parse Microsoft Outlook Structured Storage (.MSG) files cross-platform from Xojo.</p>



<p>Also offered is a <strong>Spell Checker Class</strong> to easily spell check text.</p>



<h2 class="wp-block-heading">User Interface</h2>



<p><strong>ARWaitingView</strong> is a class to prevent the user from navigating the interface while something is downloading or doing a long process. </p>



<p><strong>AXControlGrid</strong> is a complete and powerful Xojo desktop UI component for macOS and Windows that it makes possible to put Canvas-based controls in a Page or a series of Pages of a given size and, optionally, their associated captions.</p>



<p><strong>AXImageCanvas </strong>greatly simplifies the task of displaying a Picture with the ability to correctly display the image maintaining its original aspect ratio, and keeping the full resolution of the picture and reference to the original FolderItem.</p>



<p><strong>AXNumValidatedTF</strong> is a Xojo TextField subclass (32/64 bits) for Windows and macOS allowing the input validation of a defined numeric range, using the system Locale settings for decimal and grouping text formatting.</p>



<p>Antonio Rinaldi offers <strong>Doughnut</strong>, which is an extension for iOSGraphics to draw circular graphs. Additionally, <strong>iOSTableViewExtended</strong> is a subclass that adds useful features including: swipe to reload, table header and footer, customer section header and footer, contextual menus, side index, TextEdit fix and more.</p>



<p><strong>GraffitiSuite</strong> All Access, Desktop and Web are on sale! They are a collection of custom components for Xojo Desktop and Web. </p>



<p>MBS <strong>ChartDirector</strong> lets you create professional charts in Xojo, with 30 chart and gauge types.</p>



<p><strong>RubberViews</strong> from Match Software maintains the place and relative size of every control when a Window or Container Control is resized. They also offer Window Placement and Screen Extensions that are modules that let you manage windows with greater control.</p>



<h2 class="wp-block-heading">Database</h2>



<p><strong>DataViewer Component </strong>is a collection of objects for Xojo that can easily incorporate into your own projects to give SQL Query and DML functionality for SQLite and MySQL databases along with Data Export facilities. Full source code edition also available.</p>



<p>The<strong> MBS SQL Plugin</strong> is an alternative database interface to Xojo that gives access to SQL databases including Oracle, Microsoft SQL Server, DB2, Sybase, Informix, InterBase/Firebird, SQLBase, MySQL, PostgreSQL, ODBC and SQLite. Also available is the <strong>MBS SQLite Extension</strong> is a plug-in for cubeSQL Server, a plug-in for SQLite Manager (sqlabs) and an extension for SQLite that you can use in all SQLite-based database engines, including the SQLiteDatabase class in Xojo.</p>



<p><strong>SQLVue</strong> is the fast and easy way to manage your SQLite databases.</p>



<h2 class="wp-block-heading">Distribution</h2>



<p><strong>App Wrapper </strong>from Ohanaware simplified the process of preparing applications for submission to the Mac App Store and deploying on websites. Get a 30-day or a 1 year single user or team update plan during this limited time offer.</p>



<p><strong>BoxedApp Packer</strong> helps Xojo developers prepare a single executable file that contains all required files a Xojo application needs.</p>



<p>The <strong>GuancheMOS</strong> plug-in is a serial number creation and validation Engine. Also available is <strong>GuancheID</strong>, the easiest way to get a unique ID for macOS and Windows based computers, so you can use it in combination with GuancheMOS or your own software licensing scheme to make sure your software only runs on the computer the license has been generated for.</p>



<p><strong>Quick License Manager</strong> protects your Xojo Windows application with licensing for trials, perpetual or subscription-based licenses.</p>



<h2 class="wp-block-heading"><strong>Learning</strong></h2>



<p><strong>AprendeXojo</strong> has 2 Spanish-language ebooks in the store available for $20 each during the sale:&nbsp;<em>Programación Multiplataforma Xojo</em>&nbsp;and&nbsp;<em>SQLite</em>.</p>



<p><strong>xDev Magazine</strong> is an&nbsp;independent bimonthly publication focused on educating Xojo users through instruction, tutorials and programming. Score a 1 year subscription during the sale for just $40!</p>



<h2 class="wp-block-heading">Shop Now</h2>



<p>The <a href="https://www.xojo.com/store">Xojo Extras store</a> has something for every kind of Xojo developer, whether you are learning something new or looking to save some time implementing something tricky. Take a look now to see what can help make your development life easier! The Xojo May Sale runs until midnight (CT) Friday, May 7th.  </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Professional Charts in Xojo with ChartDirector</title>
		<link>https://blog.xojo.com/2020/07/27/professional-charts-in-xojo-with-chartdirector/</link>
		
		<dc:creator><![CDATA[Stefanie Juchmes]]></dc:creator>
		<pubDate>Mon, 27 Jul 2020 18:33:55 +0000</pubDate>
				<category><![CDATA[Guest Post]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Charts]]></category>
		<category><![CDATA[Monkeybread Software]]></category>
		<category><![CDATA[Third Party]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=7193</guid>

					<description><![CDATA[Do you want to work with chart in your Xojo application? You can use the MBS ChartDirector Plugin in conjunction with the ChartDirector library to display charts.]]></description>
										<content:encoded><![CDATA[
<p>Do you want to work with chart in your Xojo application? You can use the <a href="https://www.monkeybreadsoftware.de/xojo/plugin-chartdirector.shtml">MBS ChartDirector Plugin</a> in conjunction with the ChartDirector library to display charts. In this article I would like to show you some examples that demonstrate some possibilities you have to create charts.</p>



<p>In this example we create a pie chart. A pie chart has one-dimensional data, that means that we need to filled <strong>one</strong> array with data. Here is our example:&nbsp;</p>



<p>Imagine a bakery making $1,500 a day. We now want to read from our chart what percentage of the profit is made by bread, buns, cakes and cookies. For this we enter in our array the 600$ of bread, 335$ of buns, 309$ of cake and 256$ of cookies.&nbsp;</p>



<p>So our array definition looks like this:&nbsp;</p>



<p><em>Dim data(-1) As Double = Array (600, 335, 309, 256)</em></p>



<p>We don&#8217;t have to worry about the percentage, because it is automatically calculated based on the specified array.&nbsp;</p>



<p>Now we create another array with the corresponding labels. It must be ensured that the label sequence corresponds to the order of the data sequence.&nbsp;</p>



<p><em>Dim labels(-1) As String = Array (&#8220;Bread&#8221;, &#8220;Buns&#8221;, &#8220;Cake&#8221;, &#8220;Cookies&#8221;)</em></p>



<p>We also arrange the colors of the individual circle sections as an array. Here is a small tip: You can use already known color combinations, lists of color combinations that harmonize well with each other can be found in the Internet in large numbers.&nbsp;</p>



<p>I have chosen a combination of pink and purple tones:&nbsp;</p>



<p><em>Dim colors(-1) As Integer<br>
colors.Append &amp;hBB397A <br>
colors.Append &amp;h7B448D <br>
colors.Append &amp;hDE69A5<br>
colors.Append &amp;h9672c6</em></p>



<p>Then we create our diagram working environment.&nbsp;</p>



<p><em>Dim c As New CDPieChartMBS(600, 400, &amp;hffffff, &amp;hffffff, 0)</em></p>



<p>In the parameters we can set the height and width of the working environment, the background color, the edge color and the stars of the elevation effect.&nbsp;</p>



<p>In the image you can see a working environment with a red background, blue edge color and the elevation of 5, additionally the corners have been rounded with the method <em>setRoundedFrame</em>.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="768" src="https://blog.xojo.com/wp-content/uploads/2020/07/Picture-1-1024x768.png" alt="" class="wp-image-7194" srcset="https://blog.xojo.com/wp-content/uploads/2020/07/Picture-1-1024x768.png 1024w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-1-300x225.png 300w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-1-768x576.png 768w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-1.png 1424w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>But for our example we take a white background.</p>



<p>Then we can insert the title of the diagram that should appear in the middle of the upper side. In the parameters we can set the text, font, font size, font color, font box background color and the text box border color. In our example we define only the text and leave the remaining parameters at the default values.</p>



<p><em>call c.addTitle(&#8220;Pie Chart Demonstration&#8221;)&nbsp;</em></p>



<p>Now we can make some settings for the chart.</p>



<p>First we define the size and position of the pie chart.&nbsp;</p>



<p><em>c.setPieSize(300, 200, 110)</em></p>



<p>Our working area has a size of 600&#215;400 which means that if we want to position the chart in the middle of our working area we have to halve these values so we get 300 and 200 which we then specify in the parameters. The third parameter describes the size of the pie chart with the radius. If we had a ring chart instead of a pie chart, the inner radius would be given in a fourth parameter and the called function would be <em>setDonutSize</em>.&nbsp;</p>



<p>Afterwards we can specify the color of the data areas.&nbsp;</p>



<p>In the first parameter we specify that we want to set the data color, because the <em>SetColors</em> method can be used in many more areas. In the second parameter we specify the already created array <em>colors </em>:</p>



<p><em>c.setColors(c.kDataColor, colors)</em></p>



<p>Then we can set that our pie chart should be shown as a 3D figure and with the command:&nbsp;</p>



<p><em>c.set3D(deeps, 45, False) </em></p>



<p>Set the heights of the segments so that they look like stairs and the angle with which we look at the chart. The point of view depends on the shadow mode, which is switch off by default.&nbsp;</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="729" src="https://blog.xojo.com/wp-content/uploads/2020/07/Picture-2-1024x729.png" alt="" class="wp-image-7195" srcset="https://blog.xojo.com/wp-content/uploads/2020/07/Picture-2-1024x729.png 1024w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-2-300x214.png 300w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-2-768x547.png 768w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-2-1536x1093.png 1536w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-2-2048x1458.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="729" src="https://blog.xojo.com/wp-content/uploads/2020/07/Picture-3-1024x729.png" alt="" class="wp-image-7196" srcset="https://blog.xojo.com/wp-content/uploads/2020/07/Picture-3-1024x729.png 1024w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-3-300x214.png 300w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-3-768x547.png 768w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-3-1536x1093.png 1536w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-3-2048x1458.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>With Shadow Mode (2) and without Shadow Mode (3)</p>



<p>We prefer that the angle of the first segment does not start straight up, for this we use the <em>SetStartAngle</em> method. Also, the individual segments should not stick to each other and there should be a small gap between them. We want to highlight the largest segment a bit more and move it further out. In the <em>SetExplode</em> method we first specify the data segment we want to push out of the circle and the amount by which it should be pushed out:</p>



<p><em>c.setStartAngle(-20)<br>c.setExplode(0, 20)<br>c.setExplode(1, 20)<br>c.setExplode(2, 2)<br>c.setExplode(3, 2)</em></p>



<p>So that our data can also be displayed we have to pass the data to the diagram. With <em>SetData</em> we specify the data and assign the right labels to them. Both informations we find in the already prepared arrays:</p>



<p><em>c.setData(data, labels)</em></p>



<p>Our labels do not look handsome yet. We would like to change that now by defining their style. The label name should be italic, bold and a little bit bigger, than the other labels. Underneath it should be the given value in US$ and in brackets behind it the percentage value</p>



<p>The definition of this style is as given here in a format string:</p>



<p><em>c.setLabelFormat(&#8220;&lt;*block,halign=left*&gt;&lt;*font=timesbi.ttf,size=12,underline=0*&gt;{label}&lt;*/font*&gt;&lt;*br*&gt;US$ {value} ({percent}%)&#8221;)&nbsp;</em></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="729" src="https://blog.xojo.com/wp-content/uploads/2020/07/Picture-4-1024x729.png" alt="" class="wp-image-7197" srcset="https://blog.xojo.com/wp-content/uploads/2020/07/Picture-4-1024x729.png 1024w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-4-300x214.png 300w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-4-768x547.png 768w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-4-1536x1093.png 1536w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-4-2048x1458.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>In the style sting we first define the text alignment. This should be left-aligned. Then we specify timerbi.ttf as font. This font is already italics and bold (recognizable by the b and i at the end). In addition, we specify the font size with 12 and that the text is not underlined. These specifications refer to the label text. This is specified with <em>{label}</em> in the style string. After a line break the text <em>US$</em> and the value of the segment that is specified with <em>{value} </em>is following. In the default case it is assumed that the value is a number. But if it is a date we can format it with the following additions: <em>{value|mm/dd/yyyyy}</em>, <em>{value|mm/yyyyy}</em> or <em>{value|yyyyy}</em>. In our example, the percentage with <em>{percent}</em> in brackets follows.</p>



<p>If you want your segment description texts to be highlighted in the individual segment colors and have lines to the individual segments, you can add the following line:</p>



<p><em>c.setLabelLayout(c.kSideLayout)</em></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="729" src="https://blog.xojo.com/wp-content/uploads/2020/07/Picture-5-1024x729.png" alt="" class="wp-image-7198" srcset="https://blog.xojo.com/wp-content/uploads/2020/07/Picture-5-1024x729.png 1024w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-5-300x214.png 300w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-5-768x547.png 768w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-5-1536x1093.png 1536w, https://blog.xojo.com/wp-content/uploads/2020/07/Picture-5-2048x1458.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Finally, we want to display our diagram in the window as a background picture. To do this, we adjust our window size to the size of the diagram. Then we create a picture with the method makeChartPicture, which we then set as the backdrop.&nbsp;</p>



<p><em>w.Height = c.getHeight<br>w.Width = c.getWidth<br>w.Backdrop = c.makeChartPicture</em></p>



<p>Of course we could have used the picture also to write it into a file. For this we can use the method <em>Save</em> in combination with a folder item or we could have used the picture to insert it into a PDF file with <a href="https://www.monkeybreadsoftware.de/xojo/plugin-dynapdf.shtml">DynaPDF</a>.&nbsp;</p>



<p>There are many more possibilities to design charts with Chart Director, but this example should give you a short insight to the work with Chart Director.&nbsp;</p>



<p>To use these functionalities you need a license of the <a href="https://www.monkeybreadsoftware.de/xojo/plugin-chartdirector.shtml">MBS ChartDirector Plugin</a>. You get it either in the Xojo store, on our website or currently in the <a href="http://www.omegabundle.net">OmegaBundle 2020</a>.</p>



<p>I wish you a lot of fun with the charts in Xojo.&nbsp;Download the project.</p>



<p><em>Stefanie Juchmes studies computer science at the University of Bonn. She came in touch with Xojo due to the work of her brother-in-law and got a junior developer position in early 2019 at<a rel="noreferrer noopener" href="https://www.monkeybreadsoftware.de/xojo/" target="_blank">&nbsp;Monkeybread Software.</a>&nbsp;You may have also read her articles in<a rel="noreferrer noopener" href="http://www.xdevmag.com/" target="_blank">&nbsp;Xojo Developer Magazine</a>.&nbsp;</em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Building an RFC interface with MBS Xojo Plugin to SAP R/3 or SAP S/4 HANA</title>
		<link>https://blog.xojo.com/2020/05/28/building-an-rfc-interface-with-mbs-xojo-plugin-to-sap-r-3-or-sap-s-4-hana/</link>
		
		<dc:creator><![CDATA[Michael Eckert]]></dc:creator>
		<pubDate>Thu, 28 May 2020 10:00:00 +0000</pubDate>
				<category><![CDATA[Guest Post]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Enterprise Software]]></category>
		<category><![CDATA[Monkeybread Software]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[Third Party]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=7032</guid>

					<description><![CDATA[With the RFC classes of the MBS Xojo Tools Plugin you can build RFC interfaces to SAP systems.]]></description>
										<content:encoded><![CDATA[
<p>If you work with large companies, you&#8217;ve most likely heard of SAP, a widely used enterprise software solution. With the RFC classes of the <a href="https://www.monkeybreadsoftware.de/xojo/plugins.shtml">MBS Xojo Plugin</a> you can build RFC (Remote Function Call) interfaces so that Xojo apps can communicate with SAP systems. I’ve done this to SAP R/3 and SAP S/4 HANA. The MBS plugin covers the libraries of the SAP NetWeaver RFC SDK 7.50.</p>



<h3 class="wp-block-heading">The SAP interface has four steps:</h3>



<ol class="wp-block-list"><li>Determine the path to the SAP library&nbsp;</li><li>Build a connection to the SAP system</li><li>Transfer data to the SAP system</li><li>Receive data from the SAP system</li></ol>



<h3 class="wp-block-heading">Connect the SAP System</h3>



<p>Your SAP user must have the authority for RFC connections. If so, you must know some data of your SAP logon to connect to an SAP system, such as:</p>



<ul class="wp-block-list"><li>host name &#8211; a name or an IP address (ashost)</li><li>router string&nbsp;</li><li>system number (sysnr)</li><li>client (client)</li><li>language (lang)</li><li>user (user)</li><li>password (passwd)</li></ul>



<p>At first you must set the path to the SAP libraries. In Windows you have some DLL’s around SAPNWRFC.DLL and on macOS you have some DYLIB’s around LIBSAPNWRFC.DYLIB.</p>



<pre class="wp-block-preformatted">If TargetWin32
  var LibFile as string = "sapnwrfc.dll"
Else
  // get the actual folder and handle the exception
  var MacOsFolder as folderitem = app.ExecutableFile.Parent
  System.EnvironmentVariable("DYLD_LIBRARY_PATH") = MacOsFolder.NativePath
  If System.EnvironmentVariable("DYLD_LIBRARY_PATH") = "" Then
    MessageBox("DYLD_LIBRARY_PATH variable not set")
    return
  end if
  var LibFile as FolderItem = MacOsFolder.Child("libsapnwrfc.dylib")
  var LibPath As String = LibFile.parent.NativePath
  Call RFCModuleMBS.SetCurrentWorkingDirectory(libPath)
EndIf</pre>



<p>I’ve copied the SAP libraries with the Xojo build settings into the application resource folders.&nbsp;</p>



<p>If the setting of the LibPath fails then send the error message:</p>



<pre class="wp-block-preformatted">If not RFCModuleMBS.LoadLibrary(LibFile) Then
  // Failed to load library
  Messagebox RFCModuleMBS.LibraryLoadErrorMessage
  return
End If </pre>



<p>And if the LibPath is set you can do the logon as second step:</p>



<pre class="wp-block-preformatted">var loginParams As New Dictionary
loginParams.Value("ashost") = "12.345.67.89"
loginParams.Value("sysnr")  = "10"
loginParams.Value("client") = "100"
loginParams.Value("user")   = "MYUSERNAME”
loginParams.Value("passwd") = "MyPassword"
loginParams.Value("lang")   = "EN"
var ConnectionToSAP As New RFCConnectionMBS(loginParams) </pre>



<p>Please note if you have a router string you must build the host name (ashost) with a concatenation of router string and host name like this:</p>



<pre class="wp-block-preformatted">loginParams.Value("ashost") = &lt;router string&gt; + "/H/" + &lt;host name&gt;</pre>



<p>If the connection fails you will get the reason with:</p>



<pre class="wp-block-preformatted">Exception r As RFCErrorExceptionMBS
 MessageBox r.message </pre>



<h3 class="wp-block-heading">Calling an SAP Function Module</h3>



<p>If you are calling a SAP Function Module you will export key values to SAP and you will receive data or i.e. error messages. To understand the import and export parameters you must look out of the SAP function module in the surrounding world.</p>



<p>This example calls the SAP function module RFC_READ_TABLE. With this standard RFC module you can get the content of a database table and/or the SAP data dictionary description of this table.</p>



<h4 class="wp-block-heading">Exporting key values to SAP</h4>



<p>For exporting the key values to the SAP function module you must load a functions description and create a data container for executing the function module.</p>



<pre class="wp-block-preformatted">var fd as RFCFunctionDescriptionMBS = app.ConnectionToSAP.FunctionDescription("RFC_READ_TABLE")
var f as RFCFunctionMBS = fd.CreateFunction </pre>



<p>The function module RFC_READ_TABLE has two parameters:</p>



<ul class="wp-block-list"><li>the name of the table as import parameter: QUERY_TABLE</li><li>the select options of the where clause as tables parameter: OPTIONS</li></ul>



<pre class="wp-block-preformatted">f.StringValue("QUERY_TABLE") = "&lt;name of the table&gt;"

var it_OPTIONS as RFCTableMBS = f.TableValue("OPTIONS")
var is_OPTIONS as RFCStructureMBS

is_OPTIONS = it_OPTIONS.AppendNewRow
is_OPTIONS.StringValue("TEXT") = "(MATNR = '4711')" // WHERE clause</pre>



<p>You must consider that the maximum length of a where clause for the table OPTIONS is 72 digits. If the where clause length is greater than 72 you must split the clause to several lines. The clause must look like this “(MATNR = ‘1234’ AND WERKS = ‘1000’) OR (MATNR = ‘3456’ AND WERKS = ‘1000’)”.&nbsp;</p>



<p>And now you can execute the function module into the backend system:</p>



<pre class="wp-block-preformatted">f.invoke</pre>



<h4 class="wp-block-heading">Receiving data from SAP</h4>



<p>The function module RFC_READ_TABLE returns now to tables parameters:</p>



<ul class="wp-block-list"><li>FIELDS – contains the SAP data dictionary description of the returned table</li><li>DATA – contains the data found for the transferred where clauses</li></ul>



<pre class="wp-block-preformatted">TableFields as RFCTableMBS = f.TableValue("FIELDS")
TableData as RFCTableMBS = f.TableValue("DATA") </pre>



<p>If the TableFields.RowCount = 0 then the returned table contains no data. To get the content of a returned table you must loop like this:</p>



<pre class="wp-block-preformatted">If TableData.RowCount &gt; 0 then
  TableData.MoveToFirstRow
End if
For iRow as integer = 1 to TableData.RowCount
  // get a field value
  Var FieldValue as string = TableData.StringValue("&lt;Fieldname in the table record&gt;")
  If iRow &lt; TableData.RowCount then
    TabeData.MoveToNextRow
  End if
next</pre>



<h4 class="wp-block-heading">Error Handling</h4>



<p>To catch an exception, you should code into your method something like this:</p>



<pre class="wp-block-preformatted"> Exception r As RFCErrorExceptionMBS
  MessageBox r.message </pre>



<h4 class="wp-block-heading">Interpretation of Returned Data</h4>



<p>If you want to get after the INVOKE the returned data you will have&nbsp;</p>



<ul class="wp-block-list"><li>a table or</li><li>a structure or</li><li>a field</li></ul>



<p>If you have a table you will get a certain field with:</p>



<pre class="wp-block-preformatted">Var TableContent as RFCTableMBS
TableContent = f.TableValue("&lt;Name of the returned table parameters&gt;")
If TableContent.RowCount &gt; 0 then
  TableContent.MoveToFirstRow
End if
For iRow as integer = 1 to TableContent.RowCount
  ListBox1.AddRow(TableContent.StringValue("FieldOne"), TableContent.StringValue("FieldTwo"))
  If iRow &lt; TableContent.RowCount then
    TableContent.MoveToNextRow
  End if
Next</pre>



<p>If you have a structure you will get a certain field with:</p>



<pre class="wp-block-preformatted">var s As RFCStructureMBS = f.StructureValue("ES_MESSAGE")</pre>



<pre class="wp-block-preformatted">TextField1.Value = s.StringValue("FieldOne")</pre>



<p>If you have a field you will get the data with:</p>



<pre class="wp-block-preformatted">TextField1.Value = f.StringValue("FieldName")</pre>



<p>Using the above techniques with the MBS plugin, your Xojo apps can now access information contained in SAP.</p>



<p><em>Michael Eckert studied economics from 1982-1986 and has been employed at T-Systems as a software architect since 1989. Michael has worked with ERP systems for 34 years, until 1998 with PL/1, since 1998 with ABAP in SAP R/3 and SAP S/4 HANA. He&#8217;s been developing with Xojo for about 9 years.</em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Dealing with Pictures and Databases: AXImageCanvas</title>
		<link>https://blog.xojo.com/2019/08/28/dealing-with-pictures-and-databases-aximagecanvas/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Wed, 28 Aug 2019 15:14:31 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[AprendeXojo]]></category>
		<category><![CDATA[DarkMode]]></category>
		<category><![CDATA[Third Party]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=6004</guid>

					<description><![CDATA[How to save pictures in a database is without doubt one of the more frequent questions I&#8217;m asked about. I hear this from Xojo newcomers,&#8230;]]></description>
										<content:encoded><![CDATA[
<p><br>How to save pictures in a database is without doubt one of the more frequent questions I&#8217;m asked about. I hear this from Xojo newcomers, and not so newcomers, just as much as I do from people using other development environments. That&#8217;s why I decided to put all the frequent questions and operations related to the Canvas and Pictures on the drawing board …&nbsp;and AXImageCanvas is the result of that!</p>



<p>Things like drag and drop (from other sources and also to other sources), undoing the picture assigned, moving the control instances around the parent <strong>RectControl</strong> (or Window), reacting to <strong>DarkMode</strong> changes on macOS, and properly resizing the picture so it fits in the Canvas area while keeping its original aspect ratio are implemented in AXImageCanvas, among other features.</p>



<p>Of course, AXImageCanvas abstracts the user from everything related to the usual <strong>CRUD</strong> operations associated with a Database backend: Creating a new Record, Retrieving the Picture from a record, Updating the Picture of an existing record, and Deleting the Picture for the designated record. All of this trying to mimic the easiness of use we are used to when using the standard Xojo framework itself.</p>



<p>The user only needs to assign, paste or drop the Picture to display …&nbsp;and AXImageCanvas takes care of the rest.</p>



<p>So, for example, the binding behavior to a database is implemented in a way that tries to emulate one of the most appreciated features for Xojo users in the past: DataControl.</p>



<p>The user only needs to set the database instance they want to use (it may be a <strong>MySQL/MariaDB</strong>, <strong>PostgreSQL</strong> or <strong>SQLite</strong> database instance), the name of the table they want to use, the name of the column to store the pictures and (optionally) the name of the column to store the original path to a picture read from a <strong>FolderItem</strong>.</p>



<p>Even if there is only set the column to store the original Picture FolderItem path, then it will not save the Picture data itself, and it will recover the picture later to display based on the saved path information. This alleviates the database data overload for some use cases, when the developer of a solution prefers not to store the picture data in the database itself, just the path pointing to it.</p>



<p>The class is also smart enough to abstract the user from all the SQL queries it would have to write in function of the database engine used. It is completely transparent, as it is the navigation through the database records even if their IDs are not consecutive (this is a mandatory requirement: the table has to have an ID column).</p>



<p>The logic put in the class also gathers information about the database table itself, if for example it only has the two columns set to the instance (Picture column and Picture source path column; plus the mandatory ID column), then the Delete Record action will effectively delete the record from the assigned database table; otherwise, if the table has more columns, it will NOT delete the record, because it&#8217;s something you probably wouldn&#8217;t want to do … and it simply updates the displayed record to empty (nullify) the information for the Picture and (optionally) the Picture Path columns, keeping thus the rest of the record data intact.</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="AXImageCanvas" width="500" height="375" src="https://www.youtube.com/embed/IhbE5AdhiOE?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>As for PostgreSQL database, there are two paths that can be taken regarding storing Pictures. We can say that the first one is the usual path, storing the Picture data itself in a column table (valid for data not exceeding 1 GB) and through Large Objects (<strong>pg_largeobject</strong>) via the previous acquisition of an <strong>OID</strong> value. AXImageCanvas uses the first technique.</p>



<p>In addition, it also properly deals with record navigation for all the supported databases engines even if the records IDs are not consecutive; and when the records navigation is set to the &#8220;wrap around&#8221; mode, it does it also correctly for all of the supported databases engines.</p>



<p>Another common quirk it deals with answers one of the usual questions: Database Server disconnections due to the timeout. AXImageCanvas takes care of it when the connection is lost and if it is something not transient, then properly raises the exception so it can be cached by the application logic.</p>



<p>But one of the most important things is that everything can be configurable through the properties shown in the <strong>Inspector Panel</strong> of the <strong>Xojo IDE</strong>, for the maximum simplicity in the AXImageCanvas setup; and also via code to give the maximum flexibility at runtime when the application is in use, so it can react to things like changing the database engine, or simply disabling things like moving or resizing the control among others.</p>



<h2 class="wp-block-heading">Pictures and Drawing Speed</h2>



<p>What about redrawing concerns? This is something that AXImageCanvas also takes care of. It applies several image caching techniques while keeping the set Picture at its full resolution.</p>



<p>This allows, for example, abstracting you from what you can see displayed in the AXImageCanvas control at the desired size, from what you can do with the original Picture itself: from previewing it (something you can do simply pressing the space bar when the AXImageCanvas has the focus), getting more information about the Picture and (optionally) original FolderItem (press the &#8216;I&#8217; key for that while the AXImageCanvas instance has the focus), or any other operation your app would want to do, like for example exporting the picture to other format.</p>



<p>In this sense, it also takes into consideration the operations done with the control itself during the redrawing or control size changes, minimizing the writing to the Database to the strictly necessary (always, of course, there is a database associated with the instance).</p>



<h2 class="wp-block-heading">The Goals</h2>



<p>To summarize, AXImageCanvas tries to be the simplest solution when dealing with Pictures and (optionally) its storage on databases. Just drop as many instances as you need in your layout, set the behaviour through the Inspector Panel Properties (even setting the initial picture to display) …&nbsp;and you&#8217;re done! The best part is that the behaviour will be the same for Windows, macOS and Linux deployed Desktop applications, both in 32 and 64 bits.</p>



<p>Of course, you can <a href="https://www.dropbox.com/s/4rc208njqel4o7g/AXImageCanvas%201.0.zip?dl=1">download the Xojo Project Example</a> and try it yourself! This is a fully functional demo without restrictions. I&#8217;d be glad to hear from you about suggestions or features you would want to be included for better fit your needs!</p>



<p><em>Javier Rodri­guez has been&nbsp;the Xojo Spanish&nbsp;Evangelist since 2008, he’s also a Developer, Consultant and Trainer who&nbsp;has be using&nbsp;Xojo since 1998. He manages&nbsp;<a href="http://www.aprendexojo.com">AprendeXojo.com</a> and is the developer behind the GuancheMOS plug-in for Xojo Developers, GuancheID, AXImageCanvas, Markdown Parser for Xojo, HTMLColorizer for Xojo and the Snippery app, among others.</em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Loading 3rd Party Frameworks in Xojo iOS</title>
		<link>https://blog.xojo.com/2019/01/17/loading-3rd-party-frameworks-in-xojo-ios/</link>
		
		<dc:creator><![CDATA[Greg O'Lone]]></dc:creator>
		<pubDate>Thu, 17 Jan 2019 10:00:57 +0000</pubDate>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Declares]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Third Party]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=5319</guid>

					<description><![CDATA[If you're familiar with Declares in iOS, loading a 3rd Party framework requires just a couple of extra lines of code in Xojo and a CopyFilesStep. In this example build and run SimulatorStatusMagic in the Simulator in order to always show a default date and time values when you do a debug run. ]]></description>
										<content:encoded><![CDATA[<p>Did you know that it&#8217;s possible to load and use 3rd Party Frameworks in your Xojo iOS projects? There&#8217;s quite a number of good projects out there, many of which are on sites like <a href="https://github.com">GitHub</a> and freely available for use in your projects. If you&#8217;re familiar with Declares in iOS, loading a 3rd Party framework requires just a couple of extra lines of code and a CopyFilesStep.</p>
<p>Last year at XDC 2018, <a href="https://github.com/jkleroy">Jérémie Leroy</a> talked about making sure your screenshots mimicked the Apple method so that the date was always Jun 9th, the time was always 9:41 AM, the battery always shows as full and the WiFi strength always shows full. It got me thinking that it might be handy to be able to make the simulator <em>always</em> show those values when you do a debug run so that you don&#8217;t need to think about it when you are ready to start taking screenshots and movies of your app. One way to do that is to build &amp; run project like <a href="https://github.com/shinydevelopment/SimulatorStatusMagic">SimulatorStatusMagic</a> on the simulator before running your project, but it would be more useful if it was <em>automatic</em>.</p>
<p><span id="more-5319"></span></p>
<h3>Build the Framework</h3>
<p>First of all, go to the SimulatorStatusMagic Github page and clone or download the project. Just like Xojo iOS development, you&#8217;ll need <a href="https://developer.apple.com/xcode/">Xcode</a> for this step. After you&#8217;ve downloaded the project, double-click on the SimulatorStatusMagic.xcodeproj file to open it in Xcode. When the project opens, change the target to SimulatorStatusMagiciOS and build it by either pressing CMD-B or pressing the Play button. Once the build is complete, go to the project navigator, scroll down to the bottom and open the Products group to reveal the built parts of this project. The only item we&#8217;re concerned with here is the file named SimulatorStatusMagiciOS.framework. Right-click on it and select Show in Finder.</p>
<h3>Build the Project</h3>
<p>Let&#8217;s start off by making sure the framework will be available to your project at runtime.</p>
<ol>
<li>Create a folder on your drive named SimulatorStatusMagic and copy the framework file that you just built into it.</li>
<li>Launch Xojo and create a new iOS project. Save the project into that folder as well.</li>
<li>To make sure the framework will be available to your project when debugging, go to the iOS target in the Xojo navigator, right-click and select Build Step &gt; Copy Files. Make sure the step is between the Build step and the Sign step.</li>
<li>Drag the SimulatorStatusMagiciOS.framework file from the Finder into the Copy Files Step.</li>
<li>In the Xojo inspector, set Applies To to &#8220;Debug&#8221; and Destination to &#8220;App Parent Folder&#8221;.</li>
</ol>
<p>Now let&#8217;s make it so you can access the framework! We&#8217;re going to add this code in the App.Open event so that the status bar gets set up before you do anything else.</p>
<p>Getting the framework to load is fairly straightforward:</p>
<pre>#If DebugBuild
  Declare Function dlopen Lib "/usr/lib/libSystem.dylib" (name As CString, flags As Int32) As Ptr
  Call dlopen("@executable_path/SimulatorStatusMagiciOS.framework/SimulatorStatusMagiciOS", 1 Or 8)
#EndIf</pre>
<p>That magic string &#8220;@executable_path&#8221; gets translated into &#8220;wherever the current application currently is&#8221; at runtime. Now this just loads the framework. We still need to hook up the methods and properties. <em>Note: If you&#8217;re working with a framework that &#8220;activates itself&#8221; like the one that comes with <a href="https://revealapp.com">Reveal</a> (an excellent tool for tracking down iOS layout issues), this is as far as you would need to go.</em></p>
<p>To figure out what we need to do next, we need to look at the documentation and header files that come with SimulatorStatusMagic. Go back to Xcode and look at the navigator. What we&#8217;re looking for is a header file (with a .h extension) which has the definitions of each of the methods and properties which are available in this framework. The only file that meets this criteria (and the one that all the others seem to point to) is named SDStatusBarManager.h. There&#8217;s a bit of functionality available here, but the framework is set up to use the Apple recommended settings by default, so all we&#8217;re going to do here is call the enableOverrides method to activate it.</p>
<p>Go back to Xojo and update App.Open event:</p>
<pre>#If DebugBuild
  Declare Function dlopen Lib "/usr/lib/libSystem.dylib" (name As CString, flags As Int32) As Ptr
  Call dlopen("@executable_path/SimulatorStatusMagiciOS.framework/SimulatorStatusMagiciOS", 1 Or 8)

  // Start by creating a pointer to the SDStatusBarManager class itself
  Declare Function NSClassFromString Lib "Foundation" (clsName As CFStringRef) As Ptr
  Dim smclass As Ptr = NSClassFromString("SDStatusBarManager")

  // Next, we need a pointer to the shared instance of the SDStatusBarManager class
  Declare Function sharedInstance Lib "Foundation" Selector "sharedInstance" (clsref As Ptr) As Ptr
  Dim smclassShared as Ptr = sharedInstance(smclass)

  // Last, turn on the overrides
  // NOTE: We're specifically NOT using the actual lib name here. 
  // This is just to satisfy the Xojo linker. The correct framework will be used at runtime.
  Declare Sub enableOverrides Lib "Foundation" Selector "enableOverrides" (obj As Ptr)
  enableOverrides(smclassShared)
#EndIf</pre>
<p>Now if you run the project, when it opens the status bar automatically changes to the recommended defaults!</p>
<p>Please Note: These changes persist until the simulator device that you are running on is completely erased. If you need to disable it, you can do that with the disableOverrides method.</p>
<p>After posting this article, it was brought to my attention that I&#8217;d forgotten to show you how to sign the frameworks so you can build for the app store. To do that, you&#8217;ll need to add a script build step to your project, just after the Copy Files step you added above. The step can probably be set to Applies To: Release. The code should look like this:</p>
<pre>// Replace the text in the signingIdentity property with your own
Dim signingIdentity As String = "iPhone Distribution: Your Company (XXXXXXXXXX)"
Dim code As Integer
Dim cmd As String
Dim result As String
Dim builtApp As String

builtApp = CurrentBuildLocation + "/" + ReplaceAll(CurrentBuildAppName, " ", "\ ")

// Get a list of all frameworks, one per line
cmd = "ls -d1 " + builtApp + "/*.framework"
result = Trim(DoShellCommand(cmd, 30, code))

// If there was no error (like none being there), sign each one
If code = 0 Then
  Dim frameworks() As String = split(result, chr(13))
  For i As Integer = 0 To UBound(frameworks)
    frameworks(i) = ReplaceAll(frameworks(i), " ", "\ ")
    cmd = "/usr/bin/codesign -fs """ + signingIdentity + """ " + frameworks(i)

    Result = DoShellCommand(cmd, 30, code)

    // If the sign fails, print the error and stop the build
    If code &lt;&gt; 0 Then
      print Result
      cancelBuild
    End If
  Next i
End If</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
