Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

#296 - Update Stylx Creation Process #335

Merged
merged 6 commits into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/.vs
/bin/Debug
/bin/Release
/obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<ArcGIS defaultAssembly="GenerateSVGStyle.dll" defaultNamespace="GenerateSVGStyle" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd">
<AddInInfo id="{0b54db9a-45bc-445b-b275-dd6faca598b6}" version="1.0" desktopVersion="2.1">
<Name>GenerateSVGStyle</Name>
<Description>GenerateSVGStyle description</Description>
<Image>Images\AddinDesktop32.png</Image>
<Author>Acme</Author>
<Company>Acme</Company>
<Date>2/21/2018</Date>
<Subject>Framework</Subject>
<!-- Note subject can be one or more of these topics:
Content, Framework, Editing, Geodatabase, Geometry, Geoprocessing, Layouts, Map Authoring, Map Exploration -->
</AddInInfo>
<modules>
<insertModule id="GenerateSVGStyle_Module" className="Module1" autoLoad="false" caption="Module1">
<!-- uncomment to have the control hosted on a separate tab-->
<tabs>
<!--<tab id="GenerateStyle_Tab1" caption="New Tab">
<group refID="GenerateStyle_Group1"/>
</tab>-->
</tabs>
<groups>
<!-- comment this out if you have no controls on the Addin tab to avoid
an empty group-->
<group id="GenerateSVGStyle_Group1" caption="" appearsOnAddInTab="true">
<!-- host controls within groups -->
<button refID="GenerateSVGStyle_GenerateButton" size="large" />
</group>
</groups>
<controls>
<!-- add your controls here -->
<button id="GenerateSVGStyle_GenerateButton" caption="Generate SVG Style" className="GenerateButton" loadOnClick="true" smallImage="Images\GenericButtonBlue16.png" largeImage="Images\GenericButtonBlue32.png">
<tooltip heading="Tooltip Heading">Tooltip text<disabledText /></tooltip>
</button>
</controls>
</insertModule>
</modules>
</ArcGIS>
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GenerateSVGStyle
{
/// <summary>
/// Takes a CSV file and converts to a Data Table
/// IMPORTANT: the CSV *must* have a first/header row that has the desired
/// column names to be used
/// CSV lines starting with "#" will be ignored (as comments)
/// </summary>
class CsvToTableMaker
{
public CsvToTableMaker()
{

}

// Somewhat hack-ish - needed check for when file is locked or can't be opened
// (e.g. because of open/being viewed somewhere else-like Excel)
public bool IsFileOpenable(string filePath)
{
try
{
using (File.Open(filePath, FileMode.Open)) { }
}
catch (IOException ex)
{
System.Diagnostics.Trace.WriteLine("ERROR: " + " Message: " + ex.Message +
" Could not open file : " + filePath);
return false;
}

return true;
}

public bool LoadTable(string csvFile)
{
bool success = false;

if (!File.Exists(csvFile) || !(IsFileOpenable(csvFile)))
return false;

if (table != null)
{
System.Diagnostics.Trace.WriteLine(
"Warning: Unexpected: Table has been initialized previously");
return false;
}

table = new DataTable();

bool firstRow = true;
int maxHeadingColumn = 0;

foreach (string line in File.ReadLines(csvFile))
{
if (line.StartsWith("#")) // allow "#" comment character
continue;

string[] values = line.Split(',');

if (firstRow)
{
// IMPORTANT: creates column names from the first row
foreach (string columnName in values)
{
table.Columns.Add(columnName);
maxHeadingColumn++;
}
firstRow = false;
continue;
}

DataRow row = table.NewRow();

int index = 0;
foreach (string value in values)
{
if (index < maxHeadingColumn) // just in case
row[index++] = value;
}

table.Rows.Add(row);
}

success = true;

return success;
}

public DataTable Table
{
get { return table; }
}
private DataTable table = null;

public bool IsValid
{
get
{
if (table == null)
return false;

if ((table.Rows != null) && (table.Columns != null) &&
(table.Rows.Count > 0) && (table.Columns.Count > 0))
{
// Any other check needed? column names?
return true;
}

return false;
}
}

public void DebugOutput()
{
if (!IsValid)
{
System.Diagnostics.Trace.WriteLine("Table not initialized! Can't Output!");
return;
}

foreach (DataRow row in table.Rows)
{
foreach (var item in row.ItemArray)
{
System.Diagnostics.Trace.Write(" | " + item);
}
System.Diagnostics.Trace.WriteLine(" |");
}
}

}

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright 2018 Esri
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Framework.Contracts;

namespace GenerateSVGStyle
{
internal class GenerateButton : Button
{
private GenerateOptionsViewModel _vm = new GenerateOptionsViewModel();
protected override void OnClick()
{
GenerateOptions dlg = new GenerateOptions(_vm);

Module1.Current.GenerateOptionsWindow = dlg;

var ok = dlg.ShowDialog();
}
}
}
Loading