當前位置:首頁 » 背景圖片 » switch怎麼改背景圖片
擴展閱讀
動態圖片欣賞中國國花 2024-11-16 15:57:25
列印圖片從哪裡找 2024-11-16 15:55:55
手掌動脈在哪個位置圖片 2024-11-16 15:55:45

switch怎麼改背景圖片

發布時間: 2022-04-24 06:51:42

1. switch怎麼開機

  • 1

    首先找到switch主機屏幕上方的電源鍵按鈕並按住。

2. 我有兩張Winform主窗體的背景圖片,在運行時怎麼樣切換背景圖片,就像換皮膚一樣

C#winform中給mdi主窗體添加自定義背景圖片2011-07-06 16:05修改MDI窗口的主背景是MS不推薦的,但如果你需要可以使用下面的方法:

1——
原理:
MDI窗口有一個叫MdiClient的窗口對象作為主背景窗口,要修改MDI窗口的背景就是修改該MdiClient對象的背景

2——
關鍵:
如何獲得MdiClient對象

3——
方法:
MdiClient是作為MDI窗口的一個ChildControl的形式存在的,因此我們可以通過遍歷MDI窗口的Controls對象集來獲得

4——
示例:
下面的代碼把MDI窗口的主背景修改為蘭色(如果你有特別的處理請作相應的處理)

private System.Windows.Forms.MdiClient m_MdiClient;
public Form1()
{
//
// Windows 窗體設計器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調用後添加任何構造函數代碼
//
int iCnt=this.Controls.Count;
for(int i=0;i<iCnt;i++)
{
if(this.Controls[i].GetType().ToString()=="System.Windows.Forms.MdiClient")
{
this.m_MdiClient=(System.Windows.Forms.MdiClient)this.Controls[i];
break;
}
}
this.m_MdiClient.BackColor=System.Drawing.Color.Blue;
}

具體的應用中,可以參考上面的代碼把背景修改為其他的顏色、用圖片平鋪、拉伸等,就象通過代碼修改非MDI窗口的背景一樣。

另外,具體應用時,可能要考慮把這些東西放置到Paint或erasebkground等事件。

c# 2.0 給MDI主窗口添加背景最簡單的辦法,4句代碼搞定

一、將MDI主窗口的IsMdiContainer設為 False,將背景圖片放到資源文件中,資源名為BackgroundImage
二、在MDI主窗口的構造函數中InitializeComponent();之後加下面4行代碼
MdiClient m = new MdiClient();
this.Controls.Add( m );
m.Dock = DockStyle.Fill;
m.BackgroundImage = Properties.Resources.BackgroundImage ;

using System;
using System.ComponentModel;
using System.Collections;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;

namespace myBackgroundImage
{
/// <summary>
/// fat background MDI form (fbgMDIform),可定製Mdi主窗體背景。
/// </summary>
public class fbgMDIform:System.Windows.Forms.Form
{
private MDIbg_TypeList _mdibg_type;
private Image _mdibg_image;
private Image _mdibg_bgimage;

private MDIbg_AlignList _mdibg_align;
private MDIbg_ValignList _mdibg_valign;

private System.Windows.Forms.MdiClient bgMDIClient;

#region" 公共屬性 "

[Browsable(true),Description("背景圖片呈現風格:File填充,以截取右上角或重復出現的方式填滿整個工作區;Draw 拉伸,一張圖片拉伸後布滿工作區;Logo標志,一張圖片,其他屬性控制具體位置。"), Category("MDI背景擴展設置")]
public MDIbg_TypeList MDIbg_Type
{
get
{
object obj=_mdibg_type;
return (obj==null)?MDIbg_TypeList.File:(MDIbg_TypeList)obj;
}
set { _mdibg_type=value; }
}

[Browsable(true),Description("MDIContainer背景圖片"),Category("MDI背景擴展設置")]
public Image MDIbg_Image
{
get { return _mdibg_image; }
set { _mdibg_image=value; }
}

[Browsable(true),Description("MDIContainer第二背景圖片,MDIbg_Type設置為Logo時,此屬性對 應圖片以拉伸的形式在MDIbg_Image的下一層布滿工作區,若留空則由背景色替代。"), Category("MDI背景擴展設置")]
public Image MDIbg_bgImage
{
get { return _mdibg_bgimage; }
set { _mdibg_bgimage=value; }
}

[Browsable(true),Description("MDIbg_Image的左右對齊方式,取值為Left、Center、Right,MDIbg_Type設置為Logo時有效。"), Category("MDI背景擴展設置")]
public MDIbg_AlignList MDIbg_Align
{
get
{
object obj=_mdibg_align;
return (obj==null)?MDIbg_AlignList.Left:(MDIbg_AlignList)obj;
}
set { _mdibg_align=value; }
}

[Browsable(true),Description("MDIbg_Image的上下對齊方式,取值為Top、Middle、Bottom,MDIbg_Type設置為Logo時有效。"), Category("MDI背景擴展設置")]
public MDIbg_ValignList MDIbg_Valign
{
get
{
object obj=_mdibg_valign;
return (obj==null)?MDIbg_ValignList.Top:(MDIbg_ValignList)obj;
}
set { _mdibg_valign=value; }
}

#endregion

#region" 枚舉相關 "

//呈現風格枚舉
public enum MDIbg_TypeList:byte
{
File, //File填充,多張圖片重復後布滿工作區

Draw, //Draw拉伸,一張圖片拉伸後布滿工作區

Logo //Logo標志,一張圖片,其他屬性控制具體位置
}

//圖片左右對齊方式枚舉
public enum MDIbg_AlignList:byte
{
Left, //居左

Center, //居中

Right //居右
}

//圖片上下對齊方式枚舉
public enum MDIbg_ValignList:byte
{
Top, //居上

Middle, //居中

Bottom //居下

}

#endregion

public fbgMDIform()
{
this.SizeChanged += new System.EventHandler(this.MDI_Set);
this.Load+=new EventHandler(this.MDI_Set);

}

private void MDI_Set(object sender, System.EventArgs e)
{
if(this.IsMdiContainer)
{
foreach(System.Windows.Forms.Control myControl in this.Controls)
{
if(myControl.GetType().ToString() == "System.Windows.Forms.MdiClient")
{
bgMDIClient = (System.Windows.Forms.MdiClient)myControl;
break;
}
}

if(bgMDIClient.ClientSize.Width>0&&bgMDIClient.ClientSize.Height>0&&MDIbg_Image!=null)
{

System.Drawing.Bitmap myImg = new Bitmap(bgMDIClient.ClientSize.Width,bgMDIClient.ClientSize.Height);
System.Drawing.Graphics myGraphics = System.Drawing.Graphics.FromImage(myImg);
myGraphics.Clear(this.BackColor);

switch (this.MDIbg_Type)
{
case MDIbg_TypeList.File:
//填充
myImg = new Bitmap(this.MDIbg_Image);
myGraphics = System.Drawing.Graphics.FromImage(myImg);
myGraphics.Clear(this.BackColor);
myGraphics.DrawImage(this.MDIbg_Image,0,0,myImg.Width+1,myImg.Height+1);
bgMDIClient.BackgroundImage =myImg;
myGraphics.Dispose();
break;
case MDIbg_TypeList.Draw:
//拉伸
myGraphics.DrawImage(this.MDIbg_Image,0,0,myImg.Width+1,myImg.Height+1);
bgMDIClient.BackgroundImage = myImg;
myGraphics.Dispose();
break;
case MDIbg_TypeList.Logo:
//標志
myGraphics.Clear(this.BackColor);

if(this.MDIbg_bgImage!=null)
{
myGraphics.DrawImage(this.MDIbg_bgImage,0,0,myImg.Width+1,myImg.Height+1);
}
//定位
int myX,myY;
switch(this.MDIbg_Align)
{
case MDIbg_AlignList.Left:
myX=0;
break;
case MDIbg_AlignList.Right:
myX=myImg.Width-MDIbg_Image.Width;
break;

case MDIbg_AlignList.Center:
myX=(myImg.Width-MDIbg_Image.Width)/2;
break;
default:
myX=0;
break;
}
switch(this.MDIbg_Valign)
{
case MDIbg_ValignList.Top:
myY=0;
break;
case MDIbg_ValignList.Bottom:
myY=myImg.Height -MDIbg_Image.Height;
break;

case MDIbg_ValignList.Middle:
myY=(myImg.Height -MDIbg_Image.Height)/2;
break;
default:
myY=0;
break;
}
myGraphics.DrawImage(this.MDIbg_Image,myX,myY,this.MDIbg_Image.Width,this.MDIbg_Image.Height);
bgMDIClient.BackgroundImage = myImg;
myGraphics.Dispose();
break;
default:
//填充
bgMDIClient.BackgroundImage =this.MDIbg_Image;
break;
}
}
}
}

}
}
放在類庫中編譯,然後在程序中引用

3. ios中uiswitch超出的背景顏色怎樣處理

1、創建一個empty(空的)工程項目,新建一個UIViewController;
2、選中工程,右鍵-New File…選擇「Cocoa Touch Class」-Next,給個合理的名稱ViewController,再Next完成;
3、在AppDelegate.m文件包含#import "ViewController.h";
4、初始化創建ViewController的視圖控制器,並用導航欄控制器包含。將之設置為根視圖控制器。

創建添加UISwitch對象
1、創建並初始化一個UISwitch,寬高是固定的,不為0就可以顯示;
3、設置背景顏色可以看到效果;
4、將UISwitch添加到self.view中。

設置UISwitch的屬性
1、onTintColor設置開啟顏色;
2、onImage設置開啟圖片;
3、tintColor設置正常關閉顏色;
4、offImage設置關閉圖片;
5、thumbTintColor設置圓形按鈕顏色;

代碼設置開啟/關閉狀態

//設置YES或NO,是否使用animated動畫效果:
[mySwitch setOn:YES animated:YES];

獲取UISwitch的開啟/關閉狀態

1、獲取對象的isOn屬性,默認是關閉狀態;
2、如果isOn==YES則是開啟狀態,如果isOn==NO則是關閉狀態。

添加動作事件(完成)
可以選擇id類也可以選擇UISwitch類,如果是id類型,則要轉換成UISwitch類型:UISwitch *mySwitch = (UISwitch *)sender。

4. android 自定義switch樣式

修改後的MySwitch控制項介面基本與原Switch控制項一致,並且除了可支持所有SDK外,增加了2項小功能:
1. 支持用Track背景圖片的方式代替Texton Textoff等文字方式表現開關狀態
2.支持調整控制Switch的高度
下面貼出Switch修改的關鍵代碼:

/**
* <p>
* modified from android SDK 14(4.0) android.widget.Switch.
* <br/>
* <strong>new feature: </strong>
* <ol>
* <li>support SDK 1 or higher. </li>
* <li>you can use track drawable instead of text to display the changes of off-on state!</li>
* <li>you can control the Switch minimum height. </li>
* </ol>
* </p>
*
* @see {@link Switch}
* @author Wison
*/
public class MySwitch extends CompoundButton {
// Support track drawable instead of text
private Drawable mTrackOnDrawable;
private Drawable mTrackOffDrawable;

// Support minimum height
private int mSwitchMinHeight;

/**
* Construct a new Switch with a default style determined by the given theme attribute,
* overriding specific style attributes as requested.
*
* @param context The Context that will determine this widget's theming.
* @param attrs Specification of attributes that should deviate from the default styling.
* @param defStyle An attribute ID within the active theme containing a reference to the
* default style for this widget. e.g. android.R.attr.switchStyle.
*/
public MySwitch(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);

mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
Resources res = getResources();
mTextPaint.density = res.getDisplayMetrics().density;
//float scaledDensity = res.getDisplayMetrics().scaledDensity;
//mTextPaint.setCompatibilityScaling(res.getCompatibilityInfo().applicationScale);

TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Switch, defStyle, 0);

// off-on 模式: 圖片模式或文字模式,圖片模式是用Track背景圖片表示off-on的狀態,文字模式是用文字來表示off-on狀態。
mTrackOnDrawable = a.getDrawable(R.styleable.Switch_trackOn);
mTrackOffDrawable = a.getDrawable(R.styleable.Switch_trackOff);
if (checkTrackOffOnDrawable()) {
// 如果設定圖片模式,則默認顯示off狀態
mTrackDrawable = mTrackOffDrawable;
} else {
mTrackDrawable = a.getDrawable(R.styleable.Switch_track);
}

mThumbDrawable = a.getDrawable(R.styleable.Switch_thumb);
mTextOn = a.getText(R.styleable.Switch_textOn);
mTextOff = a.getText(R.styleable.Switch_textOff);
mThumbTextPadding = a.getDimensionPixelSize(R.styleable.Switch_thumbTextPadding, 0);
mSwitchMinWidth = a.getDimensionPixelSize(R.styleable.Switch_switchMinWidth, 0);

mSwitchMinHeight = a.getDimensionPixelSize(R.styleable.Switch_switchMinHeight, 0);

mSwitchPadding = a.getDimensionPixelSize(R.styleable.Switch_switchPadding, 0);

int appearance = a.getResourceId(R.styleable.Switch_switchTextAppearance, 0);
if (appearance != 0) {
setSwitchTextAppearance(context, appearance);
}
a.recycle();

ViewConfiguration config = ViewConfiguration.get(context);
mTouchSlop = config.getScaledTouchSlop();
mMinFlingVelocity = config.getScaledMinimumFlingVelocity();

// Refresh display with current params
refreshDrawableState();
setChecked(isChecked());
}

private boolean checkTrackOffOnDrawable() {
return mTrackOnDrawable != null && mTrackOffDrawable != null;
}

@SuppressLint("NewApi")
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mOnLayout == null) {
mOnLayout = makeLayout(mTextOn);
}
if (mOffLayout == null) {
mOffLayout = makeLayout(mTextOff);
}
mTrackDrawable.getPadding(mTempRect);
final int maxTextWidth = Math.max(mOnLayout.getWidth(), mOffLayout.getWidth());
final int switchWidth = Math.max(mSwitchMinWidth,
maxTextWidth * 2 + mThumbTextPadding * 4 + mTempRect.left + mTempRect.right);

// final int switchHeight = mTrackDrawable.getIntrinsicHeight();
int switchHeight;
if (mSwitchMinHeight <= 0) {
switchHeight = mTrackDrawable.getIntrinsicHeight();
} else {
switchHeight = Math.max(mSwitchMinHeight, mTempRect.top + mTempRect.bottom);
}
mThumbWidth = maxTextWidth + mThumbTextPadding * 2;

mSwitchWidth = switchWidth;
mSwitchHeight = switchHeight;

super.onMeasure(widthMeasureSpec, heightMeasureSpec);
final int measuredHeight = getMeasuredHeight();
if (measuredHeight < switchHeight) {
if (Build.VERSION.SDK_INT >= 11) {
setMeasuredDimension(getMeasuredWidthAndState(), switchHeight);
} else {
setMeasuredDimension(getMeasuredWidth(), switchHeight);
}
}
}
@Override
public void setChecked(boolean checked) {
if (checkTrackOffOnDrawable()) {
mTrackDrawable = checked ? mTrackOnDrawable : mTrackOffDrawable;
refreshDrawableState();
}
super.setChecked(checked);
mThumbPosition = checked ? getThumbScrollRange() : 0;
invalidate();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// Draw the switch
int switchLeft = mSwitchLeft;
int switchTop = mSwitchTop;
int switchRight = mSwitchRight;
int switchBottom = mSwitchBottom;

if (checkTrackOffOnDrawable()) {
mTrackDrawable = getTargetCheckedState() ? mTrackOnDrawable : mTrackOffDrawable;
refreshDrawableState();
}

mTrackDrawable.setBounds(switchLeft, switchTop, switchRight, switchBottom);
mTrackDrawable.draw(canvas);
canvas.save()
mTrackDrawable.getPadding(mTempRect);
int switchInnerLeft = switchLeft + mTempRect.left;
int switchInnerTop = switchTop + mTempRect.top;
int switchInnerRight = switchRight - mTempRect.right;
int switchInnerBottom = switchBottom - mTempRect.bottom;
canvas.clipRect(switchInnerLeft, switchTop, switchInnerRight, switchBottom);

mThumbDrawable.getPadding(mTempRect);
final int thumbPos = (int) (mThumbPosition + 0.5f);
int thumbLeft = switchInnerLeft - mTempRect.left + thumbPos;
int thumbRight = switchInnerLeft + thumbPos + mThumbWidth + mTempRect.right;

mThumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom);
mThumbDrawable.draw(canvas);

// mTextColors should not be null, but just in case
if (mTextColors != null) {
mTextPaint.setColor(mTextColors.getColorForState(getDrawableState(),
mTextColors.getDefaultColor()));
}
mTextPaint.drawableState = getDrawableState();

Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout;

if (switchText != null) {
canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2,
(switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2);
switchText.draw(canvas);
}
canvas.restore();
}
}

下面是關鍵屬性聲明:
<declare-styleable name="Switch">

<!-- Drawable to use when the switch is in the checked/"on" state. -->
<attr name="trackOn" format="reference" />
<!-- Drawable to use when the switch is in the unchecked/"off" state. -->
<attr name="trackOff" format="reference" />
<!-- Minimum height for the switch component -->
<attr name="switchMinHeight" format="dimension" />

<!-- Drawable to use as the "thumb" that switches back and forth. -->
<attr name="thumb" format="reference" />
<!-- Drawable to use as the "track" that the switch thumb slides within. -->
<attr name="track" format="reference" />
<!-- Text to use when the switch is in the checked/"on" state. -->
<attr name="textOn" format="string" />
<!-- Text to use when the switch is in the unchecked/"off" state. -->
<attr name="textOff" format="string" />
<!-- Amount of padding on either side of text within the switch thumb. -->
<attr name="thumbTextPadding" format="dimension" />
<!-- TextAppearance style for text displayed on the switch thumb. -->
<attr name="switchTextAppearance" format="reference" />
<!-- Minimum width for the switch component -->
<attr name="switchMinWidth" format="dimension" />
<!-- Minimum space between the switch and caption text -->
<attr name="switchPadding" format="dimension" />
</declare-styleable>

5. C#中如何單擊按鈕變換背景圖片

這么多個重復的代碼。。
個人建議
1、做個函數,裡面禁掉所有panel的visible.
再判斷if (comboBox1.Text == "1")就顯示panel1
或者換為switch case語句更清楚。

2、更簡潔的方式。一個string數組,存好12張圖的路徑
就用一個panel
再判斷if (comboBox1.Text == "1")就顯示panel1
或者換為switch case語句更清楚。
就設置panel1.BackgroundImage = Image.FromFile(數組元素)就一切搞掂。

有問題直接找我。

6. 如何修改NSview的背景顏色

最簡單的方法:打開圖片---選擇---色彩范圍,點擊綠色(可以按住SHIFT鍵,在綠色上反復點擊,直到綠色全部被選中),然後在選區填充白色。選區的精度可以用色彩范圍裡面的逗容差地來調節

7. java swing換背景圖片

//回答完畢,採納即可

importjava.awt.BorderLayout;
importjava.awt.Graphics;
importjava.awt.Image;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.awt.event.WindowAdapter;
importjava.awt.event.WindowEvent;
importjava.io.IOException;

importjavax.imageio.ImageIO;
importjavax.swing.BorderFactory;
importjavax.swing.JButton;
importjavax.swing.JComboBox;
importjavax.swing.JDialog;
importjavax.swing.JFrame;
importjavax.swing.JPanel;

publicclassBarextendsJPanel
{
=1L;

privateJButtonopen;

privatestaticfinalintW=300;

privatestaticfinalintH=300;

publicBar()
{
super(newBorderLayout());

JPanelpanel=newJPanel();
open=newJButton("打開");
open.addActionListener(newActionListener()
{
@Override
publicvoidactionPerformed(ActionEvente)
{
JDialogdialog=newJDialog();
dialog.setTitle("設置背景圖");
dialog.setSize(160,60);
dialog.setModal(true);
dialog.setLocationRelativeTo(Bar.this);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
finalJComboBoxcomboBox=newJComboBox(newString[]{"圖片a","圖片b"});
dialog.addWindowListener(newWindowAdapter()
{
@Override
publicvoidwindowClosing(WindowEvente)
{
try
{
intindex=comboBox.getSelectedIndex();
switch(index)
{
case0:
img=ImageIO.read(Bar.class.getResource("a.jpg"));
Bar.this.repaint();
break;
case1:
img=ImageIO.read(Bar.class.getResource("layout.png"));
Bar.this.repaint();
break;
default:
break;
}
}
catch(IOExceptione1)
{
e1.printStackTrace();
}
}
});
dialog.add(comboBox);
dialog.setVisible(true);
}
});
panel.add(open);
add(panel,BorderLayout.PAGE_START);
setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
}

Imageimg=null;

@Override
publicvoidpaint(Graphicsg)
{
super.paint(g);
g.clearRect(0,0,W,H);
g.drawImage(img,0,0,null);
g.dispose();
}

()
{
JFrameframe=newJFrame("bar");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Barb=newBar();
b.setOpaque(true);
frame.setContentPane(b);
frame.setSize(W,H);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}

publicstaticvoidmain(String[]args)
{
javax.swing.SwingUtilities.invokeLater(newRunnable()
{
publicvoidrun()
{
createAndShowGUI();
}
});
}
}


8. 如何將switch更改壁紙

直接右鍵點擊圖案上面選項中的設為桌面背景

9. switch怎麼設置壁紙

沒有壁紙。只有深淺兩個顏色的壁紙。
如果你是自製系統可以用自定義的主題

10. 任天堂switch有什麼美化桌面的軟體嗎

任天堂這種模式確實有美化桌面的軟體,這種軟體確實呃非常好用的,但是,一般人不要不要不學的話,那肯定是這個軟體是非常不好做的。