|
Nice. I voted 5 lifting your average dramatically (I also reported a little bug [^]in
the average calculation, not showing any more since I casted my vote).
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi
I'm using CodeDom and I want it to generate code such as the following:
if (var is MyClass)
{
}
The code I am currently using to perform the generation is
CodeConditionStatement ifStatement = new CodeConditionStatement();
ifStatement.Condition = new CodeBinaryOperatorExpression(lhs,
CodeBinaryOperatorType.IdentityEquality, rhs);
this code will generate the below statement
if (var == MyClass)
{
}
All that needs to change is the ==, which needs to change to 'is'. Is this possible to do in CodeDom?
Also note that 'var' can also be a child class of MyClass (which is why I did not use var.GetType() == typeof(MyClass))
thanks
|
|
|
|
|
danielk_,
Dunno, why don't you type it and see what happens? Would be a lot quicker than waiting for an answer...
Regards,
Gareth.
|
|
|
|
|
AFAIK it's impossible to generate 'is' using CodeDom. You can try to use typeof(MyClass).IsInstanceOfType(var).
|
|
|
|
|
looks good. IsInstanceOfType should do the job
thanks
|
|
|
|
|
hi
is that anyWay to save html pages to database fully (with all images,styles,...) and retrieve & display it when we request it ?
thanks
|
|
|
|
|
Sure. You need to be able to store a zip or an arbitrary number of files, as you will have no idea how many images there will be.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
thanks for reply
no i don't make zip file, i want to search in it via FTS (full text search) or use Regular Expression in html text.
|
|
|
|
|
Press x-axis it (rotates around x-axis looks OK) // Button
Press y-axis it (rotates around y-axis looks OK) // button
Press z-axis it (rotates around z-axis looks OK) // Button
Press x-axis it (rotates around x-axis looks Bad) it is rotating on z-axis, Now you cannot predict how this is going to rotate it.
I checked the angles and I was unable to setValue in any sense. Please look the code.
Best regards
Agha Khan
<Window x:Class="Wpf3DTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="600" Width="600" WindowStartupLocation="CenterScreen">
<Window.Resources>
<MeshGeometry3D x:Key="UnitCube"
Positions="-0.5 0.5 0.5, 0.5 0.5 0.5,
-0.5 -0.5 0.5, 0.5 -0.5 0.5,
0.5 0.5 -0.5, -0.5 0.5 -0.5,
0.5 -0.5 -0.5, -0.5 -0.5 -0.5,
-0.5 0.5 -0.5, -0.5 0.5 0.5,
-0.5 -0.5 -0.5, -0.5 -0.5 0.5,
0.5 0.5 0.5, 0.5 0.5 -0.5,
0.5 -0.5 0.5, 0.5 -0.5 -0.5,
-0.5 0.5 -0.5, 0.5 0.5 -0.5,
-0.5 0.5 0.5, 0.5 0.5 0.5,
0.5 -0.5 -0.5, -0.5 -0.5 -0.5,
0.5 -0.5 0.5, -0.5 -0.5 0.5"
TriangleIndices=" 0 2 1, 1 2 3
4 6 5, 5 6 7,
8 10 9, 9 10 11,
12 14 13, 13 14 15
16 18 17, 17 18 19
20 22 21, 21 22 23"
TextureCoordinates=
"0.000 0, 0.167 0, 0.000 1, 0.167 1,
0.167 0, 0.333 0, 0.167 1, 0.333 1,
0.333 0, 0.500 0, 0.333 1, 0.500 1,
0.500 0, 0.667 0, 0.500 1, 0.667 1,
0.667 0, 0.833 0, 0.667 1, 0.833 1,
0.833 0, 1.000 0, 0.833 1, 1.000 1" />
<DiffuseMaterial x:Key="DMX0Y2Z0">
<DiffuseMaterial.Brush>
<VisualBrush RenderOptions.CachingHint="Cache">
<VisualBrush.Visual>
<UniformGrid Name="GNX0Y2Z0" Rows="1" Columns="6" Width="600" Height="100">
<Grid>
<!-- Front of the cube White -->
<Rectangle Fill="Gray" Stroke="Black"/>
<Rectangle Margin="5" RadiusX="5" RadiusY="5" Fill="Honeydew" />
</Grid>
<Grid>
<!-- Back hand side of the cube Yellow -->
<Rectangle Fill="Gray" Stroke="Black"/>
<Rectangle Margin="5" RadiusX="5" RadiusY="5" Fill="Yellow" />
</Grid>
<Grid>
<!-- Left hand side cube Blue -->
<Rectangle Fill="Gray" Stroke="Black"/>
<Rectangle Margin="5" RadiusX="5" RadiusY="5" Fill="Blue" />
</Grid>
<Grid>
<!-- Right side cube Green -->
<Rectangle Fill="Gray" Stroke="Black"/>
<Rectangle Margin="5" RadiusX="5" RadiusY="5" Fill="Chartreuse" />
</Grid>
<Grid>
<!-- Top side cube Red -->
<Rectangle Fill="Gray" Stroke="Black"/>
<Rectangle Margin="5" RadiusX="5" RadiusY="5" Fill="Red" />
</Grid>
<Grid>
<!-- Bottom side cube Cyan -->
<Rectangle Fill="Gray" Stroke="Black"/>
<Rectangle Margin="5" RadiusX="5" RadiusY="5" Fill="HotPink" />
</Grid>
</UniformGrid>
</VisualBrush.Visual>
</VisualBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
<GeometryModel3D x:Key="ReCubeX0Y2Z0"
Geometry="{StaticResource UnitCube}"
Material="{StaticResource DMX0Y2Z0}">
<GeometryModel3D.Transform>
<TranslateTransform3D OffsetX="-1.0" OffsetY="1.0" OffsetZ="-1.0" />
</GeometryModel3D.Transform>
</GeometryModel3D>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<DockPanel Grid.Column="0">
<StackPanel HorizontalAlignment="Stretch">
<StackPanel.Background>
<LinearGradientBrush>
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="DarkKhaki" Offset=".3"/>
<GradientStop Color="DarkKhaki" Offset=".7"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
</StackPanel.Background>
<Canvas >
<Button Name="simpleButton1" Canvas.Left="30" Canvas.Top="110" Click="RotateClickX">Rotate X</Button>
<Button Name="simpleButton2" Canvas.Left="30" Canvas.Top="150" Click="RotateClickY">Rotate Y</Button>
<Button Name="simpleButton3" Canvas.Left="30" Canvas.Top="190" Click="RotateClickZ">Rotate Z</Button>
</Canvas>
</StackPanel>
</DockPanel>
<DockPanel Grid.ColumnSpan="2">
<ScrollBar Name="horz" DockPanel.Dock="Bottom" Orientation="Horizontal"
Minimum="-180" Maximum="180"
LargeChange="10" SmallChange="1" />
<ScrollBar Name="vert" DockPanel.Dock="Right" Orientation="Vertical"
Minimum="-180" Maximum="180"
LargeChange="10" SmallChange="1" Width="17" />
<Viewport3D Name="viewport3d">
<ModelVisual3D x:Name="CUBEX0Y2Z0" Content="{StaticResource ReCubeX0Y2Z0}"/>
<!-- Light sources. -->
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup>
<AmbientLight Color="White" />
<DirectionalLight Color="White" Direction="2, -3 -1" />
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
<!-- Camera. -->
<Viewport3D.Camera>
<PerspectiveCamera Position="-3 3 8"
LookDirection="3 -3 -8"
UpDirection="0 1 0"
FieldOfView="60">
<PerspectiveCamera.Transform>
<Transform3DGroup>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D Axis="1,0,0" Angle="{Binding ElementName=vert, Path=Value}" />
</RotateTransform3D.Rotation>
</RotateTransform3D>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D Axis="0,1,0" Angle="{Binding ElementName=horz, Path=Value}" />
</RotateTransform3D.Rotation>
</RotateTransform3D>
</Transform3DGroup>
</PerspectiveCamera.Transform>
</PerspectiveCamera>
</Viewport3D.Camera>
</Viewport3D>
</DockPanel>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Windows.Media.Media3D;
namespace Wpf3DTest
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
AxisAngleRotation3D RotationX = new AxisAngleRotation3D();
RotationX.Axis = new Vector3D(1, 0, 0);
RotationX.Angle = 0;
Transform3D t3d = new RotateTransform3D(RotationX);
Transform3DGroup transformGroup = new Transform3DGroup();
transformGroup.Children.Add(t3d); //X
AxisAngleRotation3D RotationY = new AxisAngleRotation3D();
RotationY.Angle = 0;
RotationY.Axis = new Vector3D(0, 1, 0);
t3d = new RotateTransform3D(RotationY);
transformGroup.Children.Add(t3d); //Y
AxisAngleRotation3D RotationZ = new AxisAngleRotation3D();
RotationZ.Angle = 0;
RotationZ.Axis = new Vector3D(0, 0, 1);
t3d = new RotateTransform3D(RotationZ);
transformGroup.Children.Add(t3d); //Z
int c = transformGroup.Children.Count;
CUBEX0Y2Z0.Transform = transformGroup;
}
private void RotateClickX(object sender, RoutedEventArgs e)
{
DoubleAnimation da = new DoubleAnimation();
da.By = 90;
da.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
double CurrentValue = (double)((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[0]).Rotation.GetValue(AxisAngleRotation3D.AngleProperty);
if (CurrentValue >= 360.0)
{
CurrentValue %= 360;
((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[0]).Rotation.SetValue(AxisAngleRotation3D.AngleProperty, CurrentValue);
}
AxisAngleRotation3D Rotation = (AxisAngleRotation3D)((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[0]).Rotation;
if (Rotation.Angle >= 360)
Rotation.Angle = CurrentValue;
Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, da);
}
private void RotateClickY(object sender, RoutedEventArgs e)
{
DoubleAnimation da = new DoubleAnimation();
da.By = 90;
da.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
double CurrentValue = (double)((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[1]).Rotation.GetValue(AxisAngleRotation3D.AngleProperty);
if (CurrentValue >= 360.0)
((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[1]).Rotation.SetValue(AxisAngleRotation3D.AngleProperty, 0.0);
AxisAngleRotation3D Rotation = (AxisAngleRotation3D)((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[1]).Rotation;
Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, da);
}
private void RotateClickZ(object sender, RoutedEventArgs e)
{
DoubleAnimation da = new DoubleAnimation();
da.By = 90;
da.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
double CurrentValue = (double)((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[2]).Rotation.GetValue(AxisAngleRotation3D.AngleProperty);
if (CurrentValue >= 360.0)
((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[2]).Rotation.SetValue(AxisAngleRotation3D.AngleProperty, 0.0);
AxisAngleRotation3D Rotation = (AxisAngleRotation3D)((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[2]).Rotation;
Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, da);
}
}
}
|
|
|
|
|
When you rotate an object, all the axis move. So, when you rotate around the X again, the X is not where it was.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Dear Christian Graus:
Forgive me my ignorance; I am rotating only one axis Not all (As I see it) . I think change is very small in code. Is this possible for you to guide me how to fix this problem? I would like to rotate only on desire axis about 90 degree from previous location. You help will be very much appreciated. It is blocking issue for me.
Best regards
|
|
|
|
|
Graphics g = Graphics.FromHwnd(listView.Handle);
...???
how to make a Bitmap object to copy from g?
chesnokov
|
|
|
|
|
There are many articles on doing screenshots, but I thought controls had a general method you could call that draws them onto a graphics object you provide.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Guy
why u r try get from the graphics?
try like this
Bitmap s = Bitmap.FromResource(listview.Handle);
i hope this is help to u.
|
|
|
|
|
Does that really work ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
hello
i want to get forms list in the solution of another solution.
i found that maybe i can do it by Reflection namespace but i dont know how!
plz help me.
thanks.
|
|
|
|
|
Yes, if you can do it at all, it will be via reflection. But, I doubt you can iterate over the classes of another running process ( is that what you're saying ). Can you even be sure it's a .NET project ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hello. i have 2 .net project. i want to access form's name of first poroject in second project . i want to definite authentication and authorize of users to that forms.
if you have beter idea, plz help me.
|
|
|
|
|
laleh.rajabi,
All you need to do is add a reference to the dll in your project. Right click on References -> Add Reference-> your dll
Regards,
Gareth.
|
|
|
|
|
Solution or assemblies?
If what you mean is assemblies(dlls & exe), you can get the list of classes via reflection, then look at the base class name for forms. If the form's base class is an inherited form, look for the inherited form class name.
|
|
|
|
|
By world time i mean a time of a server or anything, NOT THE COMPUTER'S TIME, it could be the Greenwich time or anything but i want it to be the same in any computer i log in.
thanks.
|
|
|
|
|
There are webservices around that do this. You're going to end up with the time on SOME computer, somewhere. But, one would assume it was going to be correct.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
How does that help ? He wants to sychronise time between PCs, DateTime.Now is not going to do that, no matter what time zone he converts it to.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|