CesControlBase - CesSolutions/Ces.WinForm.UI GitHub Wiki

Description / توضیح

This control is base control to create other control in which we need border and title. New control must inherit from this class and benefit from all features and properties.

این کنترل به عنوان کنترل پایه برای ایجاد سایر کنترل هایی که قرار است دارای Border و Title باشند استفاده می شود و کنترل های جدید باید بجای ارث بری از UserControl از CesControlBase ارث بری کنند. CesControlBase دارای چند متد و تعدادی Property می باشد که در تمام کنترل هایی که از آن ارث بری می کنند وجود خواهد داشت.

CesFocusOptions Group Properties / ویژگی های گروه "CesFocusOptions"

If new control must be created based on this control, when got focused you can set color for this situation. For example you can see "CesTextBox" code.

  • CesHasFocus : If new control need different color when get focus, value must be set to true.
  • CesFocusColor : Set color when control get focused.

اگر قرار باشد یک کنترل جدید بر پایه همین کنترل ساخته شود می توان برای زمانی که فوکوس دریافت میکند، رنگ جدید برای آن در نظر گرفت. برای مثال به کدهای کنترل "CesTextBox" رجوع کنید.

  • CesHasFocus : اگر مقدار این ویژگی برابر true باشد، کنترل در زمان دریافت فوکوس رنگ پس زمینه را به آنچه که برای این ویژگی تعیین شده تغییر خواهد داد.
  • CesFocusColor : رنگ پس زمینه کنترل در زمان دریافت فوکوس.

CesBorderOptions Group Properties / ویژگی های گروه "CesBorderOptions"

  • ChildContainer : When new control inherits from "CesBaseControl", Only one control (like Panel) can be located inside new control and other sub-controls shall be added to panel because, "CesBaseControl" only arrange "ChildContainer" inside new control.
  • CesPadding : Set new inside distance.
  • CesHasNotification : If set value to true, border color change to "CesNotificationColor".
  • CesNotificationColor : Set color for notification.
  • CesAutoHeight : If set value to true, control height will be adjusted automatically.
  • CesBackColor : Set back color.
  • CesBorderColor : Set border color.
  • CesBorderThickness : Set border thickness.
  • CesBorderRadius : Set radius of corner.
  • ChildContainer : زمانی که یک کنترل از CesControlBase ارث بری می کند تنها یک کنترل می تواند به آن اضافه کند و در صورتی که نیاز باشد کنترل جدید از چندین کنترل تشکیل شود، باید تمامی کنترل های در داخل یک Panel قرار داده شوند و در متد سازنده کنترل جدید باید مقدار این ویژگی برابر Panel و یا تنها کنترل موجود در UserControl باشد.
  • CesPadding : مقدار حاشیه داخلی اجزای کنترل.
  • CesHasNotification : اگر مقدار این ویژگی برابر true باشد، کنترل رنگ حاشیه و عنان را مطابق رنگ تعیین شده برای این منظور تغییر خواهد داد تا زمانی که مقدار این ویژگی برابر false شود.
  • CesNotificationColor : رنگ اعلان برای کنترلی که مقدار ویژگی HasNotification آن برابر true باشد.
  • CesAutoHeight : اگر مقدار این ویژگی برابر true باشد، کنترل ارتفاع خود را بصورت خودکار تنظیم خواهد کرد.
  • CesBackColor : رنگ پس زمینه.
  • CesBorderColor : رنگ حاشیه.
  • CesBorderThickness : ضخامت حاشیه.
  • CesBorderRadius : شعاع گوشه های حاشیه.

CesHasNotification

CesTitleOptions Group Properties / ویژگی های گروه "CesTitleOptions"

  • CesShowIcon : Show/Hide icon in title area.
  • CesIcon : Select image as icon to show in title area.
  • CesShowTitle : Show/Hide title text in title area.
  • CesTitleBackground : Set title area back color.
  • CesTitleFont : Set title text font.
  • CesTitleTextColor : Set color for title text.
  • CesTitleText : Set text for title to show in title area.
  • CesTitlePosition : Value must be selected from "CesTitlePositionEnum".
  • CesTitleTextAlignment : Value must be selected from "CesTitleContentAlignmentEnum".
  • CesTitleAutoWidth : If value set to true, width of title area adjust automatically.
  • CesTitleWidth : Set title area width.
  • CesTitleAutoHeight : If set value to true, title area height adjust automatically.
  • CesTitleHeight : Set title area height.
  • CesShowIcon : این امکان وجود دارد که بجای نمایش متن عنوان از آیکن استفاده کرد.
  • CesIcon : انتخاب یک آیکن برای نمایش بجای متن عنوان.
  • CesShowTitle : امکان آن را فراهم خواهد کرد که آای کنترل دارای عنوان باشد یا خیر. برای نمایش عنوان از نوع متن و یا آیکن، مقدار این ویژگی باید true باشد.
  • CesTitleBackground : رنگ پس زمینه ناحیه عنوان.
  • CesTitleFont : فونت عنوان.
  • CesTitleTextColor : رنگ متن عنوان.
  • CesTitleText : متن عنوان.
  • CesTitlePosition : موقعیت عنوان که می تواند یکی از مقادیر CesTitlePositionEnum باشد.
  • CesTitleTextAlignment : ترازبندی متن که می تواند یکی از مقادیر CesTitleContentAlignmentEnum باشد.
  • CesTitleAutoWidth : اگر مقدار این ویژگی برابر true باشد، عرض ناحیه عنوان بصورت خودکار تنظیم خواهد شد در غیر اینصورت عرض ناحیه عنوان مطابق با مقدار تنظیم شده نمایش داده خواهد شد.
  • CesTitleWidth : تعیین عرض ناحیه عنوان.
  • CesTitleAutoHeight : تعیین ارتفاع ناحیه عنوان بصورت خودکار.
  • CesTitleHeight : تعیین ارتفاع ناحیه عنوان.

CesIcon

CesTitlePosition

CesTitleTextAlignment

Methods / متدها

If changing properties value didn't applyto control, you call following methods to force control apply changes.

  • ApplyPropertyValue : Apply new value to control.
  • ArrangeControls : Arrange "CesChildContainer" control.
  • GenerateBorder : Generate border and title.

چنانچه با تغییر مقادیر property ها تغییرات اعمال نشد و یا چیدمان اجزای داخلی کنترل منظم نشدند می توانید از دو متد زیر اقدام به بروزرسانی کنترل نمایید.

  • ApplyPropertyValue : اعمال مقادیر در کنترل جدید.
  • ArrangeControls : مرتب سازی "CesChildContainer" در کنترل جدید.
  • GenerateBorder : رسم حاشیه و عنوان.

CesTitlePositionEnum

public enum CesTitlePositionEnum
{
    Top,
    Right,
    Bottom,
    Left,
}

CesTitleContentAlignmentEnum

public enum CesTitleContentAlignmentEnum
{
    Left,
    Center,
    Right,
}

Using CesControlBase / استفاده از CesControlBase

If you want to create new control based on CesControlBase, just inherit from "CesControlBase" and assign "CesChildContainer".

چنانچه بخواهید UserControl سفارشی خود را بر پایه CesControlBase ایجاد کنید کافیست که کنترل جدید از CEsControlsBase ارث بری کند و متد سازنده نیز متغیر ChildContainer را مقدار دهی کنید.

public CesDatePicker()
{
    InitializeComponent();
    ChildContainer = this.pnlChildControl;
} 

Assigning "CesChildContainer" must be done after "InitializeComponent" method in constructor. You created your control based on "CesControlBase" so far. In new control you can implement new properties and add new features to your control. If you need to update "CesControlBase" elements, you can write your code in "Paint" event then call "GenerateBorder" method.

As mentioned above, you can use "CesControlBase" to create you own control to have "Border" and "Title". Just notice that you cant only add one control in you new control and if you need more control, you must add all of them to a "Panel" control and assign this panel to "CesChildContainer".

حتما مقدار دهی ChildContainer باید بعد از متد InitializeComponent باشد. تا به اینجای کار شما کنترل سفارشی خود را برپایه CesControlBase ایجاد کرده اید. در کنترل جدید می تواند Peopertyهای خود را اضافه کنید و ویژگی های جددی به کنترل خود اضافه کنید. همچنین در صورت نیاز به بروزرسانی اجزای CesBaseControl می توانید متد Paint در کنترل جدید را کد نویسی کنید و در انتهای متد GenerateBorder را فراخوانی کنید.

همانطور که قبلا توضیح داده شد، می توانید از CesBaseControl جهت ایجاد کنترل سفارشی که مایل هستید دارای Border و Title باشد استفاده کنید. تنها به این نکته توجه کنید که یا باید یک Control تکی در UserControl خود قرار دهید و یا اگر به چندین کنترل نیاز دارید باید تمامی آنها را در یک Panel بگذارید و در متد سازنده کنترل جدید این Panel را به عنوان ChildContainer معرفی کنید.

⚠️ **GitHub.com Fallback** ⚠️