Esempio n. 1
0
        public virtual bool Undo(bool run = true)
        {
            Performing = ActionState.Undo;
            UndoTentativeAction();
            if (_undoStack.Count == 0)
            {
                return(false);
            }
            if (run)
            {
                do
                {
                    _redoStack.Push(_undoStack.Pop().Undo());
                } while (_undoStack.Count != 0 && !_undoStack.Peek().FinishGroup);

                AfterAction.Fire(this, EventArgs.Empty);
                // AfterAction(false);
            }
            return(true);
        }
Esempio n. 2
0
            // コンストラクタ
            public ClickWindow(ScreenshotProvider sp, Rectangle virtualDisplayRectangle, AfterAction aa)
            {
                // 仕方ないね
                ScreenshotProvider = sp;
                vdr = virtualDisplayRectangle;
                // クリック完了時にGUIに反映するための細工
                this.aa = aa;
                // 表示用に仮想スクリーンのビットマップを生成する
                vdb = sp.getVirtualDisplayBitmap(vdr);
                // 画像を表示するためImageコントロールを用意する
                // (http://bacchus.ivory.ne.jp/gin/post-979/)
                var ScreenshotImage = new System.Windows.Controls.Image();
                var hbitmap         = vdb.GetHbitmap();

                ScreenshotImage.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                    hbitmap, IntPtr.Zero, Int32Rect.Empty,
                    System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
                NativeMethods.DeleteObject(hbitmap);
                ScreenshotImage.Height = vdr.Height;
                ScreenshotImage.Width  = vdr.Width;
                // Gridを作成し、Imageコントロールを乗せる
                var grid = new System.Windows.Controls.Grid();

                grid.Children.Add(ScreenshotImage);
                // ウィンドウについての設定を行う
                // 縁無しに設定する
                // (http://5000164.jp/2014-03-wpf_practice_1/)
                WindowStyle        = WindowStyle.None;
                AllowsTransparency = true;
                // 表示座標を決める
                Left   = virtualDisplayRectangle.Left;
                Top    = virtualDisplayRectangle.Top;
                Height = virtualDisplayRectangle.Height;
                Width  = virtualDisplayRectangle.Width;
                // コンテンツを設定する
                Content = grid;
                // イベントを設定する
                MouseDown += ClickWindow_Click;
                KeyDown   += ClickWindow_Key;
            }
Esempio n. 3
0
        public void FirePostActions(AbstractCommand command)
        {
            try
            {
                AfterAction?.Invoke(command);
            }
            catch (Exception exception)
            {
                throw new LifecycleActionFailedException($"Failed to invoke action after command ran successfully.", exception);
            }

            try
            {
                if (ShouldPingAfter)
                {
                    IO.Http.Get(PingAfterUrl);
                }
            }
            catch (Exception exception)
            {
                throw new LifecycleActionFailedException($"Ping failed for {PingAfterUrl} after command ran successfully.", exception);
            }

            var emailSubject  = $"Command completed: {command.Name}";
            var commandOutput = command.FlushBuffer();

            try
            {
                if (ShouldEmailOutput)
                {
                    new Mail()
                    {
                        Host     = MailSettings.Host,
                        Port     = MailSettings.Port,
                        Username = MailSettings.Username,
                        Password = MailSettings.Password,
                    }
                }
                .Send(MailSettings.From, EmailOutputToAddress, emailSubject, commandOutput);
            }