本文整理汇总了C#中Canguro类的典型用法代码示例。如果您正苦于以下问题:C# Canguro类的具体用法?C# Canguro怎么用?C# Canguro使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Canguro类属于命名空间,在下文中一共展示了Canguro类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnalysisOptionsDialog
public AnalysisOptionsDialog(Canguro.Controller.CommandServices services)
{
this.services = services;
InitializeComponent();
Init();
UpdateDialog();
}
示例2: Run
/// <summary>
/// Executes the command.
/// Opens the Open File Dialog and Loads the selected tsm file.
/// Asks to save changes if needed.
/// </summary>
/// <param name="services">CommandServices object to interact with the system</param>
public override void Run(Canguro.Controller.CommandServices services)
{
if (services.Model.Modified)
{
DialogResult dr = MessageBox.Show(Culture.Get("askSaveChangesAndExit"), Application.ProductName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
if (dr == DialogResult.Cancel)
return;
else if (dr == DialogResult.Yes)
services.Run(new SaveModelCmd());
}
string path = "";
System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
dlg.Filter = "Treu Structure Model (*.tsm)|*.tsm";
dlg.DefaultExt = "tsm";
dlg.AddExtension = true;
dlg.Title = Culture.Get("OpenFileTitle");
if (services.Model.CurrentPath.Length > 0)
dlg.FileName = services.Model.CurrentPath;
dlg.CheckPathExists = true;
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
path = dlg.FileName;
try
{
if (path.Length > 0)
{
services.Model.Load(path);
}
}
catch
{
MessageBox.Show(Culture.Get("errorLoadingFile") + " " + path, Culture.Get("error"),
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例3: Run
/// <summary>
/// Executes the command.
/// Moves the joint according to a given scale factor and pivot point.
/// </summary>
/// <param name="services">CommandServices object to interact with the system</param>
public override void Run(Canguro.Controller.CommandServices services)
{
List<Canguro.Model.Joint> selection = new List<Canguro.Model.Joint>();
List<Item> selectedItems = services.GetSelection();
if (selectedItems.Count == 0)
return;
foreach (Item item in selectedItems)
{
if (item is Joint)
selection.Add((Joint)item);
else if (item is LineElement)
{
LineElement l = (LineElement)item;
if (!selection.Contains(l.I))
selection.Add(l.I);
if (!selection.Contains(l.J))
selection.Add(l.J);
}
}
Microsoft.DirectX.Vector3 piv;
float scale = services.GetSingle(Culture.Get("getScale"));
Controller.Snap.Magnet m = services.GetPoint(Culture.Get("pivotScalePoint"));
if (m == null) return;
piv = m.SnapPosition;
foreach (Canguro.Model.Joint j in selection)
{
j.X = (j.X - piv.X) * scale + piv.X;
j.Y = (j.Y - piv.Y) * scale + piv.Y;
j.Z = (j.Z - piv.Z) * scale + piv.Z;
}
}
示例4: Run
/// <summary>
/// Executes the command.
/// Creates a series of connected Line Elements given at least 2 points. Each subsequent point given adds a new Line Element.
/// </summary>
/// <param name="services">CommandServices object to interact with the system</param>
public override void Run(Canguro.Controller.CommandServices services)
{
LineElement line;
Joint joint1, joint2;
LineProps props = new StraightFrameProps();
List<LineElement> newLines = new List<LineElement>();
List<AreaElement> newAreas = new List<AreaElement>();
services.GetProperties(Culture.Get("addLineProps"), props);
joint1 = services.GetJoint(newLines);
services.TrackingService = LineTrackingService.Instance;
services.TrackingService.SetPoint(joint1.Position);
try
{
while ((joint2 = services.GetJoint(newLines)) != null)
{
if (joint2 != joint1)
{
services.Model.LineList.Add(line = new LineElement(props, joint1, joint2));
newLines.Add(line);
joint1 = joint2;
services.TrackingService.SetPoint(joint1.Position);
// Para que se refleje el cambio inmediatamente
services.Model.ChangeModel();
}
}
}
catch (Canguro.Controller.CancelCommandException) { }
if (newLines.Count == 0)
services.Model.Undo.Rollback();
else
JoinCmd.Join(services.Model, new List<Joint>(), newLines, newAreas);
}
示例5: Run
/// <summary>
/// Executes the command.
/// Sets the IsSelected property of all the Items in the Active Layer to true.
/// </summary>
/// <param name="services">CommandServices object to interact with the system</param>
public override void Run(Canguro.Controller.CommandServices services)
{
Layer layer = services.Model.ActiveLayer;
foreach (Item item in layer.Items)
item.IsSelected = true;
services.Model.ChangeSelection(null);
}
示例6: Run
/// <summary>
/// Executes the command.
/// Deletes the selected Items.
/// If none is selected, it requests a selection.
/// </summary>
/// <param name="services">CommandServices object to interact with the system</param>
public override void Run(Canguro.Controller.CommandServices services)
{
Canguro.Model.Model model = services.Model;
if (model.LoadCases.Count > 1)
{
Canguro.Model.Load.LoadCase oldCase = model.ActiveLoadCase;
// Remove associated AnalysisCase
// Find the corresponding AbstractCase
Canguro.Model.Load.AnalysisCase aCase = null;
foreach (Canguro.Model.Load.AbstractCase ac in services.Model.AbstractCases)
if (ac is Canguro.Model.Load.AnalysisCase && ac.Name.Equals(oldCase.Name))
{
aCase = (Canguro.Model.Load.AnalysisCase)ac;
break;
}
bool deleteLCase = true;
// Now remove the AnalysisCase
if (aCase != null)
deleteLCase = services.Model.AbstractCases.Remove(aCase);
if (deleteLCase)
{
services.Model.LoadCases.Remove(oldCase.Name);
services.Model.ChangeModel();
}
}
}
示例7: Run
/// <summary>
/// Executes the Non-Interactive Command.
/// Sets the RotationMatrix for the View with a Default 3D View and Executes ZoomAll.
/// </summary>
/// <param name="activeView">The Current Active View object</param>
public override void Run(Canguro.View.GraphicView activeView)
{
activeView.ArcBallCtrl.ResetRotation();
activeView.ArcBallCtrl.RotationMatrix = Matrix.RotationX(-(float)Math.PI / 2.0f) * Matrix.RotationY(-3.0f * (float)Math.PI / 4.0f) * Matrix.RotationX((float)Math.PI / 6.0f);
activeView.ViewMatrix = activeView.ArcBallCtrl.ViewMatrix;
ZoomAll.Instance.Run(activeView);
}
示例8: LineMagnet
public LineMagnet(Canguro.Model.LineElement line)
: base(line.I.Position)
{
this.direction = line.J.Position - line.I.Position;
this.type = LineMagnetType.FollowProjection;
this.line = line;
}
示例9: Reset
public void Reset(Canguro.View.GraphicView activeView)
{
if (trackingService != null)
trackingService.Reset(activeView);
snapController.Reset(activeView);
hoverController.Reset(activeView);
}
示例10: Run
/// <summary>
/// Executes the command.
/// Gets the Load Case properties from the User, adds it to the Model and sets it as Active.
/// </summary>
/// <param name="services">CommandServices object to interact with the system</param>
public override void Run(Canguro.Controller.CommandServices services)
{
string name = Culture.Get("defaultLoadCase");
LoadCase lCase = new LoadCase(name, LoadCase.LoadCaseType.Dead);
lCase.Name = name;
// services.GetProperties(lCase.Name, lCase, false);
EditLoadCaseDialog dlg = new EditLoadCaseDialog(lCase);
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (!services.Model.LoadCases.ContainsKey(lCase.Name))
services.Model.LoadCases.Add(lCase.Name, lCase);
services.Model.ActiveLoadCase = lCase;
AnalysisCase aCase = new AnalysisCase(lCase.Name);
StaticCaseProps props = aCase.Properties as StaticCaseProps;
if (props != null)
{
List<StaticCaseFactor> list = props.Loads;
list.Add(new StaticCaseFactor(lCase));
props.Loads = list;
services.Model.AbstractCases.Add(aCase);
}
}
else
services.Model.Undo.Rollback();
}
示例11: Run
public override void Run(Canguro.Controller.CommandServices services)
{
services.StoreSelection();
LineElement line = services.GetLine();
List<LinkedList<LineElement>> graph = GetLineGraph(services.Model);
ItemList<Joint> joints = services.Model.JointList;
int numJoints = joints.Count;
bool[] colors = new bool[numJoints];
Stack<LineElement> stack = new Stack<LineElement>();
stack.Push(line);
while (stack.Count > 0)
{
line = stack.Pop();
line.IsSelected = true;
if (!colors[line.I.Id])
{
line.I.IsSelected = true;
visit(graph, (int)line.I.Id, stack, line);
colors[line.I.Id] = true;
}
if (!colors[line.J.Id])
{
line.J.IsSelected = true;
visit(graph, (int)line.J.Id, stack, line);
colors[line.J.Id] = true;
}
}
services.RestoreSelection();
services.Model.ChangeSelection(null);
}
示例12: Run
/// <summary>
/// Executes the command.
/// Deletes all Items in a Layer
/// </summary>
/// <param name="services">CommandServices object to interact with the system</param>
public override void Run(Canguro.Controller.CommandServices services)
{
int count = 0;
foreach (Layer layer in services.Model.Layers)
if (layer != null)
count++;
services.Model.UnSelectAll();
if (services.Model.ActiveLayer.Items.Count > 0)
System.Windows.Forms.MessageBox.Show(Culture.Get("layerHasObjectsError"), Culture.Get("error"), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
else if (count <= 1)
System.Windows.Forms.MessageBox.Show(Culture.Get("lastLayerError"), Culture.Get("error"), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
else
{
Layer deletedLayer = services.Model.ActiveLayer;
foreach (Layer active in services.Model.Layers)
if (active != null && active != deletedLayer)
{
services.Model.ActiveLayer = active;
break;
}
Layer activeLayer = services.Model.ActiveLayer;
foreach (Item item in services.Model.LineList)
if (item != null && item.IsSelected)
item.Layer = activeLayer;
foreach (Item item in services.Model.JointList)
if (item != null && item.IsSelected)
item.Layer = activeLayer;
services.Model.Layers.Remove(deletedLayer);
}
}
示例13: RecalcPrimaryDependant
public void RecalcPrimaryDependant(Canguro.View.GraphicView activeView, PointMagnet primaryPoint, LineMagnet[] globalAxes)
{
if (primaryPoint != null)
{
// Move area to lay on the primaryPoint and to set its direction any canonic
// plane (X=x, Y=y or Z=z) which is the most paralell to the screen plane
position = primaryPoint.Position;
// Get screen plane normal
Vector3 s0 = screenNormal[0], s1 = screenNormal[1], sNormal;
activeView.Unproject(ref s0);
activeView.Unproject(ref s1);
sNormal = s0 - s1;
// Assign the area normal to the most paralell canonical plane
// (giving priority to the Z plane)
int maxCosIndex = 2;
float cosX, cosY, cosZ;
cosX = Vector3.Dot(sNormal, globalAxes[0].Direction);
cosY = Vector3.Dot(sNormal, globalAxes[1].Direction);
cosZ = Vector3.Dot(sNormal, globalAxes[2].Direction);
if (Math.Abs(cosZ) < minZPlaneAngle)
maxCosIndex = (cosX >= cosY) ? ((cosX > cosZ) ? 0 : 2) : ((cosY > cosZ) ? 1 : 2);
normal = globalAxes[maxCosIndex].Direction;
}
else
{
position = Vector3.Empty;
normal = globalAxes[2].Direction;
}
}
示例14: Run
/// <summary>
/// Executes the command.
/// Opens the Sections Dialog
/// </summary>
/// <param name="services">CommandServices object to interact with the system</param>
public override void Run(Canguro.Controller.CommandServices services)
{
SectionsGUI gui = new SectionsGUI();
if (services.ShowDialog(gui) == System.Windows.Forms.DialogResult.Cancel)
throw new Canguro.Controller.CancelCommandException();
services.Model.ChangeModel(true);
}
示例15: ButtonDown
public override void ButtonDown(Canguro.View.GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
{
gv = activeView;
oldM = gv.ViewMatrix;
firstY = e.Y;
gv.ArcBallCtrl.OnBeginZoom(e);
}