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

Commit

Permalink
Merge pull request #74 from speckleworks/new-popup
Browse files Browse the repository at this point in the history
added new popup window
  • Loading branch information
teocomi authored Aug 19, 2019
2 parents 064b5ef + 696b15b commit 6ce88c6
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 131 deletions.
21 changes: 21 additions & 0 deletions SpeckleDynamo.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,49 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
DebugRevit|Any CPU = DebugRevit|Any CPU
DebugRevit|x64 = DebugRevit|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{91E0BFFD-2945-471E-9007-3778AA174938}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91E0BFFD-2945-471E-9007-3778AA174938}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91E0BFFD-2945-471E-9007-3778AA174938}.Debug|x64.ActiveCfg = Debug|Any CPU
{91E0BFFD-2945-471E-9007-3778AA174938}.Debug|x64.Build.0 = Debug|Any CPU
{91E0BFFD-2945-471E-9007-3778AA174938}.DebugRevit|Any CPU.ActiveCfg = DebugRevit|Any CPU
{91E0BFFD-2945-471E-9007-3778AA174938}.DebugRevit|Any CPU.Build.0 = DebugRevit|Any CPU
{91E0BFFD-2945-471E-9007-3778AA174938}.DebugRevit|x64.ActiveCfg = DebugRevit|Any CPU
{91E0BFFD-2945-471E-9007-3778AA174938}.DebugRevit|x64.Build.0 = DebugRevit|Any CPU
{91E0BFFD-2945-471E-9007-3778AA174938}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91E0BFFD-2945-471E-9007-3778AA174938}.Release|Any CPU.Build.0 = Release|Any CPU
{91E0BFFD-2945-471E-9007-3778AA174938}.Release|x64.ActiveCfg = Release|Any CPU
{91E0BFFD-2945-471E-9007-3778AA174938}.Release|x64.Build.0 = Release|Any CPU
{146EBF48-E7A0-4ABE-809D-D7F3059E4EE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{146EBF48-E7A0-4ABE-809D-D7F3059E4EE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{146EBF48-E7A0-4ABE-809D-D7F3059E4EE1}.Debug|x64.ActiveCfg = Debug|Any CPU
{146EBF48-E7A0-4ABE-809D-D7F3059E4EE1}.Debug|x64.Build.0 = Debug|Any CPU
{146EBF48-E7A0-4ABE-809D-D7F3059E4EE1}.DebugRevit|Any CPU.ActiveCfg = Debug|Any CPU
{146EBF48-E7A0-4ABE-809D-D7F3059E4EE1}.DebugRevit|Any CPU.Build.0 = Debug|Any CPU
{146EBF48-E7A0-4ABE-809D-D7F3059E4EE1}.DebugRevit|x64.ActiveCfg = DebugRevit|Any CPU
{146EBF48-E7A0-4ABE-809D-D7F3059E4EE1}.DebugRevit|x64.Build.0 = DebugRevit|Any CPU
{146EBF48-E7A0-4ABE-809D-D7F3059E4EE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{146EBF48-E7A0-4ABE-809D-D7F3059E4EE1}.Release|Any CPU.Build.0 = Release|Any CPU
{146EBF48-E7A0-4ABE-809D-D7F3059E4EE1}.Release|x64.ActiveCfg = Release|Any CPU
{146EBF48-E7A0-4ABE-809D-D7F3059E4EE1}.Release|x64.Build.0 = Release|Any CPU
{1DFDF56B-7E81-4F00-96E2-94D8178220F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DFDF56B-7E81-4F00-96E2-94D8178220F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DFDF56B-7E81-4F00-96E2-94D8178220F6}.Debug|x64.ActiveCfg = Debug|Any CPU
{1DFDF56B-7E81-4F00-96E2-94D8178220F6}.Debug|x64.Build.0 = Debug|Any CPU
{1DFDF56B-7E81-4F00-96E2-94D8178220F6}.DebugRevit|Any CPU.ActiveCfg = Debug|Any CPU
{1DFDF56B-7E81-4F00-96E2-94D8178220F6}.DebugRevit|Any CPU.Build.0 = Debug|Any CPU
{1DFDF56B-7E81-4F00-96E2-94D8178220F6}.DebugRevit|x64.ActiveCfg = Debug|Any CPU
{1DFDF56B-7E81-4F00-96E2-94D8178220F6}.DebugRevit|x64.Build.0 = Debug|Any CPU
{1DFDF56B-7E81-4F00-96E2-94D8178220F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DFDF56B-7E81-4F00-96E2-94D8178220F6}.Release|Any CPU.Build.0 = Release|Any CPU
{1DFDF56B-7E81-4F00-96E2-94D8178220F6}.Release|x64.ActiveCfg = Release|Any CPU
{1DFDF56B-7E81-4F00-96E2-94D8178220F6}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
63 changes: 39 additions & 24 deletions SpeckleDynamo/Receiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,35 +543,50 @@ internal void AddedToDocument(object sender, System.EventArgs e)
InitReceiverEventsAndGlobals();
return;
}
Transmitting = true;
var myForm = new SpecklePopup.MainWindow(true, true);
//TODO: fix this it's crashing revit
//myForm.Owner = Application.Current.MainWindow;
DispatchOnUIThread(() =>


//account/form flow
Account account = null;
LocalContext.Init();
try
{
//if default account exists form is closed automatically
if (!myForm.HasDefaultAccount)
{
myForm.ShowDialog();
}
//try getting default account, exception is thrownif none is set
account = LocalContext.GetDefaultAccount();
}
catch (Exception ex)
{
}

if (myForm.restApi != null && myForm.apitoken != null)
//show account selection window
if (account == null)
{
DispatchOnUIThread(() =>
{
Email = myForm.selectedEmail;
Server = myForm.selectedServer;
//open window with isPopUp=true
var signInWindow = new SpecklePopup.SignInWindow(true);
signInWindow.ShowDialog();
if (signInWindow.AccountListBox.SelectedIndex != -1)
{
account = signInWindow.accounts[signInWindow.AccountListBox.SelectedIndex];
}
});
}

RestApi = myForm.restApi;
AuthToken = myForm.apitoken;
if (account != null)
{
Email = account.Email;
Server = account.ServerName;

Message = "";
}
else
{
Message = "";
Error("Account selection failed.");
}
Transmitting = false;
});
RestApi = account.RestApi;
AuthToken = account.Token;
}
else
{
Error("Account selection failed.");
}
Transmitting = false;
Message = "";
}

internal void ForceReceiveButton(object sender, RoutedEventArgs e)
Expand Down
75 changes: 48 additions & 27 deletions SpeckleDynamo/Sender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private Sender(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts)
public Sender()
{
Transmitting = true;

SpeckleCore.SpeckleInitializer.Initialize();
SpeckleCore.LocalContext.Init();

Expand Down Expand Up @@ -129,7 +129,7 @@ public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode
return Enumerable.Empty<AssociativeNode>();
}

if (mySender == null || mySender.StreamId == null || DataSender ==null)
if (mySender == null || mySender.StreamId == null || DataSender == null)
{
return Enumerable.Empty<AssociativeNode>();
}
Expand Down Expand Up @@ -291,42 +291,63 @@ internal void AddedToDocument(object sender, System.EventArgs e)
Message = "Account error";
return;
}

InitializeSender(false);
Message = "";
return;
}

Message = "Initialising...";
var myForm = new SpecklePopup.MainWindow(true,true);
// myForm.Owner = Application.Current.MainWindow;
DispatchOnUIThread(() =>
Transmitting = true;

//account/form flow
Account account = null;
LocalContext.Init();
try
{
//if default account exists form is closed automatically
if (!myForm.HasDefaultAccount)
{
myForm.ShowDialog();
}
//try getting default account, exception is thrownif none is set
account = LocalContext.GetDefaultAccount();
}
catch (Exception ex)
{
}

if (myForm.restApi != null && myForm.apitoken != null)
//show account selection window
if (account == null)
{
DispatchOnUIThread(() =>
{
mySender = new SpeckleApiClient(myForm.restApi);
//open window with isPopUp=true
var signInWindow = new SpecklePopup.SignInWindow(true);
signInWindow.ShowDialog();
if (signInWindow.AccountListBox.SelectedIndex != -1)
{
account = signInWindow.accounts[signInWindow.AccountListBox.SelectedIndex];
}
});
}

Email = myForm.selectedEmail;
Server = myForm.selectedServer;
if (account != null)
{
mySender = new SpeckleApiClient(account.RestApi);

Email = account.Email;
Server = account.ServerName;

RestApi = account.RestApi;
AuthToken = account.Token;

InitializeSender(true);
}
else
{
Message = "";
Error("Account selection failed.");
Transmitting = false;
}

RestApi = myForm.restApi;
AuthToken = myForm.apitoken;

InitializeSender(true);
}
else
{
Message = "";
Error("Account selection failed.");
Transmitting = false;
}
});
}

private void InitializeSender(bool init)
Expand Down Expand Up @@ -549,7 +570,7 @@ private void MetadataSender_Elapsed(object sender, ElapsedEventArgs e)
var updateResult = mySender.StreamUpdateAsync(mySender.StreamId, updateStream).GetAwaiter().GetResult();

Log += updateResult.Message;
mySender.BroadcastMessage( "stream", mySender.StreamId, new { eventType = "update-meta" });
mySender.BroadcastMessage("stream", mySender.StreamId, new { eventType = "update-meta" });
Transmitting = false;
}

Expand Down
8 changes: 4 additions & 4 deletions SpeckleDynamo/SpeckleDynamo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@
<HintPath>..\packages\DynamoVisualProgramming.ZeroTouchLibrary.2.0.2.6986\lib\net45\ProtoGeometry.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="SpeckleCore, Version=1.5.1.326, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\SpeckleCore.1.5.1.326\lib\net45\SpeckleCore.dll</HintPath>
<Reference Include="SpeckleCore, Version=1.5.2.343, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\SpeckleCore.1.5.2.343\lib\net45\SpeckleCore.dll</HintPath>
</Reference>
<Reference Include="SpecklePopup, Version=1.5.1.9, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SpecklePopup.1.5.1.9\lib\net45\SpecklePopup.dll</HintPath>
<Reference Include="SpecklePopup, Version=1.6.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SpecklePopup.1.6.8\lib\net45\SpecklePopup.dll</HintPath>
</Reference>
<Reference Include="SQLite-net, Version=1.5.231.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\sqlite-net-pcl.1.5.231\lib\netstandard1.1\SQLite-net.dll</HintPath>
Expand Down
64 changes: 44 additions & 20 deletions SpeckleDynamo/Streams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,32 +103,56 @@ internal void AddedToDocument(object sender, System.EventArgs e)
GetStreams();
return;
}
var myForm = new SpecklePopup.MainWindow(true, true);
//TODO: fix this it's crashing revit
//myForm.Owner = Application.Current.MainWindow;
this.DispatchOnUIThread(() =>

Transmitting = true;

//account/form flow
Account account = null;
LocalContext.Init();
try
{
//try getting default account, exception is thrownif none is set
account = LocalContext.GetDefaultAccount();
}
catch (Exception ex)
{
}

//show account selection window
if (account == null)
{
//if default account exists form is closed automatically
if (!myForm.HasDefaultAccount)
myForm.ShowDialog();
if (myForm.restApi != null && myForm.apitoken != null)
DispatchOnUIThread(() =>
{
Email = myForm.selectedEmail;
Server = myForm.selectedServer;
//open window with isPopUp=true
var signInWindow = new SpecklePopup.SignInWindow(true);
signInWindow.ShowDialog();
if (signInWindow.AccountListBox.SelectedIndex != -1)
{
account = signInWindow.accounts[signInWindow.AccountListBox.SelectedIndex];
}
});
}

RestApi = myForm.restApi;
AuthToken = myForm.apitoken;
if (account != null)
{
Email = account.Email;
Server = account.ServerName;

Client = new SpeckleApiClient();
RestApi = account.RestApi;
AuthToken = account.Token;

Client = new SpeckleApiClient();

GetStreams();
}
else
{
Error("Account selection failed.");
Transmitting = false;
}

GetStreams();

}
else
{
Error("Account selection failed.");
}
});
}

private void GetStreams()
Expand Down
4 changes: 2 additions & 2 deletions SpeckleDynamo/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net45" />
<package id="NUnit" version="2.6.3" targetFramework="net45" />
<package id="Prism" version="4.1.0.0" targetFramework="net45" />
<package id="SpeckleCore" version="1.5.1.326" targetFramework="net45" />
<package id="SpecklePopup" version="1.5.1.9" targetFramework="net45" />
<package id="SpeckleCore" version="1.5.2.343" targetFramework="net45" />
<package id="SpecklePopup" version="1.6.8" targetFramework="net45" />
<package id="sqlite-net-pcl" version="1.5.231" targetFramework="net45" />
<package id="SQLitePCLRaw.bundle_green" version="1.1.11" targetFramework="net45" />
<package id="SQLitePCLRaw.core" version="1.1.11" targetFramework="net45" />
Expand Down
2 changes: 1 addition & 1 deletion SpeckleDynamoExtension/SpeckleDynamoExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void Loaded(ViewLoadedParams viewLoadedParams)
speckleAccountsMenu.Click += (sender, args) =>
{
//var viewModel = new SampleWindowViewModel(p);
var window = new SpecklePopup.MainWindow(false, false)
var window = new SpecklePopup.SignInWindow()
{
Owner = viewLoadedParams.DynamoWindow,
WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner
Expand Down
8 changes: 4 additions & 4 deletions SpeckleDynamoExtension/SpeckleDynamoExtension.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@
<HintPath>..\packages\DynamoVisualProgramming.ZeroTouchLibrary.2.0.2.6986\lib\net45\ProtoGeometry.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="SpeckleCore, Version=1.5.1.326, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\SpeckleCore.1.5.1.326\lib\net45\SpeckleCore.dll</HintPath>
<Reference Include="SpeckleCore, Version=1.5.2.343, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\SpeckleCore.1.5.2.343\lib\net45\SpeckleCore.dll</HintPath>
</Reference>
<Reference Include="SpecklePopup, Version=1.5.1.9, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SpecklePopup.1.5.1.9\lib\net45\SpecklePopup.dll</HintPath>
<Reference Include="SpecklePopup, Version=1.6.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SpecklePopup.1.6.8\lib\net45\SpecklePopup.dll</HintPath>
</Reference>
<Reference Include="SQLite-net, Version=1.5.231.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\sqlite-net-pcl.1.5.231\lib\netstandard1.1\SQLite-net.dll</HintPath>
Expand Down
Loading

0 comments on commit 6ce88c6

Please sign in to comment.