private void MoveSp(float dx, float dy) { if (0 <= this.pclstNums.SelectedIndex) { Memory4bSpritePartsnumber mNum = (Memory4bSpritePartsnumber)this.pclstNums.Items[this.pclstNums.SelectedIndex]; // 移動前再描画 this.Invalidate( new Rectangle( mNum.BoundsCircleScaledOnBackground.X + (int)this.Owner_MemoryApplication.BgLocationScaled.X, mNum.BoundsCircleScaledOnBackground.Y + (int)this.Owner_MemoryApplication.BgLocationScaled.Y, mNum.BoundsCircleScaledOnBackground.Width, mNum.BoundsCircleScaledOnBackground.Height ), false); PointF old = mNum.LocationOnBackgroundActual; // 移動 this.Owner_MemoryApplication.MovePartsnumbersprite(mNum, dx, dy, this.Owner_MemoryApplication.ScaleImg, this.Owner_MemoryApplication); this.Owner_MemoryApplication.Delegate_OnChanged_SomeContents(); // 移動後再描画 this.Invalidate( new Rectangle( mNum.BoundsCircleScaledOnBackground.X + (int)this.Owner_MemoryApplication.BgLocationScaled.X, mNum.BoundsCircleScaledOnBackground.Y + (int)this.Owner_MemoryApplication.BgLocationScaled.Y, mNum.BoundsCircleScaledOnBackground.Width, mNum.BoundsCircleScaledOnBackground.Height ), false); } }
//──────────────────────────────────────── public void SetText_SpritePartsnumber(Memory4bSpritePartsnumber mNum, string sText, Memory1Application_Partsnumput memoryApplication_Partsnumput) { if (mNum.Text != sText) { mNum.Text = sText; memoryApplication_Partsnumput.IsChangedContents = true; } }
//──────────────────────────────────────── /// <summary> /// この関数は、Function2_LoadCsvに渡されます。 /// </summary> /// <param name="mNum"></param> /// <param name="scale2"></param> public void UsercontrolCanvas_OnChangeSpritePartsnumber(Memory4bSpritePartsnumber mNum, float scale2) { if (this.Owner_MemoryApplication.IsDisplayExecute && mNum.IsDefinitionExpression) { // 数値表示モードでは、名前定義は表示しません。 mNum.Scale = 1.0f; mNum.BoundsCircleScaledOnBackground = new Rectangle(); mNum.BoundsTextScaledOnBackground = new Rectangle(); goto gt_EndMethod; } mNum.Scale = scale2; float x = scale2 * mNum.LocationOnBackgroundActual.X; float y = scale2 * mNum.LocationOnBackgroundActual.Y; // ドット絵の1ドットを最小単位にして動くよう調整。スケールは 1、または 2の倍数の整数。 x = (float)((int)(x / scale2) * (int)scale2); y = (float)((int)(y / scale2) * (int)scale2); // 番号スプライトのサイズ string sText = mNum.GetText(true, this.Owner_MemoryApplication); Graphics g = this.CreateGraphics(); SizeF sizeF = g.MeasureString(sText, mNum.Font); g.Dispose(); // センタリング x -= sizeF.Width / 2; y -= sizeF.Height / 2; // 後ろに、少し大きめの丸を塗ります。 mNum.BoundsCircleScaledOnBackground = new Rectangle( (int)x - 4, (int)y - 4, (int)sizeF.Width + 8, (int)sizeF.Height + 2 ); mNum.BoundsTextScaledOnBackground = new Rectangle( (int)x, (int)y, (int)(scale2 * sizeF.Width), (int)(scale2 * sizeF.Height) ); goto gt_EndMethod; // // // // gt_EndMethod: mNum.IsDirty = false; }
//──────────────────────────────────────── public void MovePartsnumbersprite(Memory4bSpritePartsnumber mNum, float dx, float dy, float nScale, Memory1Application_Partsnumput memoryApplication_Partsnumput) { // 背景画像上のスプライト位置 mNum.LocationOnBackgroundActual = new PointF( mNum.LocationOnBackgroundActual.X + dx / nScale, mNum.LocationOnBackgroundActual.Y + dy / nScale ); //ystem.Console.WriteLine("移動前("+old.X+","+old.Y+") 移動後("+mNum.LocationOnBackgroundActual.X+","+mNum.LocationOnBackgroundActual.Y+")"); mNum.Delegate_OnChangeSprite_Partsnumber(mNum, nScale);//, ucCanvas memoryApplication_Partsnumput.IsChangedContents = true; }
//──────────────────────────────────────── /// <summary> /// 番号を追加します。 /// </summary> /// <param name="mNum"></param> public void AddPartsnumbersprite(Memory4bSpritePartsnumber mNum, bool bLoadingNow, Memory1Application_Partsnumput memoryApplication_Partsnumput) { if (!this.DictionaryLayer.ContainsKey(mNum.Number_Layer)) { List <Memory4bSpritePartsnumber> mNumList = new List <Memory4bSpritePartsnumber>(); mNumList.Add(mNum); this.DictionaryLayer.Add(mNum.Number_Layer, mNumList); } else { this.DictionaryLayer[mNum.Number_Layer].Add(mNum); } if (!bLoadingNow) { memoryApplication_Partsnumput.IsChangedContents = true; } }
public void AddNumSp(Memory4bSpritePartsnumber mNum, bool bLoadingNow) { // // this.Owner_MemoryApplication.AddPartsnumbersprite(mNum, bLoadingNow, this.Owner_MemoryApplication); // // ListBox pclst = this.pclstNums; this.PclstNums_autoInput = true;//自動入力開始 pclst.Items.Add(mNum); pclst.SelectedIndex = pclst.Items.Count - 1; this.PclstNums_autoInput = false;//自動入力終了 // // this.Owner_MemoryApplication.Delegate_OnChanged_SomeContents(); }
//──────────────────────────────────────── /// <summary> /// コンストラクター。 /// </summary> public Memory4aPartsnumbersymbolspritesImpl() { this.memoryPartsnumbersprite_Symboldefinition = new Memory4bSpritePartsnumberImpl(); this.list_MemoryPartsnumbersprite_Expression = new List<Memory4bSpritePartsnumber>(); }
//──────────────────────────────────────── /// <summary> /// この関数は、Function2_LoadCsvに渡されます。 /// </summary> /// <param name="mNum"></param> /// <param name="scale2"></param> public void UsercontrolCanvas_OnChangeSpritePartsnumber(Memory4bSpritePartsnumber mNum, float scale2) { if (this.Owner_MemoryApplication.IsDisplayExecute && mNum.IsDefinitionExpression) { // 数値表示モードでは、名前定義は表示しません。 mNum.Scale = 1.0f; mNum.BoundsCircleScaledOnBackground = new Rectangle(); mNum.BoundsTextScaledOnBackground = new Rectangle(); goto gt_EndMethod; } mNum.Scale = scale2; float x = scale2 * mNum.LocationOnBackgroundActual.X; float y = scale2 * mNum.LocationOnBackgroundActual.Y; // ドット絵の1ドットを最小単位にして動くよう調整。スケールは 1、または 2の倍数の整数。 x = (float)((int)(x / scale2) * (int)scale2); y = (float)((int)(y / scale2) * (int)scale2); // 番号スプライトのサイズ string sText = mNum.GetText( true, this.Owner_MemoryApplication); Graphics g = this.CreateGraphics(); SizeF sizeF = g.MeasureString(sText, mNum.Font); g.Dispose(); // センタリング x -= sizeF.Width / 2; y -= sizeF.Height / 2; // 後ろに、少し大きめの丸を塗ります。 mNum.BoundsCircleScaledOnBackground = new Rectangle( (int)x - 4, (int)y - 4, (int)sizeF.Width + 8, (int)sizeF.Height + 2 ); mNum.BoundsTextScaledOnBackground = new Rectangle( (int)x, (int)y, (int)(scale2 * sizeF.Width), (int)(scale2 * sizeF.Height) ); goto gt_EndMethod; // // // // gt_EndMethod: mNum.IsDirty = false; }
public void AddNumSp(Memory4bSpritePartsnumber mNum, bool bLoadingNow) { // // this.Owner_MemoryApplication.AddPartsnumbersprite(mNum, bLoadingNow, this.Owner_MemoryApplication); // // ListBox pclst = this.pclstNums; this.PclstNums_autoInput = true;//自動入力開始 pclst.Items.Add(mNum); pclst.SelectedIndex = pclst.Items.Count - 1; this.PclstNums_autoInput = false;//自動入力終了 // // this.Owner_MemoryApplication.Delegate_OnChanged_SomeContents(); }
//──────────────────────────────────────── private void _CalSelectedSpriteGui(Memory4bSpritePartsnumber selectedNum) { if (null == selectedNum) { // // ◇選択スプライトが無い場合。 // this.pctxtEdits.Text = ""; this.pctxtEdits.Enabled = false; this.pclblFontSmall.Enabled = false; this.pcrdiFontSmall.Enabled = false; this.pclblFontMiddle.Enabled = false; this.pcrdiFontMiddle.Enabled = false; this.pclblFontLarge.Enabled = false; this.pcrdiFontLarge.Enabled = false; this.pclblBgcolorBlue.Enabled = false; this.pcrdiBgcolorBlue.Enabled = false; this.pclblBgcolorGreen.Enabled = false; this.pcrdiBgcolorGreen.Enabled = false; } else { // // ◇選択スプライトが有る場合。 // this.pctxtEdits.Enabled = true; this.pctxtEdits.Text = selectedNum.Text; this.pclblFontSmall.Enabled = true; this.pcrdiFontSmall.Enabled = true; this.pclblFontMiddle.Enabled = true; this.pcrdiFontMiddle.Enabled = true; this.pclblFontLarge.Enabled = true; this.pcrdiFontLarge.Enabled = true; this.pclblBgcolorBlue.Enabled = true; this.pcrdiBgcolorBlue.Enabled = true; this.pclblBgcolorGreen.Enabled = true; this.pcrdiBgcolorGreen.Enabled = true; switch ((int)selectedNum.Font.Size) { case 10: this.pcrdiFontSmall.Checked = true; break; case 20: this.pcrdiFontMiddle.Checked = true; break; case 40: this.pcrdiFontLarge.Checked = true; break; default: this.pcrdiFontSmall.Checked = false; this.pcrdiFontMiddle.Checked = false; this.pcrdiFontLarge.Checked = false; break; } if (Brushes.Green == selectedNum.BrushBackground) { this.pcrdiBgcolorGreen.Checked = true; } else if (Brushes.Blue == selectedNum.BrushBackground) { this.pcrdiBgcolorBlue.Checked = true; } else { this.pcrdiBgcolorGreen.Checked = false; this.pcrdiBgcolorBlue.Checked = false; } } }
//──────────────────────────────────────── public void PaintSprite( Graphics g, Memory4bSpritePartsnumber memSprNum, bool isOnWindow, float scale2) { if (this.IsDisplayExecute && memSprNum.IsDefinitionExpression) { // 数値表示モードでは、名前定義は表示しません。 goto process_end; } if (memSprNum.IsDirty || memSprNum.Scale != scale2) { memSprNum.Delegate_OnChangeSprite_Partsnumber(memSprNum, scale2);//, numPutUc } Rectangle boundsCircle; if (isOnWindow) { boundsCircle = new Rectangle( memSprNum.BoundsCircleScaledOnBackground.X + (int)this.BgLocationScaled.X, memSprNum.BoundsCircleScaledOnBackground.Y + (int)this.BgLocationScaled.Y, memSprNum.BoundsCircleScaledOnBackground.Width, memSprNum.BoundsCircleScaledOnBackground.Height ); } else { boundsCircle = memSprNum.BoundsCircleScaledOnBackground; } Rectangle boundsText; if (isOnWindow) { boundsText = new Rectangle( memSprNum.BoundsTextScaledOnBackground.X + (int)this.BgLocationScaled.X, memSprNum.BoundsTextScaledOnBackground.Y + (int)this.BgLocationScaled.Y, memSprNum.BoundsTextScaledOnBackground.Width, memSprNum.BoundsTextScaledOnBackground.Height ); } else { boundsText = new Rectangle( memSprNum.BoundsTextScaledOnBackground.X, memSprNum.BoundsTextScaledOnBackground.Y, memSprNum.BoundsTextScaledOnBackground.Width, memSprNum.BoundsTextScaledOnBackground.Height ); } //// 番号スプライトのサイズ string sText = memSprNum.GetText(true, this); // 後ろに、少し大きめの丸を塗ります。 Brush backBrush; if (memSprNum.IsMouseTarget) { backBrush = Brushes.YellowGreen; } else { backBrush = memSprNum.BrushBackground; } g.FillEllipse(backBrush, boundsCircle.X, boundsCircle.Y, boundsCircle.Width, boundsCircle.Height); g.DrawEllipse(memSprNum.PenForeground, boundsCircle.X, boundsCircle.Y, boundsCircle.Width, boundsCircle.Height); // 影 g.DrawString( sText, memSprNum.Font, Brushes.Black, boundsText.Location ); boundsText.Offset(-1, -1); // 文字 g.DrawString( sText, memSprNum.Font, Brushes.White, boundsText.Location ); goto process_end; // // // // process_end: ; }
//──────────────────────────────────────── public void PaintSprite( Graphics g, Memory4bSpritePartsnumber memSprNum, bool isOnWindow, float scale2) { if (this.IsDisplayExecute && memSprNum.IsDefinitionExpression) { // 数値表示モードでは、名前定義は表示しません。 goto process_end; } if (memSprNum.IsDirty || memSprNum.Scale != scale2) { memSprNum.Delegate_OnChangeSprite_Partsnumber(memSprNum, scale2);//, numPutUc } Rectangle boundsCircle; if (isOnWindow) { boundsCircle = new Rectangle( memSprNum.BoundsCircleScaledOnBackground.X + (int)this.BgLocationScaled.X, memSprNum.BoundsCircleScaledOnBackground.Y + (int)this.BgLocationScaled.Y, memSprNum.BoundsCircleScaledOnBackground.Width, memSprNum.BoundsCircleScaledOnBackground.Height ); } else { boundsCircle = memSprNum.BoundsCircleScaledOnBackground; } Rectangle boundsText; if (isOnWindow) { boundsText = new Rectangle( memSprNum.BoundsTextScaledOnBackground.X + (int)this.BgLocationScaled.X, memSprNum.BoundsTextScaledOnBackground.Y + (int)this.BgLocationScaled.Y, memSprNum.BoundsTextScaledOnBackground.Width, memSprNum.BoundsTextScaledOnBackground.Height ); } else { boundsText = new Rectangle( memSprNum.BoundsTextScaledOnBackground.X, memSprNum.BoundsTextScaledOnBackground.Y, memSprNum.BoundsTextScaledOnBackground.Width, memSprNum.BoundsTextScaledOnBackground.Height ); } //// 番号スプライトのサイズ string sText = memSprNum.GetText(true, this); // 後ろに、少し大きめの丸を塗ります。 Brush backBrush; if (memSprNum.IsMouseTarget) { backBrush = Brushes.YellowGreen; } else { backBrush = memSprNum.BrushBackground; } g.FillEllipse(backBrush, boundsCircle.X, boundsCircle.Y, boundsCircle.Width, boundsCircle.Height); g.DrawEllipse(memSprNum.PenForeground, boundsCircle.X, boundsCircle.Y, boundsCircle.Width, boundsCircle.Height); // 影 g.DrawString( sText, memSprNum.Font, Brushes.Black, boundsText.Location ); boundsText.Offset(-1, -1); // 文字 g.DrawString( sText, memSprNum.Font, Brushes.White, boundsText.Location ); goto process_end; // // // // process_end: ; }
//──────────────────────────────────────── public void MovePartsnumbersprite(Memory4bSpritePartsnumber mNum, float dx, float dy, float nScale, Memory1Application_Partsnumput memoryApplication_Partsnumput) { // 背景画像上のスプライト位置 mNum.LocationOnBackgroundActual = new PointF( mNum.LocationOnBackgroundActual.X + dx / nScale, mNum.LocationOnBackgroundActual.Y + dy / nScale ); //ystem.Console.WriteLine("移動前("+old.X+","+old.Y+") 移動後("+mNum.LocationOnBackgroundActual.X+","+mNum.LocationOnBackgroundActual.Y+")"); mNum.Delegate_OnChangeSprite_Partsnumber(mNum, nScale);//, ucCanvas memoryApplication_Partsnumput.IsChangedContents = true; }
//──────────────────────────────────────── /// <summary> /// 番号を追加します。 /// </summary> /// <param name="mNum"></param> public void AddPartsnumbersprite(Memory4bSpritePartsnumber mNum, bool bLoadingNow, Memory1Application_Partsnumput memoryApplication_Partsnumput) { if (!this.DictionaryLayer.ContainsKey(mNum.Number_Layer)) { List<Memory4bSpritePartsnumber> mNumList = new List<Memory4bSpritePartsnumber>(); mNumList.Add(mNum); this.DictionaryLayer.Add(mNum.Number_Layer, mNumList); } else { this.DictionaryLayer[mNum.Number_Layer].Add(mNum); } if (!bLoadingNow) { memoryApplication_Partsnumput.IsChangedContents = true; } }
//──────────────────────────────────────── public void SetText_SpritePartsnumber(Memory4bSpritePartsnumber mNum, string sText, Memory1Application_Partsnumput memoryApplication_Partsnumput) { if (mNum.Text != sText) { mNum.Text = sText; memoryApplication_Partsnumput.IsChangedContents = true; } }
//──────────────────────────────────────── private void _CalSelectedSpriteGui(Memory4bSpritePartsnumber selectedNum) { if (null == selectedNum) { // // ◇選択スプライトが無い場合。 // this.pctxtEdits.Text = ""; this.pctxtEdits.Enabled = false; this.pclblFontSmall.Enabled = false; this.pcrdiFontSmall.Enabled = false; this.pclblFontMiddle.Enabled = false; this.pcrdiFontMiddle.Enabled = false; this.pclblFontLarge.Enabled = false; this.pcrdiFontLarge.Enabled = false; this.pclblBgcolorBlue.Enabled = false; this.pcrdiBgcolorBlue.Enabled = false; this.pclblBgcolorGreen.Enabled = false; this.pcrdiBgcolorGreen.Enabled = false; } else { // // ◇選択スプライトが有る場合。 // this.pctxtEdits.Enabled = true; this.pctxtEdits.Text = selectedNum.Text; this.pclblFontSmall.Enabled = true; this.pcrdiFontSmall.Enabled = true; this.pclblFontMiddle.Enabled = true; this.pcrdiFontMiddle.Enabled = true; this.pclblFontLarge.Enabled = true; this.pcrdiFontLarge.Enabled = true; this.pclblBgcolorBlue.Enabled = true; this.pcrdiBgcolorBlue.Enabled = true; this.pclblBgcolorGreen.Enabled = true; this.pcrdiBgcolorGreen.Enabled = true; switch ((int)selectedNum.Font.Size) { case 10: this.pcrdiFontSmall.Checked = true; break; case 20: this.pcrdiFontMiddle.Checked = true; break; case 40: this.pcrdiFontLarge.Checked = true; break; default: this.pcrdiFontSmall.Checked = false; this.pcrdiFontMiddle.Checked = false; this.pcrdiFontLarge.Checked = false; break; } if (Brushes.Green == selectedNum.BrushBackground) { this.pcrdiBgcolorGreen.Checked = true; } else if (Brushes.Blue == selectedNum.BrushBackground) { this.pcrdiBgcolorBlue.Checked = true; } else { this.pcrdiBgcolorGreen.Checked = false; this.pcrdiBgcolorBlue.Checked = false; } } }