示例#1
0
        /// レイアウト要素のBoundRelative領域の変更を試みる
        /// @param layoutElement レイアウト要素
        /// @param target 変更箇所
        /// @param value 変更値
        /// @param[out] changed 変更後、制約を満たす形に訂正されたBoundRelative領域
        /// @return 試行結果(訂正箇所)
        public static TryResult TryChange(
            LayoutElement layoutElement, Names target, double value,
            out RelativeLTRB changed)
        {
            // 準備
            var original = BoundRelativeInputCorrector.GetOriginal(layoutElement);

            // 訂正
            switch (target)
            {
            case Names.Left:
            case Names.Top: {
                return(BoundRelativeInputCorrector.TryChangeLow(original, target, value,
                                                                Constants.MinimumBoundRelativeSize, out changed));
            }

            case Names.Right:
            case Names.Bottom: {
                return(BoundRelativeInputCorrector.TryChangeHigh(original, target, value,
                                                                 Constants.MinimumBoundRelativeSize, out changed));
            }

            default: Debug.Fail("switch"); throw new System.ArgumentException();
            }
        }
示例#2
0
        //===================================================================
        // ファイル入力
        //===================================================================

        /// ファイル入力
        /// @param[in] path ファイルパス
        /// @return 正常終了
        /// @warning 継承クラスでのreturn falseは禁止
        public override bool ReadFile(string path)
        {
            // ファイル->ディクショナリ
            if (!base.ReadFile(path))
            {
                return(false);
            }

            // 使いまわすので注意
            int    intValue;
            double doubleValue;
            float  floatValue;
            bool   boolValue;

            // Dictionaryを調べながら値を設定する
            var           layoutElements     = new List <LayoutElement>();
            int           layoutElementCount = 0;
            int           currentIndex       = 0;
            LayoutElement current            = null;

            if (this.TryGetInt("LayoutElementCount", out intValue))
            {
                // 範囲チェック
                if (intValue < 1)
                {
                    intValue = 1;
                }
                if (Interprocess.MaxComplexLayoutElements < intValue)
                {
                    intValue = Interprocess.MaxComplexLayoutElements;
                }
                layoutElementCount = intValue;
            }

            if (this.TryGetInt("CurrentIndex", out intValue))
            {
                // 範囲チェック
                if (intValue < 0)
                {
                    intValue = 0;
                }
                if (layoutElementCount - 1 < intValue)
                {
                    intValue = layoutElementCount - 1;
                }
                currentIndex = intValue;
            }

            for (int index = 0; index < layoutElementCount; ++index)
            {
                var layoutElement = new LayoutElement(index);

                // TargetWindow
                WindowTypes windowTypes;
                if (this.TryGetWindowTypes("WindowType" + index, out windowTypes))
                {
                    switch (windowTypes)
                    {
                    case WindowTypes.Normal: {
                        UIntPtr uintptrValue;
                        if (this.TryGetUIntPtr("Window" + index, out uintptrValue))
                        {
                            layoutElement.SetWindow(uintptrValue);
                        }
                        break;
                    }

                    case WindowTypes.DXGI: {
                        layoutElement.SetWindowToDXGI();
                        break;
                    }

                    case WindowTypes.Desktop: {
                        layoutElement.SetWindowToDesktop();
                        break;
                    }
                    }
                }

                // Area
                if (this.TryGetBool("Fit" + index, out boolValue))
                {
                    layoutElement.Fit = boolValue;
                }
                if (this.TryGetInt("ClippingXWithoutFit" + index, out intValue))
                {
                    layoutElement.ClippingXWithoutFit = intValue;
                }
                if (this.TryGetInt("ClippingYWithoutFit" + index, out intValue))
                {
                    layoutElement.ClippingYWithoutFit = intValue;
                }
                if (this.TryGetInt("ClippingWidthWithoutFit" + index, out intValue))
                {
                    // 範囲チェック
                    if (intValue < Constants.MinimumClippingSize)
                    {
                        intValue = Constants.MinimumClippingSize;
                    }
                    layoutElement.ClippingWidthWithoutFit = intValue;
                }
                if (this.TryGetInt("ClippingHeightWithoutFit" + index, out intValue))
                {
                    // 範囲チェック
                    if (intValue < Constants.MinimumClippingSize)
                    {
                        intValue = Constants.MinimumClippingSize;
                    }
                    layoutElement.ClippingHeightWithoutFit = intValue;
                }

                // Options
                if (this.TryGetBool("ShowCursor" + index, out boolValue))
                {
                    layoutElement.ShowCursor = boolValue;
                }
                if (this.TryGetBool("ShowLayeredWindow" + index, out boolValue))
                {
                    layoutElement.ShowLayeredWindow = boolValue;
                }
                if (this.TryGetBool("Stretch" + index, out boolValue))
                {
                    layoutElement.Stretch = boolValue;
                }
                if (this.TryGetBool("KeepAspectRatio" + index, out boolValue))
                {
                    layoutElement.KeepAspectRatio = boolValue;
                }
                RotateDirections rotateDirections;
                if (this.TryGetRotateDirections("RotateDirection" + index, out rotateDirections))
                {
                    layoutElement.RotateDirection = rotateDirections;
                }
                // ResizeMethod
                SWScaleFlags swscaleFlags;
                if (this.TryGetSWScaleFlags("SWScaleFlags" + index, out swscaleFlags))
                {
                    layoutElement.SWScaleFlags = swscaleFlags;
                }
                if (this.TryGetBool("SWScaleAccurateRnd" + index, out boolValue))
                {
                    layoutElement.SWScaleAccurateRnd = boolValue;
                }
                if (this.TryGetBool("SWScaleIsFilterEnabled" + index, out boolValue))
                {
                    layoutElement.SWScaleIsFilterEnabled = boolValue;
                }
                if (this.TryGetFloat("SWScaleLumaGBlur" + index, out floatValue))
                {
                    SWScaleInputCorrector.TryChange(SWScaleInputCorrector.Names.LumaGBlur,
                                                    floatValue,
                                                    out floatValue);
                    layoutElement.SWScaleLumaGBlur = floatValue;
                }
                if (this.TryGetFloat("SWScaleChromaGBlur" + index, out floatValue))
                {
                    SWScaleInputCorrector.TryChange(SWScaleInputCorrector.Names.ChromaGBlur,
                                                    floatValue,
                                                    out floatValue);
                    layoutElement.SWScaleChromaGBlur = floatValue;
                }
                if (this.TryGetFloat("SWScaleLumaSharpen" + index, out floatValue))
                {
                    SWScaleInputCorrector.TryChange(SWScaleInputCorrector.Names.LumaSharpen,
                                                    floatValue,
                                                    out floatValue);
                    layoutElement.SWScaleLumaSharpen = floatValue;
                }
                if (this.TryGetFloat("SWScaleChromaSharpen" + index, out floatValue))
                {
                    SWScaleInputCorrector.TryChange(SWScaleInputCorrector.Names.ChromaSharpen,
                                                    floatValue,
                                                    out floatValue);
                    layoutElement.SWScaleChromaSharpen = floatValue;
                }
                if (this.TryGetFloat("SWScaleChromaHShift" + index, out floatValue))
                {
                    SWScaleInputCorrector.TryChange(SWScaleInputCorrector.Names.ChromaHShift,
                                                    floatValue,
                                                    out floatValue);
                    layoutElement.SWScaleChromaHShift = floatValue;
                }
                if (this.TryGetFloat("SWScaleChromaVShift" + index, out floatValue))
                {
                    SWScaleInputCorrector.TryChange(SWScaleInputCorrector.Names.ChromaVShift,
                                                    floatValue,
                                                    out floatValue);
                    layoutElement.SWScaleChromaVShift = floatValue;
                }

                // LayoutParameter
                if (this.TryGetDouble("BoundRelativeLeft" + index, out doubleValue))
                {
                    layoutElement.BoundRelativeLeft = doubleValue;
                }
                if (this.TryGetDouble("BoundRelativeTop" + index, out doubleValue))
                {
                    layoutElement.BoundRelativeTop = doubleValue;
                }
                if (this.TryGetDouble("BoundRelativeRight" + index, out doubleValue))
                {
                    layoutElement.BoundRelativeRight = doubleValue;
                }
                if (this.TryGetDouble("BoundRelativeBottom" + index, out doubleValue))
                {
                    layoutElement.BoundRelativeBottom = doubleValue;
                }
                var boundRelativeRect = BoundRelativeInputCorrector.Correct(layoutElement);
                layoutElement.BoundRelativeLeft   = boundRelativeRect.Left;
                layoutElement.BoundRelativeTop    = boundRelativeRect.Top;
                layoutElement.BoundRelativeRight  = boundRelativeRect.Right;
                layoutElement.BoundRelativeBottom = boundRelativeRect.Bottom;

                // Backup
                if (this.TryGetBool("HasBackedUp" + index, out boolValue))
                {
                    layoutElement.HasBackedUp = boolValue;
                }
                if (this.TryGetInt("BackupScreenClippingX" + index, out intValue))
                {
                    layoutElement.BackupScreenClippingX = intValue;
                }
                if (this.TryGetInt("BackupScreenClippingY" + index, out intValue))
                {
                    layoutElement.BackupScreenClippingY = intValue;
                }
                if (this.TryGetInt("BackupClippingWidth" + index, out intValue))
                {
                    // 範囲チェック
                    if (intValue < Constants.MinimumClippingSize)
                    {
                        intValue = Constants.MinimumClippingSize;
                    }
                    layoutElement.BackupClippingWidth = intValue;
                }
                if (this.TryGetInt("BackupClippingHeight" + index, out intValue))
                {
                    // 範囲チェック
                    if (intValue < Constants.MinimumClippingSize)
                    {
                        intValue = Constants.MinimumClippingSize;
                    }
                    layoutElement.BackupClippingHeight = intValue;
                }

                layoutElements.Add(layoutElement);
                if (index == currentIndex)
                {
                    current = layoutElement;
                }
            }

            this.profile.SetLayoutElements(layoutElements, current);

            return(true);
        }