コード例 #1
0
        private void listBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            UndoRedoPair ur = listBox.SelectedItem as UndoRedoPair;

            if (ur != null)
            {
                groupBoxURName.Text     = ur.Name;
                labelURDescription.Text = ur.Message;
            }
            else
            {
                groupBoxURName.Text     = "----";
                labelURDescription.Text = "";
            }
        }
コード例 #2
0
		private void DeleteGeometricObject(GeometricObjectDataBase obj)
			{
			string notice = CurrentLanguage.StandardFunction.Delete_UserNotice.Replace( "%s", obj.Name );
			if( MessageBox.Show( notice, "", MessageBoxButtons.OKCancel, MessageBoxIcon.Information ) != DialogResult.OK ) return;

			LayerData parent = obj.ParentLayer;
			int index = parent.GeometricObjects.IndexOf( obj );
			Action undo = () => { parent.GeometricObjects.Insert( index, obj ); };
			Action redo = () => { parent.GeometricObjects.Remove( obj ); };
			parent.GeometricObjects.Remove( obj );
			Selection = parent;

			UndoRedoPair urPair = new UndoRedoPair( new UndoRedoPairString( CurrentLanguage.StandardFunction.Delete + " : GeometricObject[" + obj.Name + "]", "" ), undo, redo );
			AddUndoRedoPair( urPair );
			}
コード例 #3
0
		private void DeleteLayer(LayerData layer)
			{
			string notice = CurrentLanguage.StandardFunction.Delete_UserNotice;
			if( MessageBox.Show( notice, "", MessageBoxButtons.OKCancel, MessageBoxIcon.Information ) != DialogResult.OK ) return;

			WaveguideDesignerProjectData parent = layer.Parent as WaveguideDesignerProjectData;
			int index = parent.Layers.IndexOf( layer );
			Action undo = () => { parent.Layers.Insert( index, layer ); };
			Action redo = () => { parent.Layers.Remove( layer ); };
			parent.Layers.Remove( layer );
			Selection = parent;

			UndoRedoPair urPair = new UndoRedoPair( new UndoRedoPairString( CurrentLanguage.StandardFunction.Delete + " : Layer[" + layer.Name + "]", "" ), undo, redo );
			AddUndoRedoPair( urPair );
			}
コード例 #4
0
		private void _Paste()
			{
			if( !( Selection is LayerData || Selection is GeometricObjectDataBase ) ) return;
			if( Clipboard == null ) return;

			EnableUndoRedoStoring = false;

			GeometricObjectDataBase obj = Clipboard.DeepClone() as GeometricObjectDataBase;
			LayerData target = SelectedLayer;

			target.GeometricObjects.Add( obj );
			Action undo = () => { target.GeometricObjects.Remove( obj ); };
			Action redo = () => { target.GeometricObjects.Add( obj ); };
			UndoRedoPair urPair = new UndoRedoPair( new UndoRedoPairString( CurrentLanguage.StandardFunction.Paste + " : " + obj.Name, "" ), undo, redo );
			EnableUndoRedoStoring = true;
			AddUndoRedoPair( urPair );

			ValidateProject( DoesUpdateShapeAuto );
			}
コード例 #5
0
		private void _Cut()
			{
			if( !SelectionIsStockable ) return;

			Action undo, redo;
			GeometricObjectDataBase target = Selection as GeometricObjectDataBase;
			LayerData parent = target.Parent as LayerData;
			int index = parent.GeometricObjects.IndexOf( target );
			undo = () => { parent.GeometricObjects.Insert( index, target ); };
			redo = () => { parent.GeometricObjects.Remove( target ); };
			Clipboard = Selection as GeometricObjectDataBase;
			Clipboard.ParentLayer.GeometricObjects.Remove( Clipboard );
			Selection = parent;

			UndoRedoPair urPair = new UndoRedoPair( new UndoRedoPairString( CurrentLanguage.StandardFunction.Cut + " : " + Clipboard.ToString(), "" ), undo, redo );
			AddUndoRedoPair( urPair );

			ValidateProject( DoesUpdateShapeAuto );
			}
コード例 #6
0
		private void _AddUndoRedoPair(UndoRedoPair pair)
			{
			for( int i = 0 ; i < CurrentUndoDepth ; i++ )
				_UndoRedoPairs.RemoveAt( UndoRedoCount - 1 );
			_UndoRedoPairs.Add( pair );
			CurrentUndoDepth = 0;
			}
コード例 #7
0
		/// <summary>新しいUndoRedoPairを追加する。CurrentUndoDepthが0出ない場合、現時点よりも新しいUndoRedoPairは破棄される。</summary>
		/// <param name="pair"></param>
		private void AddUndoRedoPair(UndoRedoPair pair)
			{
			string methodName = "Application.AddUndoRedoPair";
			LogMethodStart( methodName );
			WriteLog( GetIndents( 1 ) + "pair : " + pair.ToString() );
			_AddUndoRedoPair( pair );
			LogMethodEnd( methodName );
			}
コード例 #8
0
		/// <summary>プロジェクトデータのプロパティを変更する。変更はUndo/Redoリストに追加される。</summary>
		/// <param name="targetObject"></param>
		/// <param name="targetProperty"></param>
		/// <param name="newValue"></param>
		public void ChangeProperty(object targetObject, PropertyInfo targetProperty, object newValue)
			{
			LogMethodStart();
			WriteLog( GetIndents( 1 ) + "target object   : " + targetObject.ToString() );
			WriteLog( GetIndents( 1 ) + "target property : " + targetProperty.DeclaringType.FullName + "." + targetProperty.Name );
			WriteLog( GetIndents( 1 ) + "new value       : " + newValue.ToString() );
			// targetObjectがtargetPropertyを持たないクラスであればArgumentExceptionをスローする。
			if( !IsTypeOf( targetObject, targetProperty.DeclaringType ) )
				throw new ArgumentException( "Type of targetObject doesn't have property of targetProperty." );
			// newValueがtargetPropertyの型でなければArgumentExceptionをスローする。
			if( !IsTypeOf( newValue, targetProperty.PropertyType ) )
				throw new ArgumentException( "Type of newValue isn't targetProperty type." );

			// 現在の値。Undo作成に利用。
			object oldValue = targetProperty.GetValue( targetObject );

			// 値の変更。
			targetProperty.SetValue( targetObject, newValue );

			// Undo/Redoの言語対応文字列を取得する
			UndoRedoPairString urString;
			try
				{
				PropertyInfo urStringContainerGetter = typeof( LanguagePack ).GetProperty( targetObject.GetType().Name )
					?? typeof( LanguagePack ).GetProperty( targetProperty.DeclaringType.Name );
				object container = urStringContainerGetter?.GetValue( CurrentLanguage );
				PropertyInfo urStringGetter = container?.GetType().GetProperty( targetProperty.Name + "Changed" );
				urString = urStringGetter.GetValue( container ) as UndoRedoPairString;
				}
			catch
				{
				urString = CurrentLanguage.ProjectDataBase_PropertyChangedDefault;
				}

			// Undo/Redoの作成
			Action undo = () => { targetProperty.SetValue( targetObject, oldValue ); };
			Action redo = () => { targetProperty.SetValue( targetObject, newValue ); };
			UndoRedoPair urPair = new UndoRedoPair( urString, undo, redo );
			AddUndoRedoPair( urPair );
			LogMethodEnd();
			}