This is a migrated thread and some comments may be shown as answers.

Incorrect Behavior of some elements when DPI Scale is not 1

1 Answer 119 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nikolay
Top achievements
Rank 1
Nikolay asked on 25 Mar 2019, 07:45 PM

OS: Windows 7

Scale Settings: 135% (1.35 in DPI Scale)

Spotted problems:

1) radSplitContainer, collapsible - when collapse/restore first panel it restores 1.35 larger than it was.

2) CommandBarElement.SaveLayout/RestoreLayout - restores elements in a wrong position. Elements that aren't aligned with left or top border will be moved right and bottom correspondingly. I guess it saves position adjusted to DPI Scale, but restores as not adjusted 

Both can be easily reproduced with QuickStart example (e.g. split container). Repeats on the current prod version and on the current xxx.308 beta. 

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 27 Mar 2019, 08:32 AM
Hello Nikolay,

There is a known issue in the RadSplitContainer when it is run in High DPI. It is logged here: RadSplitContainer: incorrect splitter position after releasing the mouse on 125% DPI. I have also added a vote for the item on your behalf. 

Regarding the command bar, indeed the Save/Load API is not working correctly on High DPI and I have logged the issue: RadCommandBar: Saved layout is not restored correctly on High DPI. I have also updated your Telerik Points. A possible workaround is to descale the locations of the strip elements while saving the layout. You can test the custom implementation below: 
public partial class RadForm1 : Telerik.WinControls.UI.RadForm
{
    public RadForm1()
    {
        InitializeComponent();
    }
  
    string layout = @"..\..\layout.xml";
    private void radButton1_Click(object sender, EventArgs e)
    {
        XmlDocument doc = this.SaveLayoutCore();
        doc.Save(layout);
    }
  
    private XmlDocument SaveLayoutCore()
    {
        XmlDocument doc = new XmlDocument();
        XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);
        doc.AppendChild(dec);
        XmlElement rootNode = doc.CreateElement("RadCommandBarElement");
        rootNode.SetAttribute("Orientation", this.radCommandBar1.CommandBarElement.Orientation.ToString());
        rootNode.SetAttribute("Name", this.Name);
        rootNode.SetAttribute("RTL", this.RightToLeft.ToString());
  
        for (int i = 0; i < this.radCommandBar1.CommandBarElement.Rows.Count; i++)
        {
            CommandBarRowElement lineElement = this.radCommandBar1.CommandBarElement.Rows[i];
            XmlElement lineNode = doc.CreateElement("CommandBarRowElement");
            lineNode.SetAttribute("Orientation", lineElement.Orientation.ToString());
            lineNode.SetAttribute("Name", lineElement.Name);
            lineNode.SetAttribute("LineIndex", i.ToString());
  
            foreach (CommandBarStripElement stripElement in lineElement.Strips)
            {
                XmlElement stripNode = doc.CreateElement("CommandBarStripElement");
                stripNode.SetAttribute("Orientation", stripElement.Orientation.ToString());
                stripNode.SetAttribute("Name", stripElement.Name);
                stripNode.SetAttribute("DesiredLocationX", this.DescaleFloat(stripElement.DesiredLocation.X).ToString());
                stripNode.SetAttribute("DesiredLocationY", this.DescaleFloat(stripElement.DesiredLocation.Y).ToString());
                stripNode.SetAttribute("VisibleInCommandBar", stripElement.VisibleInCommandBar.ToString());
                stripNode.SetAttribute("StretchHorizontally", stripElement.StretchHorizontally.ToString());
                stripNode.SetAttribute("StretchVertically", stripElement.StretchVertically.ToString());
                stripNode.SetAttribute("EnableFloating", stripElement.EnableFloating.ToString());
                stripNode.SetAttribute("EnableDragging", stripElement.EnableDragging.ToString());
  
                int currentIndex = 0;
                for (int j = 0; j < stripElement.Items.Count; j++)
                {
                    RadCommandBarBaseItem itemElement = stripElement.Items[j];
                    XmlElement itemNode = doc.CreateElement("RadCommandBarBaseItem");
                    itemNode.SetAttribute("Orientation", itemElement.Orientation.ToString());
                    itemNode.SetAttribute("Name", itemElement.Name);
                    itemNode.SetAttribute("VisibleInStrip", itemElement.VisibleInStrip.ToString());
                    itemNode.SetAttribute("StretchHorizontally", itemElement.StretchHorizontally.ToString());
                    itemNode.SetAttribute("StretchVertically", itemElement.StretchVertically.ToString());
                    itemNode.SetAttribute("Index", currentIndex.ToString());
                    stripNode.AppendChild(itemNode);
                    ++currentIndex;
                }
  
                for (int j = 0; j < stripElement.OverflowButton.OverflowPanel.Layout.Children.Count; j++)
                {
                    RadCommandBarBaseItem itemElement = stripElement.OverflowButton.OverflowPanel.Layout.Children[j] as RadCommandBarBaseItem;
                    if (itemElement == null)
                    {
                        continue;
                    }
  
                    XmlElement itemNode = doc.CreateElement("RadCommandBarBaseItem");
                    itemNode.SetAttribute("Orientation", itemElement.Orientation.ToString());
                    itemNode.SetAttribute("Name", itemElement.Name);
                    itemNode.SetAttribute("VisibleInStrip", itemElement.VisibleInStrip.ToString());
                    itemNode.SetAttribute("StretchHorizontally", itemElement.StretchHorizontally.ToString());
                    itemNode.SetAttribute("StretchVertically", itemElement.StretchVertically.ToString());
                    itemNode.SetAttribute("Index", currentIndex.ToString());
                    stripNode.AppendChild(itemNode);
                    ++currentIndex;
                }
  
  
                lineNode.AppendChild(stripNode);
            }
  
            rootNode.AppendChild(lineNode);
        }
  
        XmlElement floatingFormsNode = SaveFloatingStripsLayout(doc);
        rootNode.AppendChild(floatingFormsNode);
        doc.AppendChild(rootNode);
  
        return doc;
    }
  
    private XmlElement SaveFloatingStripsLayout(XmlDocument doc)
    {
        XmlElement floatingFormsNode = doc.CreateElement("FloatingStrips");
        foreach (CommandBarStripElement stripElement in this.radCommandBar1.CommandBarElement.StripInfoHolder.StripInfoList)
        {
            if (stripElement.FloatingForm == null || stripElement.FloatingForm.IsDisposed)
            {
                continue;
            }
  
            XmlElement stripNode = doc.CreateElement("CommandBarStripElement");
            stripNode.SetAttribute("Orientation", stripElement.Orientation.ToString());
            stripNode.SetAttribute("Name", stripElement.Name);
            stripNode.SetAttribute("DesiredLocationX", this.DescaleFloat(stripElement.DesiredLocation.X).ToString());
            stripNode.SetAttribute("DesiredLocationY", this.DescaleFloat(stripElement.DesiredLocation.Y).ToString());
            stripNode.SetAttribute("FormLocationX", stripElement.FloatingForm.Location.X.ToString());
            stripNode.SetAttribute("FormLocationY", stripElement.FloatingForm.Location.Y.ToString());
            stripNode.SetAttribute("VisibleInCommandBar", stripElement.VisibleInCommandBar.ToString());
            stripNode.SetAttribute("StretchHorizontally", stripElement.StretchHorizontally.ToString());
            stripNode.SetAttribute("StretchVertically", stripElement.StretchVertically.ToString());
            stripNode.SetAttribute("RTL", stripElement.RightToLeft.ToString());
            stripNode.SetAttribute("EnableFloating", stripElement.EnableFloating.ToString());
            stripNode.SetAttribute("EnableDragging", stripElement.EnableDragging.ToString());
  
            int currentIndex = 0;
            for (int j = 0; j < stripElement.Items.Count; j++)
            {
                RadCommandBarBaseItem itemElement = stripElement.Items[j];
                XmlElement itemNode = doc.CreateElement("RadCommandBarBaseItem");
                itemNode.SetAttribute("Orientation", itemElement.Orientation.ToString());
                itemNode.SetAttribute("Name", itemElement.Name);
                itemNode.SetAttribute("VisibleInStrip", itemElement.VisibleInStrip.ToString());
                itemNode.SetAttribute("StretchHorizontally", itemElement.StretchHorizontally.ToString());
                itemNode.SetAttribute("StretchVertically", itemElement.StretchVertically.ToString());
                itemNode.SetAttribute("Index", currentIndex.ToString());
                stripNode.AppendChild(itemNode);
                ++currentIndex;
            }
  
            for (int j = 0; j < stripElement.FloatingForm.ItemsHostControl.Element.Layout.Children.Count; j++)
            {
                RadCommandBarBaseItem itemElement = stripElement.FloatingForm.ItemsHostControl.Element.Layout.Children[j] as RadCommandBarBaseItem;
                if (itemElement == null)
                {
                    continue;
                }
  
                XmlElement itemNode = doc.CreateElement("RadCommandBarBaseItem");
                itemNode.SetAttribute("Orientation", itemElement.Orientation.ToString());
                itemNode.SetAttribute("Name", itemElement.Name);
                itemNode.SetAttribute("VisibleInStrip", itemElement.VisibleInStrip.ToString());
                itemNode.SetAttribute("StretchHorizontally", itemElement.StretchHorizontally.ToString());
                itemNode.SetAttribute("StretchVertically", itemElement.StretchVertically.ToString());
                itemNode.SetAttribute("Index", currentIndex.ToString());
                stripNode.AppendChild(itemNode);
                ++currentIndex;
            }
  
            floatingFormsNode.AppendChild(stripNode);
        }
        return floatingFormsNode;
    }
  
    private float DescaleFloat(float value)
    {
        SizeF descale = new SizeF(1 / this.radCommandBar1.RootElement.DpiScaleFactor.Width, 1 / this.radCommandBar1.RootElement.DpiScaleFactor.Height);
  
        return TelerikDpiHelper.ScaleFloat(value, descale);
    }
  
    private void radButton2_Click(object sender, EventArgs e)
    {
        this.radCommandBar1.CommandBarElement.LoadLayout(layout);
    }
}

I hope this will help. Let me know if you need further assistance.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
General Discussions
Asked by
Nikolay
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or