Пример #1
0
		public Win32Cursor(int ident)
		{
			fIdentifier = ident;
			fHandle = Win32Cursor.LoadCursor(IntPtr.Zero, ident);
			fShowCount = 0;
			fWindow = null;
		}
Пример #2
0
 public ToolTipForm(IntPtr hwndParent)
 {
     InitializeComponent();
     _owner = new Win32Window(hwndParent);
     // _owner = new NativeWindow();
     // _owner.AssignHandle(hwndParent); (...with ReleaseHandle in Dispose)
     Debug.Print("Created ToolTipForm with parent " + hwndParent + " Owner Handle: " + (_owner == null ? "<NULL> " : _owner.Handle.ToString()) );
 }
Пример #3
0
		public Window(string title, int x, int y, int width, int height)
		{
            fWindowTitle = title;
            fWindowFrame = new Rectangle(x, y, width, height);
            fOrigin = new Point(0, 0);
            fDimension = new Size(width, height);
            fMouseCaptured = false;
			//this.Text = title;
			//this.Size = new Size(width, height);
			//this.Location = new Point(x, y);
            fBackgroundColor = RGBColor.LtGray;

		    fPlatformWindow = new Win32Window(title, x, y, width, height, this);
		}
        /// <summary>
        /// Forward アクション処理を行う。
        /// </summary>
        /// <param name="processWindow">VOICEROIDプロセスのメインウィンドウ。</param>
        private void DoForwardAction(Win32Window processWindow)
        {
            // VoiceroidUtilのメインウィンドウ作成
            var mainWinHandle =
                (HwndSource.FromVisual(this.Window) as HwndSource)?.Handle;
            if (!mainWinHandle.HasValue)
            {
                return;
            }
            var mainWin = new Win32Window(mainWinHandle.Value);

            // 最小化されていたら元に戻す
            if (processWindow.State == WindowState.Minimized)
            {
                processWindow.Restore();
            }

            // VoiceroidUtilが最前面表示されているか?
            if (mainWin.IsTopmost)
            {
                // アクティブにして非最前面ウィンドウ内の先頭へ
                try
                {
                    processWindow.Activate();
                }
                catch (Exception ex)
                {
                    ThreadTrace.WriteException(ex);
                }
            }
            else
            {
                // VoiceroidUtilのすぐ後ろにZオーダーを設定
                try
                {
                    processWindow.MoveZOrderAfter(mainWin);
                }
                catch (Exception ex)
                {
                    ThreadTrace.WriteException(ex);
                }
            }
        }
Пример #5
0
        int _topOffset; // Might be trying to move the tooltip out of the way of Excel's tip - we track this extra offset here

        #endregion Fields

        #region Constructors

        public ToolTipForm(IntPtr hwndOwner)
        {
            Debug.Assert(hwndOwner != IntPtr.Zero);
            InitializeComponent();
            _owner = new Win32Window(hwndOwner);
            // CONSIDER: Maybe make a more general solution that lazy-loads as needed
            _fonts = new Dictionary<FontStyle, Font>
            {
                { FontStyle.Regular, new Font("Segoe UI", 9, FontStyle.Regular) },
                { FontStyle.Bold, new Font("Segoe UI", 9, FontStyle.Bold) },
                { FontStyle.Italic, new Font("Segoe UI", 9, FontStyle.Italic) },
                { FontStyle.Underline, new Font("Segoe UI", 9, FontStyle.Underline) },
                { FontStyle.Bold | FontStyle.Italic, new Font("Segoe UI", 9, FontStyle.Bold | FontStyle.Italic) },

            };
            //_textBrush = new SolidBrush(Color.FromArgb(68, 68, 68));  // Best matches Excel's built-in color, but I think a bit too light
            _textBrush = new SolidBrush(Color.FromArgb(52, 52, 52));
            _linkBrush = new SolidBrush(Color.Blue);
            _borderPen = new Pen(Color.FromArgb(195, 195, 195));
            _borderLightPen = new Pen(Color.FromArgb(225, 225, 225));
            SetStyle(ControlStyles.UserMouse | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            Debug.Print($"Created ToolTipForm with owner {hwndOwner}");
        }
 public static void SetDropDownWidth(this ComboBox combo, int value)
 {
     Win32Window.SendMessage(combo.Handle, (int)CB.SETDROPPEDWIDTH, value, 0);
 }
Пример #7
0
 public RoleElevationDialogWrapper(Win32Window window)
     : base(window)
 {
 }
Пример #8
0
 public void Start()
 {
     Stop();
     checkWorkingAreaThread = new Thread(() =>
     {
         SystemInterop.RECT rect = WorkAreaManager.GetWorkingArea();
         while (true)
         {
             var newRect = WorkAreaManager.GetWorkingArea();
             if (rect.Bottom != newRect.Bottom ||
                 rect.Top != newRect.Top ||
                 rect.Left != newRect.Left ||
                 rect.Right != newRect.Right)
             {
                 if (WorkingAreaChanged != null)
                 {
                     WorkingAreaChanged(this, new EventArgs());
                 }
                 rect = newRect;
             }
             Thread.Sleep(100); // ~10ips
         }
     });
     checkWorkingAreaThread.Start();
     checkWindowsThread = new Thread(() =>
     {
         while (true)
         {
             // Check windows list
             int windowCount = 0;
             WindowInterop.EnumWindows((h, p) =>
             {
                 if (isTaskBarWindow(h))
                 {
                     windowCount++;
                 }
                 return(true);
             }, 0);
             if (windowCount != Windows.Count && WindowListChanged != null)
             {
                 WindowListChanged(this, new EventArgs());
             }
             // Check active window
             IntPtr activeHwnd = WindowInterop.GetForegroundWindow();
             var activeWindow  = new Win32Window(activeHwnd);
             var isDock        = activeWindow.FileName == Process.GetCurrentProcess().MainModule.FileName;
             if (ActiveWindow != activeHwnd && ActiveWindowChanged != null && !isDock)
             {
                 ActiveWindowChanged(activeHwnd, new EventArgs());
             }
             // Check active window location
             if (activeHwnd != IntPtr.Zero && !isDock)
             {
                 WindowInterop.Rect windowRect = new WindowInterop.Rect();
                 WindowInterop.GetWindowRect(activeHwnd, ref windowRect);
                 if (windowRect != ActiveWindowRect && ActiveWindowRectChanged != null)
                 {
                     ActiveWindowRectChanged(this, new WindowRectEventArgs(ActiveWindowRect = windowRect));
                 }
             }
             Thread.Sleep(50); // ~20ips
         }
     });
     checkWindowsThread.Start();
 }
Пример #9
0
 public NewTagDialogWrapper(Win32Window window)
     : base(window)
 {
 }
 protected BaseRuleAction(Win32Window target, WindowManager windowManager)
 {
     this.Target        = target;
     this.WindowManager = windowManager;
 }
Пример #11
0
        /// <summary>
        /// Clears the contents of the InkX control.
        /// </summary>
        public void Clear()
        {
#if !DESIGN
            Win32Window.SendMessage(ChildHandle, (int)InkXMessage.ClearAll, 0, 0);
#endif
        }
Пример #12
0
        public static IUIItem GetControl(AppProcess process, MappedItem window, MappedItem control, AppManager appManager)
        {
            Process wProcess = Process.GetProcessesByName(process.Name).First();
            Application application = Application.Attach(wProcess);

            Window appWindow = null;

            if (control.Type == "pane")
            {

            }

            /*IEnumerable<string> enumerable = application.GetWindows().Select(w => w.Title);
            IEnumerable<string> list2 = application.GetWindows().Select(w => w.AutomationElement.Current.Name);
            */
            List<string> windowTitles2 = GetWindowsForProcess(process.Name);

            if (!window.Name.IsNullOrEmpty())
                appWindow = application.GetWindow(SearchCriteria.ByAutomationId(window.Name), InitializeOption.NoCache);
            else
            {
                for (int i = 0; i < 5; i++)
                {
                    List<string> windowTitles = GetWindowsForProcess(process.Name);
                    string windowName = window.Text;
                    string closestTitle = windowTitles[0];
                    decimal toleranceLevel = windowName.Length * 0.7m;

                    foreach (string windowTitle in windowTitles)
                    {
                        int num1 = LevenshteinDistance.GetToleranceLevel(windowTitle, windowName);
                        if (num1 < toleranceLevel)
                        {
                            toleranceLevel = num1;
                            closestTitle = windowTitle;
                        }
                    }

                    try
                    {
                        List<Window> windows = application.GetWindows();

                        appWindow = application.GetWindows().FirstOrDefault(w => w.AutomationElement.Current.Name.Equals(closestTitle));

                        if (appWindow == null)
                        {
                            List<IntPtr> handles = EnumerateProcessWindowHandles(wProcess.Id).ToList();

                            Dictionary<string, IntPtr> windowHandleDict = new Dictionary<string, IntPtr>();

                            StringBuilder builder = new StringBuilder(1024);

                            foreach (IntPtr myIntPtr in handles)
                            {
                                GetWindowText(myIntPtr, builder, 1024);

                                string windowTitle = builder.ToString();
                                windowHandleDict[windowTitle] = myIntPtr;
                            }

                            AutomationElement element = AutomationElement.FromHandle(windowHandleDict[closestTitle]);

                            appWindow = new Win32Window(element, WindowFactory.Desktop, InitializeOption.NoCache,
                                new NullWindowSession());
                        }

                        break;
                    }
                    catch (Exception ex)
                    {

                    }

                }
            }

            BringWindowToFront(appWindow.AutomationElement.Current.NativeWindowHandle);

            if (control == null || control.Type == "window" || control.Equals(window))
                return appWindow;

            Stack<MappedItem> mappedItemTree = new Stack<MappedItem>();
            MappedItem currentMappedItem = control;

            if (window == null)
            {

            }

            while (currentMappedItem != window)
            {
                mappedItemTree.Push(currentMappedItem);
                currentMappedItem = appManager.GetMappedItem(currentMappedItem.ParentId);
            }

            IUIItem currentControl = appWindow;
            AutomationElement elemn;

            while (mappedItemTree.Count > 0)
            {
                MappedItem currentMappedItemControl = mappedItemTree.Pop();

                if (!currentMappedItemControl.Name.IsNullOrEmpty())
                {
                    AutomationElement element = currentControl.AutomationElement.FindFirst(TreeScope.Descendants,
                        new PropertyCondition(AutomationElement.AutomationIdProperty, currentMappedItemControl.Name));

                    //AutomationElement element = currentControl.GetElement(SearchCriteria.ByAutomationId(currentMappedItemControl.Name));

                    currentControl = new UIItem(element, new NullActionListener());

                    continue;
                }

                if (!string.IsNullOrEmpty(currentMappedItemControl.Text))
                {
                    currentControl = new UIItem(currentControl.GetElement(SearchCriteria.ByText(currentMappedItemControl.Text)),
                        new NullActionListener());

                    continue;
                }

            }

            return currentControl;
        }
Пример #13
0
        /// <summary>
        /// ファイルドロップ処理を行う。
        /// </summary>
        /// <param name="ownWindowHandle">
        /// WM_COPYDATA メッセージ送信元ウィンドウハンドル。
        /// </param>
        /// <param name="filePathes">ファイルパス列挙。</param>
        /// <param name="stepFrameCount">ドロップ後に進めるフレーム数。</param>
        /// <param name="layer">レイヤー位置指定。既定位置にするならば 0 。</param>
        /// <param name="timeoutMilliseconds">
        /// タイムアウトミリ秒数。負数ならばタイムアウトしない。
        /// </param>
        /// <returns>処理結果。</returns>
        public static Result Run(
            IntPtr ownWindowHandle,
            IEnumerable <string> filePathes,
            int stepFrameCount      = 0,
            int layer               = 0,
            int timeoutMilliseconds = -1)
        {
            ValidateArguments(filePathes, stepFrameCount, layer);

            // 処理対象ウィンドウ取得
            var result = ReadTargetWindow(out var targetWindow);

            if (result != Result.Success)
            {
                return(result);
            }

            // 拡張編集ウィンドウが表示されていないと失敗するので確認
            var aviUtlWindowHandle = targetWindow.GetOwner()?.Handle;

            if (!aviUtlWindowHandle.HasValue)
            {
                return(Result.ExEditWindowNotFound);
            }
            var exEditWindow =
                Win32Window.FromDesktop()
                .FindChildren()
                .FirstOrDefault(
                    win =>
                    win.GetOwner()?.Handle == aviUtlWindowHandle.Value &&
                    win
                    .GetText(timeoutMilliseconds)?
                    .StartsWith(ExEditWindowTitlePrefix) == true);

            if (exEditWindow == null || !exEditWindow.IsExists)
            {
                return(Result.ExEditWindowNotFound);
            }
            if (!exEditWindow.IsVisible)
            {
                return(Result.ExEditWindowInvisible);
            }

            var dataPtr   = IntPtr.Zero;
            var lParamPtr = IntPtr.Zero;

            try
            {
                // 送信文字列作成
                var data =
                    ((layer == 0) ? DefaultLayerPosition : layer) + "\0" +
                    stepFrameCount + "\0" +
                    string.Join("\0", filePathes) + "\0";
                dataPtr = Marshal.StringToHGlobalUni(data);

                // LPARAM 作成
                COPYDATASTRUCT lParam;
                lParam.Param       = UIntPtr.Zero;
                lParam.DataSize    = data.Length * 2;
                lParam.DataAddress = dataPtr;
                lParamPtr          = Marshal.AllocHGlobal(Marshal.SizeOf(lParam));
                Marshal.StructureToPtr(lParam, lParamPtr, false);

                // WM_COPYDATA メッセージ送信
                var msgRes =
                    targetWindow.SendMessage(
                        WM_COPYDATA,
                        ownWindowHandle,
                        lParamPtr,
                        timeoutMilliseconds);
                if (!msgRes.HasValue)
                {
                    return(Result.MessageTimeout);
                }
            }
            catch (Exception ex)
            {
                ThreadTrace.WriteException(ex);
                return(Result.MessageFail);
            }
            finally
            {
                if (lParamPtr != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(lParamPtr);
                }
                if (dataPtr != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(dataPtr);
                }
            }

            return(Result.Success);
        }
Пример #14
0
        /// <summary>
        /// 『ごちゃまぜドロップス』から対象ウィンドウハンドルを読み取る。
        /// </summary>
        /// <param name="dest">対象ウィンドウハンドルの設定先。</param>
        /// <returns>処理結果。</returns>
        private static Result ReadTargetWindow(out Win32Window dest)
        {
            dest = null;

            switch (GcmzInfoReader.Read(out var info))
            {
Пример #15
0
 public DRFailoverWizardWrapper(Win32Window window)
     : base(window)
 {
 }
Пример #16
0
        int NativeInterfaces.IFileDialogEvents.OnFileOk(NativeInterfaces.IFileDialog pfd)
        {
            int hr = NativeConstants.S_OK;

            NativeInterfaces.IShellItem shellItem = null;

            if (NativeMethods.SUCCEEDED(hr))
            {
                hr = FileSaveDialog.GetResult(out shellItem);
            }

            if (!NativeMethods.SUCCEEDED(hr))
            {
                throw Marshal.GetExceptionForHR(hr);
            }

            string pathName = null;

            try
            {
                shellItem.GetDisplayName(NativeConstants.SIGDN.SIGDN_FILESYSPATH, out pathName);
            }

            finally
            {
                if (shellItem != null)
                {
                    try
                    {
                        Marshal.ReleaseComObject(shellItem);
                    }

                    catch (Exception)
                    {
                    }

                    shellItem = null;
                }
            }

            string pathNameResolved = ResolveName(pathName);

            NativeInterfaces.IOleWindow oleWindow = (NativeInterfaces.IOleWindow)pfd;

            try
            {
                IntPtr hWnd = IntPtr.Zero;
                oleWindow.GetWindow(out hWnd);
                Win32Window win32Window = new Win32Window(hWnd, oleWindow);

                // File name/path validation
                if (hr >= 0)
                {
                    try
                    {
                        // Verify that these can be parsed correctly
                        string fileName = Path.GetFileName(pathNameResolved);
                        string dirName  = Path.GetDirectoryName(pathNameResolved);
                    }

                    catch (Exception ex)
                    {
                        if (!FileDialogUICallbacks.ShowError(win32Window, pathNameResolved, ex))
                        {
                            throw;
                        }

                        hr = NativeConstants.S_FALSE;
                    }
                }

                if (hr >= 0)
                {
                    // Overwrite existing file
                    if (!OverwritePrompt)
                    {
                        hr = NativeConstants.S_OK;
                    }
                    else if (File.Exists(pathNameResolved))
                    {
                        FileOverwriteAction action = FileDialogUICallbacks.ShowOverwritePrompt(win32Window, pathNameResolved);

                        switch (action)
                        {
                        case FileOverwriteAction.Cancel:
                            hr = NativeConstants.S_FALSE;
                            break;

                        case FileOverwriteAction.Overwrite:
                            hr = NativeConstants.S_OK;
                            break;

                        default:
                            throw new InvalidEnumArgumentException();
                        }
                    }
                }
            }

            catch (Exception)
            {
            }

            finally
            {
                try
                {
                    Marshal.ReleaseComObject(oleWindow);
                }

                catch (Exception)
                {
                }

                oleWindow = null;
            }

            return(hr);
        }
 public void TestNullFromIntPtrZero()
 {
     Assert.IsNull(Win32Window.FromHandle(IntPtr.Zero));
 }
Пример #18
0
 public WindowItem(HWND hwnd)
 {
     _window = new Win32Window(hwnd);
     _window.CustomErrorHandler = OnError;
 }
Пример #19
0
        /// <summary>
        /// Stops the currently playing audio (if applicable).
        /// </summary>
        public void Stop()
        {
#if !DESIGN
            Win32Window.SendMessage(ChildHandle, (int)InkXMessage.VoiceStop, 0, 0);
#endif
        }
Пример #20
0
        int NativeInterfaces.IFileDialogEvents.OnFileOk(NativeInterfaces.IFileDialog pfd)
        {
            int hr = NativeConstants.S_OK;

            FileOpenDialog.GetResults(out NativeInterfaces.IShellItemArray results);

            results.GetCount(out uint count);

            List <NativeInterfaces.IShellItem> items         = new List <NativeInterfaces.IShellItem>();
            List <NativeInterfaces.IShellItem> needLocalCopy = new List <NativeInterfaces.IShellItem>();
            List <NativeInterfaces.IShellItem> cannotCopy    = new List <NativeInterfaces.IShellItem>();
            List <string> localPathNames = new List <string>();

            for (uint i = 0; i < count; ++i)
            {
                results.GetItemAt(i, out NativeInterfaces.IShellItem item);
                items.Add(item);
            }

            foreach (NativeInterfaces.IShellItem item in items)
            {
                // If it's a file system object, nothing special needs to be done.
                item.GetAttributes((NativeConstants.SFGAO) 0xffffffff, out NativeConstants.SFGAO sfgaoAttribs);

                if ((sfgaoAttribs & NativeConstants.SFGAO.SFGAO_FILESYSTEM) == NativeConstants.SFGAO.SFGAO_FILESYSTEM)
                {
                    item.GetDisplayName(NativeConstants.SIGDN.SIGDN_FILESYSPATH, out string pathName);

                    localPathNames.Add(pathName);
                }
                else if ((sfgaoAttribs & NativeConstants.SFGAO.SFGAO_STREAM) == NativeConstants.SFGAO.SFGAO_STREAM)
                {
                    needLocalCopy.Add(item);
                }
                else
                {
                    cannotCopy.Add(item);
                }
            }

            Marshal.ReleaseComObject(results);
            results = null;

            if (needLocalCopy.Count > 0)
            {
                IntPtr hwnd = IntPtr.Zero;
                NativeInterfaces.IOleWindow oleWindow = (NativeInterfaces.IOleWindow)pfd;
                oleWindow.GetWindow(out hwnd);
                Win32Window win32Window = new Win32Window(hwnd, oleWindow);

                IFileTransferProgressEvents progressEvents = this.FileDialogUICallbacks.CreateFileTransferProgressEvents();

                void copyThreadProc()
                {
                    try
                    {
                        progressEvents.SetItemCount(needLocalCopy.Count);

                        for (int i = 0; i < needLocalCopy.Count; ++i)
                        {
                            NativeInterfaces.IShellItem item = needLocalCopy[i];

                            progressEvents.SetItemOrdinal(i);
                            CopyResult result = CreateLocalCopy(item, progressEvents, out string pathName);

                            if (result == CopyResult.Success)
                            {
                                localPathNames.Add(pathName);
                            }
                            else if (result == CopyResult.Skipped)
                            {
                                // do nothing
                            }
                            else if (result == CopyResult.CancelOperation)
                            {
                                hr = NativeConstants.S_FALSE;
                                break;
                            }
                            else
                            {
                                throw new InvalidEnumArgumentException();
                            }
                        }
                    }

                    finally
                    {
                        OperationResult result;

                        if (hr == NativeConstants.S_OK)
                        {
                            result = OperationResult.Finished;
                        }
                        else
                        {
                            result = OperationResult.Canceled;
                        }

                        progressEvents.EndOperation(result);
                    }
                }

                Thread copyThread = new Thread(copyThreadProc);
                copyThread.SetApartmentState(ApartmentState.STA);

                void OnUIShown(object sender, EventArgs e)
                {
                    copyThread.Start();
                }

                this.cancelSink = new CancelableTearOff();
                progressEvents.BeginOperation(win32Window, OnUIShown, cancelSink);
                this.cancelSink = null;
                copyThread.Join();

                Marshal.ReleaseComObject(oleWindow);
                oleWindow = null;
            }

            this.FileNames = localPathNames.ToArray();

            // If they selected a bunch of files, and then they all errored or something, then don't proceed.
            if (this.FileNames.Length == 0)
            {
                hr = NativeConstants.S_FALSE;
            }

            foreach (NativeInterfaces.IShellItem item in items)
            {
                Marshal.ReleaseComObject(item);
            }

            items.Clear();
            items = null;

            GC.KeepAlive(pfd);
            return(hr);
        }
Пример #21
0
 public NewNetworkWizardWrapper(Win32Window window)
     : base(window)
 {
 }
Пример #22
0
 public OptionsDialogWrapper(Win32Window window)
     : base(window)
 {
 }
 static void processLogic_OnWindowDestroyed(Win32Window window)
 {
     WindowManager.Instance.WindowDestroyed(window);
 }
 public static void SetDroppedDown(this ComboBox combo, bool value)
 {
     Win32Window.SendMessage(combo.Handle, (int)CB.SHOWDROPDOWN, value ? 1 : 0, 0);
 }
Пример #25
0
 public WindowCustomizer(IntPtr hWnd)
 {
     w32wnd = new Win32Window(hWnd);
 }
Пример #26
0
            /// <summary>
            /// メインウィンドウのコントロール群を更新する。
            /// </summary>
            /// <returns>成功したならば true 。そうでなければ false 。</returns>
            private bool UpdateControls()
            {
                List <Win32Window> controls = null;
                Win32Window        talkEdit = null;

                Win32Window[] buttons = null;

                // 子コントロール群取得
                try
                {
                    var mainWin = new Win32Window(this.MainWindowHandle);
                    controls = mainWin.FindDescendants();
                }
                catch (Exception ex)
                {
                    ThreadTrace.WriteException(ex);
                    return(false);
                }
                if (controls == null)
                {
                    // ちょうどアプリ終了したタイミング等で null になりうる
                    return(false);
                }

                // トークテキスト入力欄取得
                try
                {
                    talkEdit =
                        controls.FirstOrDefault(c => c.ClassName.Contains("RichEdit"));
                }
                catch (Exception ex)
                {
                    ThreadTrace.WriteException(ex);
                    return(false);
                }
                if (talkEdit == null)
                {
                    return(false);
                }

                // ボタン群ハンドル取得
                try
                {
                    buttons =
                        controls
                        .Where(c => c.ClassName.Contains("BUTTON"))
                        .Take(3)
                        .ToArray();
                }
                catch (Exception ex)
                {
                    ThreadTrace.WriteException(ex);
                    return(false);
                }
                if (buttons.Length < 3)
                {
                    return(false);
                }

                this.TalkEdit   = talkEdit;
                this.PlayButton = buttons[0];
                this.StopButton = buttons[1];
                this.SaveButton = buttons[2];

                return(true);
            }
Пример #27
0
        /// <summary>
        /// Method.
        /// </summary>
        /// <param name=""></param>
        /// <returns>Makes the Window into a dockable window</returns>
        public void MakeDockable()
        {
            Win32Window window = new Win32Window(_windowID);

            switch (Type)
            {
                case WindowType.Browser:
                    _dockableWindow = new DockableWindowForm(window);
                    break;
                case WindowType.CartographicLegend:
                    _dockableWindow = new DockableWindowForm(window);
                    break;
                case WindowType.LegendDesigner:
                    _dockableWindow = new DockableWindowForm(window);
                    break;
                case WindowType.Graph:
                    _dockableWindow = new DockableWindowForm(window);
                    break;
                case WindowType.Layout:
                    _dockableWindow = new DockableWindowForm(window);
                    break;
                case WindowType.Mapper:
                    _dockableWindow = new DockableWindowForm(window);
                    break;
                case WindowType.Mapper3D:
                    _dockableWindow = new DockableWindowForm(window);
                    break;

                default:
                    _dockableWindow = new DockableWindowForm(window, window.Title);
                    break;
            }
        }
Пример #28
0
            public void ShowAnimateNode()
            {
                //FIXME make this test automatable

                Application.IsRunningInUnitTest = true;
                Application.InitSysDependencies();

                MeshBuffer meshBuffer = new MeshBuffer();
                MeshList   meshList   = new MeshList();

                var primitiveRenderer = new BuiltinGeometryRenderer();

                Node node = new Node(1);

                node.Geometry = new PathGeometry();

                var window = new Win32Window();

                window.Init(new Point(100, 100), new Size(800, 600), WindowTypes.Regular);

                var renderer = new Win32OpenGLRenderer();

                renderer.Init(window.Pointer, window.ClientSize);

                window.Show();

                var A = new Point(200, 200);
                var B = new Point(600, 200);
                var C = new Point(400, 400);

                while (true)
                {
                    Time.OnFrameBegin();
                    Keyboard.Instance.OnFrameBegin();

                    window.MainLoop(() =>
                    {
                        if (Keyboard.Instance.KeyDown(Key.Escape))
                        {
                            Application.Quit();
                        }

                        var normal = (Time.time % 1000) / 1000f * 2 - 1;
                        var rad    = normal * Math.PI;
                        var A_     = A + 50 * new Vector(Math.Cos(rad) - Math.Sin(rad), Math.Sin(rad) + Math.Cos(rad));
                        rad       += Math.PI * 0.333;
                        var B_     = B + 30 * new Vector(Math.Cos(rad) - Math.Sin(rad), Math.Sin(rad) + Math.Cos(rad));
                        rad       += Math.PI * 0.666;
                        var C_     = C + 70 * new Vector(Math.Cos(rad) - Math.Sin(rad), Math.Sin(rad) + Math.Cos(rad));

                        var d = node.Geometry as PathGeometry;
                        d.PathClear();
                        d.PathMoveTo(A_);
                        d.PathLineTo(B_);
                        d.PathLineTo(C_);
                        d.PathStroke(2, Color.Blue);

                        //update nodes
                        if (node.ActiveInTree)//this is actually always true
                        {
                            node.Draw(primitiveRenderer, meshList);
                        }

                        //rebuild mesh buffer
                        meshBuffer.Clear();
                        meshBuffer.Init();
                        meshBuffer.Build(meshList);

                        //draw mesh buffer to screen
                        renderer.Clear(Color.FrameBg);
                        renderer.DrawMeshes((int)window.ClientSize.Width, (int)window.ClientSize.Height,
                                            (shapeMesh: meshBuffer.ShapeMesh, imageMesh: meshBuffer.ImageMesh, meshBuffer.TextMesh));
                        renderer.SwapBuffers();
                    });

                    if (Application.RequestQuit)
                    {
                        break;
                    }

                    Keyboard.Instance.OnFrameEnd();
                    Time.OnFrameEnd();
                }
            }
Пример #29
0
 /// <summary>
 /// StopFlash アクション処理を行う。
 /// </summary>
 /// <param name="processWindow">VOICEROIDプロセスのメインウィンドウ。</param>
 private void DoStopFlashAction(Win32Window processWindow) =>
     processWindow.FlashTray(false);
 public static bool GetDroppedDown(this ComboBox combo)
 {
     return(Win32Window.SendMessage(combo.Handle, (int)CB.GETDROPPEDSTATE, 0, 0) != IntPtr.Zero);
 }
Пример #31
0
        /// <summary>
        /// ファイルドロップ処理を行う。
        /// </summary>
        /// <param name="ownWindowHandle">
        /// WM_COPYDATA メッセージ送信元ウィンドウハンドル。
        /// </param>
        /// <param name="filePathes">ファイルパス列挙。</param>
        /// <param name="stepFrameCount">ドロップ後に進めるフレーム数。</param>
        /// <param name="layer">レイヤー位置指定。既定位置にするならば 0 。</param>
        /// <param name="timeoutMilliseconds">
        /// タイムアウトミリ秒数。負数ならばタイムアウトしない。
        /// </param>
        /// <returns>処理結果。</returns>
        public static Result Run(
            IntPtr ownWindowHandle,
            IEnumerable <string> filePathes,
            int stepFrameCount      = 0,
            int layer               = 0,
            int timeoutMilliseconds = -1)
        {
            ValidateArguments(filePathes, stepFrameCount, layer);

            // 処理対象ウィンドウ取得
            var result = ReadTargetWindow(out var targetWindow);

            if (result != Result.Success)
            {
                return(result);
            }

            // 拡張編集ウィンドウが表示されていないと失敗するので確認
            var aviUtlWindowHandle = targetWindow.GetOwner()?.Handle;

            if (!aviUtlWindowHandle.HasValue)
            {
                return(Result.ExEditWindowNotFound);
            }
            var exEditWindow =
                Win32Window.FromDesktop()
                .FindChildren()
                .FirstOrDefault(
                    win =>
                    win.GetOwner()?.Handle == aviUtlWindowHandle.Value &&
                    win
                    .GetText(timeoutMilliseconds)?
                    .StartsWith(ExEditWindowTitlePrefix) == true);

            if (exEditWindow == null || !exEditWindow.IsExists)
            {
                return(Result.ExEditWindowNotFound);
            }
            if (!exEditWindow.IsVisible)
            {
                return(Result.ExEditWindowInvisible);
            }

            // 『ごちゃまぜドロップス』 v0.3.12 以降であればミューテクスによる排他制御が可能
            Mutex mutex;

            try
            {
                // 開けなければ mutex は null
                Mutex.TryOpenExisting(GcmzMutexName, out mutex);
            }
            catch (Exception ex)
            {
                ThreadTrace.WriteException(ex);
                return(Result.MutexOpenFail);
            }

            var  data        = new COPYDATASTRUCT();
            var  lParam      = IntPtr.Zero;
            bool mutexLocked = false;

            try
            {
                // COPYDATASTRUCT 作成
                // 『ごちゃまぜドロップス』 v0.3.11 以前なら旧フォーマットを使う
                var gcmzLayer = (layer == 0) ? -MinLayer : layer;
                data =
                    (mutex == null) ?
                    CreateCopyDataStructLegacy(gcmzLayer, stepFrameCount, filePathes) :
                    CreateCopyDataStruct(gcmzLayer, stepFrameCount, filePathes);

                // LPARAM 値作成
                lParam = Marshal.AllocHGlobal(Marshal.SizeOf(data));
                Marshal.StructureToPtr(data, lParam, false);

                // ミューテクスが有効なら排他制御開始
                if (mutex != null)
                {
                    try
                    {
                        if (!mutex.WaitOne((timeoutMilliseconds < 0) ? -1 : timeoutMilliseconds))
                        {
                            return(Result.MutexLockTimeout);
                        }
                        mutexLocked = true;
                    }
                    catch (Exception ex)
                    {
                        ThreadTrace.WriteException(ex);
                        return(Result.MutexLockFail);
                    }
                }

                // WM_COPYDATA メッセージ送信
                var msgRes =
                    targetWindow.SendMessage(
                        WM_COPYDATA,
                        ownWindowHandle,
                        lParam,
                        timeoutMilliseconds);
                if (!msgRes.HasValue)
                {
                    return(Result.MessageTimeout);
                }
            }
            catch (Exception ex)
            {
                ThreadTrace.WriteException(ex);
                return(Result.MessageFail);
            }
            finally
            {
                if (mutex != null)
                {
                    if (mutexLocked)
                    {
                        mutex.ReleaseMutex();
                    }
                    mutex.Dispose();
                }
                if (lParam != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(lParam);
                }
                if (data.DataAddress != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(data.DataAddress);
                }
            }

            return(Result.Success);
        }
Пример #32
0
 public IEnumerable <IInternalWindow> GetWindowsSync()
 {
     return(Win32Window.GetOpenWindows().Values.OrderBy((window) => window.Handle.ToInt64()));
 }
 public static int GetDropDownWidth(this ComboBox combo)
 {
     return((int)Win32Window.SendMessage(combo.Handle, (int)CB.GETDROPPEDWIDTH, 0, 0));
 }
Пример #34
0
 /// <summary>
 /// StopFlash アクション処理を行う。
 /// </summary>
 /// <param name="processWindow">VOICEROIDプロセスのメインウィンドウ。</param>
 private void DoStopFlashAction(Win32Window processWindow) =>
 processWindow.FlashTray(false);
 public CommandErrorDialogWrapper(Win32Window window)
     : base(window)
 {
 }
Пример #36
0
        public async Task Run(IProcess process, VoiceroidAction action)
        {
            if (process == null)
            {
                throw new ArgumentNullException(nameof(process));
            }
            if (
                process.MainWindowHandle == IntPtr.Zero ||
                action == VoiceroidAction.None)
            {
                return;
            }

            // VOICEROIDのメインウィンドウ作成
            var processWin = new Win32Window(process.MainWindowHandle);

            // アクション別メソッド作成
            Action method = null;
            switch (action)
            {
            case VoiceroidAction.Forward:
                method = () => this.DoForwardAction(processWin);
                break;

            case VoiceroidAction.StopFlash:
                method = () => this.DoStopFlashAction(processWin);
                break;

            default:
                return;
            }

            // メソッド実施
            await this.Window.Dispatcher.InvokeAsync(method);
        }
Пример #37
0
        void OnToolbarEvent(object sender, AppBarEventArgs e)
        {
            Debug.Print("OnToolbarEvent - Action: {0}, Data: {1}, ReserveScreen: {2}, Win32Window.IsFullScreen {3}", e.Action, e.Data, ReserveScreen, Win32Window.IsFullScreen());

            switch (e.Action)
            {
            case AppBarNotificationAction.FullScreenApp:
                IsFullScreenAppOpen = (bool)e.Data;

                if (IsFullScreenAppOpen && ReserveScreen)
                {
                    //Topmost = false;
                    //Win32Window.SetWindowPos(Handle, (IntPtr)HWND.BOTTOM, 0, 0, 0, 0, SWP.NOMOVE | SWP.NOSIZE | SWP.NOACTIVATE);
                }
                else if (!IsFullScreenAppOpen && ReserveScreen)
                {
                    //Topmost = true;
                    //Win32Window.SetWindowPos(Handle, (IntPtr)HWND.NOTOPMOST, 0, 0, 0, 0, SWP.NOMOVE | SWP.NOSIZE | SWP.NOACTIVATE | SWP.FRAMECHANGED);
                }
                AppBarEvent(this, e);
                break;

            default:
                AppBarEvent(this, e);
                break;
            }
        }