Example #1
1
 /// <summary>Draws a snapped orthogonal line.</summary>
 internal static void DrawOrthogonal(DrawingContext dc, Orientation orientation, Pen pen, double q, double p0, double p1) {
    if (orientation == Orientation.Horizontal) {
       DrawHorizontal(dc, pen, q, p0, p1);
    } else {
       DrawVertical(dc, pen, q, p0, p1);
    }
 }
Example #2
0
 public Area(Orientation.EnumOrientation orientation, bool rootUsed, List<Node> nodes)
 {
     _id = 0;
     RootUsed = rootUsed;
     Orientation = orientation;
     Nodes = nodes;
 }
Example #3
0
 public TrafficLights(int northSouthDuration, int westEastDuration, int timeShift, Orientation startingOrientation = Orientation.NorthSouth)
 {
     NorthSouthDuration = northSouthDuration;
     WestEastDuration = westEastDuration;
     TimeShift = timeShift;
     StartingLightingState = startingOrientation;
 }
 public ManipulationTracker(Orientation direction, double limit = 0.0) :
     this()
 {
     _limit = new Point(limit, limit);
     _fixed = true;
     _orientation = direction;
 }
 /// <summary>
 /// Creates new gradient stack panel
 /// </summary>
 /// <param name="orientation">Stack orientation</param>
 /// <param name="startColor">Gradient start color</param>
 /// <param name="endColor">Gradient stop color</param>
 public GradientStackPanel(Orientation orientation, Color startColor, Color endColor)
     : base(orientation)
 {
     this.startColor = startColor;
     this.endColor = endColor;
     this.solidBrush = new SolidColorBrush(ColorUtility.ColorFromRGB(164, 164, 164));
 }
        /// <summary>
        /// Ctor
        /// </summary>
        public LoopItemsPanel()
        {
            orientation = Orientation.Vertical;
            this.ManipulationMode = this.Orientation == Orientation.Vertical
                ? (ManipulationModes.TranslateY | ManipulationModes.TranslateInertia)
                : (ManipulationModes.TranslateX | ManipulationModes.TranslateInertia);
            this.IsHitTestVisible = true;
            this.ManipulationDelta += OnManipulationDelta;
            this.ManipulationCompleted += OnManipulationCompleted;
            this.Tapped += OnTapped;
            this.Loaded += OnLoaded;

            this.internalSlider = new Slider
            {
                SmallChange = 0.0000000001,
                Minimum = double.MinValue,
                Maximum = double.MaxValue,
                StepFrequency = 0.0000000001,
                Orientation = this.Orientation
            };
            internalSlider.ValueChanged += OnOffsetChanged;

            this.CreateStoryboard();
            this.LayoutUpdated += OnLayoutUpdated;
        }
 public PaintScrollBarTrackEventArgs(
     Graphics graphics,
     Rectangle trackRect,
     Orientation orientation)
     : this(graphics, trackRect, orientation, true)
 {
 }
Example #8
0
 public Position(int positionX, int positionY, Orientation orientation)
     : this()
 {
     PositionX = positionX;
     PositionY = positionY;
     Orientation = orientation;
 }
Example #9
0
		bool displayUnitSelector; // Indicates whether Grid UnitSeletor should be displayed.
		
		public GridRailAdorner(DesignItem gridItem, AdornerPanel adornerPanel, Orientation orientation)
		{
			Debug.Assert(gridItem != null);
			Debug.Assert(adornerPanel != null);
			
			this.gridItem = gridItem;
			this.grid = (Grid)gridItem.Component;
			this.adornerPanel = adornerPanel;
			this.orientation = orientation;
			this.displayUnitSelector=false;
			this.unitSelector = new GridUnitSelector(this);
			adornerPanel.Children.Add(unitSelector);
			
			if (orientation == Orientation.Horizontal) {
				this.Height = RailSize;
				previewAdorner = new GridColumnSplitterAdorner(this, gridItem, null, null);
			} else { // vertical
				this.Width = RailSize;
				previewAdorner = new GridRowSplitterAdorner(this, gridItem, null, null);
			}
			unitSelector.Orientation = orientation;
			previewAdorner.IsPreview = true;
			previewAdorner.IsHitTestVisible = false;
			unitSelector.Visibility = Visibility.Hidden;
			
		}
Example #10
0
 public GridLabel(string text, double location, Orientation orientation, Brush brush=null) {
   Text = text;
   Location = location;
   Orientation = orientation;
   Brush = brush ?? _defaultBrush;
   IsFloating = false;
 }
Example #11
0
 public Separator()
 {
     SetStyle(ControlStyles.ResizeRedraw, true);
     m_orientation = Orientation.Horizontal;
     m_alignment = ContentAlignment.MiddleCenter;
     OnResize(EventArgs.Empty);
 }
        public static void DrawAquaPill(Graphics g, RectangleF drawRectF, Color drawColor, Orientation orientation)
        {
            var colorBlend = new ColorBlend();

            var color1 = OpacityMix(Color.White, SoftLightMix(drawColor, Color.Black, 100), 40);
            var color2 = OpacityMix(Color.White, SoftLightMix(drawColor, CreateColorFromRgb(64, 64, 64), 100), 20);
            var color3 = SoftLightMix(drawColor, CreateColorFromRgb(128, 128, 128), 100);
            var color4 = SoftLightMix(drawColor, CreateColorFromRgb(192, 192, 192), 100);
            var color5 = OverlayMix(SoftLightMix(drawColor, Color.White, 100), Color.White, 75);

            //
            colorBlend.Colors = new[] { color1, color2, color3, color4, color5 };
            colorBlend.Positions = new[] { 0, 0.25f, 0.5f, 0.75f, 1 };
            var gradientBrush = orientation == Orientation.Horizontal ? new LinearGradientBrush(new Point((int)drawRectF.Left, (int)drawRectF.Top - 1), new Point((int)drawRectF.Left, (int)drawRectF.Top + (int)drawRectF.Height + 1), color1, color5) :
                new LinearGradientBrush(new Point((int)drawRectF.Left - 1, (int)drawRectF.Top), new Point((int)drawRectF.Left + (int)drawRectF.Width + 1, (int)drawRectF.Top), color1, color5);
            gradientBrush.InterpolationColors = colorBlend;
            FillPill(gradientBrush, drawRectF, g);

            //
            color2 = Color.White;
            colorBlend.Colors = new[] { color2, color3, color4, color5 };
            colorBlend.Positions = new[] { 0, 0.5f, 0.75f, 1 };
            gradientBrush = orientation == Orientation.Horizontal ? new LinearGradientBrush(new Point((int)drawRectF.Left + 1, (int)drawRectF.Top), new Point((int)drawRectF.Left + 1, (int)drawRectF.Top + (int)drawRectF.Height - 1), color2, color5) :
                                                                    new LinearGradientBrush(new Point((int)drawRectF.Left, (int)drawRectF.Top + 1), new Point((int)drawRectF.Left + (int)drawRectF.Width - 1, (int)drawRectF.Top + 1), color2, color5);
            gradientBrush.InterpolationColors = colorBlend;
            FillPill(gradientBrush, RectangleF.Inflate(drawRectF, -3, -3), g);
        }
 public Rover(int xCoordinate, int yCoordinate, Orientation orientation, Plateau plateau)
 {
     XCoordinate = xCoordinate;
     YCoordinate = yCoordinate;
     Orientation = orientation;
     Plateau = plateau;
 }
Example #14
0
        public GameBase(Orientation orientation)
            : base()
        {
            _instance = this;

            GraphicsDeviceManager graphics = new GraphicsDeviceManager(this);

            if (orientation == Orientation.Portrait)
            {
                graphics.SupportedOrientations = DisplayOrientation.Portrait | DisplayOrientation.PortraitDown;
            }
            else
            {
                graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
            }

            graphics.IsFullScreen = true;

            Content.RootDirectory = "Content";

            GlobalTimerController.ClearInstance();
            TouchProcessor.ClearInstance();

            _scenes = new Dictionary<Type, Scene>();
            _currentScene = null;
            _tombstoneFileName = DefaultTombstoneFileName;
            _sceneTransitionCrossFadeTextureName = "";

            PurchaseManager = new External_APIS.iOS.InAppPurchaseManager();
        }
Example #15
0
        /// <summary>
        /// Perform drawing of a separator glyph.
        /// </summary>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="paletteBack">Background palette details.</param>
        /// <param name="paletteBorder">Border palette details.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="canMove">Can the separator be moved.</param>
        public override void DrawSeparator(RenderContext context,
                                           Rectangle displayRect,
                                           IPaletteBack paletteBack,
                                           IPaletteBorder paletteBorder,
                                           Orientation orientation,
                                           PaletteState state,
                                           bool canMove)
        {
            // Let base class perform standard processing
            base.DrawSeparator(context,
                               displayRect,
                               paletteBack,
                               paletteBorder,
                               orientation,
                               state,
                               canMove);

            // If we are drawing the background then draw grab handles on top
            if (paletteBack.GetBackDraw(state) == InheritBool.True)
            {
                // Only draw grab handle if the user can move the separator
                if (canMove)
                    DrawGrabHandleGlyph(context, displayRect, orientation, state);
            }
        }
Example #16
0
        public Menu(Device device, Point location, Orientation orientation, params MenuItem[] items)
        {
            Log.Trace("Menu()");
            this.Device = device;
            Items = new List <MenuItem>(items);
            Location = location;
            Orientation = orientation;
            ForeColor = Color.White;
            SelectedForeColor = Color.Red;
            Font = new Font ("Arial", 12, FontStyle.Bold);
            ItemPadding = 15;

            DrawingFont = new SharpDX.Direct3D9.Font (device, Font);

            IncrementMenuKey = new Key (Keys.OemCloseBrackets);
            DecrementMenuKey = new Key (Keys.OemOpenBrackets);
            IncrementValueKey = new Key (Keys.PageUp);
            DecrementValueKey = new Key (Keys.PageDown);
            ResetToZeroKey = new Key (Keys.End);

            IncrementMenuKey.OnJustPressed += (sender, args) => { SelectedIndex = (SelectedIndex + 1).Clamp(SelectedIndex, Items.Count - 1); };
            DecrementMenuKey.OnJustPressed += (sender, args) => { SelectedIndex = (SelectedIndex - 1).Clamp(0, SelectedIndex); };
            IncrementValueKey.OnHold += (sender, args) => Items[SelectedIndex].IncrementValue(2);
            DecrementValueKey.OnHold += (sender, args) => Items[SelectedIndex].DecrementValue(2);
            ResetToZeroKey.OnJustPressed += (sender, args) => { Items[SelectedIndex].Value = 0; };
        }
Example #17
0
        private static LinearGradientBrush CreateGradientBrush(Orientation orientation, params Color[] colors)
        {
            var brush = new LinearGradientBrush();
            var negatedStops = 1 / (float)colors.Length;

            for (var i = 0; i < colors.Length; i++)
            {
                brush.GradientStops.Add(new GradientStop { Offset = negatedStops * i, Color = colors[i] });
            }

            // creating the full loop
            brush.GradientStops.Add(new GradientStop { Offset = negatedStops * colors.Length, Color = colors[0] });

            if (orientation == Orientation.Vertical)
            {
                brush.StartPoint = new Point(0, 1);
                brush.EndPoint = new Point();
            }
            else
            {
                brush.EndPoint = new Point(1, 0);
            }

            return brush;
        }
Example #18
0
        public static void FlipTest(TexImage image, ITexLibrary library, Orientation orientation)
        {
            library.Execute(image, new FlippingRequest(orientation));

            Assert.IsTrue(TestTools.ComputeSHA1(image.Data, image.DataSize).Equals(TestTools.GetInstance().Checksum["FlipTest_" + orientation + "_" + image.Name]));
            //Console.WriteLine("FlipTest_" + orientation + "_" + image.Name + "." + TestTools.ComputeSHA1(image.Data, image.DataSize));
        }
 public static void SetPicturePathConfig(PicMode picMode, Orientation orientation, MainWindow wnd, string value)
 {
     switch (picMode)
     {
         case PicMode.Wallpaper:
             switch (orientation)
             {
                 case Orientation.Landscape:
                     wnd.config.wpLandscape = value;
                     break;
                 case Orientation.Portrait:
                     wnd.config.wpPortrait = value;
                     break;
             }
             break;
         case PicMode.Lockscreen:
             switch (orientation)
             {
                 case Orientation.Landscape:
                     wnd.config.lcLandscape = value;
                     break;
                 case Orientation.Portrait:
                     wnd.config.lcPortrait = value;
                     break;
             }
             break;
     }
 }
 public static string GetPicturePathConfig(PicMode picMode, Orientation orientation, MainWindow wnd)
 {
     if (wnd == null) return null;
     switch (picMode)
     {
         case PicMode.Wallpaper:
             switch(orientation)
             {
                 case Orientation.Landscape:
                     return wnd.config.wpLandscape;
                 case Orientation.Portrait:
                     return wnd.config.wpPortrait;
             }
             break;
         case PicMode.Lockscreen:
             switch(orientation)
             {
                 case Orientation.Landscape:
                     return wnd.config.lcLandscape;
                 case Orientation.Portrait:
                     return wnd.config.lcPortrait;
             }
             break;
     }
     return null;
 }
Example #21
0
 /// <summary>
 /// Constructor for Boat class.
 /// </summary>
 /// <param name="game">Game class for this Drawable Game Component.</param>
 /// <param name="boat">Boat to be copied.</param>
 public Boat(Game game, Boat boat)
     : base(game)
 {
     position = boat.position;
     size = boat.size;
     arah = boat.arah;
 }
		private void ChangeWindowSize(Orientation type, System.Windows.Window window)
		{
			if (type == Orientation.Horizontal)
			{
				if (window != null && this.Mode != Orientation.Horizontal)
				{
					if (window.WindowState == System.Windows.WindowState.Normal)
					{
						Settings.Current.VerticalSize = new System.Windows.Point(window.Width, window.Height);
					}

					window.Height = Settings.Current.HorizontalSize.Y;
					window.Width = Settings.Current.HorizontalSize.X;
				}
			}
			else
			{
				if (window != null && this.Mode != Orientation.Vertical)
				{
					if (window.WindowState == System.Windows.WindowState.Normal)
					{
						Settings.Current.HorizontalSize = new System.Windows.Point(window.Width, window.Height);
					}

					window.Height = Settings.Current.VerticalSize.Y;
					window.Width = Settings.Current.VerticalSize.X;
				}
			}
		}
Example #23
0
    // Use this for initialization
    protected virtual void Start()
    {
        if (transform.rotation.Equals(Quaternion.identity))
        {
            orientation = Orientation.Vertical;
            transform.position = new Vector3(
                ((int)Mathf.Round(transform.position.x / Values.blockSize)) * Values.blockSize,
                ((int)Mathf.Round((transform.position.y - Values.halfBlock) / Values.blockSize)) * Values.blockSize + Values.halfBlock,
                transform.position.z);

            if ((int)transform.rotation.eulerAngles.z % 180 != 0)
                transform.eulerAngles = new Vector3(0, 0, 0);
        }
        else
        {
            orientation = Orientation.Horizontal;
            transform.position = new Vector3(
                ((int)Mathf.Round((transform.position.x - Values.halfBlock) / Values.blockSize)) * Values.blockSize + Values.halfBlock,
                ((int)Mathf.Round(transform.position.y / Values.blockSize)) * Values.blockSize,
                transform.position.z);

            if ((int)(transform.rotation.eulerAngles.z + 90) % 180 != 0)
                transform.eulerAngles = new Vector3(0, 0, 90);
        }
    }
        private static CustomBoxView CalculateNewEmptyArea(CustomBoxView currentEmptyArea, Orientation orientation, double rowToAllRatio)
        {
            CustomBoxView newEmptyArea = new CustomBoxView();

            if (orientation == Orientation.Horizontal)
            {
                double size = Math.Round(currentEmptyArea.HeightRequest * rowToAllRatio);
                if (currentEmptyArea.HeightRequest > size)
                {
                    newEmptyArea.MyX = currentEmptyArea.MyX;
                    newEmptyArea.MyY = currentEmptyArea.MyY + size;

                    newEmptyArea.WidthRequest = currentEmptyArea.WidthRequest;
                    newEmptyArea.HeightRequest = currentEmptyArea.HeightRequest - size;
                }
            }
            else
            {
                double size = Math.Round(currentEmptyArea.WidthRequest * rowToAllRatio);
                if (currentEmptyArea.WidthRequest > size)
                {
                    newEmptyArea.MyX = currentEmptyArea.MyX + size;
                    newEmptyArea.MyY = currentEmptyArea.MyY;

                    newEmptyArea.WidthRequest = currentEmptyArea.WidthRequest - size;
                    newEmptyArea.HeightRequest = currentEmptyArea.HeightRequest;
                }
            }

            return newEmptyArea;
        }
Example #25
0
 /// <summary>
 /// Default constructor requires a name, the bounds of the object, the orientation of projection, and a collection of properties assigned to the object
 /// </summary>
 /// <param name="name"></param>
 /// <param name="bounds"></param>
 /// <param name="orientation"></param>
 /// <param name="properties"></param>
 public MapObject(string name, Rectangle bounds, Orientation orientation, PropertyCollection properties)
 {
     Name = name;
     Bounds = bounds;
     Orientation = orientation;
     Properties = properties;
 }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="g"></param>
		/// <param name="drawRectF"></param>
		/// <param name="drawColor"></param>
		/// <param name="orientation"></param>
		public static void DrawAquaPillSingleLayer(Graphics g, RectangleF drawRectF, Color drawColor, Orientation orientation, BrushStyle brushStyle)
		{
		    if (brushStyle == BrushStyle.LinearGradient)
		    {
		        var colorBlend = new ColorBlend();
		        var color1 = drawColor;
                var color2 = ControlPaint.Light(color1);
                var color3 = ControlPaint.Light(color2);
                var color4 = ControlPaint.Light(color3);

		        colorBlend.Colors = new[] {color1, color2, color3, color4};
		        colorBlend.Positions = new[] {0, 0.25f, 0.65f, 1};

		        var gradientBrush = orientation == Orientation.Horizontal
		                                                ? new LinearGradientBrush(
		                                                      new Point((int) drawRectF.Left, (int) drawRectF.Top),
		                                                      new Point((int) drawRectF.Left,
		                                                                (int) drawRectF.Top + (int) drawRectF.Height), color1,
		                                                      color4)
		                                                : new LinearGradientBrush(
		                                                      new Point((int) drawRectF.Left, (int) drawRectF.Top),
		                                                      new Point((int) drawRectF.Left + (int) drawRectF.Width,
		                                                                (int) drawRectF.Top), color1, color4);
		        gradientBrush.InterpolationColors = colorBlend;

		        FillPill(gradientBrush, drawRectF, g);
		    }
		    else
		    {
                FillPill(new SolidBrush(drawColor), drawRectF, g);
		    }
		}
Example #27
0
 public ProgressBar(Orientation orientation)
 {
     Orientation = orientation;
     Background = new SolidColorBrush(Colors.DarkGray);
     Foreground = new SolidColorBrush(Colors.White);
     Value = 0;
 }
Example #28
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g"></param>
        /// <param name="drawRectF"></param>
        /// <param name="drawColor"></param>
        /// <param name="orientation"></param>
        public static void DrawAquaPill(Graphics g, RectangleF drawRectF, Color drawColor, Orientation orientation)
        {
            System.Drawing.Drawing2D.LinearGradientBrush gradientBrush;
            System.Drawing.Drawing2D.ColorBlend colorBlend = new System.Drawing.Drawing2D.ColorBlend();

            var color1 = ColorHelper.OpacityMix(Color.White, ColorHelper.SoftLightMix(drawColor, Color.Black, 100), 40);
            var color2 = ColorHelper.OpacityMix(Color.White, ColorHelper.SoftLightMix(drawColor, ColorHelper.CreateColorFromRGB(64, 64, 64), 100), 20);
            var color3 = ColorHelper.SoftLightMix(drawColor, ColorHelper.CreateColorFromRGB(128, 128, 128), 100);
            var color4 = ColorHelper.SoftLightMix(drawColor, ColorHelper.CreateColorFromRGB(192, 192, 192), 100);
            var color5 = ColorHelper.OverlayMix(ColorHelper.SoftLightMix(drawColor, Color.White, 100), Color.White, 75);

            //
            colorBlend.Colors = new Color[] { color1, color2, color3, color4, color5 };
            colorBlend.Positions = new float[] { 0, 0.25f, 0.5f, 0.75f, 1 };
            if (orientation == Orientation.Horizontal)
                gradientBrush = new System.Drawing.Drawing2D.LinearGradientBrush(new Point((int)drawRectF.Left, (int)drawRectF.Top - 1), new Point((int)drawRectF.Left, (int)drawRectF.Top + (int)drawRectF.Height + 1), color1, color5);
            else
                gradientBrush = new System.Drawing.Drawing2D.LinearGradientBrush(new Point((int)drawRectF.Left - 1, (int)drawRectF.Top), new Point((int)drawRectF.Left + (int)drawRectF.Width + 1, (int)drawRectF.Top), color1, color5);
            gradientBrush.InterpolationColors = colorBlend;
            FillPill(gradientBrush, drawRectF, g);

            //
            color2 = Color.White;
            colorBlend.Colors = new Color[] { color2, color3, color4, color5 };
            colorBlend.Positions = new float[] { 0, 0.5f, 0.75f, 1 };
            if (orientation == Orientation.Horizontal)
                gradientBrush = new System.Drawing.Drawing2D.LinearGradientBrush(new Point((int)drawRectF.Left + 1, (int)drawRectF.Top), new Point((int)drawRectF.Left + 1, (int)drawRectF.Top + (int)drawRectF.Height - 1), color2, color5);
            else
                gradientBrush = new System.Drawing.Drawing2D.LinearGradientBrush(new Point((int)drawRectF.Left, (int)drawRectF.Top + 1), new Point((int)drawRectF.Left + (int)drawRectF.Width - 1, (int)drawRectF.Top + 1), color2, color5);
            gradientBrush.InterpolationColors = colorBlend;
            FillPill(gradientBrush, RectangleF.Inflate(drawRectF, -3, -3), g);
        }
Example #29
0
 private Vector3 getEntrance(Orientation orientation, int y, Vector3 towerLocation)
 {
     if(orientation == Orientation.East)       { return towerLocation + new Vector3(xMax - 1, y, zMax / 2); }
     else if(orientation == Orientation.North) { return towerLocation + new Vector3(xMax / 2, y, zMax - 1); }
     else if(orientation == Orientation.South) { return towerLocation + new Vector3(xMax / 2, y, 0);        }
     else                                      { return towerLocation + new Vector3(0, y, zMax / 2);        }
 }
        /// <summary>
        /// Initialize a new instance of the NavigatorOutlook class.
        /// </summary>
        /// <param name="navigator">Reference to owning navigator instance.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public NavigatorOutlook(KryptonNavigator navigator,
                                NeedPaintHandler needPaint)
        {
            Debug.Assert(navigator != null);

            // Remember back reference
            _navigator = navigator;

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Create compound objects
            _full = new NavigatorOutlookFull(navigator, needPaint);
            _mini = new NavigatorOutlookMini(navigator, needPaint);

            // Default values
            _checkButtonStyle = ButtonStyle.NavigatorStack;
            _overflowButtonStyle = ButtonStyle.NavigatorOverflow;
            _borderEdgeStyle = PaletteBorderStyle.ControlClient;
            _orientation = Orientation.Vertical;
            _itemOrientation = ButtonOrientation.Auto;
            _headerSecondaryVisible = InheritBool.False;
            _textMoreButtons = _defaultMoreButtons;
            _textFewerButtons = _defaultFewerButtons;
            _textAddRemoveButtons = _defaultAddRemoveButtons;
            _showDropDownButton = true;
        }
Example #31
0
        /// <summary>
        /// show loading window 显示加载动画
        /// </summary>
        /// <param name="type">动画类型</param>
        /// <param name="alertText">提示文本</param>
        /// <param name="point">显示起始点</param>
        /// <param name="size">窗口的大小</param>
        /// <param name="icon">图标</param>
        /// <param name="orientation">方向</param>
        /// <param name="brush">颜色</param>
        /// <param name="outTime">超时关闭时间 5s</param>
        public void ShowLoading(LoadType type, String alertText, Point point, Size size, String icon = null, Orientation orientation = Orientation.Horizontal, object brush = null, int outTime = 5)
        {
            if (mTimer != null)
            {
                mTimer.Dispose();
            }
            Instance.mAlterText   = alertText;
            Instance.mLoadType    = type;
            Instance.mShowType    = ShowType.Loading;
            Instance.mPoint       = point;
            Instance.mSize        = size;
            Instance.mIcon        = icon;
            Instance.MOutTime     = outTime;
            Instance.mBrush       = brush;
            Instance.mOrientation = orientation;
            Instance.Style        = Instance.FindResource(MMRK.LoadingStyle.ToString()) as Style;

            mTimer = new System.Threading.Timer(delegate
            {
                Instance.Dispatcher.Invoke(new Action(delegate
                {
                    Instance.Close();
                }));
            }, null, outTime * 1000, 0);
            Instance.Show();
        }
Example #32
0
 public override string RadioGroupSize(bool buttons, Orientation orientation, Size size) => buttons
     ? orientation == Orientation.Horizontal ? $"btn-group-{ToSize( size )}" : $"btn-group-vertical-{ToSize( size )}"
     : null;
Example #33
0
 internal bool GetExpandsForOrientation(Orientation o)
 {
     return(child.ExpandsForOrientation(o));
 }
Example #34
0
        private void TestArrangeOverrideCore(Orientation orientation)
        {
            ResetState();

            DepthAlignment = DepthAlignment.Stretch;

            // Create and add children
            var child1 = new ArrangeValidator {
                DepthAlignment = DepthAlignment.Stretch
            };
            var child2 = new ArrangeValidator {
                DepthAlignment = DepthAlignment.Stretch
            };
            var child3 = new ArrangeValidator {
                DepthAlignment = DepthAlignment.Stretch
            };

            Children.Add(child1);
            Children.Add(child2);
            Children.Add(child3);

            // set the stack orientation
            Orientation = orientation;

            // set children margins
            Children[0].Margin = rand.NextThickness(10, 11, 12, 13, 14, 15);
            Children[1].Margin = rand.NextThickness(10, 11, 12, 13, 14, 15);
            Children[2].Margin = rand.NextThickness(10, 11, 12, 13, 14, 15);

            // set an available size
            var availablesizeWithMargins    = 1000 * rand.NextVector3();
            var availableSizeWithoutMargins = CalculateSizeWithoutThickness(ref availablesizeWithMargins, ref MarginInternal);

            // set the arrange validator values
            foreach (ArrangeValidator child in Children)
            {
                child.ReturnedMeasuredValue = 1000 * rand.NextVector3();
                child.ExpectedArrangeValue  = CalculateSizeWithoutThickness(ref availableSizeWithoutMargins, ref child.MarginInternal);
                child.ExpectedArrangeValue[(int)Orientation] = child.ReturnedMeasuredValue[(int)Orientation];
            }

            // Measure the stack
            Measure(availableSizeWithoutMargins);
            Arrange(availablesizeWithMargins, false);

            // compute the children accumulated sizes
            var acculumatedDesiredSizeWithMarginsList = new List <Vector3>();

            for (int i = 0; i < Children.Count; i++)
            {
                var accumulatedVector = Vector3.Zero;
                for (int j = 0; j < i; j++)
                {
                    for (int dim = 0; dim < 3; ++dim)
                    {
                        accumulatedVector[dim] += Children[j].RenderSize[dim] + Children[j].Margin[dim] + Children[j].Margin[dim + 3];
                    }
                }

                acculumatedDesiredSizeWithMarginsList.Add(accumulatedVector);
            }

            // checks the stack arranged size
            Assert.AreEqual(availableSizeWithoutMargins, RenderSize);

            // Checks the children arrange matrix
            for (int i = 0; i < Children.Count; i++)
            {
                var childOffsets = -RenderSize / 2;

                switch (orientation)
                {
                case Orientation.Horizontal:
                    childOffsets.X += acculumatedDesiredSizeWithMarginsList[i].X;
                    break;

                case Orientation.Vertical:
                    childOffsets.Y += acculumatedDesiredSizeWithMarginsList[i].Y;
                    break;

                case Orientation.InDepth:
                    childOffsets.Z += acculumatedDesiredSizeWithMarginsList[i].Z;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(orientation));
                }

                Utilities.AssertAreNearlyEqual(Matrix.Translation(childOffsets), Children[i].DependencyProperties.Get(PanelArrangeMatrixPropertyKey));
            }
        }
Example #35
0
        private void TestMeasureOverrideCore(Orientation orientation)
        {
            // set the stack orientation
            Orientation = orientation;

            // set children margins
            Children[0].Margin = rand.NextThickness(10, 11, 12, 13, 14, 15);
            Children[1].Margin = rand.NextThickness(10, 11, 12, 13, 14, 15);
            Children[2].Margin = rand.NextThickness(10, 11, 12, 13, 14, 15);

            // set an available size
            var availablesizeWithMargins    = 1000 * rand.NextVector3();
            var availableSizeWithoutMargins = CalculateSizeWithoutThickness(ref availablesizeWithMargins, ref MarginInternal);

            // set the validator expected and return values
            foreach (MeasureValidator child in Children)
            {
                // set the children desired size via the Measure override return value
                child.ReturnedMeasuredValue = 100 * rand.NextVector3();

                // set the expected size for child provided size validation
                var expectedSize = CalculateSizeWithoutThickness(ref availableSizeWithoutMargins, ref child.MarginInternal);
                expectedSize[(int)Orientation] = float.PositiveInfinity;
                child.ExpectedMeasureValue     = expectedSize;
            }

            // Measure the stack
            Measure(availablesizeWithMargins);

            // compute the children max desired sizes
            var maximumDesiredSizeWithMargins = Vector3.Zero;

            foreach (var child in Children)
            {
                maximumDesiredSizeWithMargins = new Vector3(
                    Math.Max(maximumDesiredSizeWithMargins.X, child.DesiredSizeWithMargins.X),
                    Math.Max(maximumDesiredSizeWithMargins.Y, child.DesiredSizeWithMargins.Y),
                    Math.Max(maximumDesiredSizeWithMargins.Z, child.DesiredSizeWithMargins.Z));
            }

            // compute the children accumulated sizes
            var acculumatedDesiredSizeWithMargins = Children.Aggregate(Vector3.Zero, (current, child) => current + child.DesiredSizeWithMargins);

            // Checks the desired size
            switch (orientation)
            {
            case Orientation.Horizontal:
                Assert.AreEqual(acculumatedDesiredSizeWithMargins.X, DesiredSize.X);
                Assert.AreEqual(maximumDesiredSizeWithMargins.Y, DesiredSize.Y);
                Assert.AreEqual(maximumDesiredSizeWithMargins.Z, DesiredSize.Z);
                break;

            case Orientation.Vertical:
                Assert.AreEqual(maximumDesiredSizeWithMargins.X, DesiredSize.X);
                Assert.AreEqual(acculumatedDesiredSizeWithMargins.Y, DesiredSize.Y);
                Assert.AreEqual(maximumDesiredSizeWithMargins.Z, DesiredSize.Z);
                break;

            case Orientation.InDepth:
                Assert.AreEqual(maximumDesiredSizeWithMargins.X, DesiredSize.X);
                Assert.AreEqual(maximumDesiredSizeWithMargins.Y, DesiredSize.Y);
                Assert.AreEqual(acculumatedDesiredSizeWithMargins.Z, DesiredSize.Z);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(orientation));
            }
        }
Example #36
0
        private void SetupDefaultAnchoringUI(
            Orientation orientation,
            Scroller scroller,
            AutoResetEvent scrollerLoadedEvent)
        {
            Log.Comment("Setting up default anchoring UI with Scroller");

            StackPanel stackPanel = new StackPanel();

            stackPanel.Name        = "stackPanel";
            stackPanel.Orientation = orientation;
            stackPanel.Margin      = new Thickness(30);

            Border border = new Border();

            border.Name            = "border";
            border.BorderThickness = new Thickness(3);
            border.BorderBrush     = new SolidColorBrush(Colors.Chartreuse);
            border.Margin          = new Thickness(15);
            border.Background      = new SolidColorBrush(Colors.Beige);
            border.Child           = stackPanel;

            Verify.IsNotNull(scroller);
            scroller.Name = "scroller";
            if (orientation == Orientation.Vertical)
            {
                scroller.IsChildAvailableWidthConstrained = true;
                scroller.Width  = c_defaultAnchoringUIScrollerConstrainedSize;
                scroller.Height = c_defaultAnchoringUIScrollerNonConstrainedSize;
            }
            else
            {
                scroller.IsChildAvailableHeightConstrained = true;
                scroller.Width  = c_defaultAnchoringUIScrollerNonConstrainedSize;
                scroller.Height = c_defaultAnchoringUIScrollerConstrainedSize;
            }
            scroller.Background = new SolidColorBrush(Colors.AliceBlue);
            scroller.Child      = border;

            InsertStackPanelChild(stackPanel, 0 /*operationCount*/, 0 /*newIndex*/, c_defaultAnchoringUIStackPanelChildrenCount /*newCount*/);

            if (scrollerLoadedEvent != null)
            {
                scroller.Loaded += (object sender, RoutedEventArgs e) =>
                {
                    Log.Comment("Scroller.Loaded event handler");
                    scrollerLoadedEvent.Set();
                };
            }

            scroller.AnchorRequested += (Scroller sender, ScrollerAnchorRequestedEventArgs args) =>
            {
                Log.Comment("Scroller.AnchorRequested event handler");

                Verify.IsNull(args.AnchorElement);
                Verify.AreEqual(args.AnchorCandidates.Count, 0);

                StackPanel sp = (sender.Child as Border).Child as StackPanel;
                foreach (Border b in sp.Children)
                {
                    args.AnchorCandidates.Add(b);
                }
            };

            Log.Comment("Setting window content");
            MUXControlsTestApp.App.TestContentRoot = scroller;
        }
Example #37
0
        private void AnchoringElementWithResizedViewport(Orientation orientation, double viewportSizeChange)
        {
            using (ScrollerTestHooksHelper scrollerTestHooksHelper = new ScrollerTestHooksHelper())
            {
                Scroller       scroller                 = null;
                AutoResetEvent scrollerLoadedEvent      = new AutoResetEvent(false);
                AutoResetEvent scrollerViewChangedEvent = new AutoResetEvent(false);

                RunOnUIThread.Execute(() =>
                {
                    scroller = new Scroller();

                    SetupDefaultAnchoringUI(orientation, scroller, scrollerLoadedEvent);
                });

                WaitForEvent("Waiting for Loaded event", scrollerLoadedEvent);

                ChangeZoomFactor(scroller, 2.0f, 0.0f, 0.0f, ScrollerViewKind.Absolute, ScrollerViewChangeKind.DisableAnimation);

                double horizontalOffset = 0.0;
                double verticalOffset   = 0.0;

                RunOnUIThread.Execute(() =>
                {
                    if (orientation == Orientation.Vertical)
                    {
                        verticalOffset = (scroller.ExtentHeight * 2.0 - scroller.Height) / 2.0;
                        scroller.VerticalAnchorRatio = 0.5;
                    }
                    else
                    {
                        horizontalOffset = (scroller.ExtentWidth * 2.0 - scroller.Width) / 2.0;
                        scroller.HorizontalAnchorRatio = 0.5;
                    }
                });

                ChangeOffsets(scroller, horizontalOffset, verticalOffset, ScrollerViewKind.Absolute, ScrollerViewChangeKind.DisableAnimation, ScrollerViewChangeSnapPointRespect.IgnoreSnapPoints, false /*hookViewChanged*/);

                RunOnUIThread.Execute(() =>
                {
                    Log.Comment("Scroller view prior to viewport size change: HorizontalOffset={0}, VerticalOffset={1}, ZoomFactor={2}",
                                scroller.HorizontalOffset, scroller.VerticalOffset, scroller.ZoomFactor);

                    scroller.ViewChanged += delegate(Scroller sender, object args)
                    {
                        Log.Comment("ViewChanged - HorizontalOffset={0}, VerticalOffset={1}, ZoomFactor={2}",
                                    sender.HorizontalOffset, sender.VerticalOffset, sender.ZoomFactor);
                        scrollerViewChangedEvent.Set();
                    };

                    if (orientation == Orientation.Vertical)
                    {
                        Log.Comment("Changing viewport height");
                        scroller.Height += viewportSizeChange;
                    }
                    else
                    {
                        Log.Comment("Changing viewport width");
                        scroller.Width += viewportSizeChange;
                    }
                });

                WaitForEvent("Waiting for Scroller.ViewChanged event", scrollerViewChangedEvent);
                IdleSynchronizer.Wait();

                RunOnUIThread.Execute(() =>
                {
                    Log.Comment("Scroller view after viewport size change: HorizontalOffset={0}, VerticalOffset={1}, ZoomFactor={2}",
                                scroller.HorizontalOffset, scroller.VerticalOffset, scroller.ZoomFactor);
                    Log.Comment("Expecting offset change equal to half the viewport size change");
                    if (orientation == Orientation.Vertical)
                    {
                        Verify.AreEqual(scroller.VerticalOffset, verticalOffset - viewportSizeChange / 2.0);
                    }
                    else
                    {
                        Verify.AreEqual(scroller.HorizontalOffset, horizontalOffset - viewportSizeChange / 2.0);
                    }
                });
            }
        }
Example #38
0
        private void AnchoringAtFarEdgeWhileDecreasingViewport(Orientation orientation)
        {
            if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2))
            {
                Log.Comment("Skipping test on RS1 where InteractionTracker's AdjustPositionXIfGreaterThanThreshold/AdjustPositionYIfGreaterThanThreshold are ineffective in this scenario.");
                return;
            }

            using (ScrollerTestHooksHelper scrollerTestHooksHelper = new ScrollerTestHooksHelper())
            {
                Scroller       scroller                 = null;
                AutoResetEvent scrollerLoadedEvent      = new AutoResetEvent(false);
                AutoResetEvent scrollerViewChangedEvent = new AutoResetEvent(false);

                RunOnUIThread.Execute(() =>
                {
                    scroller = new Scroller();

                    SetupDefaultAnchoringUI(orientation, scroller, scrollerLoadedEvent);
                });

                WaitForEvent("Waiting for Loaded event", scrollerLoadedEvent);

                ChangeZoomFactor(scroller, 2.0f, 0.0f, 0.0f, ScrollerViewKind.Absolute, ScrollerViewChangeKind.DisableAnimation);

                double horizontalOffset = 0.0;
                double verticalOffset   = 0.0;

                RunOnUIThread.Execute(() =>
                {
                    if (orientation == Orientation.Vertical)
                    {
                        verticalOffset = scroller.ExtentHeight * 2.0 - scroller.Height;
                        scroller.VerticalAnchorRatio = 1.0;
                    }
                    else
                    {
                        horizontalOffset = scroller.ExtentWidth * 2.0 - scroller.Width;
                        scroller.HorizontalAnchorRatio = 1.0;
                    }
                });

                ChangeOffsets(scroller, horizontalOffset, verticalOffset, ScrollerViewKind.Absolute, ScrollerViewChangeKind.DisableAnimation, ScrollerViewChangeSnapPointRespect.IgnoreSnapPoints, false /*hookViewChanged*/);

                RunOnUIThread.Execute(() =>
                {
                    scroller.ViewChanged += delegate(Scroller sender, object args)
                    {
                        Log.Comment("ViewChanged - HorizontalOffset={0}, VerticalOffset={1}, ZoomFactor={2}",
                                    sender.HorizontalOffset, sender.VerticalOffset, sender.ZoomFactor);
                        scrollerViewChangedEvent.Set();
                    };

                    if (orientation == Orientation.Vertical)
                    {
                        Log.Comment("Decreasing viewport height");
                        scroller.Height -= 100;
                    }
                    else
                    {
                        Log.Comment("Decreasing viewport width");
                        scroller.Width -= 100;
                    }
                });

                WaitForEvent("Waiting for Scroller.ViewChanged event", scrollerViewChangedEvent);
                IdleSynchronizer.Wait();

                RunOnUIThread.Execute(() =>
                {
                    if (orientation == Orientation.Vertical)
                    {
                        verticalOffset = scroller.ExtentHeight * 2.0 - scroller.Height;
                    }
                    else
                    {
                        horizontalOffset = scroller.ExtentWidth * 2.0 - scroller.Width;
                    }

                    Log.Comment("Scroller offset change expected");
                    Verify.AreEqual(scroller.HorizontalOffset, horizontalOffset);
                    Verify.AreEqual(scroller.VerticalOffset, verticalOffset);
                });
            }
        }
Example #39
0
 public WrapPanel()
 {
     // default orientation
     Orientation = Orientation.Horizontal;
 }
Example #40
0
 public override string RadioGroup(bool buttons, Orientation orientation) => buttons
     ? orientation == Orientation.Horizontal ? "btn-group btn-group-toggle" : "btn-group-vertical btn-group-toggle"
     : null;
Example #41
0
 internal void SetOrientation(Orientation orientation)
 {
     ready           = true;
     dragOrientation = orientation;
     InvalidateVisual();
 }
Example #42
0
        /// <summary>
        /// 弹窗提示
        /// </summary>
        /// <param name="alertText">提示的文本</param>
        /// <param name="caption">标题</param>
        /// <param name="buttonType">按钮类型</param>
        /// <param name="iconType">图标类型</param>
        /// <param name="orientation">内容显示方向</param>
        /// <param name="yesBtnText">确定按键的文本</param>
        /// <param name="nobtnText">取消按键的文本</param>
        /// <returns></returns>
        public Result ShowBox(String alertText, string caption, ButtonType buttonType, IconType iconType, Orientation orientation = Orientation.Horizontal, string yesBtnText = null, String nobtnText = null)
        {
            Instance.ShowInTaskbar = true;
            Instance.Style         = Instance.FindResource(MMRK.BoxStyle.ToString()) as Style;
            Instance.mShowType     = ShowType.messageBox;
            Instance.mAlterText    = alertText;
            Instance.mCapution     = caption;
            Instance.MYesBtnText   = yesBtnText;
            Instance.MNoBtnText    = nobtnText;
            Instance.mButtonType   = buttonType;
            Instance.mOrientation  = orientation;
            Instance.mIconType     = iconType;
            bool result = (bool)Instance.ShowDialog();

            return(result == true ? Result.Yes : Result.No);
        }
Example #43
0
 public ThumDragWidget(Orientation orientation)
 {
     this.orientation = orientation;
 }
Example #44
0
 /// <summary>
 /// Restores control state information from a previous page request that was
 /// saved by the <see cref="System.Web.UI.Control.SaveControlState"/> method.
 /// </summary>
 /// <param name="savedState">
 /// An <see cref="System.Object"/> that represents the control state to be restored.
 /// </param>
 protected override void LoadControlState(object savedState)
 {
     object[] controlState = (object[])savedState;
     base.LoadControlState(controlState[0]);
     this.orientation = ((bool)controlState[1]) ? Orientation.Horizontal : Orientation.Vertical;
 }
Example #45
0
File: Player.cs Project: 3ldh/Zappy
 public bool IsOrientationDifferent(Orientation orient)
 {
     return(nextOrientation != orient);
 }
Example #46
0
        private void DrawProgress(Orientation orientation, Graphics graphics)
        {
            if (_progressBarStyle == ProgressBarStyle.Marquee)
            {
                if (!DesignMode && Enabled)
                {
                    StartTimer();
                }

                if (!Enabled)
                {
                    StopTimer();
                }

                if (Value == Maximum)
                {
                    StopTimer();
                    DrawProgressContinuous(graphics);
                }
                else
                {
                    DrawProgressMarquee(graphics);
                }
            }
            else
            {
                int _indexValue;

                GraphicsPath _progressPath;
                Rectangle    _progressRectangle;

                switch (orientation)
                {
                case Orientation.Horizontal:
                {
                    _indexValue        = (int)Math.Round(((Value - Minimum) / (double)(Maximum - Minimum)) * (Width - 2));
                    _progressRectangle = new Rectangle(0, 0, _indexValue + _border.Thickness, Height);
                    _progressPath      = VisualBorderRenderer.CreateBorderTypePath(_progressRectangle, _border);
                }

                break;

                case Orientation.Vertical:
                {
                    _indexValue        = (int)Math.Round(((Value - Minimum) / (double)(Maximum - Minimum)) * (Height - 2));
                    _progressRectangle = new Rectangle(0, Height - _indexValue - _border.Thickness - 1, Width, _indexValue);
                    _progressPath      = VisualBorderRenderer.CreateBorderTypePath(_progressRectangle, _border);
                }

                break;

                default:
                {
                    throw new ArgumentOutOfRangeException(nameof(orientation), orientation, null);
                }
                }

                if (_indexValue > 1)
                {
                    graphics.SetClip(ControlGraphicsPath);
                    graphics.FillRectangle(new SolidBrush(_progressColor), _progressRectangle);
                    VisualControlRenderer.DrawHatch(graphics, _hatch, _progressPath);
                    graphics.ResetClip();
                }
            }

            DrawText(graphics);
        }
 ICreativeImagesSearch ICreativeImagesSearch.WithOrientation(Orientation value)
 {
     return(WithOrientation(value));
 }
Example #48
0
 public RotatingLabel()
 {
     _rotationAngle   = 0d;
     _textOrientation = Orientation.Rotate;
     Size             = new Size(105, 12);
 }
Example #49
0
        private static void EdgeEvent(DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle triangle, TriangulationPoint point)
        {
            if (IsEdgeSideOfTriangle(triangle, ep, eq))
            {
                return;
            }

            TriangulationPoint p1 = triangle.PointCCW(point);
            Orientation        o1 = TriangulationUtil.Orient2d(eq, p1, ep);

            if (o1 == Orientation.Collinear)
            {
                if (triangle.Contains(eq, p1))
                {
                    triangle.MarkConstrainedEdge(eq, p1);
                    // We are modifying the constraint maybe it would be better to
                    // not change the given constraint and just keep a variable for the new constraint
                    tcx.EdgeEvent.ConstrainedEdge.Q = p1;
                    triangle = triangle.NeighborAcross(point);
                    EdgeEvent(tcx, ep, p1, triangle, p1);
                }
                else
                {
                    throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet");
                }
                if (tcx.IsDebugEnabled)
                {
                    Debug.WriteLine("EdgeEvent - Point on constrained edge");
                }
                return;
            }

            TriangulationPoint p2 = triangle.PointCW(point);
            Orientation        o2 = TriangulationUtil.Orient2d(eq, p2, ep);

            if (o2 == Orientation.Collinear)
            {
                if (triangle.Contains(eq, p2))
                {
                    triangle.MarkConstrainedEdge(eq, p2);
                    // We are modifying the constraint maybe it would be better to
                    // not change the given constraint and just keep a variable for the new constraint
                    tcx.EdgeEvent.ConstrainedEdge.Q = p2;
                    triangle = triangle.NeighborAcross(point);
                    EdgeEvent(tcx, ep, p2, triangle, p2);
                }
                else
                {
                    throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet");
                }
                if (tcx.IsDebugEnabled)
                {
                    Debug.WriteLine("EdgeEvent - Point on constrained edge");
                }
                return;
            }

            if (o1 == o2)
            {
                // Need to decide if we are rotating CW or CCW to get to a triangle
                // that will cross edge
                if (o1 == Orientation.CW)
                {
                    triangle = triangle.NeighborCCW(point);
                }
                else
                {
                    triangle = triangle.NeighborCW(point);
                }
                EdgeEvent(tcx, ep, eq, triangle, point);
            }
            else
            {
                // This triangle crosses constraint so lets flippin start!
                FlipEdgeEvent(tcx, ep, eq, triangle, point);
            }
        }
 IEditorialImagesSearch IEditorialImagesSearch.WithOrientation(Orientation value)
 {
     return(WithOrientation(value));
 }
Example #51
0
 public int GetDimension(Orientation ori)
 {
     return(ori == Orientation.Horizontal ? Width : Height);
 }
 IBlendedImagesSearch IBlendedImagesSearch.WithOrientation(Orientation value)
 {
     return(WithOrientation(value));
 }
Example #53
0
 internal UVSize(Orientation orientation)
 {
     U            = V = 0d;
     _orientation = orientation;
 }
Example #54
0
        public FormatBar(Orientation orientation, int spacing) : base(orientation, spacing)
        {
            StyleContext.AddClass("search-bar");

            var label = new Label("Format Bar");

            label.Hexpand = true;
            label.Halign  = Align.Center;
            label.Margin  = 6;

            // Format Bar
            var boldButton = new Button();

            boldButton.Image      = Image.NewFromIconName("format-text-bold-symbolic", IconSize.SmallToolbar);
            boldButton.ActionName = "format.bold";

            var italicButton = new Button();

            italicButton.Image      = Image.NewFromIconName("format-text-italic-symbolic", IconSize.SmallToolbar);
            italicButton.ActionName = "format.italic";

            var underlineButton = new Button();

            underlineButton.Image      = Image.NewFromIconName("format-text-underline-symbolic", IconSize.SmallToolbar);
            underlineButton.ActionName = "format.underline";

            var formatGrid = new Grid();

            formatGrid.StyleContext.AddClass("linked");
            formatGrid.Add(boldButton);
            formatGrid.Add(italicButton);
            formatGrid.Add(underlineButton);

            // Justify Bar
            var justifyLeftButton = new Button();

            justifyLeftButton.Image      = Image.NewFromIconName("format-justify-left-symbolic", IconSize.SmallToolbar);
            justifyLeftButton.ActionName = "format.justify-left";

            var justifyRightButton = new Button();

            justifyRightButton.Image      = Image.NewFromIconName("format-justify-right-symbolic", IconSize.SmallToolbar);
            justifyRightButton.ActionName = "format.justify-right";

            var justifyCenterButton = new Button();

            justifyCenterButton.Image      = Image.NewFromIconName("format-justify-center-symbolic", IconSize.SmallToolbar);
            justifyCenterButton.ActionName = "format.justify-center";

            var justifyFillButton = new Button();

            justifyFillButton.Image      = Image.NewFromIconName("format-justify-fill-symbolic", IconSize.SmallToolbar);
            justifyFillButton.ActionName = "format.justify-fill";

            var justifyGrid = new Grid();

            justifyGrid.StyleContext.AddClass("linked");
            justifyGrid.Add(justifyLeftButton);
            justifyGrid.Add(justifyCenterButton);
            justifyGrid.Add(justifyRightButton);
            justifyGrid.Add(justifyFillButton);

            // Remove formatting button
            var clearButton = new Button();

            clearButton.Image      = Image.NewFromIconName("edit-clear-symbolic", IconSize.SmallToolbar);
            clearButton.ActionName = "format.clear";

            Add(formatGrid);
            Add(justifyGrid);
            PackEnd(clearButton, false, true, 0);
        }
Example #55
0
 public void Initialize(Orientation dir)
 {
     ViewObject = new SeparatorWidget();
     ResetFittingSize();
 }
Example #56
0
 public void SetOrientation(Orientation ori)
 {
     box.Orientation = ori;
 }
Example #57
0
        internal ScrollBar(ScrollableWidget parent, GuiWidget background, GuiWidget thumbView, Orientation orientation = Orientation.Vertical)
        {
            ParentScrollWidget = parent;

            this.background = background;
            thumb           = new ThumDragWidget(orientation);
            thumb.AddChild(thumbView);

            AddChild(background);
            AddChild(thumb);

            this.Margin = ScrollBar.DefaultMargin;

            ParentScrollWidget.BoundsChanged            += Bounds_Changed;
            ParentScrollWidget.ScrollArea.BoundsChanged += Bounds_Changed;
            ParentScrollWidget.ScrollPositionChanged    += Bounds_Changed;
            ParentScrollWidget.ScrollArea.MarginChanged += Bounds_Changed;

            UpdateScrollBar();
        }
Example #58
0
 public UniformSpacingPanel()
 {
     _orientation = Orientation.Horizontal;
 }
Example #59
0
 internal ScrollBar(ScrollableWidget parent, Orientation orientation = Orientation.Vertical)
     : this(parent, new DefaultThumbBackground(), new DefaultThumbView(), orientation)
 {
 }
Example #60
0
        /// <summary>
        /// Sets the value(s) of a tag in a TIFF file/stream open for writing.
        /// </summary>
        /// <param name="tif">An instance of the <see cref="Tiff"/> class.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="value">The tag value(s).</param>
        /// <returns>
        /// <c>true</c> if tag value(s) were set successfully; otherwise, <c>false</c>.
        /// </returns>
        /// <seealso cref="Tiff.SetField"/>
        public virtual bool SetField(Tiff tif, TiffTag tag, FieldValue[] value)
        {
            const string module = "vsetfield";

            TiffDirectory td     = tif.m_dir;
            bool          status = true;
            int           v32    = 0;
            int           v      = 0;

            bool end        = false;
            bool badvalue   = false;
            bool badvalue32 = false;

            switch (tag)
            {
            case TiffTag.SUBFILETYPE:
                td.td_subfiletype = (FileType)value[0].ToByte();
                break;

            case TiffTag.IMAGEWIDTH:
                td.td_imagewidth = value[0].ToInt();
                break;

            case TiffTag.IMAGELENGTH:
                td.td_imagelength = value[0].ToInt();
                break;

            case TiffTag.BITSPERSAMPLE:
                td.td_bitspersample = value[0].ToShort();
                // If the data require post-decoding processing to byte-swap samples, set it
                // up here. Note that since tags are required to be ordered, compression code
                // can override this behavior in the setup method if it wants to roll the post
                // decoding work in with its normal work.
                if ((tif.m_flags & TiffFlags.SWAB) == TiffFlags.SWAB)
                {
                    switch (td.td_bitspersample)
                    {
                    case 16:
                        tif.m_postDecodeMethod = Tiff.PostDecodeMethodType.pdmSwab16Bit;
                        break;

                    case 24:
                        tif.m_postDecodeMethod = Tiff.PostDecodeMethodType.pdmSwab24Bit;
                        break;

                    case 32:
                        tif.m_postDecodeMethod = Tiff.PostDecodeMethodType.pdmSwab32Bit;
                        break;

                    case 64:
                        tif.m_postDecodeMethod = Tiff.PostDecodeMethodType.pdmSwab64Bit;
                        break;

                    case 128:
                        // two 64's
                        tif.m_postDecodeMethod = Tiff.PostDecodeMethodType.pdmSwab64Bit;
                        break;
                    }
                }
                break;

            case TiffTag.COMPRESSION:
                v = value[0].ToInt() & 0xffff;
                Compression comp = (Compression)v;
                // If we're changing the compression scheme, then notify the previous module
                // so that it can cleanup any state it's setup.
                if (tif.fieldSet(FieldBit.Compression))
                {
                    if (td.td_compression == comp)
                    {
                        break;
                    }

                    tif.m_currentCodec.Cleanup();
                    tif.m_flags &= ~TiffFlags.CODERSETUP;
                }
                // Setup new compression scheme.
                status = tif.setCompressionScheme(comp);
                if (status)
                {
                    td.td_compression = comp;
                }
                else
                {
                    status = false;
                }
                break;

            case TiffTag.PHOTOMETRIC:
                td.td_photometric = (Photometric)value[0].ToInt();
                break;

            case TiffTag.THRESHHOLDING:
                td.td_threshholding = (Threshold)value[0].ToByte();
                break;

            case TiffTag.FILLORDER:
                v = value[0].ToInt();
                FillOrder fo = (FillOrder)v;
                if (fo != FillOrder.LSB2MSB && fo != FillOrder.MSB2LSB)
                {
                    badvalue = true;
                    break;
                }

                td.td_fillorder = fo;
                break;

            case TiffTag.ORIENTATION:
                v = value[0].ToInt();
                Orientation or = (Orientation)v;
                if (or < Orientation.TOPLEFT || Orientation.LEFTBOT < or)
                {
                    badvalue = true;
                    break;
                }
                else
                {
                    td.td_orientation = or;
                }
                break;

            case TiffTag.SAMPLESPERPIXEL:
                // XXX should cross check - e.g. if pallette, then 1
                v = value[0].ToInt();
                if (v == 0)
                {
                    badvalue = true;
                    break;
                }

                td.td_samplesperpixel = (short)v;
                break;

            case TiffTag.ROWSPERSTRIP:
                v32 = value[0].ToInt();
                if (v32 == 0)
                {
                    badvalue32 = true;
                    break;
                }

                td.td_rowsperstrip = v32;
                if (!tif.fieldSet(FieldBit.TileDimensions))
                {
                    td.td_tilelength = v32;
                    td.td_tilewidth  = td.td_imagewidth;
                }
                break;

            case TiffTag.MINSAMPLEVALUE:
                td.td_minsamplevalue = value[0].ToUShort();
                break;

            case TiffTag.MAXSAMPLEVALUE:
                td.td_maxsamplevalue = value[0].ToUShort();
                break;

            case TiffTag.SMINSAMPLEVALUE:
                td.td_sminsamplevalue = value[0].ToDouble();
                break;

            case TiffTag.SMAXSAMPLEVALUE:
                td.td_smaxsamplevalue = value[0].ToDouble();
                break;

            case TiffTag.XRESOLUTION:
                td.td_xresolution = value[0].ToFloat();
                break;

            case TiffTag.YRESOLUTION:
                td.td_yresolution = value[0].ToFloat();
                break;

            case TiffTag.PLANARCONFIG:
                v = value[0].ToInt();
                PlanarConfig pc = (PlanarConfig)v;
                if (pc != PlanarConfig.CONTIG && pc != PlanarConfig.SEPARATE)
                {
                    badvalue = true;
                    break;
                }
                td.td_planarconfig = pc;
                break;

            case TiffTag.XPOSITION:
                td.td_xposition = value[0].ToFloat();
                break;

            case TiffTag.YPOSITION:
                td.td_yposition = value[0].ToFloat();
                break;

            case TiffTag.RESOLUTIONUNIT:
                v = value[0].ToInt();
                ResUnit ru = (ResUnit)v;
                if (ru < ResUnit.NONE || ResUnit.CENTIMETER < ru)
                {
                    badvalue = true;
                    break;
                }

                td.td_resolutionunit = ru;
                break;

            case TiffTag.PAGENUMBER:
                td.td_pagenumber[0] = value[0].ToShort();
                td.td_pagenumber[1] = value[1].ToShort();
                break;

            case TiffTag.HALFTONEHINTS:
                td.td_halftonehints[0] = value[0].ToShort();
                td.td_halftonehints[1] = value[1].ToShort();
                break;

            case TiffTag.COLORMAP:
                v32 = 1 << td.td_bitspersample;
                Tiff.setShortArray(out td.td_colormap[0], value[0].ToShortArray(), v32);
                Tiff.setShortArray(out td.td_colormap[1], value[1].ToShortArray(), v32);
                Tiff.setShortArray(out td.td_colormap[2], value[2].ToShortArray(), v32);
                break;

            case TiffTag.EXTRASAMPLES:
                if (!setExtraSamples(td, ref v, value))
                {
                    badvalue = true;
                    break;
                }

                break;

            case TiffTag.MATTEING:
                if (value[0].ToShort() != 0)
                {
                    td.td_extrasamples = 1;
                }
                else
                {
                    td.td_extrasamples = 0;
                }

                if (td.td_extrasamples != 0)
                {
                    td.td_sampleinfo    = new ExtraSample[1];
                    td.td_sampleinfo[0] = ExtraSample.ASSOCALPHA;
                }
                break;

            case TiffTag.TILEWIDTH:
                v32 = value[0].ToInt();
                if ((v32 % 16) != 0)
                {
                    if (tif.m_mode != Tiff.O_RDONLY)
                    {
                        badvalue32 = true;
                        break;
                    }

                    Tiff.WarningExt(tif, tif.m_clientdata, tif.m_name,
                                    "Nonstandard tile width {0}, convert file", v32);
                }
                td.td_tilewidth = v32;
                tif.m_flags    |= TiffFlags.ISTILED;
                break;

            case TiffTag.TILELENGTH:
                v32 = value[0].ToInt();
                if ((v32 % 16) != 0)
                {
                    if (tif.m_mode != Tiff.O_RDONLY)
                    {
                        badvalue32 = true;
                        break;
                    }

                    Tiff.WarningExt(tif, tif.m_clientdata, tif.m_name,
                                    "Nonstandard tile length {0}, convert file", v32);
                }
                td.td_tilelength = v32;
                tif.m_flags     |= TiffFlags.ISTILED;
                break;

            case TiffTag.TILEDEPTH:
                v32 = value[0].ToInt();
                if (v32 == 0)
                {
                    badvalue32 = true;
                    break;
                }

                td.td_tiledepth = v32;
                break;

            case TiffTag.DATATYPE:
                v = value[0].ToInt();
                SampleFormat sf = SampleFormat.VOID;
                switch (v)
                {
                case DATATYPE_VOID:
                    sf = SampleFormat.VOID;
                    break;

                case DATATYPE_INT:
                    sf = SampleFormat.INT;
                    break;

                case DATATYPE_UINT:
                    sf = SampleFormat.UINT;
                    break;

                case DATATYPE_IEEEFP:
                    sf = SampleFormat.IEEEFP;
                    break;

                default:
                    badvalue = true;
                    break;
                }

                if (!badvalue)
                {
                    td.td_sampleformat = sf;
                }

                break;

            case TiffTag.SAMPLEFORMAT:
                v  = value[0].ToInt();
                sf = (SampleFormat)v;
                if (sf < SampleFormat.UINT || SampleFormat.COMPLEXIEEEFP < sf)
                {
                    badvalue = true;
                    break;
                }

                td.td_sampleformat = sf;

                // Try to fix up the SWAB function for complex data.
                if (td.td_sampleformat == SampleFormat.COMPLEXINT &&
                    td.td_bitspersample == 32 && tif.m_postDecodeMethod == Tiff.PostDecodeMethodType.pdmSwab32Bit)
                {
                    tif.m_postDecodeMethod = Tiff.PostDecodeMethodType.pdmSwab16Bit;
                }
                else if ((td.td_sampleformat == SampleFormat.COMPLEXINT ||
                          td.td_sampleformat == SampleFormat.COMPLEXIEEEFP) &&
                         td.td_bitspersample == 64 && tif.m_postDecodeMethod == Tiff.PostDecodeMethodType.pdmSwab64Bit)
                {
                    tif.m_postDecodeMethod = Tiff.PostDecodeMethodType.pdmSwab32Bit;
                }
                break;

            case TiffTag.IMAGEDEPTH:
                td.td_imagedepth = value[0].ToInt();
                break;

            case TiffTag.SUBIFD:
                if ((tif.m_flags & TiffFlags.INSUBIFD) != TiffFlags.INSUBIFD)
                {
                    td.td_nsubifd = value[0].ToInt();
                    Tiff.setLong8Array(out td.td_subifd, value[1].TolongArray(), td.td_nsubifd);
                }
                else
                {
                    Tiff.ErrorExt(tif, tif.m_clientdata, module,
                                  "{0}: Sorry, cannot nest SubIFDs", tif.m_name);
                    status = false;
                }
                break;

            case TiffTag.YCBCRPOSITIONING:
                td.td_ycbcrpositioning = (YCbCrPosition)value[0].ToShort();
                break;

            case TiffTag.YCBCRSUBSAMPLING:
                td.td_ycbcrsubsampling[0] = value[0].ToShort();
                td.td_ycbcrsubsampling[1] = value[1].ToShort();
                break;

            case TiffTag.TRANSFERFUNCTION:
                v = ((td.td_samplesperpixel - td.td_extrasamples) > 1 ? 3 : 1);
                for (int i = 0; i < v; i++)
                {
                    Tiff.setShortArray(out td.td_transferfunction[i], value[0].ToShortArray(), 1 << td.td_bitspersample);
                }
                break;

            case TiffTag.REFERENCEBLACKWHITE:
            {
                float[] fa = value[0].ToFloatArray();
                if (fa == null)
                {
                    badvalue = true;
                    break;
                }

                Tiff.setFloatArray(out td.td_refblackwhite, fa, 6);
            }
            break;

            case TiffTag.INKNAMES:
                v = value[0].ToInt();
                string s = value[1].ToString();
                v      = checkInkNamesString(tif, v, s);
                status = v > 0;
                if (v > 0)
                {
                    setNString(out td.td_inknames, s, v);
                    td.td_inknameslen = v;
                }
                break;

            default:
                // This can happen if multiple images are open with
                // different codecs which have private tags. The global tag
                // information table may then have tags that are valid for
                // one file but not the other. If the client tries to set a
                // tag that is not valid for the image's codec then we'll
                // arrive here. This happens, for example, when tiffcp is
                // used to convert between compression schemes and
                // codec-specific tags are blindly copied.
                TiffFieldInfo fip = tif.FindFieldInfo(tag, TiffType.ANY);
                if (fip == null || fip.Bit != FieldBit.Custom)
                {
                    Tiff.ErrorExt(tif, tif.m_clientdata, module,
                                  "{0}: Invalid {1}tag \"{2}\" (not supported by codec)",
                                  tif.m_name, Tiff.isPseudoTag(tag) ? "pseudo-" : string.Empty,
                                  fip != null ? fip.Name : "Unknown");
                    status = false;
                    break;
                }

                // Find the existing entry for this custom value.
                int tvIndex = -1;
                for (int iCustom = 0; iCustom < td.td_customValueCount; iCustom++)
                {
                    if (td.td_customValues[iCustom].info.Tag == tag)
                    {
                        tvIndex = iCustom;
                        td.td_customValues[iCustom].value = null;
                        break;
                    }
                }

                // Grow the custom list if the entry was not found.
                if (tvIndex == -1)
                {
                    td.td_customValueCount++;
                    TiffTagValue[] new_customValues = Tiff.Realloc(
                        td.td_customValues, td.td_customValueCount - 1, td.td_customValueCount);
                    td.td_customValues = new_customValues;

                    tvIndex = td.td_customValueCount - 1;
                    td.td_customValues[tvIndex].info  = fip;
                    td.td_customValues[tvIndex].value = null;
                    td.td_customValues[tvIndex].count = 0;
                }

                // Set custom value ... save a copy of the custom tag value.
                int tv_size = Tiff.dataSize(fip.Type);
                if (tv_size == 0)
                {
                    status = false;
                    Tiff.ErrorExt(tif, tif.m_clientdata, module,
                                  "{0}: Bad field type {1} for \"{2}\"",
                                  tif.m_name, fip.Type, fip.Name);
                    end = true;
                    break;
                }

                int paramIndex = 0;
                if (fip.PassCount)
                {
                    if (fip.WriteCount == TiffFieldInfo.Variable2)
                    {
                        td.td_customValues[tvIndex].count = value[paramIndex++].ToInt();
                    }
                    else
                    {
                        td.td_customValues[tvIndex].count = value[paramIndex++].ToInt();
                    }
                }
                else if (fip.WriteCount == TiffFieldInfo.Variable ||
                         fip.WriteCount == TiffFieldInfo.Variable2)
                {
                    td.td_customValues[tvIndex].count = 1;
                }
                else if (fip.WriteCount == TiffFieldInfo.Spp)
                {
                    td.td_customValues[tvIndex].count = td.td_samplesperpixel;
                }
                else
                {
                    td.td_customValues[tvIndex].count = fip.WriteCount;
                }

                if (fip.Type == TiffType.ASCII)
                {
                    string ascii;
                    Tiff.setString(out ascii, value[paramIndex++].ToString());
                    td.td_customValues[tvIndex].value = Tiff.Latin1Encoding.GetBytes(ascii);
                }
                else
                {
                    td.td_customValues[tvIndex].value = new byte[tv_size * td.td_customValues[tvIndex].count];
                    if ((fip.PassCount ||
                         fip.WriteCount == TiffFieldInfo.Variable ||
                         fip.WriteCount == TiffFieldInfo.Variable2 ||
                         fip.WriteCount == TiffFieldInfo.Spp ||
                         td.td_customValues[tvIndex].count > 1) &&
                        fip.Tag != TiffTag.PAGENUMBER &&
                        fip.Tag != TiffTag.HALFTONEHINTS &&
                        fip.Tag != TiffTag.YCBCRSUBSAMPLING &&
                        fip.Tag != TiffTag.DOTRANGE)
                    {
                        byte[] apBytes = value[paramIndex++].GetBytes();
                        Buffer.BlockCopy(apBytes, 0, td.td_customValues[tvIndex].value, 0, Math.Min(apBytes.Length, td.td_customValues[tvIndex].value.Length));
                    }
                    else
                    {
                        // XXX: The following loop required to handle
                        // PAGENUMBER, HALFTONEHINTS,
                        // YCBCRSUBSAMPLING and DOTRANGE tags.
                        // These tags are actually arrays and should be
                        // passed as arrays to SetField() function, but
                        // actually passed as a list of separate values.
                        // This behavior must be changed in the future!

                        // Upd: This loop also processes some EXIF tags with
                        // UNDEFINED type (like EXIF_FILESOURCE or EXIF_SCENETYPE)
                        // In this case input value is string-based, so
                        // in TiffType.UNDEFINED case we use FieldValue.GetBytes()[0]
                        // construction instead of direct call of FieldValue.ToByte() method.
                        byte[] val    = td.td_customValues[tvIndex].value;
                        int    valPos = 0;
                        for (int i = 0; i < td.td_customValues[tvIndex].count; i++, valPos += tv_size)
                        {
                            switch (fip.Type)
                            {
                            case TiffType.UNDEFINED:
                                val[valPos] = value[paramIndex + i].GetBytes()[0];
                                break;

                            case TiffType.BYTE:
                                val[valPos] = value[paramIndex + i].ToByte();
                                break;

                            case TiffType.SBYTE:
                                val[valPos] = (byte)value[paramIndex + i].ToSByte();
                                break;

                            case TiffType.SHORT:
                                Buffer.BlockCopy(BitConverter.GetBytes(value[paramIndex + i].ToUShort()), 0, val, valPos, tv_size);
                                break;

                            case TiffType.SSHORT:
                                Buffer.BlockCopy(BitConverter.GetBytes(value[paramIndex + i].ToShort()), 0, val, valPos, tv_size);
                                break;

                            case TiffType.LONG:
                            case TiffType.IFD:
                                Buffer.BlockCopy(BitConverter.GetBytes(value[paramIndex + i].ToUInt()), 0, val, valPos, tv_size);
                                break;

                            case TiffType.SLONG:
                                Buffer.BlockCopy(BitConverter.GetBytes(value[paramIndex + i].ToInt()), 0, val, valPos, tv_size);
                                break;

                            case TiffType.RATIONAL:
                            case TiffType.SRATIONAL:
                            case TiffType.FLOAT:
                                Buffer.BlockCopy(BitConverter.GetBytes(value[paramIndex + i].ToFloat()), 0, val, valPos, tv_size);
                                break;

                            case TiffType.DOUBLE:
                                Buffer.BlockCopy(BitConverter.GetBytes(value[paramIndex + i].ToDouble()), 0, val, valPos, tv_size);
                                break;

                            default:
                                Array.Clear(val, valPos, tv_size);
                                status = false;
                                break;
                            }
                        }
                    }
                }
                break;
            }

            if (!end && !badvalue && !badvalue32)
            {
                if (status)
                {
                    tif.setFieldBit(tif.FieldWithTag(tag).Bit);
                    tif.m_flags |= TiffFlags.DIRTYDIRECT;
                }
            }

            if (badvalue)
            {
                Tiff.ErrorExt(tif, tif.m_clientdata, module,
                              "{0}: Bad value {1} for \"{2}\" tag",
                              tif.m_name, v, tif.FieldWithTag(tag).Name);
                return(false);
            }

            if (badvalue32)
            {
                Tiff.ErrorExt(tif, tif.m_clientdata, module,
                              "{0}: Bad value {1} for \"{2}\" tag",
                              tif.m_name, v32, tif.FieldWithTag(tag).Name);
                return(false);
            }

            return(status);
        }