コード例 #1
0
        /// <summary> Measure the text using the default font of indicated graphics context. </summary>
        /// <param name="display"> The display pointer, that specifies the connection to the X server. <see cref="IntPtr"/> </param>
        /// <param name="gc"> The crapchics context to use for measuring. <see cref="IntPtr"/> </param>
        /// <param name="text"> The text to measure. <see cref="X11.TChar[]"/> </param>
        /// <returns> The measured size of the indicated text. <see cref="TSize"/> </returns>
        public virtual TSize MeasureTextLine(IntPtr display, IntPtr gc, X11.TChar[] text)
        {
            TSize result = new TSize(5, 5);

            if (display == IntPtr.Zero)
            {
                Console.WriteLine(CLASS_NAME + "::MeasureTextLine () ERROR: Argument null: display");
                return(result);
            }
            if (gc == IntPtr.Zero)
            {
                Console.WriteLine(CLASS_NAME + "::MeasureTextLine () ERROR: Argument null: gc");
                return(result);
            }

            TInt gcID = X11lib.XGContextFromGC(gc);

            if (gcID != 0)
            {
                TInt direction   = 0;
                TInt fontAscent  = 0;
                TInt fontDescent = 0;
                X11lib.XCharStruct xCharStruct = new X11lib.XCharStruct();

                X11lib.XQueryTextExtents(display, gcID, text, (X11.TInt)text.Length, ref direction, ref fontAscent, ref fontDescent, ref xCharStruct);
                result.Width  = (int)xCharStruct.width;
                result.Height = (int)fontAscent + (int)fontDescent;
            }
            else
            {
                Console.WriteLine(CLASS_NAME + "::MeasureTextLine () ERROR: Cannot investigate default font ressource ID of underlaying graphics context.");
            }
            return(result);
        }
コード例 #2
0
        /// <summary> Calculate the preferred size acting like a HBox. </summary>
        /// <returns> The preferred size. <see cref="TIntSize"/> </returns>
        private TSize PreferredSizeHBox()
        {
            TSize preferredSize = new TSize(0, 0);

            for (int counter = 0; counter < _children.Count; counter++)
            {
                TSize childPreferredSize = _children[counter].PreferredSize();
                if ((int)childPreferredSize.Width > 0)
                {
                    preferredSize.Width = preferredSize.Width + childPreferredSize.Width;
                }
                if ((int)childPreferredSize.Height > 0)
                {
                    preferredSize.Height = Math.Max(preferredSize.Height, childPreferredSize.Height);
                }

                if (counter > 0)
                {
                    preferredSize.Width = preferredSize.Width + _horzSpacing;
                }
            }
            preferredSize.Width  = preferredSize.Width + _borderWidth * 2 + _frameWidth * 2;
            preferredSize.Height = preferredSize.Height + _borderWidth * 2 + _frameWidth * 2;

            return(preferredSize);
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("SizeId,TypeSize")] TSize tSize)
        {
            if (id != tSize.SizeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tSize);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TSizeExists(tSize.SizeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tSize));
        }
コード例 #4
0
            protected override T GetFirst()
            {
                Interval <T, TSize> interval = _interval;

                // When anchor is set, start the interval at the next anchor position.
                if (_isAnchorSet)
                {
                    TSize anchorDiff = Operator <T, TSize> .Subtract(_interval.Start, _anchor);

                    double stepSize = ConvertSizeToDouble(_step);
                    double diff     = Math.Abs(ConvertSizeToDouble(anchorDiff)) % stepSize;
                    if (diff > 0)
                    {
                        if (_anchor.CompareTo(_interval.Start) < 0)
                        {
                            diff = stepSize - diff;
                        }
                        TSize addition = ConvertDoubleToSize(diff);
                        interval = new Interval <T, TSize>(
                            Operator <T, TSize> .AddSize(_interval.Start, addition), true,
                            _interval.End, _interval.IsEndIncluded);
                    }
                }

                // When first value doesn't lie in interval, immediately step.
                return(interval.IsStartIncluded ? interval.Start : Operator <T, TSize> .AddSize(interval.Start, _step));
            }
コード例 #5
0
 /// <summary> updates the current bracket then moves to the next lower one
 /// </summary>
 /// <param name="t"> Current bracket size</param>
 private void scanArray2(TSize t)
 {
     /* //String a = GetControlSummary( Parent, 0 );
      * TourneyMatchUp[] temp = null;
      * switch (t) {
      *   case TSize.St:
      *       temp = getArray( TSize.St );
      *       updateArray( temp, getArray( TSize.Q ), 4 );
      *       //orderAndSet( temp, 4 );
      *       scanArray( TSize.Q );
      *       break;
      *   case TSize.Q:
      *       temp = getArray( TSize.Q );
      *       updateArray( temp, getArray( TSize.S ), 3 );
      *       //orderAndSet( temp, 3 );
      *       scanArray( TSize.S );
      *       break;
      *   case TSize.S:
      *       temp = getArray( TSize.S );
      *       updateArray( temp, getArray( TSize.F ), 2 );
      *       //orderAndSet( temp, 2 );
      *       scanArray( TSize.F );
      *       break;
      *   case TSize.F:
      *       temp = getArray( TSize.F );
      *       updateArray( temp, TourneyWinner );
      *       //orderAndSet( temp, 1 );
      *       break;
      * }*/
     //Parent.Invalidate();
 }
コード例 #6
0
        /// <summary> Calcualate layout after a position or size change. </summary>
        /// <param name="assignedPosition"> The position of the top left top corner assigned by the window manager (for shell widgets) or geometry management (by non-shell widgets). <see cref="TPoint"/> </param>
        /// <param name="availableSize"> The available size. <see cref="TIntSize"/> </param>
        /// <remarks> This method is defined at XrwRectObj for compatibility, but must be implemented for composite widgets only. </remarks>
        public override void CalculateChildLayout(TPoint assignedPosition, TSize availableSize)
        {
            int    borderAndFrame = _borderWidth + _frameWidth;
            TPoint childPosition  = new TPoint(assignedPosition.X + borderAndFrame,
                                               assignedPosition.Y + borderAndFrame);

            for (int counter = 0; counter < _children.Count; counter++)
            {
                TSize preferredSize = _children[counter].PreferredSize();

                if (_children[counter].ExpandToAvailableWidth == true)
                {
                    if (preferredSize.Width < availableSize.Width - borderAndFrame - borderAndFrame)
                    {
                        preferredSize.Width = availableSize.Width - borderAndFrame - borderAndFrame;
                    }
                }
                if (_children[counter].ExpandToAvailableHeight == true)
                {
                    if (preferredSize.Height < availableSize.Height - borderAndFrame - borderAndFrame)
                    {
                        preferredSize.Height = availableSize.Height - borderAndFrame - borderAndFrame;
                    }
                }

                GeometryManagerAccess.SetAssignedGeometry(_children[counter], childPosition, preferredSize);
            }
        }
コード例 #7
0
        // ###############################################################################
        // ### M E T H O D S
        // ###############################################################################

        #region XrwRectObj overrides

        /// <summary> Calculate the preferred size. </summary>
        /// <returns> The preferred size. <see cref="TIntSize"/> </returns>
        public override TSize PreferredSize()
        {
            TSize preferredSize = new TSize(_borderWidth * 2, _borderWidth * 2);

            for (int counter = 0; counter < _children.Count; counter++)
            {
                TSize childPreferredSize = _children[counter].PreferredSize();
                if ((int)childPreferredSize.Width > 0)
                {
                    preferredSize.Width = Math.Max(preferredSize.Width, childPreferredSize.Width);
                }
                if ((int)childPreferredSize.Height > 0)
                {
                    preferredSize.Height = preferredSize.Height + childPreferredSize.Height;
                }

                if (counter > 0)
                {
                    preferredSize.Height = preferredSize.Height + _vertSpacing;
                }
            }
            preferredSize.Width  = preferredSize.Width + _borderWidth * 2 + _frameWidth * 2;
            preferredSize.Height = preferredSize.Height + _borderWidth * 2 + _frameWidth * 2;

            return(preferredSize);
        }
コード例 #8
0
        // ###############################################################################
        // ### M E T H O D S
        // ###############################################################################

        #region XrwRectObj overrides

        /// <summary> Calculate the preferred size. </summary>
        /// <returns> The preferred size. <see cref="TSize"/> </returns>
        public override TSize PreferredSize()
        {
            TSize textMeasure   = _lines.Measure(new TSize(0, _space * 2));
            TSize preferredSize = new TSize(Math.Max(MIN_WIDTH + _borderWidth * 2 + _frameWidth * 2 + _leftMargin + _rightMargin,
                                                     textMeasure.Width + _borderWidth * 2 + _frameWidth * 2 + _leftMargin + _rightMargin),
                                            Math.Max(MIN_HEIGHT + _borderWidth * 2 + _frameWidth * 2,
                                                     textMeasure.Height + _borderWidth * 2 + _frameWidth * 2));

            TSize bitmapMeasure = new TSize(0, 0);

            if (_offBitmap != null)
            {
                bitmapMeasure.Width  = _offBitmap.Width + _space;
                bitmapMeasure.Height = Math.Max(preferredSize.Height, _offBitmap.Height + _space * 2 + _borderWidth * 2 + _frameWidth * 2);
            }
            if (_onBitmap != null)
            {
                bitmapMeasure.Width  = Math.Max(bitmapMeasure.Width, _onBitmap.Width + _space);
                bitmapMeasure.Height = Math.Max(bitmapMeasure.Height, Math.Max(preferredSize.Height, _onBitmap.Height + _space * 2 + _borderWidth * 2 + _frameWidth * 2));
            }
            preferredSize.Width += bitmapMeasure.Width;
            preferredSize.Height = Math.Max(preferredSize.Height, bitmapMeasure.Height);

            if (_fixedSize.Width >= 0 && _fixedSize.Width > MIN_WIDTH)
            {
                preferredSize.Width = _fixedSize.Width + _borderWidth * 2 + _frameWidth * 2 + _leftMargin + _rightMargin;
            }

            if (_fixedSize.Height >= 0 && _fixedSize.Height > MIN_HEIGHT)
            {
                preferredSize.Height = _fixedSize.Height + _borderWidth * 2 + _frameWidth * 2;
            }

            return(preferredSize);
        }
コード例 #9
0
        /// <summary> Draw text with current font of indicated graphics context. </summary>
        /// <param name="display"> The display pointer, that specifies the connection to the X server. <see cref="IntPtr"/> </param>
        /// <param name="window"> The window to draw on. <see cref="IntPtr"/> </param>
        /// <param name="gc"> The graphics context to use for drawing. <see cref="IntPtr"/> </param>
        /// <param name="text"> The tyt to draw. <see cref="X11.TChar[]"/> </param>
        /// <param name="area"> The area to draw within. <see cref="Rectangle"/> </param>
        /// <param name="horzAlign"> The horizontal alignment (0.5F is centered). <see cref="XFloat"/> </param>
        /// <param name="vertAlign"> The vertical alignment (0.5F is centered). <see cref="XFloat"/> </param>
        public virtual void DrawTextLine(IntPtr display, IntPtr window, IntPtr gc, X11.TChar[] text, X11.TRectangle area, float horzAlign, float vertAlign)
        {
            if (display == IntPtr.Zero)
            {
                Console.WriteLine(CLASS_NAME + "::DrawTextLine () ERROR: Argument null: display");
                return;
            }
            if (window == IntPtr.Zero)
            {
                Console.WriteLine(CLASS_NAME + "::DrawTextLine () ERROR: Argument null: window");
                return;
            }
            if (gc == IntPtr.Zero)
            {
                Console.WriteLine(CLASS_NAME + "::DrawTextLine () ERROR: Argument null: gc");
                return;
            }

            if (horzAlign < 0.0F || horzAlign > 1.0F)
            {
                Console.WriteLine(CLASS_NAME + "::DrawTextLine () ERROR: Argument out of range (0.0 ... 1.0): horzAlign");
                if (horzAlign < 0.0F)
                {
                    horzAlign = 0.0F;
                }
                if (horzAlign > 1.0F)
                {
                    horzAlign = 1.0F;
                }
            }
            if (vertAlign < 0.0F || vertAlign > 1.0F)
            {
                Console.WriteLine(CLASS_NAME + "::DrawTextLine () ERROR: Argument out of range (0.0 ... 1.0): vertAlign");
                if (vertAlign < 0.0F)
                {
                    vertAlign = 0.0F;
                }
                if (vertAlign > 1.0F)
                {
                    vertAlign = 1.0F;
                }
            }

            TSize textMeasure = MeasureTextLine(display, gc, text);
            int   textX       = (int)((area.Width - textMeasure.Width) * horzAlign);

            if (textX < _borderWidth + 2)
            {
                textX = _borderWidth + 2;
            }
            if (textX > area.Width - textMeasure.Width - _borderWidth - 2)
            {
                textX = area.Width - textMeasure.Width - _borderWidth - 2;
            }

            int textY = (int)((area.Height - textMeasure.Height) * vertAlign) + (int)(textMeasure.Height * 0.85F);

            X11lib.XDrawString(display, window, gc, (TInt)((int)area.Left + (int)textX), (TInt)((int)area.Top + (int)textY), text, (X11.TInt)text.Length);
        }
コード例 #10
0
        /// <summary> Initializing constructor. </summary>
        /// <param name="display">The display pointer, that specifies the connection to the X server. <see cref="System.IntPtr"/> </param>
        /// <param name="screenNumber"> The appropriate screen number on the host server. <see cref="System.Int32"/> </param>
        /// <param name="parentWindow"> The X11 *** parent *** window for X11 calls. This widget has no X11 *** own *** window. <see cref="System.IntPtr"/> </param>
        /// <param name="fixedSize"> The fixed size, that ist to use (if set) rather than the calcualated size. Passed as reference to avoid structure copy constructor calls. <see cref="TIntSize"/> </param>
        /// <param name="label"> The label to display. <see cref="System.String"/> </param>
        /// <param name="leftBitmap"> The left bitmap to display. <see cref="XrwBitmap"/> </param>
        /// <param name="leftShared"> Indicate wether the leftBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param>
        /// <param name="rightBitmap"> The right bitmap to display. <see cref="XrwBitmap"/> </param>
        /// <param name="rightShared"> Indicate wether the rightBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param>
        public XrwCommand(IntPtr display, X11.TInt screen, IntPtr parentWindow, ref TSize fixedSize, string label, X11Graphic leftBitmap, bool leftShared, X11Graphic rightBitmap, bool rightShared)
            : base(display, screen, parentWindow, ref fixedSize, label, leftBitmap, leftShared, rightBitmap, rightShared)
        {
            // Create a *** own *** window and exchange the *** parent ***  window against it.
            base.InitializeOwnWindow();

            InitializeCommandRessources();
        }
コード例 #11
0
        /// <summary> Initializing constructor. </summary>
        /// <param name="display">The display pointer, that specifies the connection to the X server. <see cref="System.IntPtr"/> </param>
        /// <param name="screenNumber"> The appropriate screen number on the host server. <see cref="System.Int32"/> </param>
        /// <param name="parentWindow"> The X11 *** parent *** window for X11 calls. This widget has no X11 *** own *** window. <see cref="System.IntPtr"/> </param>
        /// <param name="fixedSize"> The fixed size, that ist to use (if set) rather than the calcualated size. Passed as reference to avoid structure copy constructor calls. <see cref="TIntSize"/> </param>
        /// <param name="label"> The label to display. <see cref="System.String"/> </param>
        public XrwLabel(IntPtr display, X11.TInt screen, IntPtr parentWindow, ref TSize fixedSize, string label)
            : base(display, screen, parentWindow, ref fixedSize)
        {
            _label = label;
            _lines = new Multiline(this, _label);

            InitializeLabelRessources();
        }
コード例 #12
0
 public static void RequestSize(TSize size)
 {
     if (size.NotNull())
     {
         size.Width  = (size.Columns * MiniSize.Width);
         size.Height = (size.Rows * MiniSize.Height);
     }
 }
コード例 #13
0
        /// <summary> Initializing constructor. </summary>
        /// <param name="display">The display pointer, that specifies the connection to the X server. <see cref="IntPtr"/> </param>
        /// <param name="screenNumber"> The appropriate screen number on the host server. <see cref="System.Int32"/> </param>
        /// <param name="parentWindow"> The X11 *** parent *** window that will be the parent for an X11 *** own ** window. <see cref="IntPtr"/> </param>
        /// <param name="fixedSize"> The fixed size, that ist to use (if set) rather than the calcualated size. <see cref="TIntSize"/> </param>
        /// <param name="label"> The label to display. <see cref="System.String"/> </param>
        public XrwCommand(IntPtr display, X11.TInt screen, IntPtr parentWindow, ref TSize fixedSize, string label)
            : base(display, screen, parentWindow, ref fixedSize, label)
        {
            // Create a *** own *** window and exchange the *** parent ***  window against it.
            base.InitializeOwnWindow();

            InitializeCommandRessources();
        }
コード例 #14
0
        /// <summary> Initializing constructor. </summary>
        /// <param name="parent"> The parent (associated top-level) shell (an override shell can't be a top-level shell. <see cref="IntPtr"/> </param>
        /// <param name="fixedSize"> The fixed size, that ist to use (if set) rather than the calcualated size. Passed as reference to avoid structure copy constructor calls. <see cref="TSize"/> </param>
        public XrwOverrideShell(XrwApplicationShell parent, ref TSize fixedSize)
            : base(parent.Display, parent.Screen, parent.Window, ref fixedSize)
        {
            _parent = parent;

            TPoint assignedPosition = new TPoint(0, 0);

            InitializeOverrideShellResources(ref assignedPosition);
        }
コード例 #15
0
 /// <summary> Calcualate layout after a position or size change. </summary>
 /// <param name="assignedPosition"> The position of the top left top corner assigned by the window manager (for shell widgets) or geometry management (by non-shell widgets). <see cref="TPoint"/> </param>
 /// <param name="availableSize"> The available size. <see cref="TIntSize"/> </param>
 /// <remarks> This method is defined at XrwRectObj for compatibility, but must be implemented for composite widgets only. </remarks>
 public override void CalculateChildLayout(TPoint assignedPosition, TSize availableSize)
 {
     if (_orientation == TOrientation.Horizontal)
     {
         CalculateChildLayoutHBox(assignedPosition, availableSize);
     }
     else
     {
         CalculateChildLayoutVBox(assignedPosition, availableSize);
     }
 }
コード例 #16
0
        public async Task <IActionResult> Create([Bind("SizeId,TypeSize")] TSize tSize)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tSize);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tSize));
        }
コード例 #17
0
ファイル: HiveBase.cs プロジェクト: ggeurts/nhive
            public static TSize LinearSpeed <TInput>(TInput begin, TInput end)
                where TInput : struct, IInputIterator <T, TSize, TInput>
            {
                TSize count = Size.Zero;

                for (TInput i = begin; !i.Equals(end); i.Increment())
                {
                    Size.Increment(ref count);
                }
                return(count);
            }
コード例 #18
0
        /// <summary> Get the measured text size in pixel. </summary>
        /// <param name="summand"> The size to add. <see cref="TSize"/> </param>
        /// <returns> The measured text size in pixel. <see cref="TSize"/> </returns>
        public TSize Measure(TSize summand)
        {
            TSize textMeasure = new TSize(0, 0);

            for (int cntLines = 0; cntLines < this.Count; cntLines++)
            {
                textMeasure.Width   = Math.Max(textMeasure.Width, this[cntLines].WidthInPixel);
                textMeasure.Height += this[cntLines].HeightInPixel;
            }
            textMeasure.Add(summand);
            return(textMeasure);
        }
コード例 #19
0
        /// <summary> Initializing constructor. </summary>
        /// <param name="display">The display pointer, that specifies the connection to the X server. <see cref="System.IntPtr"/> </param>
        /// <param name="screenNumber"> The appropriate screen number on the host server. <see cref="System.Int32"/> </param>
        /// <param name="parentWindow"> The X11 *** parent *** window for X11 calls. This widget has no X11 *** own *** window. <see cref="System.IntPtr"/> </param>
        /// <param name="fixedSize"> The fixed size, that ist to use (if set) rather than the calcualated size. Passed as reference to avoid structure copy constructor calls. <see cref="TIntSize"/> </param>
        /// <param name="label"> The label to display. <see cref="System.String"/> </param>
        /// <param name="leftBitmap"> The left bitmap to display. <see cref="XrwBitmap"/> </param>
        /// <param name="leftShared"> Indicate wether the leftBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param>
        /// <param name="rightBitmap"> The right bitmap to display. <see cref="XrwBitmap"/> </param>
        /// <param name="rightShared"> Indicate wether the rightBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param>
        public XrwLabel(IntPtr display, X11.TInt screen, IntPtr parentWindow, ref TSize fixedSize, string label, X11Graphic leftBitmap, bool leftShared, X11Graphic rightBitmap, bool rightShared)
            : base(display, screen, parentWindow, ref fixedSize)
        {
            _label             = label;
            _lines             = new Multiline(this, _label);
            _leftBitmap        = leftBitmap;
            _leftBitmapShared  = leftShared;
            _rightBitmap       = rightBitmap;
            _rightBitmapShared = rightShared;

            InitializeLabelRessources();
        }
 public Enumerator(
     IInterval <T, TSize> interval, TSize step,
     Func <T, T, TSize> subtract,
     Func <T, TSize, T> addSize,
     Func <TSize, double> convertSizeToDouble,
     Func <double, TSize> convertDoubeToSize,
     Func <T, bool, T, bool, IInterval <T, TSize> > createInstance,
     T anchorAt)
     : this(interval, step, subtract, addSize, convertSizeToDouble, convertDoubeToSize, createInstance)
 {
     _isAnchorSet = true;
     _anchor      = anchorAt;
 }
コード例 #21
0
        // ToDo: Clip
        protected void DrawTextLines(Multiline lines, TRectangle clientArea, float horzTextAlign, float vertTextAlign)
        {
            int        FUZZY         = 4;                            // Avoid line hiding on rounding errors.
            int        drawableLines = lines.CompleteDrawableLines(clientArea.Height + FUZZY);
            TSize      textMeasure   = lines.Measure(0, drawableLines - 1);
            int        extraHeight   = (int)((clientArea.Height - textMeasure.Height) * vertTextAlign);
            TRectangle lineArea      = new TRectangle(clientArea.X, clientArea.Y + extraHeight, clientArea.Width, 0);

            for (int cntLines = 0; cntLines < drawableLines; cntLines++)
            {
                DrawTextLine(_display, _window, _gc, lines[cntLines].Text, lineArea, horzTextAlign, 0.0F);
                lineArea.Y += lines[cntLines].HeightInPixel;
            }
        }
コード例 #22
0
        /// <summary> Initializing constructor. </summary>
        /// <param name="fixedSize"> The fixed size, that ist to use (if set) rather than the calcualated size. Passed as reference to avoid structure copy constructor calls. <see cref="TSize"/> </param>
        public XrwRectObj(ref TSize fixedSize)
        {
            if (fixedSize.Width < MIN_WIDTH)
            {
                Console.WriteLine(CLASS_NAME + "::Ctr () WARNING: The width must be greater or equal MIN_WIDTH.");
                fixedSize.Width = MIN_WIDTH;
            }
            if (fixedSize.Height < MIN_HEIGHT)
            {
                Console.WriteLine(CLASS_NAME + "::Ctr () WARNING: The height must be greater or equal MIN_HEIGHT.");
                fixedSize.Height = MIN_HEIGHT;
            }

            _fixedSize = fixedSize;
        }
コード例 #23
0
ファイル: StreamBuffer.cs プロジェクト: ggeurts/nhive
 public void CopyTo(T[] array, TSize arrayIndex)
 {
     if (typeof(TSize) == typeof(int))
     {
         Array.Copy(_items, 0, array, Size.ToInt32(arrayIndex), _count);
     }
     else
     {
         long targetIndex = Size.ToInt64(arrayIndex);
         for (int i = 0; i < _count; i++, targetIndex++)
         {
             array[targetIndex] = _items[i];
         }
     }
 }
コード例 #24
0
        /// <summary> Initializing constructor. </summary>
        /// <param name="display">The display pointer, that specifies the connection to the X server. <see cref="System.IntPtr"/> </param>
        /// <param name="screenNumber"> The appropriate screen number on the host server. <see cref="System.Int32"/> </param>
        /// <param name="parentWindow"> The X11 *** parent *** window for X11 calls. This widget has no X11 *** own *** window. <see cref="System.IntPtr"/> </param>
        /// <param name="fixedSize"> The fixed size, that ist to use (if set) rather than the calcualated size. Passed as reference to avoid structure copy constructor calls. <see cref="TIntSize"/> </param>
        /// <param name="label"> The label to display. <see cref="System.String"/> </param>
        /// <param name="offBitmap"> The right bitmap to display. <see cref="XrwBitmap"/> </param>
        /// <param name="offShared"> Indicate wether the offBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param>
        /// <param name="onBitmap"> The left bitmap to display. <see cref="XrwBitmap"/> </param>
        /// <param name="onShared"> Indicate wether the onBitmap is shared (desposed by caller) or private (disposed together with tis label). <see cref="System.Boolean"/> </param>
        public XrwToggle(IntPtr display, X11.TInt screen, IntPtr parentWindow, ref TSize fixedSize, string label, X11Graphic offBitmap, bool offShared, X11Graphic onBitmap, bool onShared)
            : base(display, screen, parentWindow, ref fixedSize)
        {
            _label           = label;
            _lines           = new Multiline(this, _label);
            _offBitmap       = offBitmap;
            _offBitmapShared = offShared;
            _onBitmap        = onBitmap;
            _onBitmapShared  = onShared;

            // Create a *** own *** window and exchange the *** parent ***  window against it.
            base.InitializeOwnWindow();

            InitializeToggleRessources();
        }
コード例 #25
0
        /// <summary> Get the measured text size in pixel. </summary>
        /// <param name="startLineIndex"> The zero based index of the first line to measure. <see cref="System.Int32"/> </param>
        /// <param name="endLineIndex"> The zero based index of the last line to measure. <see cref="System.Int32"/> </param>
        /// <returns> The measured text size in pixel. <see cref="TSize"/> </returns>
        public TSize Measure(int startLineIndex, int endLineIndex)
        {
            TSize textMeasure = new TSize(0, 0);

            if (startLineIndex >= this.Count || endLineIndex < startLineIndex)
            {
                return(textMeasure);
            }

            for (int cntLines = startLineIndex; cntLines <= endLineIndex; cntLines++)
            {
                textMeasure.Width   = Math.Max(textMeasure.Width, this[cntLines].WidthInPixel);
                textMeasure.Height += this[cntLines].HeightInPixel;
            }
            return(textMeasure);
        }
コード例 #26
0
        /// <summary> Calculate the preferred size. </summary>
        /// <returns> The preferred size. <see cref="TSize"/> </returns>
        public virtual TSize PreferredSize()
        {
            TSize preferredSize = new TSize(MIN_WIDTH + _borderWidth * 2, MIN_HEIGHT + _borderWidth * 2);

            if (_fixedSize.Width >= 0 && _fixedSize.Width > MIN_WIDTH)
            {
                preferredSize.Width = _fixedSize.Width + _borderWidth * 2;
            }

            if (_fixedSize.Height >= 0 && _fixedSize.Height > MIN_HEIGHT)
            {
                preferredSize.Height = _fixedSize.Height + _borderWidth * 2;
            }

            return(preferredSize);
        }
 /// <summary>
 /// Create a new enumerator which traverses across an interval in specified steps.
 /// </summary>
 /// <param name = "interval">The interval which to traverse.</param>
 /// <param name = "step">The steps to step forward each time.</param>
 public Enumerator(
     IInterval <T, TSize> interval, TSize step,
     Func <T, T, TSize> subtract,
     Func <T, TSize, T> addSize,
     Func <TSize, double> convertSizeToDouble,
     Func <double, TSize> convertDoubeToSize,
     Func <T, bool, T, bool, IInterval <T, TSize> > createInstance)
 {
     _interval            = interval;
     _step                = step;
     _subtract            = subtract;
     _addSize             = addSize;
     _convertSizeToDouble = convertSizeToDouble;
     _convertDoubleToSize = convertDoubeToSize;
     _createInstance      = createInstance;
 }
コード例 #28
0
        /// <summary> Set the assigned position and size, calculated by the geometry management. </summary>
        /// <param name="rectObj"> The rectangle object to set the assigned position and size for. <see cref="XrwRectObj"/> </param>
        /// <param name="position"> The assigned position to set. <see cref="TPoint"/> </param>
        /// <param name="size"> The assigned position to set. <see cref="TSize"/> </param>
        public static void SetAssignedGeometry(XrwRectObj rectObj, TPoint position, TSize size)
        {
            if (rectObj == null)
            {
                Console.WriteLine("GeometryManagerAccess::SetAssignedGeometry () ERROR: Argument null: rectObj");
                return;
            }

            // Fixed size always has priority!
            if (rectObj.IsFixedWidth == true)
            {
                size.Width = rectObj.FixedSize.Width;
            }
            if (rectObj.IsFixedWidth == true)
            {
                size.Height = rectObj.FixedSize.Height;
            }
            rectObj._assignedSize = size;

            if (rectObj.HasOwnWindow && (rectObj is XrwVisibleRectObj))
            {
                // Transfer the geometry to the underlaying window.
                XrwVisibleRectObj visibleRect = rectObj as XrwVisibleRectObj;
                if (visibleRect.Display != IntPtr.Zero && visibleRect.Window != IntPtr.Zero)
                {
                    // This call causes a ConfigureNotify event.
                    X11lib.XMoveResizeWindow(visibleRect.Display, visibleRect.Window, (TInt)position.X, (TInt)position.Y, (TUint)size.Width, (TUint)size.Height);
                    visibleRect._assignedPosition = new TPoint(0, 0);
                }
                else
                {
                    throw new AccessViolationException("XrwVisibleRectObj or inherited widget without display or window.");
                }
            }
            else
            {
                rectObj._assignedPosition = position;
            }

            // Child should be prevented from overwriting parent's border.
            size.Width  -= 2 * rectObj.BorderWidth;
            size.Height -= 2 * rectObj.BorderWidth;

            rectObj.CalculateChildLayout(position, size);
        }
コード例 #29
0
        // ###############################################################################
        // ### M E T H O D S
        // ###############################################################################

        #region XrwRectObj overrides

        /// <summary> Calculate the preferred size. </summary>
        /// <returns> The preferred size. <see cref="TIntSize"/> </returns>
        public override TSize PreferredSize()
        {
            TSize preferredSize = new TSize(0, 0);

            for (int counter = 0; counter < _children.Count; counter++)
            {
                TSize childPreferredSize = _children[counter].PreferredSize();
                if ((int)childPreferredSize.Width > preferredSize.Width)
                {
                    preferredSize.Width = childPreferredSize.Width;
                }
                if ((int)childPreferredSize.Height > preferredSize.Height)
                {
                    preferredSize.Height = childPreferredSize.Height;
                }
            }
            preferredSize.Width  = preferredSize.Width + _borderWidth * 2 + _frameWidth * 2;
            preferredSize.Height = preferredSize.Height + _borderWidth * 2 + _frameWidth * 2;

            return(preferredSize);
        }
コード例 #30
0
        /// <summary> Calcualate layout after a position or size change. </summary>
        /// <remarks> This method is defined at XrwRectObj for compatibility, but must be implemented for composite widgets only. </remarks>
        public void CalculateChildLayout()
        {
            TPoint childPosition = new TPoint(_borderWidth, _borderWidth);
            TSize  requestedSize = new TSize(0, 0);

            List <ChildData> childData = new List <ChildData>();

            for (int counter = 0; counter < _children.Count; counter++)
            {
                TSize preferredSize = _children[counter].PreferredSize();
                childData.Add(new ChildData(_children[counter], preferredSize));

                if (requestedSize.Width < preferredSize.Width)
                {
                    requestedSize.Width = preferredSize.Width;
                }
                requestedSize.Height += preferredSize.Height;
                if (counter > 0)
                {
                    requestedSize.Height += _vertSpacing;
                }
            }
            requestedSize.Width  = Math.Max(MIN_WIDTH, requestedSize.Width);
            requestedSize.Height = Math.Max(MIN_HEIGHT, requestedSize.Height);

            for (int counter = 0; counter < childData.Count; counter++)
            {
                ChildData cd = childData[counter];

                cd.Widget._assignedPosition.X = childPosition.X;
                cd.Widget._assignedPosition.Y = childPosition.Y;

                cd.Widget._assignedSize.Width  = requestedSize.Width;
                cd.Widget._assignedSize.Height = cd.Size.Height;

                childPosition.Y = childPosition.Y + cd.Size.Height + _vertSpacing;
            }
            this._assignedSize.Width  = requestedSize.Width + 2 * _borderWidth;
            this._assignedSize.Height = requestedSize.Height + 2 * _borderWidth;
        }