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

Commit

Permalink
feat(robock): follow title changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mika-f committed Jun 16, 2019
1 parent 7ca0261 commit 772536d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Source/Robock/Models/CaptureSources/ICaptureSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ public interface ICaptureSource : IDisposable, INotifyPropertyChanged
void RenderThumbnail(IntPtr hDest, Rect position, Rect available);

// void RenderPreview(IRenderer);

// Window 間で同じインスタンス共有できない (Dispose される)
ICaptureSource Clone();
}
}
5 changes: 5 additions & 0 deletions Source/Robock/Models/CaptureSources/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public void RenderThumbnail(IntPtr hDest, Rect position, Rect available)
NativeMethods.DwmUpdateThumbnailProperties(_hThumb, ref thumbnailProps);
}

public ICaptureSource Clone()
{
return new Window(_hWnd);
}

private void Update()
{
var sb = new StringBuilder(1024);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public WindowPickerDialogViewModel()
RenderPosition.Where(w => !w.IsEmpty).Subscribe(_ => UpdateChildDisplayPosition()).AddTo(this);
SelectedSource = new ReactiveProperty<CaptureSourceViewModel>();
SelectCommand = new ReactiveCommand();
SelectCommand.Subscribe(_ => RequestClose?.Invoke(new DialogResult(ButtonResult.OK, new DialogParameters { { "CaptureSource", SelectedSource.Value?.CaptureSource } }))).AddTo(this);
SelectCommand.Subscribe(_ => RequestClose?.Invoke(new DialogResult(ButtonResult.OK, new DialogParameters { { "CaptureSource", SelectedSource.Value?.CaptureSource?.Clone() } }))).AddTo(this);
CancelCommand = new ReactiveCommand();
CancelCommand.Subscribe(_ => RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel))).AddTo(this);
}
Expand Down
6 changes: 2 additions & 4 deletions Source/Robock/ViewModels/Tabs/DesktopViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class DesktopViewModel : TabViewModel
public ReactiveProperty<bool> IsSelected { get; }
public ReactiveProperty<ICaptureSource> CaptureSource { get; }
public ReadOnlyReactiveProperty<bool> IsCaptureSourceSelected { get; }
public ReadOnlyReactiveProperty<string> CaptureSourceName { get; }
public ReactiveProperty<double> PreviewHeight { get; set; }
public ReactiveProperty<double> PreviewWidth { get; set; }
public ReactiveProperty<double> RenderTop { get; set; }
Expand Down Expand Up @@ -79,7 +78,6 @@ public DesktopViewModel(Desktop desktop, IDialogService dialogService)
IsSelected = new ReactiveProperty<bool>(desktop.IsPrimary);
CaptureSource = new ReactiveProperty<ICaptureSource>();
IsCaptureSourceSelected = CaptureSource.Select(w => w != null).ToReadOnlyReactiveProperty().AddTo(this);
CaptureSourceName = CaptureSource.Select(w => w?.Name ?? "キャプチャーするウィンドウを選択してください").ToReadOnlyReactiveProperty().AddTo(this);
Renderer = IsCaptureSourceSelected.Do(_ => Renderer?.Value?.Dispose())
.Select(w => w ? (IRenderer) new BitBltRenderer(IntPtr.Zero) : null)
.ToReadOnlyReactiveProperty().AddTo(this);
Expand All @@ -103,8 +101,8 @@ public DesktopViewModel(Desktop desktop, IDialogService dialogService)
{
dialogService.ShowDialog(nameof(WindowPickerDialog), new DialogParameters(), r =>
{
if(r.Parameters.ContainsKey("CaptureSource"))
CaptureSource.Value = r.Parameters.GetValue<ICaptureSource>("CaptureSource");
if (r.Parameters.ContainsKey("CaptureSource"))
CaptureSource.Value = r.Parameters.GetValue<ICaptureSource>("CaptureSource");
});
}).AddTo(this);
ClearSelectCommand = CaptureSource.Select(w => w != null).ToReactiveCommand();
Expand Down
4 changes: 2 additions & 2 deletions Source/Robock/Views/Tabs/DesktopTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
Height="25"
HorizontalAlignment="Stretch"
IsEnabled="False"
Text="{Binding CaptureSourceName.Value, Mode=OneWay}"
ToolTip="{Binding CaptureSourceName.Value, Mode=OneWay}"
Text="{Binding CaptureSource.Value.Name, Mode=OneWay, FallbackValue='キャプチャーするウィンドウを選択してください'}"
ToolTip="{Binding CaptureSource.Value.Name, Mode=OneWay, FallbackValue='キャプチャーするウィンドウを選択してください'}"
ToolTipService.ShowOnDisabled="{Binding IsCaptureSourceSelected.Value, Mode=OneWay}" />
<Button Grid.Column="1"
Height="25"
Expand Down

0 comments on commit 772536d

Please sign in to comment.