private void TreeList_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { TreeListItem item = WpfUtil.GetTreeListItem(e.OriginalSource); if (item == null) { e.Handled = true; return; } TreeList list = (TreeList)sender; if (list.SelectedItem != null) { return; } Point pt = e.GetPosition((UIElement)sender); HitTestResult result = VisualTreeHelper.HitTest(list, pt); if (result != null) { item = WpfUtil.GetTreeListItem(result.VisualHit); if (item != null) { item.IsSelected = true; } } }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values == null || values.Length != 6 || !(values[0] is PackageItemType) || !(values[1] is string) || !(values[2] is bool) || !(values[3] is double) || !(values[4] is double) || !(values[5] is DependencyObject)) { return(null); } int x = (int)(double)values[3]; int y = (int)(double)values[4]; if (x < 1) { x = 1; } if (y < 1) { y = 1; } PackageItemType type = (PackageItemType)values[0]; if (type == PackageItemType.Folder) { bool isExpanded = (bool)values[2]; ImageMoniker moniker = isExpanded ? KnownMonikers.FolderOpened : KnownMonikers.FolderClosed; return(WpfUtil.ThemeImage((DependencyObject)values[5], WpfUtil.GetIconForImageMoniker(moniker, x, y))); } string name = (string)values[1]; bool isThemeIcon; ImageSource source = WpfUtil.GetIconForFile((DependencyObject)values[5], name, out isThemeIcon); return(source); }
private void DataGrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { DataGridRow row = WpfUtil.GetGridRow(e.OriginalSource); if (row == null) { e.Handled = true; return; } DataGrid grid = (DataGrid)sender; if (grid.SelectedItem != null) { return; } Point pt = e.GetPosition((UIElement)sender); HitTestResult result = VisualTreeHelper.HitTest(grid, pt); if (result != null) { row = WpfUtil.GetGridRow(result.VisualHit); if (row != null) { row.IsSelected = true; } } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var uri = value as Uri; if (uri == null) { return(new BitmapImage(defaultUri)); } try { var image = new BitmapImage(); image.BeginInit(); image.DecodePixelWidth = int.Parse((string)parameter); image.CacheOption = BitmapCacheOption.OnLoad; image.UriSource = uri; image.EndInit(); while (image.IsDownloading) { WpfUtil.DoEvents(); } return(image); } catch { return(new BitmapImage(defaultUri)); } }
public void RefreshAspectColoration() { if (ItemVariationTable.Items.Count == 0) { return; } for (int i = 0; i < AspectTable.Items.Count; i++) { DependencyObject obj = AspectTable.ItemContainerGenerator.ContainerFromIndex(i); if (obj == null) { continue; } IEnumerable <Button> buttons = WpfUtil.FindVisualChildren <Button>(obj).ToList(); buttons.Select(x => new { label = (AspectTable.Items[i] as IItemAspect).Name, value = x }).ToList() .ForEach(z => { if (((ItemVariationTable.SelectedItem ?? ItemVariationTable.Items[0]) as NinjaItem).Aspects.Any(y => y.Name.Contains(z.label))) { z.value.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#651fff")); } else { z.value.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9e9e9e")); } }); } }
private void FileTreeView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { TreeListItem item = WpfUtil.GetTreeListItem(e.OriginalSource); if (item == null) { return; } FileComponent file = FileController.SelectedItem; if (file != null) { if (file.File) { file.Open(); } else { TreeNode node = FileTreeView.SelectedNode; if (node != null) { FileTreeView.SetIsExpanded(node, !node.IsExpanded); } } } FileTreeView.UnselectAll(); }
private void m_listener_rendering(object sender, EventArgs e) { if (this.Child != m_zapPanel) { m_zapPanel = (ZapPanel)this.Child; m_zapPanel.RenderTransform = m_traslateTransform; } if (m_zapPanel != null) { int actualTargetIndex = Math.Max(0, Math.Min(m_zapPanel.Children.Count - 1, TargetIndex)); double targetPercentOffset = -actualTargetIndex / (double)m_zapPanel.Children.Count; targetPercentOffset = double.IsNaN(targetPercentOffset) ? 0 : targetPercentOffset; bool stopListening = !WpfUtil.Animate( m_percentOffset, m_velocity, targetPercentOffset, .05, .3, .1, c_diff, c_diff, out m_percentOffset, out m_velocity); double targetPixelOffset = m_percentOffset * (this.RenderSize.Width * m_zapPanel.Children.Count); m_traslateTransform.X = targetPixelOffset; if (stopListening) { m_listener.StopListening(); } } }
private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { WpfUtil.DataGrid_MouseDoubleClick <MainWindowViewModel.IpResult>(sender, e, ipResult => { Clipboard.SetDataObject(ipResult.Ip, true); VirtualRoot.Out.ShowSuccess(ipResult.Ip, "复制成功", autoHideSeconds: 1); }); }
public void ShowWindow(Action <UserControl> beforeShow = null) { beforeShow?.Invoke(_uc); if (Vm.IsDialogWindow || Vm.HasOwner) { var owner = WpfUtil.GetTopWindow(); if (this != owner) { this.Owner = owner; } } if (Vm.IsDialogWindow || Vm.HasOwner || Vm.HeaderVisible == Visibility.Collapsed) { this.ShowInTaskbar = false; } if (Vm.IsDialogWindow) { this.WindowStartupLocation = WindowStartupLocation.CenterOwner; this.ShowDialogEx(); } else { this.Topmost = Vm.IsTopMost; this.ShowActivated = true; this.Show(); if (this.WindowState == WindowState.Minimized) { this.WindowState = WindowState.Normal; } this.Activate(); } }
public static void Login(Action onLoginSuccess, string serverHost = null, Action btnCloseClick = null) { WpfUtil.Login(onLoginSuccess: () => { NTMinerContext.MinerStudioContext.UserAppSettingSet.Init(RpcRoot.RpcUser.LoginedUser.UserAppSettings); onLoginSuccess?.Invoke(); }, serverHost, btnCloseClick); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values == null || values.Length != 4 || !(values[0] is FileTreeModel) || !(values[1] is double) || !(values[2] is double) || !(values[3] is DependencyObject)) { return(null); } int x = (int)(double)values[1]; int y = (int)(double)values[2]; if (x < 1) { x = 1; } if (y < 1) { y = 1; } FileTreeModel model = (FileTreeModel)values[0]; if (!model.IsFile) { bool isExpanded = model.IsExpanded; ImageMoniker moniker = isExpanded ? KnownMonikers.FolderOpened : KnownMonikers.FolderClosed; return(WpfUtil.ThemeImage((DependencyObject)values[3], WpfUtil.GetIconForImageMoniker(moniker, x, y))); } string name = model.Name; bool isThemeIcon; ImageSource source = WpfUtil.GetIconForFile((DependencyObject)values[3], name, out isThemeIcon); return(source); }
public static void Login(Action onLoginSuccess) { if (!IsLogined()) { UIThread.Execute(() => { var topWindow = WpfUtil.GetTopWindow(); LoginWindow window = new LoginWindow(onLoginSuccess); if (topWindow != null && topWindow.GetType() != typeof(NotiCenterWindow)) { window.Owner = topWindow; window.WindowStartupLocation = WindowStartupLocation.CenterOwner; } window.Closing += (sender, e) => { if (IsLogined()) { onLoginSuccess?.Invoke(); } }; window.ShowSoftDialog(); window.PasswordFocus(); }); } else { onLoginSuccess?.Invoke(); } }
private SearchVideoByTemporaryModel() : base(true) { if (!WpfUtil.IsDesignMode() && !string.IsNullOrWhiteSpace(SettingModel.Instance.MailAddress)) { Reload().ConfigureAwait(false); } }
public NTMinerFileEdit(string iconName, NTMinerFileViewModel vm) { this.DataContext = vm; InitializeComponent(); this.PathIcon.Data = AppUtil.GetResource <Geometry>(iconName); this.Owner = WpfUtil.GetTopWindow(); }
private void m_listener_Rendering(object sender, EventArgs e) { bool stillAnimating = false; foreach (SetCard3D card in m_cards) { double zTranslateTarget = (card.IsChecked) ? 50 : 0; zTranslateTarget += (card.IsMouseOver) ? -10 : 0; double attractionFactor = .05; attractionFactor *= 1 + (card.Variation - .5); double newTranslate, newVelocity; stillAnimating = WpfUtil.Animate(card.TranslateTransform3D.OffsetZ, card.CurrentZVelocity, zTranslateTarget, attractionFactor, .3, 1000, .00001, .00001, out newTranslate, out newVelocity) || stillAnimating; card.CurrentZVelocity = newVelocity; card.TranslateTransform3D.OffsetZ = newTranslate; } if (!stillAnimating) { m_listener.StopListening(); } }
private void ShowWindow <TUc>(Action <ContainerWindow, TUc> beforeShow = null) where TUc : UserControl { beforeShow?.Invoke(this, (TUc)_uc); if (Vm.IsMaskTheParent && this.Owner == null) { var owner = WpfUtil.GetTopWindow(); if (owner != null && this != owner) { this.Owner = owner; } } if (Vm.IsMaskTheParent || this.Owner != null) { this.ShowInTaskbar = false; this.BtnMin.Visibility = Visibility.Collapsed; } if (Vm.IsMaskTheParent) { this.WindowStartupLocation = WindowStartupLocation.CenterOwner; this.ShowSoftDialog(); } else { this.ShowActivated = true; this.Show(); if (this.WindowState == WindowState.Minimized) { this.WindowState = WindowState.Normal; } this.Activate(); } }
public NTMinerFileEdit(string iconName, NTMinerFileViewModel vm) { this.DataContext = vm; InitializeComponent(); this.PathIcon.Data = (Geometry)Application.Current.Resources[iconName]; this.Owner = WpfUtil.GetTopWindow(); }
private void DataGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (!DevMode.IsDevMode) { return; } WpfUtil.DataGrid_MouseDoubleClick <ServerMessageViewModel>(sender, e); }
private static void OnSetIsEnabledCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e) { if (!WpfUtil.IsDesignMode()) { // Window読込時イベント BehaviorUtil.Loaded(sender as Window, Window_Loaded); } }
private void DataGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (!Vm.MainMenu.IsMinerStudioOuterAdmin) { return; } WpfUtil.DataGrid_EditRow <ServerMessageViewModel>(sender, e); }
private PackageSearchItem(string name, string alias = null) { Alias = alias ?? name; _dispatcher = Dispatcher.CurrentDispatcher; CollapsedItemText = name; Icon = WpfUtil.GetIconForImageMoniker(KnownMonikers.Package, 24, 24); _infoTask = new Lazy <Task <IPackageInfo> >(() => VSPackage.Manager.Provider.GetPackageInfoAsync(CollapsedItemText)); }
public MainViewModel() { if (!WpfUtil.IsDesignMode() && Instance != null) { throw new InvalidOperationException("This ViewModel cannot create multiple instances."); } Instance = this; }
public SearchVideoByMylistModel(string url) : this() { if (!WpfUtil.IsDesignMode()) { MylistUrl = url; Reload().ConfigureAwait(false); } }
/// <summary> /// Valueプロパティが変更された際の処理 /// </summary> /// <param name="target">対象</param> /// <param name="e">イベント情報</param> private static void OnSetFormatCallback(DependencyObject target, DependencyPropertyChangedEventArgs e) { var textbox = target as TextBox; var value = WpfUtil.GetIsNotNull(GetValue(textbox), textbox.Text, "0"); BehaviorUtil.Loaded(textbox, (sender, tmp) => SetText(textbox, double.Parse(value)) ); }
private void OnLoaded(object sender, RoutedEventArgs e) { Icon = WpfUtil.GetIconForImageMoniker(KnownMonikers.JSWebScript, 16, 16); Title = Vsix.Name; ViewModel = new InstallDialogViewModel(Dispatcher, _configFileName, _deps, _folder, CloseDialog); FocusManager.SetFocusedElement(cbName, cbName); }
public MinerClientSetting(MinerClientSettingViewModel vm) { this.DataContext = vm; InitializeComponent(); var owner = WpfUtil.GetTopWindow(); if (this != owner) { this.Owner = owner; } }
private void DataGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { DataGridRow row = WpfUtil.GetGridRow(e.OriginalSource); if (row == null) { DataGrid grid = (DataGrid)sender; grid.UnselectAll(); e.Handled = true; } }
private void TreeList_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { TreeListItem item = WpfUtil.GetTreeListItem(e.OriginalSource); if (item == null) { TreeList list = (TreeList)sender; list.UnselectAll(); e.Handled = true; } }
/// <summary> /// target以下の論理ツリー上の子要素をコンソール出力。階層分インデントする。 /// 要素がControlでNameを持っていた場合は併せて出力。 /// </summary> private void PrintLogicalChildren(DependencyObject target) { //代入用変数定義 ControlChildren SetVal = new ControlChildren(); var TabId = string.Empty; var MenuName = string.Empty; var TabID = new List <string>(); var ProgramID = new List <string>(); var No = new List <int>(); var Name = new List <string>(); WpfUtil.OperateLogicalChildren(target, t => { String contName = ""; Control cont = t as Control; if (cont != null && cont.Name.Length > 0) { if (cont.GetType() == typeof(Button)) { // 非表示のボタンは表示対象外とする if (cont.Visibility != System.Windows.Visibility.Hidden) { // タブID TabID.Add(TabId); // プログラムID ProgramID.Add(cont.Name); // メニュー番号 int SubNo = Int32.Parse(Convert.ToString(((Button)(cont)).Content).Substring(0, Convert.ToString(((Button)(cont)).Content).IndexOf("."))); No.Add(SubNo); // メニュー名称 Name.Add(Convert.ToString(((Button)(cont)).Content).Substring(Convert.ToString(((Button)(cont)).Content).IndexOf(".") + 1)); } } else if (cont.GetType() == typeof(TabItem)) { MenuName = Convert.ToString(((HeaderedContentControl)(cont)).Header); TabId = cont.Name; } } if (!contName.Equals(string.Empty)) { Console.WriteLine(contName); } } ); //メニュ項目設定 SetVal.TabID = TabID.ToArray(); SetVal.ProgramID = ProgramID.ToArray(); SetVal.No = No.ToArray(); SetVal.Name = Name.ToArray(); MenuList.Add(MenuName, SetVal); }
public CoinProfileViewModel(ICoinProfile innerProfile) { _inner = innerProfile; this.Up = new DelegateCommand <string>(propertyName => { WpfUtil.Up(this, propertyName); }); this.Down = new DelegateCommand <string>(propertyName => { WpfUtil.Down(this, propertyName); }); this.CopyWallet = new DelegateCommand(() => { string wallet = this.Wallet ?? "无"; Clipboard.SetDataObject(wallet, true); VirtualRoot.Out.ShowSuccess(wallet, header: "复制成功"); }, () => { return(this.SelectedWallet != null && !string.IsNullOrEmpty(this.SelectedWallet.Address)); }); this.CopyDualCoinWallet = new DelegateCommand(() => { string wallet = this.DualCoinWallet ?? "无"; Clipboard.SetDataObject(wallet, true); VirtualRoot.Out.ShowSuccess(wallet, header: "复制成功"); }, () => { return(this.SelectedDualCoinWallet != null && !string.IsNullOrEmpty(this.SelectedDualCoinWallet.Address)); }); this.HideWallet = new DelegateCommand(() => { this.IsHideWallet = true; }); this.ShowWallet = new DelegateCommand(() => { this.IsHideWallet = false; }); this.HideDualCoinWallet = new DelegateCommand(() => { this.IsDualCoinHideWallet = true; }); this.ShowDualCoinWallet = new DelegateCommand(() => { this.IsDualCoinHideWallet = false; }); this.AddWallet = new DelegateCommand(() => { if (AppRoot.CoinVms.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm)) { Guid id = Guid.NewGuid(); var wallets = coinVm.Wallets.Where(a => a.IsTestWallet).ToArray(); int sortNumber = wallets.Length == 0 ? 1 : wallets.Max(a => a.SortNumber) + 1; new WalletViewModel(id) { CoinId = CoinId, SortNumber = sortNumber, AfterClose = () => { if (NTMinerContext.Instance.MinerProfile.TryGetWallet(id, out IWallet wallet)) { this.SelectedWallet = AppRoot.WalletVms.WalletList.FirstOrDefault(a => a.Id == id); } } }.Edit.Execute(FormType.Add); }