Skip to content

Commit

Permalink
fix(rhino): stream edit view selection issues in rhino (#1614)
Browse files Browse the repository at this point in the history
  • Loading branch information
teocomi authored Sep 27, 2022
1 parent 5b60500 commit 726e2df
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class SpeckleRhinoConnectorPlugin : PlugIn
private static string SpeckleKey = "speckle2";

public ConnectorBindingsRhino Bindings { get; private set; }
public MainViewModel ViewModel { get; private set; }

internal bool _initialized;

Expand All @@ -39,7 +38,6 @@ public void Init()

SpeckleCommand.InitAvalonia();
Bindings = new ConnectorBindingsRhino();
ViewModel = new MainViewModel(Bindings);

RhinoDoc.BeginOpenDocument += RhinoDoc_BeginOpenDocument;
RhinoDoc.EndOpenDocument += RhinoDoc_EndOpenDocument;
Expand Down Expand Up @@ -82,9 +80,6 @@ private void RhinoDoc_EndOpenDocument(object sender, DocumentOpenEventArgs e)

private void RhinoDoc_BeginOpenDocument(object sender, DocumentOpenEventArgs e)
{
//new document => new view model (used by the panel only)
ViewModel = new MainViewModel(Bindings);

if (e.Merge) // this is a paste or import event
{
// get existing streams in doc before a paste or import operation to use for cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ public Panel()
try
{
InitializeComponent();
//Set in the Plugin so that it's not disposed each time the panel is closed
this.DataContext = SpeckleRhinoConnectorPlugin.Instance.ViewModel;
//set here otherwise we get errors about re-used visual parents when closing and re-opening the panel
//there might be other solutions too. If changing this behaviour make sure to refresh the view model
//when opening a new file as well
var viewModel = new MainViewModel(SpeckleRhinoConnectorPlugin.Instance.Bindings);
this.DataContext = viewModel;
AvaloniaHost.Content = new MainUserControl();
}
catch (Exception ex)
{

}



}

Expand Down
12 changes: 5 additions & 7 deletions DesktopUI2/DesktopUI2/ViewModels/StreamViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class StreamViewModel : ReactiveObject, IRoutableViewModel
{

public StreamState StreamState { get; set; }
private IScreen HostScreen { get; set; }
public IScreen HostScreen { get; set; }

private ConnectorBindings Bindings;

Expand Down Expand Up @@ -306,8 +306,8 @@ public List<ApplicationObjectViewModel> FilteredReport
else
{
var filterItems = _reportSelectedFilterItems.Any() ? Report.Where(o => _reportSelectedFilterItems.Any(a => o.Status == a)).ToList() : Report;
return SearchQuery == "" ?
filterItems :
return SearchQuery == "" ?
filterItems :
filterItems.Where(o => _searchQueryItems.All(a => o.SearchText.ToLower().Contains(a.ToLower()))).ToList();
}
}
Expand All @@ -320,13 +320,13 @@ public string Log
{
get
{
string defaultMessage = string.IsNullOrEmpty(Progress.Report.ConversionLogString) ?
string defaultMessage = string.IsNullOrEmpty(Progress.Report.ConversionLogString) ?
"\nWelcome to the report! \n\nObjects you send or receive will appear here to help you understand how your document has changed." :
Progress.Report.ConversionLogString;

string reportInfo = $"\nOperation: {(PreviewOn ? "Preview " : "")}{(IsReceiver ? "Received at " : "Sent at ")}{DateTime.Now.ToLocalTime().ToString("dd/MM/yy HH:mm:ss")}";
reportInfo += $"\nTotal: {Report.Count} objects";
reportInfo += Progress.Report.OperationErrors.Any() ? $"\n\nErrors: \n{Progress.Report.OperationErrorsString}":"";
reportInfo += Progress.Report.OperationErrors.Any() ? $"\n\nErrors: \n{Progress.Report.OperationErrorsString}" : "";

return Report.Any() || Progress.Report.OperationErrors.Any() ? reportInfo : defaultMessage;
}
Expand Down Expand Up @@ -478,8 +478,6 @@ private string Url
}
}

IScreen IRoutableViewModel.HostScreen => throw new NotImplementedException();

public void UpdateVisualParentAndInit(IScreen hostScreen)
{
HostScreen = hostScreen;
Expand Down

0 comments on commit 726e2df

Please sign in to comment.