Skip to content

Commit 804cebd

Browse files
committed
Merge pull request #1481 from kellyelton/master
Fixed issue with bad winforms and added api call showWinForm
2 parents 7e628c0 + b7fe64b commit 804cebd

File tree

9 files changed

+31
-65
lines changed

9 files changed

+31
-65
lines changed

octgnFX/Octgn/Play/PlayWindow.xaml.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,15 @@ private void Open(object sender, RoutedEventArgs e)
568568
//ofd.InitialDirectory = Program.Game.Definition.DecksPath;
569569
if (ofd.ShowDialog() != true) return;
570570
// Try to load the file contents
571+
LoadDeck(ofd.FileName);
572+
}
573+
574+
private void LoadDeck(string path)
575+
{
571576
try
572577
{
573578
var game = GameManager.Get().GetById(Program.GameEngine.Definition.Id);
574-
var newDeck = new Deck().Load(game, ofd.FileName);
579+
var newDeck = new Deck().Load(game, path);
575580
//DataNew.Entities.Deck newDeck = Deck.Load(ofd.FileName,
576581
// Program.GamesRepository.Games.First(g => g.Id == Program.Game.Definition.Id));
577582
// Load the deck into the game

octgnFX/Octgn/Scripting/Engine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ private string ConvertWinforms(string str)
679679
break;
680680
}
681681
}
682-
var newLine = string.Format("{0}_api.FormToWindow({1})", padding, name);
682+
var newLine = string.Format("{0}showWinForm({1})", padding, name);
683683
ret.AppendLine(newLine);
684684
line = sr.ReadLine();
685685
}

octgnFX/Octgn/Scripting/Versions/3.1.0.0.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ def convertToString(obj):
153153
return "\"{}\"".format(obj);
154154
return str(obj)
155155

156+
def showWinForm(form):
157+
_api.ShowWinForm(form)
158+
156159
class Markers(object):
157160
def __init__(self, card):
158161
self._cardId = card._id

octgnFX/Octgn/Scripting/Versions/3.1.0.1.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ def convertToString(obj):
154154
return "\"{}\"".format(obj);
155155
return str(obj)
156156

157+
def showWinForm(form):
158+
_api.ShowWinForm(form)
159+
157160
class Markers(object):
158161
def __init__(self, card):
159162
self._cardId = card._id

octgnFX/Octgn/Scripting/Versions/3.1.0.2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ def convertToString(obj):
151151
return "\"{}\"".format(obj);
152152
return str(obj)
153153

154+
def showWinForm(form):
155+
_api.ShowWinForm(form)
156+
154157
class Markers(object):
155158
def __init__(self, card):
156159
self._cardId = card._id

octgnFX/Octgn/Scripting/Versions/Script_3_1_0_0.cs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,29 +1396,12 @@ public void ResetGame()
13961396
QueueAction(() => Program.Client.Rpc.ResetReq());
13971397
}
13981398

1399-
public void FormToWindow(System.Windows.Forms.Form form)
1399+
public void ShowWinForm(System.Windows.Forms.Form form)
14001400
{
14011401
QueueAction(() =>
14021402
{
1403-
form.TopLevel = false;
1404-
form.FormBorderStyle = FormBorderStyle.None;
1405-
1406-
var win = new System.Windows.Window();
1407-
win.Owner = WindowManager.PlayWindow;
1408-
var holder = new System.Windows.Forms.Integration.WindowsFormsHost();
1409-
holder.Child = form;
1410-
win.Content = holder;
1411-
//win.SizeToContent = SizeToContent.WidthAndHeight;
1412-
win.Width = form.Width;
1413-
win.Height = form.Height;
1414-
win.Title = form.Text;
1415-
1416-
form.FormClosed += (sender, args) =>
1417-
{
1418-
win.Close();
1419-
};
1420-
1421-
win.ShowDialog();
1403+
form.ShowDialog();
1404+
return;
14221405
});
14231406
}
14241407
}

octgnFX/Octgn/Scripting/Versions/Script_3_1_0_1.cs

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Windows.Media;
1111
using System.Windows.Media.Imaging;
1212
using System.Windows.Threading;
13+
using Octgn.Controls;
1314
using Octgn.Core;
1415
using Octgn.Core.DataExtensionMethods;
1516
using Octgn.Core.Util;
@@ -24,6 +25,7 @@
2425
using Card = Octgn.Play.Card;
2526
using Counter = Octgn.Play.Counter;
2627
using Group = Octgn.Play.Group;
28+
using HorizontalAlignment = System.Windows.HorizontalAlignment;
2729
using Marker = Octgn.Play.Marker;
2830
using Player = Octgn.Play.Player;
2931

@@ -775,7 +777,7 @@ public void CardSetAnchored(int cardId, bool anchored)
775777
{
776778
if (card == null)
777779
return;
778-
card.SetAnchored(false, anchored);
780+
card.SetAnchored(false, anchored);
779781
});
780782
}
781783

@@ -1284,7 +1286,7 @@ public void PlayerSetGlobalVariable(int id, string name, object value)
12841286
}
12851287
else
12861288
QueueAction(() => Player.LocalPlayer.GlobalVariables.Add(name, val));
1287-
Program.Client.Rpc.PlayerSetGlobalVariable(Player.LocalPlayer, name, oldvalue ?? "",val);
1289+
Program.Client.Rpc.PlayerSetGlobalVariable(Player.LocalPlayer, name, oldvalue ?? "", val);
12881290
}
12891291

12901292
public string PlayerGetGlobalVariable(int id, string name)
@@ -1418,29 +1420,12 @@ public void ResetGame()
14181420
QueueAction(() => Program.Client.Rpc.ResetReq());
14191421
}
14201422

1421-
public void FormToWindow(System.Windows.Forms.Form form)
1423+
public void ShowWinForm(Form form)
14221424
{
14231425
QueueAction(() =>
14241426
{
1425-
form.TopLevel = false;
1426-
form.FormBorderStyle = FormBorderStyle.None;
1427-
1428-
var win = new System.Windows.Window();
1429-
win.Owner = WindowManager.PlayWindow;
1430-
var holder = new System.Windows.Forms.Integration.WindowsFormsHost();
1431-
holder.Child = form;
1432-
win.Content = holder;
1433-
//win.SizeToContent = SizeToContent.WidthAndHeight;
1434-
win.Width = form.Width;
1435-
win.Height = form.Height;
1436-
win.Title = form.Text;
1437-
1438-
form.FormClosed += (sender, args) =>
1439-
{
1440-
win.Close();
1441-
};
1442-
1443-
win.ShowDialog();
1427+
form.ShowDialog();
1428+
return;
14441429
});
14451430
}
14461431
}

octgnFX/Octgn/Scripting/Versions/Script_3_1_0_2.cs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,29 +1443,12 @@ public void ResetGame()
14431443
QueueAction(() => Program.Client.Rpc.ResetReq());
14441444
}
14451445

1446-
public void FormToWindow(System.Windows.Forms.Form form)
1446+
public void ShowWinForm(System.Windows.Forms.Form form)
14471447
{
14481448
QueueAction(() =>
14491449
{
1450-
form.TopLevel = false;
1451-
form.FormBorderStyle = FormBorderStyle.None;
1452-
1453-
var win = new System.Windows.Window();
1454-
win.Owner = WindowManager.PlayWindow;
1455-
var holder = new System.Windows.Forms.Integration.WindowsFormsHost();
1456-
holder.Child = form;
1457-
win.Content = holder;
1458-
//win.SizeToContent = SizeToContent.WidthAndHeight;
1459-
win.Width = form.Width;
1460-
win.Height = form.Height;
1461-
win.Title = form.Text;
1462-
1463-
form.FormClosed += (sender, args) =>
1464-
{
1465-
win.Close();
1466-
};
1467-
1468-
win.ShowDialog();
1450+
form.ShowDialog();
1451+
return;
14691452
});
14701453
}
14711454
}

recentchanges.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
1+
Fixed issue with winforms - Kelly
2+
Added api call showWinForm - Kelly

0 commit comments

Comments
 (0)