{
The get
{
If (Component is RibbonButton button)
{
The return button. The Owner;
}
return null;
}
}
In this sentence: the if (Component is RibbonButton button) at the back of the button is what do you mean not understand take to help it.
Make it clear that the code is a ribbon of abroad interface source code.
All the code is as follows:
Internal class RibbonButtonDesigner
: RibbonElementWithItemCollectionDesigner
{
Public override Ribbon Ribbon
{
The get
{
If (Component is RibbonButton button)
{
The return button. The Owner;
}
return null;
}
}
Public override RibbonItemCollection Collection
{
The get
{
If (Component is RibbonButton button)
{
The return button. DropDownItems;
}
return null;
}
}
}
A lot of places so
. The namespace System. Windows Forms
{
Internal class RibbonButtonListDesigner
: RibbonElementWithItemCollectionDesigner
{
Public override Ribbon Ribbon
{
The get
{
If (Component is RibbonButtonList list)//the list here
{
Return the list. The Owner;
}
return null;
}
}
Public override RibbonItemCollection Collection
{
The get
{
If (Component is RibbonButtonList list)
{
Return the list. The Buttons;
}
return null;
}
}
}
}
Don't know other places
Private bool? _isopeninvisualstudiodesigner; Here? What is the meaning, usage???
Public Rectangle ScrollBarBounds=& gt; A Rectangle. FromLTRB (ButtonUpBounds ButtonUpBounds. Left, Top, ButtonDownBounds. Right, ButtonDownBounds. Bottom); \ \ like=& gt; What the hell is this???????????
Public RibbonMouseSensor (Control Control, Ribbon Ribbon)
: this ()
{
The Control=Control?? Throw new ArgumentNullException (nameof (control));
Ribbon=Ribbon?? Throw new ArgumentNullException (nameof (ribbon));
AddHandlers ();
}
The two words
The Control=Control?? Throw new ArgumentNullException (nameof (control));
Ribbon=Ribbon?? Throw new ArgumentNullException (nameof (ribbon));
?? What do you mean, usage???
CodePudding user response:
Starting from the c # 7.0, is operator support Type model (Type Pattern), "when performing Pattern matching, using Type model is will test whether the expression can be converted to the specified Type, if you can, then transform it into the Type of a variable" (https://docs.microsoft.com/zh-cn/dotnet/csharp/language-reference/keywords/is),Previous versions of the type test is more troublesome, for example:
//the old version:
If (Component is RibbonButton)//test
{
RibbonButton button=(RibbonButton) Component;//type conversion
The return button. The Owner;
}
return null;
//c # version 7.0:
If (Component is RibbonButton button)//test, and if you can convert
{
The return button. The Owner;
}
return null;
Suggest you look at the new feature of c #, such as bool? As the nullable value types,?????? Throw to throw expression, etc.,
They can help increase the coding efficiency, is a code fewer but stronger expression ability,
After the c # version 7.0 and 7.1, 7.2, 7.3, is the latest version is the c #, 8 #,
CodePudding user response:
If (Component is RibbonButton button)The equivalent of
If (Component is RibbonButton)
The button=Component as RibbonButton;
CodePudding user response:
Thank you very much for the above two brothers helpOthers don't understand, also please help:
Public void AddTabVerb (object sender, EventArgs e)
{
If (Control is Ribbon r)
{
IDesignerHost host=GetService (typeof (IDesignerHost)) as IDesignerHost;
RibbonTab TAB=host? . The CreateComponent (typeof (RibbonTab)) as RibbonTab; //here? . How to understand
If (TAB==null) return;
TAB. Text=TAB. Site. The Name;
Ribbon. The Tabs. The Add (TAB);
R.R efresh ();
}
}
///& lt; Summary>
///Gets the Ribbon of the designer
///& lt;/summary>
Public Ribbon Ribbon=& gt; Control the as Ribbon; //here & gt; How to understand,
Is the Expression - bodied members (c # programming guide) here?
All the above problems in VS2015 treated as error handling,,
CodePudding user response: