//tests //copy function in models private void CopyExecute(object obj) { //tests //Console.WriteLine("From : " + LeftSide.SelectedPath); //Console.WriteLine("Where : " + RightSide.SelectedPath) string source = ""; string target = ""; //LEFT SIDE if (LeftSide.SelectedPath != null) { source = Path.Combine(LeftSide.CurrentPath, LeftSide.GetSelectedPath()); target = Path.GetFullPath(RightSide.CurrentPath); } // RIGHT SIDE else if (RightSide.SelectedPath != null) { source = Path.Combine(RightSide.CurrentPath, RightSide.GetSelectedPath()); target = Path.GetFullPath(LeftSide.CurrentPath); } copyModel.Copy(source, target); // Model -> CopyModel.cs UpdateView(); //UpdateView }
internal BattleState GetWithDefeatedRemoved() { BattleStageSide newLeftSide = LeftSide.GetRepositionedSurvivors(); BattleStageSide newRightSide = RightSide.GetRepositionedSurvivors(); return(new BattleState(newLeftSide, newRightSide)); }
private void RemoveAllSides() { SuspendLayout(); if (LeftSide != null) { LeftSide.Parent = null; LeftSide.Dispose(); LeftSide = null; } if (TopSide != null) { TopSide.Parent = null; TopSide.Dispose(); TopSide = null; } if (RightSide != null) { RightSide.Parent = null; RightSide.Dispose(); RightSide = null; } if (BottomSide != null) { BottomSide.Parent = null; BottomSide.Dispose(); BottomSide = null; } RootControl.SetBounds( ViewConstants.Spacing, ViewConstants.Spacing, Width - ViewConstants.Spacing * 2, Height - ViewConstants.Spacing * 2, BoundsSpecified.All); ResumeLayout(true); }
static void Main(string[] args) { int Sstate = Convert.ToInt32(Console.ReadLine()); int Ystate = Convert.ToInt32(Console.ReadLine()); int Nstate = Convert.ToInt32(Console.ReadLine()); string Tape = ">" + Console.ReadLine() + "_"; Dictionary <LeftSide, RightSide> Rules = new Dictionary <LeftSide, RightSide>(); string s; while ((s = Console.ReadLine()) != "") { string[] tr = s.Split(' '); // state symbol state' symbol' command Rules.Add(new LeftSide(Convert.ToInt32(tr[0]), Convert.ToChar(tr[1])), new RightSide(Convert.ToInt32(tr[2]), Convert.ToChar(tr[3]), Convert.ToChar(tr[4]))); } int State = Sstate; int TapeIdx = 1; const int VK_SPACE = 0x20; try { while (State != Ystate && State != Nstate) { if ((GetKeyState(VK_SPACE) & 0x8000) != 0) { Console.WriteLine("Work interrupted"); return; } RightSide r = Rules[new LeftSide(State, Tape[TapeIdx])]; State = r.State; Tape = (Tape.Remove(TapeIdx, 1)).Insert(TapeIdx, r.Symbol.ToString()); if (r.Command == 'L') { TapeIdx--; } else if (r.Command == 'R') { TapeIdx++; } if (TapeIdx >= Tape.Length) { Tape += "_"; } } Console.WriteLine(State == Ystate ? "String accepted" : "String rejected"); } catch (Exception) { Console.WriteLine("String rejected"); } Console.WriteLine("Tape: " + Tape); }
public override string ToString() { char op = char.MinValue; switch (this.operation) { case CSharpMulDivOperation.Multiplication: op = '*'; break; case CSharpMulDivOperation.Division: op = '/'; break; case CSharpMulDivOperation.Remainder: op = '%'; break; case CSharpMulDivOperation.Term: return(this.RightSide.ToString()); default: return(null); } return(string.Format("{0} {1} {2}", LeftSide.ToString(), op, RightSide.ToString())); }
public int isValid() { if (LeftSideInt.HasValue && RightSideInt.HasValue) { if (LeftSideInt.Value != RightSideInt.Value) { return(1); } else { return(0); } } else if (LeftSideInt.HasValue) { return(1); } else if (RightSideInt.HasValue) { return(1); } else { if (LeftSide.Trim() != RightSide.Trim()) { return(1); } else { return(0); } } }
public void SetRightSideControls(RightSide _RightSide) { _RightSide._SetDetailedListItem(this); _RightSide.__MergeInitialize(); m_RightSideWidth = _RightSide.Width; m_MinHeight = _RightSide.Height; for (int i = 0; i < _RightSide.Controls.Count; ++i) { Control control = _RightSide.Controls[i]; control.Anchor = AnchorStyles.Top | AnchorStyles.Right; control.Location = new Point((this.Width - m_RightSideWidth) + control.Left, control.Top); control.MouseClick += This_MouseClick; control.MouseDown += This_MouseDown; control.MouseEnter += This_MouseEnter; control.MouseUp += This_MouseUp; _RightSide.Controls.Remove(control); this.Controls.Add(control); --i; } var eventLambda = new EventSelectedDelegate((DetailedListItem _ListItem) => { _RightSide.SelectedChanged(m_Selected); }); EventSelectChanged += eventLambda; eventLambda(this); }
public MeshCutData(CutterMesh victimMesh, CutterPlane blade) { VictimMesh = victimMesh; LeftSide.SetTargetMesh(victimMesh); RightSide.SetTargetMesh(victimMesh); Blade = blade; }
public void WriteXml(XmlWriter writer) { writer.WriteStartElement("RootPanel"); if (RootPanel != null) { RootPanel.WriteXml(writer); } writer.WriteEndElement(); writer.WriteStartElement("TopSide"); if (TopSide != null) { TopSide.WriteXml(writer); } writer.WriteEndElement(); writer.WriteStartElement("RightSide"); if (RightSide != null) { RightSide.WriteXml(writer); } writer.WriteEndElement(); writer.WriteStartElement("LeftSide"); if (LeftSide != null) { LeftSide.WriteXml(writer); } writer.WriteEndElement(); writer.WriteStartElement("BottomSide"); if (BottomSide != null) { BottomSide.WriteXml(writer); } writer.WriteEndElement(); // Write all floating windows (can be LayoutDocumentFloatingWindow or LayoutAnchorableFloatingWindow). // To prevent "can not create instance of abstract type", the type is retrieved with GetType().Name writer.WriteStartElement("FloatingWindows"); foreach (var layoutFloatingWindow in FloatingWindows) { writer.WriteStartElement(layoutFloatingWindow.GetType().Name); layoutFloatingWindow.WriteXml(writer); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteStartElement("Hidden"); foreach (var layoutAnchorable in Hidden) { writer.WriteStartElement(layoutAnchorable.GetType().Name); layoutAnchorable.WriteXml(writer); writer.WriteEndElement(); } writer.WriteEndElement(); }
private void RemoveTopSide() { if (TopSide != null) { TopSide.Parent = null; TopSide.Dispose(); TopSide = null; var bounds = RootControl.Bounds; bounds.Y -= Renderer.SideTabHeight; bounds.Height += Renderer.SideTabHeight; RootControl.Bounds = bounds; var vcs = Height - Renderer.SideTabHeight * 2; if (BottomSide != null) { vcs -= Renderer.SideTabHeight; } if (LeftSide != null) { var h = LeftSide.Height; var len = LeftSide.OptimalLength; if (h >= len) { LeftSide.Top = ViewConstants.Spacing; } else { if (len > vcs) { len = vcs; } LeftSide.SetBounds( 0, ViewConstants.Spacing, Renderer.SideTabHeight, len, BoundsSpecified.Y | BoundsSpecified.Height); } } if (RightSide != null) { var h = RightSide.Height; var len = RightSide.OptimalLength; if (h >= len) { RightSide.Top = ViewConstants.Spacing; } else { if (len > vcs) { len = vcs; } RightSide.SetBounds( 0, ViewConstants.Spacing, Renderer.SideTabHeight, len, BoundsSpecified.Y | BoundsSpecified.Height); } } } }
public Shift CalcShift(Reading reading) { return(new Shift( FrontSide.CalcPercDiff(reading.FrontSide) , RearSide.CalcPercDiff(reading.RearSide) , RightSide.CalcPercDiff(reading.RightSide) , LeftSide.CalcPercDiff(reading.LeftSide) )); }
public override object SatisfiedBy(Dictionary <string, object> values) { Contract.RequiresNotNull(values, "values != null"); var leftValue = LeftSide.SatisfiedBy(values); var rightValue = RightSide.SatisfiedBy(values) as object[]; return(rightValue.Contains(leftValue)); }
private void OnFinish() { if (state == 3) { return; } else { int logs = isPlayer1 ? GameCanvas.GetPlayer1Logs() : GameCanvas.GetPlayer2Logs(); if (logs >= buildCosts[state]) { spamKeyMinigame.currentValue = 0.5f; if (isPlayer1) { GameCanvas.SetPlayer1Logs(logs - buildCosts[state]); } else { GameCanvas.SetPlayer2Logs(logs - buildCosts[state]); } state++; if (state == 3) { buildCostObject.SetActive(false); photonView.RPC("EnableSpamKey", RpcTarget.Others, true, 0, false); if (OnMaximum != null) { OnMaximum.Invoke(); } if (isPlayer1) { LeftSide.AddNewDamBeaver(); } else { RightSide.AddNewDamBeaver(); } } else { photonView.RPC("EnableSpamKey", RpcTarget.Others, true, buildCosts[state], true); } buildCostText.text = buildCosts[state].ToString(); AudioSFXReferences.PlayPurchase(); } } }
//sadly it's not a joke!! ha ha....no! public void SideSplitter(List <string> strings) { //started at element 1 to skip error with none int text; for (int i = 1; i < strings.Count(); i++) { string firstValue = strings[i].Split('\t').First(); string lastValue = strings[i].Split('\t').Last(); LeftSide.Add(Int32.Parse(firstValue)); RightSide.Add(Int32.Parse(lastValue)); } }
public int isValid() { string cleanedLeftSide = LeftSide.Trim().TrimStart(new char[] { '\'' }).TrimEnd(new char[] { '\'' }); string cleanedRightSide = RightSide.Trim().TrimStart(new char[] { '\'' }).TrimEnd(new char[] { '\'' }); if (cleanedLeftSide.Contains(cleanedRightSide)) { return(1); } else { return(0); } }
public Tile(long id, char[][] content) { Id = id; Content = content; Sides = new[] { TopSide, RightSide, BottomSide, LeftSide, string.Join("", TopSide.Reverse()), string.Join("", RightSide.Reverse()), string.Join("", BottomSide.Reverse()), string.Join("", LeftSide.Reverse()) }; }
bool AssertEquality(Variable[] valuePairs) { var dif = Math.Abs(LeftSide.EvaluateFor(valuePairs) - RightSide.EvaluateFor(valuePairs)); if (dif == 0) { Console.WriteLine("Right side = Left side"); return(true); } if (dif < 0.1) { Console.WriteLine("Right side is almost same as Left side, difference = {0}", dif); return(true); } return(false); }
public void Can_merge_to_a_third_destination_type() { // Arrange var left = new LeftSide { Name = "Test" }; var right = new RightSide { Age = 10 }; // Act var result = left.Merge <Destination, LeftSide, RightSide>(right); // Assert result.Should().NotBeNull(); result.Name.Should().Be(left.Name); result.Age.Should().Be(right.Age); }
private void Update() { if (photonView.IsMine) { if (Input.GetKeyDown(keyCode) && !_isBought) { int fishs = isPlayer1 ? GameCanvas.GetPlayer1Fish() : GameCanvas.GetPlayer2Fish(); int beavers = isPlayer1 ? GameCanvas.GetPlayer1Beavers() : GameCanvas.GetPlayer2Beavers(); if (Input.GetKeyDown(keyCode) && (fishs >= buildCost) && (beavers >= 1)) { if (isPlayer1) { GameCanvas.SetPlayer1Fish(fishs - buildCost); GameCanvas.SetPlayer1Beavers(beavers - 1); } else { GameCanvas.SetPlayer2Fish(fishs - buildCost); GameCanvas.SetPlayer2Beavers(beavers - 1); } holdKeyMinigame.currentHoldTime = 0.0f; holdKeyBold.SetActive(true); buildCostObject.SetActive(false); photonView.RPC("OnBought", RpcTarget.Others); _isBought = true; AudioSFXReferences.PlayPurchase(); if (isPlayer1) { LeftSide.AddNewFishBeaver(); } else { RightSide.AddNewFishBeaver(); } } } } }
private void RemoveRightSide() { if (RightSide != null) { RightSide.Parent = null; RightSide.Dispose(); RightSide = null; RootControl.Width += Renderer.SideTabHeight; var hcs = Width - ViewConstants.Spacing * 2; if (LeftSide != null) { hcs -= Renderer.SideTabHeight; } if (TopSide != null) { var w = TopSide.Width; var len = TopSide.OptimalLength; if (w < len) { if (len > hcs) { len = hcs; } TopSide.Width = len; } } if (BottomSide != null) { var w = BottomSide.Height; var len = BottomSide.OptimalLength; if (w < len) { if (len > hcs) { len = hcs; } BottomSide.Width = len; } } } }
internal void AddSideChild(IDockElement ele, DockSide side) { switch (side) { case DockSide.Left: LeftSide.Attach(ele); break; case DockSide.Right: RightSide.Attach(ele); break; case DockSide.Top: TopSide.Attach(ele); break; case DockSide.Bottom: BottomSide.Attach(ele); break; } }
/// <summary> /// Releases the unmanaged resources used by the <see cref="T:System.Windows.Forms.Control"/> and its child controls and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { lock (_grids) { _grids.Remove(this); } if (disposing) { _dockMarkers.Dispose(); if (LeftSide != null) { LeftSide.Dispose(); LeftSide = null; } if (TopSide != null) { TopSide.Dispose(); TopSide = null; } if (RightSide != null) { RightSide.Dispose(); RightSide = null; } if (BottomSide != null) { BottomSide.Dispose(); BottomSide = null; } if (PopupsStack != null) { PopupsStack.Dispose(); PopupsStack = null; } RootControl = null; _floatingViewForms.Clear(); } base.Dispose(disposing); }
public override string ToString() { string op = string.Empty; switch (this.Operation) { case CSharpShiftOperation.Term: return(this.RightSide.ToString()); case CSharpShiftOperation.LeftShift: op = "<<"; break; case CSharpShiftOperation.RightShift: op = ">>"; break; default: return(null); } return(string.Format("{0} {1} {2}", LeftSide.ToString(), op, RightSide.ToString())); }
public override string ToString() { char op = char.MinValue; switch (this.Operation) { case CSharpAddSubtOperation.Term: return(this.RightSide.ToString()); case CSharpAddSubtOperation.Addition: op = '+'; break; case CSharpAddSubtOperation.Subtraction: op = '-'; break; default: return(null); } return(string.Format("{0} {1} {2}", LeftSide.ToString(), op, RightSide.ToString())); }
public override string ToString() { string op = string.Empty; switch (this.operation) { case CSharpInequalityOperation.Term: return(this.RightSide.ToString()); case CSharpInequalityOperation.Equality: op = "=="; break; case CSharpInequalityOperation.Inequality: op = "!="; break; default: return(null); } return(string.Format("{0} {1} {2}", LeftSide.ToString(), op, RightSide.ToString())); }
public virtual string GenerateCode() { if (RightSide == null) { throw new MissingMandatoryElementException("RightSide is mandatory in Operation with non-unary operator"); } if (Operator == null) { throw new MissingMandatoryElementException("Operator is mandatory in Operation"); } if (Operator.Value.IsUnaryOperator()) { return($"{Operator.Value.GenerateCode()}({RightSide.GenerateCode()})"); } if (LeftSide == null) { throw new MissingMandatoryElementException("LeftSide is mandatory in Operation"); } return($"({LeftSide.GenerateCode()}) {Operator.Value.GenerateCode()} ({RightSide.GenerateCode()})"); }
private void UpdateView() { LeftSide.UpdateCurrentPathContent(); RightSide.UpdateCurrentPathContent(); }
public override IEnumerable <string> GetArguments() => base.GetArguments().Concat(RightSide.GetArguments());
public override object SatisfiedBy(Dictionary <string, object> dictionary) { Contract.RequiresNotNull(dictionary, "dictionary != null"); return(Equals(LeftSide.SatisfiedBy(dictionary), true) && Equals(RightSide.SatisfiedBy(dictionary), true)); }
public static void WriteToFile(SpineStorage storage, string filename) { var keys = storage.Keys; var sp_keys = storage.SpinousProcessKeys; logger.Info("Create XML for storage file - {0}", filename); XDocument doc = new XDocument(); doc.Add(new XElement("storage")); var root = doc.Element("storage"); #region Window Parameters var window = new XElement("window"); window.Add(new XAttribute("center", storage.windowCenter)); window.Add(new XAttribute("width", storage.windowWidth)); root.Add(window); logger.Info("Add window parameters for file - {0}", filename); #endregion #region Direction Parameters var direction = new XElement("direction"); direction.Add(new XAttribute("value", storage.direction)); root.Add(direction); logger.Info("Add direction parameter for file - {0}", filename); var imageDirection = new XElement("imageDirection"); imageDirection.Add(new XAttribute("value", storage.imageDirection)); root.Add(imageDirection); logger.Info("Add image direction parameter for file - {0}", filename); #endregion #region Angle Parameters var angle = new XElement("angle"); angle.Add(new XAttribute("value", storage.GetRotatingAngle())); root.Add(angle); logger.Info("Add angle parameter for file - {0}", filename); #endregion #region Marker Points var markers = new XElement("markers"); if (storage.GetMarkersCount() != 0) { for (int i = 0; i < 4; i++) { var point = storage.GetMarkerPoint(i); var p = new XElement("point"); p.Add(new XAttribute("x", point.X)); p.Add(new XAttribute("y", point.Y)); markers.Add(p); } } root.Add(markers); logger.Info("Add markers parameter for file - {0}", filename); #endregion #region Marker Line var markerLine = storage.MarkerLine; if (markerLine != null) { XElement marker = new XElement("markerline"); marker.Add(new XAttribute("size", storage.MarkerSize)); marker.Add(new XAttribute("length", storage.MarkerLength)); XElement point_first = new XElement("point_first"); XElement point_second = new XElement("point_second"); point_first.Add(new XAttribute("first", markerLine.Item1.Item1)); point_first.Add(new XAttribute("second", markerLine.Item1.Item2)); point_first.Add(new XAttribute("third", markerLine.Item1.Item3)); marker.Add(point_first); point_second.Add(new XAttribute("first", markerLine.Item2.Item1)); point_second.Add(new XAttribute("second", markerLine.Item2.Item2)); point_second.Add(new XAttribute("third", markerLine.Item2.Item3)); marker.Add(point_second); root.Add(marker); } #endregion logger.Info("Add pixel parameters for file - {0}", filename); foreach (var key in keys) { var state = storage.GetDescription(key); var element = new XElement("spine"); var attr = new XAttribute("key", key); element.Add(attr); var points_element = new XElement("points"); var upleft_el = new XElement("point"); upleft_el.SetAttributeValue("x", state.UpLeft.X); upleft_el.SetAttributeValue("y", state.UpLeft.Y); var downleft_el = new XElement("point"); downleft_el.SetAttributeValue("x", state.DownLeft.X); downleft_el.SetAttributeValue("y", state.DownLeft.Y); var downright_el = new XElement("point"); downright_el.SetAttributeValue("x", state.DownRight.X); downright_el.SetAttributeValue("y", state.DownRight.Y); var upright_el = new XElement("point"); upright_el.SetAttributeValue("x", state.UpRight.X); upright_el.SetAttributeValue("y", state.UpRight.Y); points_element.Add(upleft_el); points_element.Add(downleft_el); points_element.Add(downright_el); points_element.Add(upright_el); element.Add(points_element); var geom_element = new XElement("geometry"); IDescriptionCalculator <SpineDescription> calc = null; if (storage.direction == 0) { calc = new RightSide(state); } else if (storage.direction == 1) { calc = new LeftSide(state); } else if (storage.direction == 2) { calc = new FrontSide(state); } else if (storage.direction == 3) { calc = new BackSide(state); } var ks = calc.Keys; foreach (var key_param in ks) { var geom_node = new XElement("param"); attr = new XAttribute("key", key_param); geom_node.Add(attr); attr = new XAttribute("value", calc.GetParameter(key_param)); geom_node.Add(attr); geom_element.Add(geom_node); } element.Add(geom_element); root.Add(element); logger.Info("Add spine {0} parameters for file - {1}", key, filename); } foreach (var key in sp_keys) { var state = storage.GetSpinousProcessDescription(key); var element = new XElement("process"); var attr = new XAttribute("key", key); element.Add(attr); var points_element = new XElement("points"); var uptp_el = new XElement("point"); uptp_el.SetAttributeValue("x", state.UpPoint.X); uptp_el.SetAttributeValue("y", state.UpPoint.Y); var vertp_el = new XElement("point"); vertp_el.SetAttributeValue("x", state.VertexPoint.X); vertp_el.SetAttributeValue("y", state.VertexPoint.Y); var downtp_el = new XElement("point"); downtp_el.SetAttributeValue("x", state.DownPoint.X); downtp_el.SetAttributeValue("y", state.DownPoint.Y); points_element.Add(uptp_el); points_element.Add(vertp_el); points_element.Add(downtp_el); element.Add(points_element); var geom_element = new XElement("geometry"); IDescriptionCalculator <SpinousProcessDescription> calc1 = null; if (storage.direction == 0) { calc1 = new DescriptionCalculators.SpinousProcess.RightSide(state); } else if (storage.direction == 1) { calc1 = new DescriptionCalculators.SpinousProcess.LeftSide(state); } var ks = calc1.Keys; foreach (var key_param in ks) { var geom_node = new XElement("param"); attr = new XAttribute("key", key_param); geom_node.Add(attr); attr = new XAttribute("value", calc1.GetParameter(key_param)); geom_node.Add(attr); geom_element.Add(geom_node); } element.Add(geom_element); root.Add(element); logger.Info("Add process {0} parameters for file - {1}", key, filename); } doc.Save(filename); logger.Info("Storage file has been saved - {0}", filename); }