bool AcceptableUndockingStartPoint() { #if alldbg || dbg DesktopPanelTool.Lib.Debug.WriteLine($"acceptable start point: has parent={WPFHelper.HasParent<WidgetControl>(Mouse.DirectlyOver as DependencyObject)}"); #endif return(!WPFHelper.HasParent <WidgetControl>(Mouse.DirectlyOver as DependencyObject)); }
/// <summary> /// XML化する /// </summary> /// <param name="t"></param> /// <returns>XML</returns> public static Task <string> ToXMLAsync( this ITrigger t) => Task.Run(() => { if (t == null) { return(string.Empty); } var xws = new XmlWriterSettings() { OmitXmlDeclaration = true, Indent = true, }; var ns = new XmlSerializerNamespaces(); ns.Add(string.Empty, string.Empty); var sb = new StringBuilder(); using (var xw = XmlWriter.Create(sb, xws)) { var xs = new XmlSerializer(t.GetType()); WPFHelper.Invoke(() => xs.Serialize(xw, t, ns)); } sb.Replace("utf-16", "utf-8"); return(sb.ToString() + Environment.NewLine); });
public void CopyInkCanvasObjects(InkCanvas inkCanvas, InkCanvas clipboardCanvas) { var selectionBounds = inkCanvas.GetSelectionBounds(); if (selectionBounds.IsEmpty) { return; } Clear(clipboardCanvas); var selectedElements = inkCanvas.GetSelectedElements().ToList(); var selectedStrokes = new StrokeCollection(inkCanvas.GetSelectedStrokes()); ClearSelection(inkCanvas); var elements = new List <UIElement>(); WPFHelper.CloneElementsTo(elements, selectedElements.GetEnumerator(), clipboardCanvas); WPFHelper.CloneStrokesTo(clipboardCanvas.Strokes, selectedStrokes); elements.ForEach(element => clipboardCanvas.Children.Add(element)); inkCanvas.Select(selectedStrokes, selectedElements); var dataObject = new DataObject(); dataObject.SetData(ClipboardIdFormat, _clipboardStateId = Guid.NewGuid()); dataObject.SetData(DataFormats.Bitmap, ImageHelper.GetCroppedImageFromInkCanvas(selectionBounds, inkCanvas)); Clipboard.SetDataObject(dataObject); }
private void btnMark_Click(object sender, RoutedEventArgs e) { if (this.OrderReturns.Count < 1) { MessageBox.Show("没有需要打印的数据"); return; } try { foreach (var item in this.OrderReturns) { item.ProcessState = "处理中"; WPFHelper.DoEvents(); this.OrderReturnService.Update(item.Source); item.ProcessState = "退货中"; WPFHelper.DoEvents(); } MessageBox.Show("已完成"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static void LoadTTSCache() { if (Settings.Default.Player != WavePlayerTypes.WASAPIBuffered) { return; } var volume = Settings.Default.WaveVolume / 100f; WPFHelper.BeginInvoke(() => { }, DispatcherPriority.SystemIdle).Task.ContinueWith((_) => Task.Run(() => { var count = 0; try { Logger.Info("Started loading TTS caches."); BufferedWavePlayer.PlayerSet.LoadTTSHistory(); count = BufferedWavePlayer.Instance.BufferWaves(volume); } finally { Logger.Info($"Completed loading TTS caches. {count} files has loaded."); } })); }
public static void ShowTitleCard( string title, int tryCount, DateTime recordingTime) { if (window == null) { window = new TitleCardView(); } window.VideoTitle = title; window.TryCount = tryCount; window.RecordingTime = recordingTime; window.Show(); if (!window.Config.IsAlwaysShow) { WPFHelper.BeginInvoke(async() => { await Task.Delay(TimeSpan.FromSeconds(2.7)); window.Close(); window = null; }); } }
private void ChangeBtn(BtnType btnType) { Image btnIcon = WPFHelper.GetVisualChild <Image>(Btn); switch (btnType) { case BtnType.BTN_CANCEL: Btn.Click -= BtnSearch_OnClick; Btn.Click += BtnCancel_OnClick; BitmapImage closeIcon = new BitmapImage(new Uri("close.png", UriKind.Relative)); btnIcon.Source = closeIcon; TbxInput.IsEnabled = false; break; case BtnType.BTN_SEARCH: Btn.Click -= BtnCancel_OnClick; Btn.Click += BtnSearch_OnClick; BitmapImage searchIcon = new BitmapImage(new Uri("search.png", UriKind.Relative)); btnIcon.Source = searchIcon; TbxInput.IsEnabled = true; break; default: break; } }
/// <summary> /// 開始する /// </summary> public async void Begin() { this.isOver = false; // FFXIVプラグインのバージョンをチェックする FFXIVPlugin.Instance.ActPluginAttachedCallback = () => { var ver = FFXIVPlugin.Instance.ActPlugin.GetType().Assembly.GetName().Version; if (ver.Major >= 2) { WPFHelper.InvokeAsync(() => { ModernMessageBox.ShowDialog( "This Hojoring not supported FFXIV_ACT_Plugin v2 or later." + Environment.NewLine + "You should update to Hojoring v7 or later.", "Attention", MessageBoxButton.OK); }); } }; // FFXIVのスキャンを開始する // FFXIVプラグインへのアクセスを開始する await Task.Run(() => FFXIVPlugin.Instance.Start( Settings.Default.LogPollSleepInterval, Settings.Default.FFXIVLocale)); // ログバッファを生成する this.LogBuffer = new LogBuffer(); await Task.Run(() => { // テーブルコンパイラを開始する TableCompiler.Instance.Begin(); // サウンドコントローラを開始する SoundController.Instance.Begin(); }); // Overlayの更新スレッドを開始する this.BeginOverlaysThread(); // ログ監視タイマを開始する this.detectLogsWorker = new ThreadWorker( () => this.DetectLogsCore(), 0, nameof(this.detectLogsWorker)); // Backgroudスレッドを開始する this.backgroudWorker = new System.Timers.Timer(); this.backgroudWorker.AutoReset = true; this.backgroudWorker.Interval = 5000; this.backgroudWorker.Elapsed += (s, e) => { this.BackgroundCore(); }; this.detectLogsWorker.Run(); this.backgroudWorker.Start(); }
public static void ShowTimeline( TimelineModel timelineModel) { if (!TimelineSettings.Instance.Enabled || !TimelineSettings.Instance.OverlayVisible) { return; } // 有効な表示データが含まれていない? if (!timelineModel.ExistsActivities()) { return; } WPFHelper.Invoke(() => { if (TimelineView == null) { TimelineView = new TimelineOverlay(); TimelineView.Show(); } TimelineView.Model = timelineModel; ChangeClickthrough(TimelineSettings.Instance.Clickthrough); TimelineView.OverlayVisible = true; }); }
public bool ExternalScrollEmulation(int eDelta) { { var hit = VisualTreeHelper.HitTest(HierarchicalNotesList, Mouse.GetPosition(HierarchicalNotesList)); if (hit != null) { var sv = WPFHelper.GetScrollViewer(HierarchicalNotesList); if (sv == null) { return(false); } sv.ScrollToVerticalOffset(sv.VerticalOffset - eDelta / 3f); return(true); } } { var hit = VisualTreeHelper.HitTest(FolderTreeView, Mouse.GetPosition(FolderTreeView)); if (hit != null) { var sv = WPFHelper.GetScrollViewer(FolderTreeView); if (sv == null) { return(false); } sv.ScrollToVerticalOffset(sv.VerticalOffset - eDelta / 3f); return(true); } } return(false); }
private void btnGetTemplateControlList_Click(object sender, RoutedEventArgs e) { List <Visual> visualList = WPFHelper.GetTemplateControlList(slider); StringBuilder sb = new StringBuilder(); FrameworkElement fe; int count = 0; foreach (var visual in visualList) { fe = visual as FrameworkElement; if (fe != null) { sb.AppendLine($"Name:{fe.Name} Type:{visual.GetType().FullName}"); } else { count++; } } if (count > 0) { sb.AppendLine($"no FrameworkElement :{count}"); } string str = sb.ToString(); }
private void btnUpload_Click(object sender, RoutedEventArgs e) { try { var printHistorys = this.GetSelected(sender); if (printHistorys.Length < 1) { return; } this.ResetViewState(printHistorys); foreach (var item in printHistorys) { try { this.printHistoryService.Upload(item.Source); item.State = "上传成功"; item.Background = null; } catch (Exception ex) { item.Background = Brushes.Red; item.State = ex.Message; } WPFHelper.DoEvents(); } MessageBox.Show("已完成"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public override void Initialize() { this.Model.RestartTickerCallback = () => WPFHelper.InvokeAsync( this.BeginAnimation, DispatcherPriority.Normal); this.Config.PropertyChanged += (_, e) => { switch (e.PropertyName) { case nameof(this.Config.Visible): if (this.Config.Visible) { this.Model.StartSync(); } else { this.Model.StopSync(); } break; case nameof(this.Config.TestMode): if (this.Config.TestMode) { this.BeginAnimation(); } break; } }; if (this.Config.Visible) { this.Model.StartSync(); } }
private void AddCopy(InkCanvas inkCanvas) { var strokeCollection = new StrokeCollection(); foreach (var selectedStroke in _selectedStrokes) { var stroke = selectedStroke.Clone(); strokeCollection.Add(stroke); inkCanvas.Strokes.Add(stroke); } var uiElementCollection = new List <UIElement>(); foreach (UIElement selectedElement in _selectedElements) { var element = WPFHelper.Clone(selectedElement, inkCanvas); if (element == null) { continue; } uiElementCollection.Add(element); inkCanvas.Children.Add(element); InkCanvas.SetLeft(element, InkCanvas.GetLeft(selectedElement)); InkCanvas.SetTop(element, InkCanvas.GetTop(selectedElement)); } _repetitions.Add(new Tuple <ReadOnlyCollection <UIElement>, StrokeCollection>(new ReadOnlyCollection <UIElement>(uiElementCollection), strokeCollection)); }
public void Paste(InkCanvas inkCanvas, InkCanvas clipboardCanvas) { if (!ContainsImage()) { EventBroker.Instance.ActionResult(Resources.Title_Paste, Resources.Message_Clipboard_does_not_contain_any_image_as_expected); return; } if (ClipboardWasChangedOutside()) { var image = ImageHelper.AddImageTo(inkCanvas, new Bitmap(GetImage())); ActivateSelectionMode(inkCanvas); inkCanvas.Select(new List <UIElement> { image }); return; } _currentPasteOffset += PasteOffset; ClearSelection(inkCanvas); var elements = new List <UIElement>(); var strokes = new StrokeCollection(); WPFHelper.CloneElementsTo(elements, clipboardCanvas.Children.GetEnumerator(), inkCanvas, _currentPasteOffset); WPFHelper.CloneStrokesTo(strokes, clipboardCanvas.Strokes, _currentPasteOffset); elements.ForEach(element => inkCanvas.Children.Add(element)); inkCanvas.Strokes.Add(strokes); ActivateSelectionMode(inkCanvas); inkCanvas.Select(strokes, elements); }
private void btnMarkDelivery_Click(object sender, RoutedEventArgs e) { try { var so = this.orders.Where(obj => obj.IsChecked).ToArray(); if (so.Length < 1) { throw new Exception("没有选择订单"); } var os = ServiceContainer.GetService <OrderService>(); foreach (var o in so) { WPFHelper.DoEvents(); try { os.MarkPopDelivery(o.Source.Id, ""); o.State = "标记成功"; o.Background = null; } catch (Exception ex) { o.State = ex.Message; o.Background = Brushes.Red; } } MessageBox.Show("所有订单标记完成"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
bool CheckMouseOutWindow() { #if alldbg || dbg DesktopPanelTool.Lib.Debug.WriteLine($"mouse directlyOver={Mouse.DirectlyOver}"); #endif if (Mouse.DirectlyOver is DependencyObject o && o != null) { var ancestor = WPFHelper.FindLogicalAncestor(o); #if alldbg || dbg DesktopPanelTool.Lib.Debug.WriteLine($"ancestor = {ancestor}"); #endif if (!(ancestor is Window w && AssociatedObject != w)) { return(false); } } POINT p = new POINT(); GetCursorPos(ref p); var x = p.X; var y = p.Y; if (_canMove) { GetWindowCoordinates(); } return(x < _left || x > _right || y <= _top || y >= _bottom); }
private void AppendLogLine( string message, Exception ex = null, bool err = false) { // UIに出力する var text = $"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff")}] {message}"; if (ex != null) { text += Environment.NewLine + ex.ToString(); } this.log.AppendLine(text); WPFHelper.BeginInvoke(() => this.RaisePropertyChanged(nameof(this.Log))); // NLogに出力する var log = $"[DISCORD] {message}"; if (ex == null && !err) { this.Logger.Trace(log); } else { this.Logger.Error(ex, log); } }
private async void XMLPasteOnClick(object sender, RoutedEventArgs e) { var text = string.Empty; await WPFHelper.InvokeAsync(() => { for (int i = 0; i < 10; i++) { try { var obj = Clipboard.GetDataObject(); if (obj != null && obj.GetDataPresent(DataFormats.Text)) { text = (string)obj.GetData(DataFormats.Text); } break; } catch (Exception ex) when(ex is InvalidOperationException || ex is COMException) { Thread.Sleep(5); } } }); if (!string.IsNullOrEmpty(text)) { this.XMLEditor.Text = text; CommonSounds.Instance.PlayAsterisk(); } }
private async void ReplaceButton() { if (this.SwitchVisibleButton != null && !this.SwitchVisibleButton.IsDisposed && this.SwitchVisibleButton.IsHandleCreated) { var leftButton = ( from Control x in ActGlobals.oFormActMain.Controls where !x.Equals(this.SwitchVisibleButton) && ( x is Button || x is CheckBox ) orderby x.Left select x).FirstOrDefault(); var location = leftButton != null ? new Point(leftButton.Left - this.SwitchVisibleButton.Width - 1, 0) : new Point(ActGlobals.oFormActMain.Width - 533, 0); await WPFHelper.InvokeAsync(() => { if (this.SwitchVisibleButton != null) { this.SwitchVisibleButton.Location = location; } }); } }
private void FilterView_PreviewMouseMove(object sender, MouseEventArgs e) { // Get the current mouse position Point mousePos = e.GetPosition(null); Vector diff = startPoint - mousePos; if (e.LeftButton == MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { // Get the dragged ListViewItem ListView listView = sender as ListView; ListViewItem listViewItem = WPFHelper.FindAnchestor <ListViewItem>((DependencyObject)e.OriginalSource); if (listViewItem == null) { return; } // Find the data behind the ListViewItem AssetItem item = (AssetItem)listView.ItemContainerGenerator. ItemFromContainer(listViewItem); // Initialize the drag & drop operation DataObject dragData = new DataObject("assetFormat", item); DragDrop.DoDragDrop(listViewItem, dragData, DragDropEffects.Move); } }
/// <summary> /// 終了 /// </summary> public virtual void End() { MainWorker.Instance.GetDataMethod -= this.GetDataDelegate; MainWorker.Instance.UpdateOverlayDataMethod -= this.UpdateOverlayDataDelegate; lock (MainWorker.Instance.ViewRefreshLocker) { WPFHelper.Invoke(() => { foreach (var item in this.ViewList) { item.ViewModel?.Dispose(); item.View?.Close(); } this.ViewList.Clear(); }); this.nameVM = null; this.hpVM = null; this.hpBarVM = null; this.actionVM = null; this.distanceVM = null; } }
private void btnMarkPopDelivery_Click(object sender, RoutedEventArgs e) { try { var selected = this.GetSelected(sender); this.ResetViewState(selected); WPFHelper.DoEvents(); foreach (var item in selected) { try { item.Background = Brushes.Yellow; item.State = ""; ServiceContainer.GetService <OrderService>().MarkPopDelivery(item.Source.OrderId, ""); ServiceContainer.GetService <PrintHistoryService>().Update(item.Source); item.State = "标记发货成功"; item.Background = null; } catch (Exception ex) { item.State = ex.Message; item.Background = Brushes.Red; } finally { WPFHelper.DoEvents(); } } MessageBox.Show("已完成"); } catch (Exception ex) { MessageBox.Show("标记发货失败:" + ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnUpload_Click(object sender, RoutedEventArgs e) { try { var s = ServiceContainer.GetService <DeliveryInService>(); List <string> uploadedDeliveryNumbers = new List <string>(); foreach (var item in this.deliveryInViewModels) { WPFHelper.DoEvents(); //已经上传过 if (item.Id > 0) { item.State = "上传成功"; continue; } //货到付款订单,标记已拒签 if (item.SourceOrder != null && item.SourceOrder.PopPayType == PopPayType.COD) { item.SourceOrder.Refused = true; ServiceContainer.GetService <OrderService>().Update(item.SourceOrder); } //上传记录 DeliveryIn di = new DeliveryIn { Comment = item.OrderGoodsInfo, CreateTime = DateTime.Now, DeliveryCompany = item.DeliveryCompany, DeliveryNumber = item.DeliveryNumber, CreateOperator = OperatorService.LoginOperator.Number, Id = 0, }; di.Id = s.Save(di); item.Id = di.Id; WPFHelper.DoEvents(); //如果是拒签就创建退货,并处理 if (item.IsRefused) { var ors = ServiceContainer.GetService <OrderReturnService>(); var id = ors.Create(item.OrderId, item.SourceOrderGoods.Id, item.DeliveryCompany, item.DeliveryNumber, OrderReturnType.REFUSED, OrderReturnReason.DAY7, item.SourceOrderGoods.Count); var or = ors.GetById(id.data); or.ProcessOperator = OperatorService.LoginOperator.Number; or.ProcessTime = DateTime.Now; or.State = OrderReturnState.PROCESSED; ors.Update(or); } item.State = "上传成功"; WPFHelper.DoEvents(); } MessageBox.Show("上传成功"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public Profile(TwitterUser user) { InitializeComponent(); txtScreenName.Text = "@" + user.ScreenName; txtName.Text = user.Name; txtProfile.Text = user.Description; ImageProfile.Source = WPFHelper.CreateImage(user.ProfileImageUrl); }
private void ValueOnSizeChanged(object sender, SizeChangedEventArgs sizeChangedEventArgs) { if (Data != null) { _itemsPanel = WPFHelper.GetVisualChild <Panel>(WPFHelper.GetVisualChild <ItemsPresenter>(Parent)); Data.ReDraw(); } }
public void CloseNotice() { WPFHelper.Invoke(() => { this.Model = null; this.Close(); }); }
private void PropertyCheckBox_Click(object sender, RoutedEventArgs e) { CheckBox checkBox = sender as CheckBox; DataGridRow parentRow = WPFHelper.GetParentObject <DataGridRow>(checkBox, null); PropertyListItem sourceItem = parentRow.Item as PropertyListItem; GlobalCfg.Instance.SetCurrentIsNeedGen(_IDItemSelected.ID, sourceItem.EnName, checkBox.IsChecked.Value); }
private void ProcessConfig() { if (config.ver < WPFHelper.GetCurrentVer()) { config.ver = WPFHelper.GetCurrentVer(); config.SaveConfig(); } }
public TimelineManagerView() { this.InitializeComponent(); this.SetLocale(Settings.Default.UILocale); this.LoadConfigViewResources(); if (!WPFHelper.IsDesignMode) { if (this.TimelineConfig.Enabled) { WPFHelper.BeginInvoke(async() => { try { await Task.Run(() => TimelineManager.Instance.LoadTimelineModels()); } catch (Exception ex) { TimelineModel.ShowRazorDumpFile(); ModernMessageBox.ShowDialog( ex.Message, "Timeline Loader", MessageBoxButton.OK, ex.InnerException); } }); } } this.StyleListView.SelectionChanged += (x, y) => { if (this.TimelineConfig.DesignMode) { var selectedStyle = this.StyleListView.SelectedItem as TimelineStyle; TimelineOverlay.HideDesignOverlay(false); TimelineOverlay.ShowDesignOverlay(selectedStyle); TimelineNoticeOverlay.HideDesignOverlay(); TimelineNoticeOverlay.ShowDesignOverlay(selectedStyle); } }; this.timer.Tick += (x, y) => { if (TimelineController.CurrentController != null) { // ついでにスタートボタンのラベルを切り替える this.StartButtonLabel = TimelineController.CurrentController.IsRunning ? StopString : StartString; } }; this.timer.Start(); }