c# - Make the ProgressRing in MahApps.Metro Smaller -


it looks mahapps.metro progressring control defaults minimum size of 60x60.

there property progressring called "islarge", when set "false" seems have no effect on being able make progressring smaller 60x60.

obiviously changing height , width properties not affect either.

looking on github actual c# code progressring, looks there several properties affect ellipse diameter, etc, these properties private properties, , can not set outside calls.

how can make smaller? 20x20 or 30x30?

in below code specify islarge=false, , set size 30x30, still defaults 60x60.

<window x:class="wpfapplication3.mainwindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         xmlns:controls="clr-namespace:mahapps.metro.controls;assembly=mahapps.metro"         title="mainwindow" height="350" width="525">     <window.resources>         <resourcedictionary>             <resourcedictionary.mergeddictionaries>                 <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/colours.xaml" />                 <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/fonts.xaml" />                 <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/controls.xaml" />                 <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/accents/orange.xaml" />                 <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/accents/baselight.xaml" />             </resourcedictionary.mergeddictionaries>         </resourcedictionary>     </window.resources>          <grid>             <controls:progressring isactive="true" islarge="false" height="30" width="30"></controls:progressring>         </grid> </window> 

below snippets of code "progressring.cs" file found on github - mahapps.metro

namespace mahapps.metro.controls {     [templatevisualstate(name = "large", groupname = "sizestates")]     [templatevisualstate(name = "small", groupname = "sizestates")]     [templatevisualstate(name = "inactive", groupname = "activestates")]     [templatevisualstate(name = "active", groupname = "activestates")]     public class progressring : control           private void setmaxsidelength(double width)         {             maxsidelength = width <= 60 ? 60.0 : width;         }          private void setellipsediameter(double width)         {             if (width <= 60)             {                 ellipsediameter = 6.0;             }             else             {                 ellipsediameter = width * 0.1 + 6;             }         }          private void updatelargestate()         {             action action;              if (islarge)                 action = () => visualstatemanager.gotostate(this, "large", true);             else                 action = () => visualstatemanager.gotostate(this, "small", true);              if (_deferredactions != null)                 _deferredactions.add(action);              else                 action();         } 

edit:mainwindow.xaml

<grid>     <controls:progressring x:name="pring" islarge="false" minheight="15" minwidth="15" height="15" width="15"></controls:progressring> </grid> 

edit:mainwindow.xaml.cs

    public partial class mainwindow : window     {         public mainwindow()         {             initializecomponent();             pring.ellipsediameter = 5;         }     } 

you have find style progressring , set width , height. me, style located at: mahapps.metro master \ mahapps.metro \ themes \ progressring.xaml:

<style targettype="{x:type controls:progressring}">     <setter property="foreground" value="{dynamicresource accentcolorbrush}"/>     <setter property="ishittestvisible" value="false"/>     <setter property="horizontalalignment" value="center"/>     <setter property="verticalalignment" value="center"/>     <setter property="minheight" value="30"/>     <setter property="minwidth" value="30"/>  ... 

by default, there width , height of 60. far understand, easy set width , height directly affects ellipses.

edit:

what make ring smaller, can play around parameters ellipsediameter , ellipseoffset through code, because xaml not available (as private).

private void setellipsediameter(double width) {     if (width <= 60)     {         ellipsediameter = 3.0; // default 6.0     }     else     {         ellipsediameter = width * 0.1 + 6;     } }  private void setellipseoffset(double width) {     if (width <= 60)     {         ellipseoffset = new thickness(0, 12, 0, 0); // default 24     }     else     {         ellipseoffset = new thickness(0, width * 0.4 + 12, 0, 0);     } } 

edit2:

to set diameter of ellipse can done follows. have properties ellipsediameter setter public:

public double ellipsediameter {          {         return (double)getvalue(ellipsediameterproperty);      }      set // default private     {         setvalue(ellipsediameterproperty, value);     } } 

in setellipsediameter checking on size of ellipse, if width less 60 set 6.0. comment out.

private void setellipsediameter(double width) {     //if (width <= 60)     //{     //    ellipsediameter = 6.0;     //}     //else     //{     //    ellipsediameter = width * 0.1 + 6;     //}  } 

and in style set diameter of ellipse that:

<setter property="minheight" value="30"/> <setter property="minwidth" value="30"/> <setter property="ellipsediameter" value="3.0" /> 

the same goes ellipseoffset. he, too, @ first private, , have check width smaller 60:

private void setellipseoffset(double width) {     // can drop check     if (width <= 60)     {         ellipseoffset = new thickness(0, 24, 0, 0);      }     else     {         ellipseoffset = new thickness(0, width * 0.4 + 24, 0, 0);     } } 

forging these operations these parameters, can configure width , height of progressring control.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -