Skip to content

Commit

Permalink
issue #18 resolve for c# project
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitryvhf committed Jan 27, 2020
1 parent ab7b202 commit ffbc383
Show file tree
Hide file tree
Showing 7 changed files with 629 additions and 559 deletions.
8 changes: 7 additions & 1 deletion L2ScriptMaker/Extensions/VbCompatibleHelper/Conversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ namespace L2ScriptMaker.Extensions.VbCompatibleHelper
{
public static class Conversions
{
public static bool ToBoolean(string value) => Convert.ToBoolean(value);
public static bool ToBoolean(string value)
{
if (value == "1") value = "true";
if (value == "0") value = "false";

return Convert.ToBoolean(value.ToLower());
}

public static short ToShort(int value) => Convert.ToInt16(value);
public static short ToShort(string value) => Convert.ToInt16(value);
Expand Down
6 changes: 6 additions & 0 deletions L2ScriptMaker/Extensions/VbCompatibleHelper/Libraries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public static string GetNeedParamFromStr(string SourceStr, string MaskStr)
FirstPos = Strings.InStr(1, SourceStr, " " + MaskStr + "="); // + 1
if (FirstPos == default(int))
{
if (SourceStr.StartsWith(MaskStr))
{
GetNeedParamFromStrRet = SourceStr.Remove(0, MaskStr.Length + 1).Trim();
return GetNeedParamFromStrRet;
}

GetNeedParamFromStrRet = "";
return GetNeedParamFromStrRet;
}
Expand Down
28 changes: 28 additions & 0 deletions L2ScriptMaker/Extensions/WinFormsControlExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace L2ScriptMaker.Extensions
{
public class SelectedItem
{
public string Text { get; set; }
public string Value { get; set; }
}

public static class WinFormsControlExtension
{
public static void SelectItembyValue(this ComboBox comboBox, string value)
{
comboBox.SelectedIndex = -1;

SelectedItem foundItem = comboBox.Items.OfType<SelectedItem>().FirstOrDefault(a => a.Value == value);
if (foundItem == null) return;

comboBox.SelectedItem = foundItem;
}
}
}
1 change: 1 addition & 0 deletions L2ScriptMaker/L2ScriptMaker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<Compile Include="Extensions\VbCompatibleHelper\Libraries.cs" />
<Compile Include="Extensions\VbCompatibleHelper\MyAssemblyInfo.cs" />
<Compile Include="Extensions\VbCompatibleHelper\Strings.cs" />
<Compile Include="Extensions\WinFormsControlExtension.cs" />
<Compile Include="Modules\AI\AIbuyselllistEditor.cs">
<SubType>Form</SubType>
</Compile>
Expand Down
Loading

0 comments on commit ffbc383

Please sign in to comment.