Exemple #1
0
        /// <summary>
        /// Initializes the designer with the component.
        /// </summary>
        /// <param name="component"></param>
        public override void Initialize(System.ComponentModel.IComponent component)
        {
            radioPanel = (MgRadioPanel)component;

            base.Initialize(component);

            ((MgRadioPanel)radioPanel).SelectedIndexChanged += control_SelectedIndexChanged;

            IComponentChangeService service = (IComponentChangeService)this.GetService(typeof(IComponentChangeService));

            if (service != null)
            {
                service.ComponentChanging += new ComponentChangingEventHandler(service_ComponentChanging);
            }
        }
Exemple #2
0
        /// <summary>
        /// Set the control specific properties.
        /// </summary>
        /// <param name="control"></param>
        internal override void setSpecificControlProperties(Control control)
        {
            MgRadioPanel radioPanel = ((MgRadioPanel)control);

            if (_refreshItemList)
            {
                GuiUtils.SetLayoutNumColumns(radioPanel, _columnsInRadio);
                GuiUtils.setItemsList(control, _itemList);
                _refreshItemList = false;
            }

            ControlUtils.SetStyle3D(radioPanel, Style);
            ControlUtils.SetBorderStyle(radioPanel, ControlBorderType);
            GuiUtils.SetRadioAppearance(control, _appearance);
            GuiUtils.SetImageToRadio(OrgImage, ImageFileName, radioPanel, CtrlImageStyle.Copied);
            ControlUtils.SetContentAlignment(radioPanel, ContentAlignment);
            GuiUtils.SetChecked(radioPanel, _selectionIdx);
            ControlUtils.SetMultiLine(radioPanel, MultiLine);

            ((TagData)radioPanel.Tag).Tooltip = Tooltip;

            GuiUtils.resumeLayout(control, true);
            GuiUtils.performLayout(control);
        }
Exemple #3
0
            /// <summary>
            /// </summary>
            /// <param name = "container"></param>
            /// <param name = "layoutEventArgs"></param>
            /// <returns></returns>
            public override bool Layout(object container, LayoutEventArgs layoutEventArgs)
            {
                Control parent = container as Control;

                if (parent.Controls.Count == 0)
                {
                    return(false);
                }
                Size          clientRect         = ((Panel)container).Size;
                int           radioLineSeperator = 0;
                int           radioColSeperator  = 0;
                MgRadioButton radioButton        = (MgRadioButton)parent.Controls[0];
                Boolean       isAppearanceButton = (radioButton.Appearance == Appearance.Button);
                int           radionInColumn     = getCountOfButtonsInColumn(parent.Controls.Count, isAppearanceButton);

                Rectangle radioRect = new Rectangle(0, 0, 0, 0);

                if (parent.Controls.Count == 1)
                {
                    radioButton.SetBounds(0, 0, clientRect.Width, clientRect.Height);
                }
                else
                {
                    int i      = 0;
                    int width  = 0;
                    int height = 0;

                    int numColumns = _numColumns;

                    if (isAppearanceButton)
                    {
                        numColumns = Math.Min(numColumns, parent.Controls.Count);
                        width      = radioRect.Width = clientRect.Width / numColumns;
                        height     = radioRect.Height = clientRect.Height / radionInColumn;
                        // Fixed defect #:137271: radioColSeperator & radioLineSeperator will be 0 for button
                        radioColSeperator  = 0;
                        radioLineSeperator = 0;
                        radioRect.X        = radioLineSeperator;
                        radioRect.Y        = radioColSeperator;
                    }
                    else
                    {
                        MgRadioPanel mgRadioPanel = container as MgRadioPanel;
                        if (radioButton.Image != null)
                        {
                            // Measure the radio button image size.
                            width  = radioButton.Image.Width;
                            height = radioButton.Image.Height;
                        }
                        else
                        {
                            //find the maximun string size in the composite
                            foreach (Control c in parent.Controls)
                            {
                                MgRadioButton mgRadioButton = (MgRadioButton)c;
                                Size          textExt       = Utils.GetTextExt(mgRadioPanel.Font, mgRadioButton.TextToDisplay, c);
                                width  = Math.Max(width, textExt.Width);
                                height = Math.Max(height, textExt.Height);
                            }
                        }
                        // add extras
                        width  = (int)((float)(RADIO_RECT_DX + RADIO_TEXT_SPACE + width + 1) * Utils.GetDpiScaleRatioX(parent));
                        height = (int)((float)(Math.Max(RADIO_RECT_DY, height + 2) * Utils.GetDpiScaleRatioY(parent)));

                        PointF fm = Utils.GetFontMetricsByFont(mgRadioPanel, (mgRadioPanel).Font);

                        radioLineSeperator = (int)fm.Y / 2;
                        height             = Math.Max(height, (clientRect.Height - (radionInColumn * radioLineSeperator)) / radionInColumn);
                        radioColSeperator  = (int)Math.Max((clientRect.Width - (numColumns * width)) / (numColumns + 1), fm.X / 2);

                        // Use DisplayRectangle so that parent.Padding is honored.
#if !PocketPC
                        Rectangle parentDisplayRectangle = parent.DisplayRectangle;
#else
                        Rectangle parentDisplayRectangle = parent.Bounds;
                        parentDisplayRectangle.X = parentDisplayRectangle.Y = 0;
#endif
                        Point nextControlLocation = parentDisplayRectangle.Location;

                        // calculate the bounds of the first button in the first column
                        radioRect.Y      = radioLineSeperator;
                        radioRect.Height = height;
                        // TODO: Hebrew

                        if (mgRadioPanel.RightToLeft == RightToLeft.Yes)
                        {
                            radioRect.X = mgRadioPanel.Width - radioColSeperator - width;
                        }
                        else
                        {
                            radioRect.X = radioColSeperator;
                        }
                        radioRect.Width = width;
                    }

                    foreach (Control c in parent.Controls)
                    {
                        radioButton = (MgRadioButton)c;
                        {
                            // checks if skip to another column is needed
                            if (numColumns > 1 && i > 0 && (i % radionInColumn) == 0)
                            {
                                // TODO: Hebrew
                                MgRadioPanel mgRadioPanel = container as MgRadioPanel;
                                if (mgRadioPanel.RightToLeft == RightToLeft.Yes)
                                {
                                    radioRect.X -= width + radioColSeperator;
                                }
                                else
                                {
                                    radioRect.X += width + radioColSeperator;
                                }
                                radioRect.Y = radioLineSeperator;
                            }
                        }

                        if (radioRect.X + radioRect.Width > clientRect.Width)
                        {
                            radioRect.Width = clientRect.Width - radioRect.X;
                        }
                        if (radioRect.Y + radioRect.Height > clientRect.Height)
                        {
                            radioRect.Height = clientRect.Height - radioRect.Y;
                        }
                        // set the radio bounds
                        radioButton.SetBounds(radioRect.X, radioRect.Y, radioRect.Width, radioRect.Height);

                        // sets the next radio location
                        radioRect.Y += radioLineSeperator + height;
                        i++;
                    }
                }
                return(false);
            }
Exemple #4
0
        /// <summary> </summary>
        internal override void handleEvent(EventType type, Object sender, EventArgs e)
        {
            ControlsMap  controlsMap  = ControlsMap.getInstance();
            Control      control      = (Control)sender;
            RadioButton  radioButton  = (RadioButton)sender;
            MgRadioPanel mgRadioPanel = (MgRadioPanel)radioButton.Parent;
            MapData      mapData      = controlsMap.getMapData(mgRadioPanel);

            if (mapData == null)
            {
                return;
            }

            GuiMgControl guiMgControl        = mapData.getControl();
            Type         senderType          = sender.GetType();
            bool         leftClickWasPressed = false;

            var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(guiMgControl));

            try
            {
                switch (type)
                {
                case EventType.MOUSE_DOWN:
                    //fixed bug #435168 , saveing the widget that we made MouseDown on the comosite control
                    ((TagData)mgRadioPanel.Tag).MouseDownOnControl = radioButton;
                    GuiUtils.checkAndCloseTreeEditorOnClick(control);
                    MouseEventArgs mouseEvtArgs = (MouseEventArgs)e;
                    GuiUtils.SaveLastClickInfo(mapData, (Control)sender, new Point(mouseEvtArgs.X, mouseEvtArgs.Y));
#if !PocketPC //tmp
                    GuiUtils.setTooltip(control, "");
#endif
                    String Value = GuiUtils.GetRadioButtonIndex(radioButton);
                    GuiUtils.setSuggestedValueOfChoiceControlOnTagData(mgRadioPanel, Value);
                    Events.OnSelection(Value, guiMgControl, mapData.getIdx(), true);
                    //the right click isn't move the focus to the control, only on left click.
                    leftClickWasPressed = (((MouseEventArgs)e).Button == MouseButtons.Left);

                    if (leftClickWasPressed)
                    {
                        Events.OnMouseDown(null, guiMgControl, null, leftClickWasPressed, mapData.getIdx(), false, true);
#if !PocketPC
                        GuiUtils.AssessDrag(control, (MouseEventArgs)e, mapData);
#endif
                    }
                    else
                    {
                        control.Focus();
                    }
                    return;

                case EventType.KEY_DOWN:
                    ((TagData)mgRadioPanel.Tag).MouseDownOnControl = null;
                    break;
                }
            }
            finally
            {
                contextIDGuard.Dispose();
            }

            DefaultHandler.getInstance().handleEvent(type, sender, e, mapData);
        }