public PresetTreeViewContainer() { this.InitializeComponent(); this.presetsService.PresetFolderManuallyExpanded += (sender, model) => { var item = UIUtilities.FindDescendant <TreeViewItem>(this.presetTreeView, viewItem => { return(viewItem.Header == model); }); //var item = this.presetTreeView.ContainerFromItem(model); // TODO: Find the TreeViewItem for the PresetFolderViewModel if (item != null) { DispatchUtilities.BeginInvoke( () => { UIUtilities.BringIntoView(item); }, DispatcherPriority.Background); } }; }
public PresetTreeViewItem() { this.MouseLeftButtonUp += this.OnMouseLeftButtonUp; this.Selected += (sender, args) => { if (!object.ReferenceEquals(sender, args.OriginalSource)) { return; } var item = args.OriginalSource as TreeViewItem; if (item?.Header is PresetViewModel) { UIUtilities.BringIntoView(item); } }; }
public Main() { Ioc.Container.RegisterSingleton <Main>(() => this); this.InitializeComponent(); this.sourceRow.Height = new GridLength(Config.SourcePaneHeightStar, GridUnitType.Star); this.queueRow.Height = new GridLength(Config.QueuePaneHeightStar, GridUnitType.Star); this.Activated += (sender, args) => { DispatchUtilities.BeginInvoke(async() => { // Need to yield here for some reason, otherwise the activation is blocked. await Task.Yield(); this.toastNotificationService.Clear(); }); }; this.notifyIcon = new NotifyIcon { Visible = false }; this.notifyIcon.Click += (sender, args) => { this.RestoreWindow(); }; this.notifyIcon.DoubleClick += (sender, args) => { this.RestoreWindow(); }; StreamResourceInfo streamResourceInfo = System.Windows.Application.GetResourceStream(new Uri("pack://application:,,,/VidCoder_icon.ico")); if (streamResourceInfo != null) { Stream iconStream = streamResourceInfo.Stream; this.notifyIcon.Icon = new Icon(iconStream); } this.RefreshQueueColumns(); this.LoadCompletedColumnWidths(); #if DEBUG var debugDropDown = new DropDownButton { Header = "Debug" }; var loadScanFromJsonItem = new Fluent.MenuItem { Header = "Load scan from JSON..." }; loadScanFromJsonItem.Click += (sender, args) => { DebugJsonDialog dialog = new DebugJsonDialog("Debug Scan JSON"); dialog.ShowDialog(); if (!string.IsNullOrWhiteSpace(dialog.Json)) { try { var scanObject = JsonConvert.DeserializeObject <JsonScanObject>(dialog.Json); this.viewModel.UpdateFromNewVideoSource(new VideoSource { Titles = scanObject.TitleList, FeatureTitle = scanObject.MainFeature }); } catch (Exception exception) { MessageBox.Show(this, "Could not parse scan JSON:" + Environment.NewLine + Environment.NewLine + exception.ToString()); } } }; debugDropDown.Items.Add(loadScanFromJsonItem); var queueFromJsonItem = new Fluent.MenuItem { Header = "Queue job from JSON..." }; queueFromJsonItem.Click += (sender, args) => { if (!this.viewModel.HasVideoSource) { StaticResolver.Resolve <IMessageBoxService>().Show("Must open source before adding queue job from JSON"); return; } EncodeJobViewModel jobViewModel = this.viewModel.CreateEncodeJobVM(); DebugJsonDialog dialog = new DebugJsonDialog("Debug Encode JSON"); dialog.ShowDialog(); if (!string.IsNullOrWhiteSpace(dialog.Json)) { try { JsonEncodeObject encodeObject = JsonConvert.DeserializeObject <JsonEncodeObject>(dialog.Json); jobViewModel.DebugEncodeJsonOverride = dialog.Json; jobViewModel.Job.FinalOutputPath = encodeObject.Destination.File; jobViewModel.Job.SourcePath = encodeObject.Source.Path; this.processingService.Queue(jobViewModel); } catch (Exception exception) { MessageBox.Show(this, "Could not parse encode JSON:" + Environment.NewLine + Environment.NewLine + exception.ToString()); } } }; debugDropDown.Items.Add(queueFromJsonItem); var throwExceptionItem = new Fluent.MenuItem { Header = "Throw exception" }; throwExceptionItem.Click += (sender, args) => { throw new InvalidOperationException("Rats."); }; debugDropDown.Items.Add(throwExceptionItem); var addLogItem = new Fluent.MenuItem { Header = "Add 1 log item" }; addLogItem.Click += (sender, args) => { StaticResolver.Resolve <IAppLogger>().Log("This is a log item"); }; debugDropDown.Items.Add(addLogItem); var addTenLogItems = new Fluent.MenuItem { Header = "Add 10 log items" }; addTenLogItems.Click += (sender, args) => { for (int i = 0; i < 10; i++) { StaticResolver.Resolve <IAppLogger>().Log("This is a log item"); } }; debugDropDown.Items.Add(addTenLogItems); var addLongLogItem = new Fluent.MenuItem { Header = "Add long log item" }; addLongLogItem.Click += (sender, args) => { StaticResolver.Resolve <IAppLogger>().Log("This is a log item\r\nthat is split into multiple lines\r\nOh yes indeed"); }; debugDropDown.Items.Add(addLongLogItem); var doAnActionItem = new Fluent.MenuItem { Header = "Perform action" }; doAnActionItem.Click += (sender, args) => { var app = (App)System.Windows.Application.Current; app.ChangeTheme(new Uri("/Themes/Dark.xaml", UriKind.Relative)); }; debugDropDown.Items.Add(doAnActionItem); this.toolsRibbonGroupBox.Items.Add(debugDropDown); #endif this.DataContextChanged += this.OnDataContextChanged; TheDispatcher = this.Dispatcher; this.statusText.Opacity = 0.0; NameScope.SetNameScope(this, new NameScope()); this.RegisterName("StatusText", this.statusText); var storyboard = (Storyboard)this.FindResource("StatusTextStoryboard"); storyboard.Completed += (sender, args) => { this.statusText.Visibility = Visibility.Collapsed; }; this.presetTreeViewContainer.PresetTreeView.OnHierarchyMouseUp += (sender, args) => { this.presetButton.IsDropDownOpen = false; }; this.presetButton.DropDownOpened += (sender, args) => { var item = UIUtilities.FindDescendant <TreeViewItem>(this.presetTreeViewContainer.PresetTreeView, viewItem => { return(viewItem.Header == this.viewModel.PresetsService.SelectedPreset); }); if (item != null) { UIUtilities.BringIntoView(item); } }; this.Loaded += (e, o) => { this.RestoredWindowState = this.WindowState; }; this.statusService.MessageShown += (o, e) => { this.ShowStatusMessage(e.Value); }; this.queueView.SelectionChanged += this.QueueView_SelectionChanged; }