private static void UpdateSysLinux(DirectoryInfo directoryInfo) { foreach (var file in directoryInfo.GetFiles("*", SearchOption.AllDirectories)) { switch (file.Name) { case "chain.c32": break; case "vesamenu.c32": break; case "menu.c32": break; case "libutil.c32": break; case "libcom32.c32": break; case "ifcpu64.c32": break; default: continue; } file.Delete(); WpfUtilities.WriteResourceToFile( new Uri($"pack://application:,,,/Resources/SysLinuxFiles/{file.Name}"), file.FullName); } }
private void topControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (ViewModel == null) { return; } if ((ViewModel.NodeLogic is CodeBlockNodeModel) == false) { // Do not return focus to search if this is a code block node. var view = WpfUtilities.FindUpVisualTree <DynamoView>(this); ViewModel.DynamoViewModel.ReturnFocusToSearch(); view.mainGrid.Focus(); } Guid nodeGuid = ViewModel.NodeModel.GUID; ViewModel.DynamoViewModel.ExecuteCommand( new DynCmd.SelectModelCommand(nodeGuid, Keyboard.Modifiers.AsDynamoType())); if (e.ClickCount == 2) { if (ViewModel.GotoWorkspaceCommand.CanExecute(null)) { e.Handled = true; ViewModel.GotoWorkspaceCommand.Execute(null); } } }
public void ResetEnabled() { _stateBrush = Application.Current.Resources["TabItemTextSelectedForeground"] as SolidColorBrush; _stateInactiveBrush = Application.Current.Resources["TabItemTextNormalForeground"] as SolidColorBrush; Grid presenter = WpfUtilities.FindParentControl <Grid>(this); if (presenter == null) { return; } if (!(presenter.Children[2] is TextBox)) { return; } TextBox box = (TextBox)presenter.Children[2]; if (box.Text == "Visible") { Foreground = _stateBrush; } else { Foreground = _stateInactiveBrush; } }
public void ResetEnabled() { _stateBrush = Brushes.Black; _stateInactiveBrush = new SolidColorBrush(Color.FromArgb(255, 215, 215, 215)); Grid presenter = WpfUtilities.FindParentControl <Grid>(this); if (presenter == null) { return; } if (!(presenter.Children[2] is TextBox)) { return; } TextBox box = (TextBox)presenter.Children[2]; if (box.Text == "Visible") { Foreground = _stateBrush; } else { Foreground = _stateInactiveBrush; } }
private void topControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (ViewModel == null || Keyboard.Modifiers == System.Windows.Input.ModifierKeys.Control) { return; } var view = WpfUtilities.FindUpVisualTree <DynamoView>(this); ViewModel.DynamoViewModel.OnRequestReturnFocusToView(); view.mainGrid.Focus(); Guid nodeGuid = ViewModel.NodeModel.GUID; ViewModel.DynamoViewModel.ExecuteCommand( new DynCmd.SelectModelCommand(nodeGuid, Keyboard.Modifiers.AsDynamoType())); if (e.ClickCount == 2) { if (ViewModel.GotoWorkspaceCommand.CanExecute(null)) { e.Handled = true; ViewModel.GotoWorkspaceCommand.Execute(null); } } }
public SearchView(SearchViewModel searchViewModel, DynamoViewModel dynamoViewModel) { viewModel = searchViewModel; this.dynamoViewModel = dynamoViewModel; DataContext = viewModel; InitializeComponent(); Loaded += OnSearchViewLoaded; Unloaded += OnSearchViewUnloaded; SearchTextBox.IsVisibleChanged += delegate { if (SearchTextBox.IsVisible) { this.viewModel.SearchCommand.Execute(null); Keyboard.Focus(this.SearchTextBox); var view = WpfUtilities.FindUpVisualTree <DynamoView>(this); SearchTextBox.InputBindings.AddRange(view.InputBindings); SearchTextBlock.Text = Properties.Resources.SearchTextBlockText; } }; searchForegroundBrushNormal.Freeze(); searchForegroundBrushHover.Freeze(); }
private void _updateMetaGrf() { try { _mainTabControl.Dispatch(p => p.IsEnabled = false); Progress = -1; _metaGrf.Update(_metaGrfViewer.Paths); _delayedReloadDatabase = true; _tviItemDb.Dispatcher.Invoke(new Action(delegate { _tviItemDb.CheckValid(); })); _mainTabControl.Dispatcher.Invoke(new Action(delegate { try { if (!WpfUtilities.IsTab(_mainTabControl.SelectedItem as TabItem, "Settings")) { ReloadDatabase(); } } catch (Exception err) { ErrorHandler.HandleException(err); } })); } catch (Exception err) { ErrorHandler.HandleException(err); } finally { Progress = 100; _mainTabControl.Dispatch(p => p.IsEnabled = true); } }
public CustomManagerProperty(TextBox textBox, string grfPath, string ext, int row, int col, int rSpan, int cSpan) { _image = new Image { Stretch = Stretch.None, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; _image.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor); _viewer = new ScrollViewer(); Grid grid = new Grid(); //grid.ColumnDefinitions.Add(new ColumnDefinition) WpfUtilities.SetGridPosition(_viewer, row, rSpan, col, cSpan); _viewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; _viewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; _viewer.Content = _image; _textBox = textBox; _grfPath = grfPath.Trim('\\'); _ext = ext; _attribute = null; _textBox.TextChanged += _textBox_TextChanged; VirtualFileDataObject.SetDraggable(_image, _wrapper); _viewer.SizeChanged += delegate { _viewer.MaxHeight = _viewer.ActualHeight; }; }
private void RunButton_OnClick(object sender, RoutedEventArgs e) { var dynamoView = WpfUtilities.FindUpVisualTree <DynamoView>(this); var dynamoVm = dynamoView.DataContext as DynamoViewModel; dynamoVm.OnRequestReturnFocusToView(); }
private bool _isCurrentTabSelected() { TabControl tabControl = WpfUtilities.FindParentControl <TabControl>(this); TabItem selectedTab = tabControl.Items[tabControl.SelectedIndex] as TabItem; return(selectedTab != null && WpfUtilities.IsTab(this, selectedTab.Header.ToString())); }
protected override Size ArrangeOverride(Size arrangeSize) { if (this.Children.Count <= 0) { // A port list without any port in it. return(base.ArrangeOverride(arrangeSize)); } var itemsControl = WpfUtilities.FindUpVisualTree <ItemsControl>(this); var generator = itemsControl.ItemContainerGenerator; int itemIndex = 0; double x = 0, y = 0; foreach (UIElement child in this.Children) { var portVm = generator.ItemFromContainer(child) as PortViewModel; var lineIndex = portVm.PortModel.LineIndex; var multiplier = ((lineIndex == -1) ? itemIndex : lineIndex); var portHeight = portVm.PortModel.Height; y = multiplier * portHeight; child.Arrange(new Rect(x, y, arrangeSize.Width, portHeight)); itemIndex = itemIndex + 1; } return(base.ArrangeOverride(arrangeSize)); }
private void OnSampleFileSelected(object sender, RoutedEventArgs e) { var dp = e.OriginalSource as DependencyObject; var treeViewItem = WpfUtilities.FindUpVisualTree <TreeViewItem>(dp) as TreeViewItem; if (sampleFileTreeView.SelectedItem != null) { treeViewItem.IsExpanded = !treeViewItem.IsExpanded; } var filePath = (sampleFileTreeView.SelectedItem as SampleFileEntry).FilePath; if (string.IsNullOrEmpty(filePath)) { return; } if (!Path.GetExtension(filePath).Equals(".dyn")) { return; } var dvm = this.dynamoViewModel; if (dvm.OpenCommand.CanExecute(filePath)) { dvm.OpenCommand.Execute(filePath); } }
public ClickSelectTextBoxEffect() { this.Loaded += delegate { this.BorderThickness = new System.Windows.Thickness(0); //this.Padding = new System.Windows.Thickness(0); if (this.Parent is Border) { WpfUtilities.AddFocus(this); } else { Panel parent = this.Parent as Panel; if (parent != null) { int oldPosition = parent.Children.IndexOf(this); parent.Children.Remove(this); Border border = new Border(); border.VerticalAlignment = this.VerticalAlignment; border.HorizontalAlignment = this.HorizontalAlignment; border.BorderThickness = new System.Windows.Thickness(1); border.Child = this; border.Margin = this.Margin; this.Margin = new System.Windows.Thickness(0); parent.Children.Insert(oldPosition, border); WpfUtilities.SetGridPosition(border, (int)this.GetValue(Grid.RowProperty), (int)this.GetValue(Grid.ColumnProperty)); WpfUtilities.AddFocus(this); } } }; }
public static void ItemGroupCopyEntries(List <ReadableTuple <int> > items, BaseDb gdb, TabControl control, ServerType serverType) { var parent = WpfUtilities.FindDirectParentControl <SdeEditor>(control); parent.AsyncOperation.SetAndRunOperation(new GrfThread(delegate { items = items.OrderBy(p => p.GetKey <int>()).ToList(); StringBuilder builder = new StringBuilder(); try { AProgress.Init(parent); DbLoaderErrorHandler.Start(); var dbItems = gdb.GetMeta <int>(ServerDbs.Items); List <string> aegisNames = dbItems.FastItems.Select(p => p.GetStringValue(ServerItemAttributes.AegisName.Index)).ToList(); List <string> names = dbItems.FastItems.Select(p => p.GetStringValue(ServerItemAttributes.Name.Index)).ToList(); for (int i = 0; i < items.Count; i++) { AProgress.IsCancelling(parent); DbWriterMethods.DbItemGroupWriter2(items[i], serverType, builder, gdb, aegisNames, names); parent.Progress = (i + 1f) / items.Count * 100f; } } catch (OperationCanceledException) { } finally { AProgress.Finalize(parent); DbLoaderErrorHandler.Stop(); } Clipboard.SetText(builder.ToString()); }, parent, 200, null, true, true)); }
public static void AddTagGeneratorTabChangedEvent <TKey>(TabControl control, GDbTab tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { control.SelectionChanged += delegate(object sender, SelectionChangedEventArgs e) { if (e == null || e.RemovedItems.Count <= 0 || e.RemovedItems[0] as TabItem == null || (e.AddedItems.Count > 0 && e.AddedItems[0] as TabItem == null)) { return; } if (e.AddedItems.Count <= 0) { return; } TabItem item = e.AddedItems[0] as TabItem; if (gdb.DbSource.AlternativeName != null) { if (WpfUtilities.IsTab(item, gdb.DbSource.Filename) || WpfUtilities.IsTab(item, gdb.DbSource.AlternativeName)) { gdb.To <TKey>().TabGenerator.OnTabVisualUpdate((GDbTabWrapper <TKey, ReadableTuple <TKey> >)tab, settings, gdb); } } else { if (WpfUtilities.IsTab(item, gdb.DbSource)) { gdb.To <TKey>().TabGenerator.OnTabVisualUpdate((GDbTabWrapper <TKey, ReadableTuple <TKey> >)tab, settings, gdb); } } }; }
private void _addSearchAttributeSub(Grid searchGrid, string attribute, int row, int column) { CheckBox box = new CheckBox(); box.Margin = new Thickness(3); TextBlock block = new TextBlock { Text = attribute }; box.MouseEnter += delegate { block.Foreground = new SolidColorBrush(Color.FromArgb(255, 5, 119, 193)); block.Cursor = Cursors.Hand; block.TextDecorations = TextDecorations.Underline; }; box.MouseLeave += delegate { block.Foreground = Brushes.Black; block.Cursor = Cursors.Arrow; block.TextDecorations = null; }; box.Content = block; while (searchGrid.RowDefinitions.Count <= row) { searchGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(-1, GridUnitType.Auto) }); } WpfUtilities.SetGridPosition(box, row, column); _itemsSearchSettings.Link(box, attribute); searchGrid.Children.Add(box); }
private void _addSearch(Grid searchGrid, string display, FrameworkElement element, int row, int column, bool isItalic = false) { Label label = new Label(); label.Content = display; if (isItalic) { label.FontStyle = FontStyles.Italic; } while (searchGrid.RowDefinitions.Count <= row) { searchGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(-1, GridUnitType.Auto) }); } WpfUtilities.SetGridPosition(label, row, column); if (element != null) { WpfUtilities.SetGridPosition(element, row, column + 2); element.Margin = new Thickness(2); searchGrid.Children.Add(element); } searchGrid.Children.Add(label); }
private void operation_Finished(object sender, EventArgs e) { var operation = (OperationBase)sender; CleanAfterOperation(operation); WpfUtilities.ThreadSafeInvoke(() => Finished.Add(operation)); }
private static ListBoxItem GetVisibleCategory(ListBox parent, int startIndex, Key key) { if (parent.Equals(null)) { return(null); } var index = startIndex; var generator = parent.ItemContainerGenerator; var category = generator.ContainerFromIndex(index) as ListBoxItem; while (category != null && !WpfUtilities.ChildOfType <Expander>(category, string.Empty).IsExpanded) { if (key == Key.Down) { index++; } if (key == Key.Up) { index--; } if (0 <= index && index < parent.Items.Count) { category = generator.ContainerFromIndex(index) as ListBoxItem; } else { category = null; } } return(category); }
private void FileSystemTreeSource_OnTreeReceived(FileSystemTree fileSystemTree) { WpfUtilities.Post(_control, () => { ViewModel.ServerIsRunning = true; OnFileSystemTreeScanSuccess(fileSystemTree); }); }
public PresetOverwritePrompt() { InitializeComponent(); this.Owner = WpfUtilities.FindUpVisualTree <DynamoView>(this); this.WindowStartupLocation = WindowStartupLocation.CenterOwner; this.Loaded += PresetOverwritePrompt_Loaded; }
public static void FadeIn() { if (windowStackIndex == 0) { WpfUtilities.ThreadSafeInvoke(() => Application.Current.MainWindow.Opacity = 0.7); } windowStackIndex++; }
public Grid AddGrid(int row, int col, int rowSpan, int colSpan) { Grid element = new Grid(); WpfUtilities.SetGridPosition(element, row, rowSpan, col, colSpan); _deployControls.Add(new Tuple <FrameworkElement, FrameworkElement>(element, null)); return(element); }
public static void FadeOut() { windowStackIndex--; if (windowStackIndex == 0) { WpfUtilities.ThreadSafeInvoke(() => Application.Current.MainWindow.Opacity = 1); } }
private void _textBox_TextChanged(object sender, TextChangedEventArgs e) { try { if (!_tab.ItemsEventsDisabled) { DisplayableProperty <TKey, TValue> .ApplyCommand(_tab, _attribute, _textBox.Text); } try { byte[] data = _tab.ProjectDatabase.MetaGrf.GetDataBuffered(EncodingService.FromAnyToDisplayEncoding(GrfPath.Combine(_grfPath1, _textBox.Text.ExpandString()) + _ext)); if (data != null) { WpfUtilities.TextBoxOk(_textBox); _wrapper1.Image = ImageProvider.GetImage(data, _ext); _wrapper1.Image.MakePinkTransparent(); _imageResource.Tag = _textBox.Text; _imageResource.Source = _wrapper1.Image.Cast <BitmapSource>(); } else { WpfUtilities.TextBoxError(_textBox); _wrapper1.Image = null; _imageResource.Source = null; } } catch (ArgumentException) { WpfUtilities.TextBoxError(_textBox); _wrapper1.Image = null; _imageResource.Source = null; } try { byte[] data2 = _tab.ProjectDatabase.MetaGrf.GetDataBuffered(EncodingService.FromAnyToDisplayEncoding(GrfPath.Combine(_grfPath2, _textBox.Text.ExpandString()) + _ext)); if (data2 != null) { _wrapper2.Image = ImageProvider.GetImage(data2, _ext); _wrapper2.Image.MakePinkTransparent(); _imagePreview.Tag = _textBox.Text; _imagePreview.Source = _wrapper2.Image.Cast <BitmapSource>(); //_imagePreview.Source.Freeze(); } else { _wrapper2.Image = null; _imagePreview.Source = null; } } catch (ArgumentException) { _wrapper2.Image = null; _imagePreview.Source = null; } } catch (Exception err) { ErrorHandler.HandleException(err); } }
public void SelectDirectory(DirectoryEntryViewModel directoryEntry, TreeView treeView, Action beforeSelectItem, Action afterSelectItem) { if (ReferenceEquals(CurrentRootNodesViewModel, _fileSystemEntryRootNodes)) { return; } var chromiumRoot = GetChromiumRoot(directoryEntry); var entryViewModel = _fileSystemEntryRootNodes.OfType <DirectoryEntryViewModel>() .FirstOrDefault(x => SystemPathComparer.Instance.Comparer.Equals(x.Name, chromiumRoot.Name)); if (entryViewModel == null) { return; } foreach (var childName in directoryEntry.Name.Split(Path.DirectorySeparatorChar)) { var childViewModel = entryViewModel .Children .OfType <DirectoryEntryViewModel>() .FirstOrDefault(x => SystemPathComparer.Instance.Comparer.Equals(x.Name, childName)); if (childViewModel == null) { entryViewModel.EnsureAllChildrenLoaded(); childViewModel = entryViewModel .Children .OfType <DirectoryEntryViewModel>() .FirstOrDefault(x => SystemPathComparer.Instance.Comparer.Equals(x.Name, childName)); if (childViewModel == null) { return; } } entryViewModel = childViewModel; } SwitchToFileSystemTree(); entryViewModel.IsExpanded = true; entryViewModel.IsSelected = true; WpfUtilities.Invoke(treeView, DispatcherPriority.ApplicationIdle, () => { try { beforeSelectItem(); try { WpfUtilities.SelectItem(treeView, entryViewModel); } finally { afterSelectItem(); } } catch (Exception e) { Logger.LogException(e, "Error updating TreeView UI to show selected item."); } }); }
public DisplayLabel() { FocusVisualStyle = null; Margin = new Thickness(-4, -4, 0, -4); Padding = new Thickness(0); FontSize = 12; MouseEnter += delegate { if (_dbSource != null) { if (FtpHelper.HasBeenMapped()) { ToolTip = DbPathLocator.DetectPath(_dbSource); } else { ToolTip = "Directory has not been mapped yet. Load the database first."; } } if (ToolTip == null) { ToolTip = "File not found. This database will be disabled."; } }; SizeChanged += delegate { if (!_isLoaded) { Grid presenter = WpfUtilities.FindParentControl <Grid>(this); TextBox box = (TextBox)presenter.Children[2]; if (box.Text == "Visible") { Foreground = _stateBrush; } else { Foreground = _stateInactiveBrush; } box.TextChanged += delegate { if (box.Text == "Visible") { Foreground = _stateBrush; } else { Foreground = _stateInactiveBrush; } }; _isLoaded = true; } }; }
public PresetPrompt() { InitializeComponent(); this.Owner = WpfUtilities.FindUpVisualTree <DynamoView>(this); this.WindowStartupLocation = WindowStartupLocation.CenterOwner; this.nameBox.Focus(); }
private CustomPopupPlacement[] PlacementCallback(Size popup, Size target, Point offset) { // http://stackoverflow.com/questions/1918877/how-can-i-get-the-dpi-in-wpf // MAGN 7397 Library tooltip popup is offset over library items on highres monitors (retina and >96 dpi) //Youtrack http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-7397 PresentationSource source = PresentationSource.FromVisual(this); double xfactor = 1.0; if (source != null) { xfactor = source.CompositionTarget.TransformToDevice.M11; } double gap = Configurations.ToolTipTargetGapInPixels; var dynamoWindow = WpfUtilities.FindUpVisualTree <DynamoView>(this.PlacementTarget); if (dynamoWindow == null) { SetDataContext(null, true); return(null); } Point targetLocation = this.PlacementTarget .TransformToAncestor(dynamoWindow) .Transform(new Point(0, 0)); double x = 0; // Count width. // multiplying by xfactor scales the placement point of the library UI tooltip to the correct location //otherwise direct pixel coordinates are off by this factor due to screen dpi. var placementTarget = PlacementTarget as FrameworkElement; if (placementTarget != null) { x = (placementTarget.ActualWidth + gap * 2 + targetLocation.X * (-1)) * xfactor; } // Count height. var availableHeight = dynamoWindow.ActualHeight - popup.Height - (targetLocation.Y + Configurations.NodeButtonHeight); double y = 0; if (availableHeight < Configurations.BottomPanelHeight) { y = availableHeight - (Configurations.BottomPanelHeight + gap * 4); } return(new[] { new CustomPopupPlacement() { Point = new Point(x, y), PrimaryAxis = PopupPrimaryAxis.Horizontal } }); }
void NotificationsControl_Loaded(object sender, RoutedEventArgs e) { var window = WpfUtilities.FindUpVisualTree <DynamoView>(this); if (window == null) { return; } window.PreviewMouseDown += window_PreviewMouseDown; }