From: sukhyungkang <35091460+sukhyungkang@users.noreply.github.com> Date: Mon, 17 Apr 2023 07:55:47 +0000 (+0900) Subject: [Applications] Add Set/Get window position api for AppControl (#5084) X-Git-Tag: accepted/tizen/unified/20231205.024657~371 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e49da5585944e40e9bee4514a3ef7ae5057aeb3d;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Applications] Add Set/Get window position api for AppControl (#5084) Signed-off-by: SukhyungKang Co-authored-by: hjhun <36876573+hjhun@users.noreply.github.com> --- diff --git a/src/Tizen.Applications.Common/Interop/Interop.AppControl.cs b/src/Tizen.Applications.Common/Interop/Interop.AppControl.cs index 2ec3d9b..c0dbfaa 100755 --- a/src/Tizen.Applications.Common/Interop/Interop.AppControl.cs +++ b/src/Tizen.Applications.Common/Interop/Interop.AppControl.cs @@ -164,5 +164,10 @@ internal static partial class Interop [DllImport(Libraries.AppControl, EntryPoint = "app_control_foreach_default_application")] internal static extern ErrorCode ForeachDefaultApplication(DefaultApplicationCallback callback, IntPtr userData); + [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_window_position")] + internal static extern ErrorCode SetWindowPosition(SafeAppControlHandle handle, int x, int y, int w, int h); + + [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_window_position")] + internal static extern ErrorCode GetWindowPosition(SafeAppControlHandle handle, out int x, out int y, out int w, out int h); } } diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs index c134061..da9bbc2 100755 --- a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs @@ -985,6 +985,52 @@ namespace Tizen.Applications } /// + /// Sets the window position. + /// + /// The window position object. + /// Thrown when the argument is null. + /// Thrown when the argument is invalid. + /// Thrown when the invalid operation error occurs. + /// 11 + public void SetWindowPosition(WindowPosition windowPosition) + { + if (windowPosition == null) + { + throw new ArgumentNullException(nameof(windowPosition)); + } + + Interop.AppControl.ErrorCode err = Interop.AppControl.SetWindowPosition(this.SafeAppControlHandle, windowPosition.PositionX, windowPosition.PositionY, windowPosition.Width, windowPosition.Height); + if (err != Interop.AppControl.ErrorCode.None) + { + if (err == Interop.AppControl.ErrorCode.InvalidParameter) + { + throw new ArgumentException("Invalid arguments"); + } + else + { + throw new InvalidOperationException("err = " + err); + } + } + } + + /// + /// Gets the window position. + /// + /// The window position. + /// Thrown when the invalid operation error occurs. + /// 11 + public WindowPosition GetWindowPosition() + { + Interop.AppControl.ErrorCode err = Interop.AppControl.GetWindowPosition(this.SafeAppControlHandle, out int x, out int y, out int w, out int h); + if (err != Interop.AppControl.ErrorCode.None) + { + throw new InvalidOperationException("err = " + err); + } + + return new WindowPosition(x, y, w, h); + } + + /// /// Class for extra data. /// /// 3 diff --git a/src/Tizen.Applications.Common/Tizen.Applications/WindowPosition.cs b/src/Tizen.Applications.Common/Tizen.Applications/WindowPosition.cs new file mode 100755 index 0000000..be56e5f --- /dev/null +++ b/src/Tizen.Applications.Common/Tizen.Applications/WindowPosition.cs @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System.ComponentModel; + +namespace Tizen.Applications +{ + /// + /// Represents the window position of the application. + /// + /// 11 + public class WindowPosition + { + /// + /// Initializes the instance of the WindowPosition class. + /// + /// The X position. + /// The Y position. + /// The width. + /// The height. + /// 11 + public WindowPosition(int x, int y, int w, int h) + { + PositionX = x; + PositionY = y; + Width = w; + Height = h; + } + + /// + /// The X position. + /// + /// 11 + public int PositionX + { + set; + get; + } + + /// + /// The Y position. + /// + /// 11 + public int PositionY + { + set; + get; + } + + /// + /// The width. + /// + /// 11 + public int Width + { + set; + get; + } + + /// + /// The height. + /// + /// 11 + public int Height + { + set; + get; + } + } +}