private void InitializeDefaultSelections() { // Set filter options and filter index openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); openFileDialog.Filter = GetFileDialogFilter(); openFileDialog.FilterIndex = 0; openFileDialog.Multiselect = true; // Set default input folder _mInputFolderDialog = new CommonOpenFileDialog(); _mInputFolderDialog.IsFolderPicker = true; _mInputFolderDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // Set default input format fileFormatComboBox.Items.AddRange(ConversionManager.GetSupportedFormats().ToArray()); fileFormatComboBox.SelectedIndex = 0; // Set default output folder _mOutputPathDialog = new CommonOpenFileDialog(); _mOutputPathDialog.IsFolderPicker = true; _mOutputPathDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); outputLocationTextBox.Text = _mOutputPathDialog.InitialDirectory; // Event handlers fileRadioButton.Click += fileRadioButton_isClicked; folderRadioButton.Click += folderRadioButton_isClicked; }
/// <summary> /// Retrieves a page from the wiki and save it locally in order to be merged to the active document. /// </summary> /// <param name="pageFullName">The full name of the wiki page.</param> /// <param name="localFileName">String reference to the file path of the created document.</param> private void OpenForMerge(String pageFullName, out String localFileName) { String content = Client.GetRenderedPageContent(pageFullName); String suffix = "__LATEST"; String folder = addin.AddinSettings.PagesRepository + "TempPages"; localFileName = pageFullName.Replace(".", "-") + suffix; ConvertToNormalFolder(folder); ConversionManager pageConverter; //TODO: The converter info should be merged. pageConverter = new ConversionManager(addin.AddinSettings, addin.serverURL, folder, pageFullName, localFileName, addin.Client); //pageConverters.Add(pageFullName + suffix, pageConverter); content = pageConverter.ConvertFromWebToWord(content); localFileName = folder + "\\" + localFileName + ".html"; addin.currentLocalFilePath = localFileName; StringBuilder pageContent = new StringBuilder(content); //Process the content pageContent.Insert(0, startDocument); pageContent.Append(endDocument); //Save the file if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } StreamWriter writer = new StreamWriter(localFileName, false, Encoding.UTF8); writer.Write(pageContent.ToString()); writer.Close(); }
/// <summary> /// Creates a <code>SSXManager</code> from the cleaned HTML of a local editing page. /// </summary> /// <param name="pageConverter">An instance of the <code>ConversionManager</code> for this page.</param> /// <param name="cleanHTML">Cleaned HTML of the local page.</param> /// <returns>An instance of a <code>SSXManager</code>.</returns> public static SSXManager BuildFromLocalHTML(ConversionManager pageConverter, string cleanHTML) { SSXManager ssxManager = new SSXManager(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(cleanHTML); XmlNodeList styleNodes = xmlDoc.GetElementsByTagName("style"); string pageCSSContent = ""; foreach (XmlNode styleNode in styleNodes) { pageCSSContent += styleNode.InnerText; } XmlRpcStruct dictionary = new XmlRpcStruct(); dictionary.Add("code", pageCSSContent); dictionary.Add("name", "XOfficeStyle"); dictionary.Add("use", "currentPage"); dictionary.Add("parse", "0"); dictionary.Add("cache", "forbid"); XWikiObject ssxObject = new XWikiObject(); ssxObject.className = SSX_CLASS_NAME; ssxObject.pageId = pageConverter.States.PageFullName; ssxObject.objectDictionary = dictionary; ssxManager.pageFullName = pageConverter.States.PageFullName; ssxManager.pageCSSContent = pageCSSContent; ssxManager.pageStyleSheetExtensions = new List <XWikiObject>(); ssxManager.pageStyleSheetExtensions.Add(ssxObject); ssxManager.pageConverter = pageConverter; return(ssxManager); }
/// <summary> /// Process incoming quotes /// </summary> /// <param name="input"></param> protected void OnInputQuote(dynamic input) { var dateAsk = ConversionManager.To <long>(input.askdate); var dateBid = ConversionManager.To <long>(input.biddate); var currentAsk = ConversionManager.To <double>(input.ask); var currentBid = ConversionManager.To <double>(input.bid); var previousAsk = _point?.Ask ?? currentAsk; var previousBid = _point?.Bid ?? currentBid; var symbol = $"{ input.symbol }"; var point = new PointModel { Ask = currentAsk, Bid = currentBid, Bar = new PointBarModel(), Instrument = Account.Instruments[symbol], AskSize = ConversionManager.To <double>(input.asksz), BidSize = ConversionManager.To <double>(input.bidsz), Time = DateTimeOffset.FromUnixTimeMilliseconds(Math.Max(dateAsk, dateBid)).DateTime, Last = ConversionManager.Compare(currentBid, previousBid) ? currentAsk : currentBid }; _point = point; UpdatePointProps(point); }
/// <summary> /// Saves the currently edited page or document to the server. /// </summary> private void SaveToXWiki() { try { String contentFilePath = ""; addin.ReinforceApplicationOptions(); String filePath = addin.ActiveDocumentFullName; String currentFileName = Path.GetDirectoryName(addin.ActiveDocumentFullName); currentFileName += "\\" + Path.GetFileNameWithoutExtension(addin.ActiveDocumentFullName); String tempExportFileName = currentFileName + "_TempExport.html"; if (!ShadowCopyDocument(addin.ActiveDocumentInstance, tempExportFileName, addin.SaveFormat)) { UserNotifier.Error(UIMessages.ERROR_SAVING_PAGE); return; } contentFilePath = tempExportFileName; StreamReader sr = new StreamReader(contentFilePath); String fileContent = sr.ReadToEnd(); sr.Close(); File.Delete(contentFilePath); String cleanHTML = ""; cleanHTML = new CommentsRemover().Clean(fileContent); cleanHTML = new HeadSectionRemover().Clean(cleanHTML); ConversionManager pageConverter; if (pageConverters.ContainsKey(addin.CurrentPageFullName)) { pageConverter = pageConverters[addin.CurrentPageFullName]; } else { pageConverter = new ConversionManager(addin.ServerURL, Path.GetDirectoryName(contentFilePath), addin.CurrentPageFullName, Path.GetFileName(contentFilePath), addin.Client); } cleanHTML = pageConverter.ConvertFromWordToWeb(cleanHTML); cleanHTML = new BodyContentExtractor().Clean(cleanHTML); if (addin.AddinStatus.Syntax == null) { addin.AddinStatus.Syntax = addin.DefaultSyntax; } //Convert the source to the propper encoding. Encoding iso = Client.ServerEncoding; byte[] content = Encoding.Unicode.GetBytes(cleanHTML); byte[] wikiContent = null; wikiContent = Encoding.Convert(Encoding.Unicode, iso, content); cleanHTML = iso.GetString(wikiContent); SavePage(addin.CurrentPageFullName, ref cleanHTML, addin.AddinStatus.Syntax); } catch (COMException ex) { string message = "An internal Word error appeared when trying to save your file."; message += Environment.NewLine + ex.Message; Log.Exception(ex); UserNotifier.Error(message); } }
public void SetDisplayUnitToSimUnitRatioTest() { float displayUnitsPerSimUnit = 0F; // TODO: Initialize to an appropriate value ConversionManager.SetDisplayUnitToSimUnitRatio(displayUnitsPerSimUnit); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
/// <summary> /// Genrate output based on input data /// </summary> protected virtual IPointModel Parse(dynamic input) { var props = input.Split(" "); long.TryParse(props[0], out long dateTime); double.TryParse(props[1], out double bid); double.TryParse(props[2], out double bidSize); double.TryParse(props[3], out double ask); double.TryParse(props[4], out double askSize); var response = new PointModel { Time = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(dateTime), Ask = ask, Bid = bid, Last = ask, AskSize = askSize, BidSize = bidSize }; if (ConversionManager.Compare(askSize, 0)) { response.Last = bid; } return(response); }
public WebImageAdaptorFilter(ConversionManager manager) { this.manager = manager; serverURL = manager.States.ServerURL; localFolder = manager.States.LocalFolder; localFilename = manager.States.LocalFileName; }
/// <summary> /// Process incoming quotes /// </summary> /// <param name="input"></param> protected void OnInputQuote(InputPointModel input) { var dateAsk = input.AskDate; var dateBid = input.BidDate; var currentAsk = input.Ask; var currentBid = input.Bid; var previousAsk = _point?.Ask ?? currentAsk; var previousBid = _point?.Bid ?? currentBid; var symbol = input.Symbol; var point = new PointModel { Ask = currentAsk, Bid = currentBid, Bar = new PointBarModel(), Instrument = Account.Instruments[symbol], AskSize = input.AskSize, BidSize = input.BidSize, Time = DateTimeOffset.FromUnixTimeMilliseconds(Math.Max(dateAsk.Value, dateBid.Value)).DateTime, Last = ConversionManager.Compare(currentBid, previousBid) ? currentAsk : currentBid }; _point = point; UpdatePointProps(point); }
/// <summary> /// Group items by time /// </summary> /// <param name="nextPoint"></param> /// <param name="previousPoint"></param> /// <param name="span"></param> /// <returns></returns> protected T CreateGroup(T nextPoint, T previousPoint, TimeSpan?span) { if (nextPoint.Ask == null && nextPoint.Bid == null) { return(nextPoint); } var nextGroup = nextPoint.Clone() as IPointModel; nextGroup.AskSize ??= nextPoint.AskSize ?? 0.0; nextGroup.BidSize ??= nextPoint.BidSize ?? 0.0; nextGroup.Ask ??= nextPoint.Ask ?? nextPoint.Bid; nextGroup.Bid ??= nextPoint.Bid ?? nextPoint.Ask; nextGroup.Bar.Open ??= previousPoint?.Last ?? nextGroup.Ask; nextGroup.Bar.Close ??= previousPoint?.Last ?? nextGroup.Bid; nextGroup.Last ??= nextGroup.Bar.Close; nextGroup.TimeFrame = span; nextGroup.Time = ConversionManager.Cut(nextPoint.Time, span); nextGroup.Bar.Low ??= Math.Min(nextGroup.Bid.Value, nextGroup.Ask.Value); nextGroup.Bar.High ??= Math.Max(nextGroup.Ask.Value, nextGroup.Bid.Value); return((T)nextGroup); }
/// <summary> /// Default constructor. /// </summary> public WebMacrosAdaptorFilterTest() { manager = ConversionManagerTestUtil.DummyConversionManager(); initialHTML = ""; expectedHTML = ""; initialXmlDoc = new XmlDocument(); }
/// <summary> /// Converts the constructor parameters. /// </summary> /// <param name = "constructor">The constructor.</param> /// <param name = "configuration">The configuration.</param> /// <returns></returns> private object[] ConvertConstructorParameters(ConstructorInfo constructor, IConfiguration configuration) { var conversionManager = ConversionManager; var parameters = constructor.GetParameters(); var parameterValues = new object[parameters.Length]; for (int i = 0, n = parameters.Length; i < n; ++i) { var parameter = parameters[i]; var paramConfig = FindChildIgnoreCase(configuration, parameter.Name); if (paramConfig == null) { throw new ConverterException(string.Format("Child '{0}' missing in {1} element.", parameter.Name, configuration.Name)); } var paramType = parameter.ParameterType; if (!ConversionManager.CanHandleType(paramType)) { throw new ConverterException(string.Format("No converter found for child '{0}' in {1} element (type: {2}).", parameter.Name, configuration.Name, paramType.Name)); } parameterValues[i] = ConvertChildParameter(paramConfig, paramType); } return(parameterValues); }
public void LoadContent(bool reload) { Texture2D textFieldDefault = ConversionManager.BitmapToTexture(Resource1.textfield_default_9, this.main.GraphicsDevice); Texture2D textFieldSelected = ConversionManager.BitmapToTexture(Resource1.textfield_selected_9, this.main.GraphicsDevice); Texture2D textFieldRight = ConversionManager.BitmapToTexture(Resource1.textfield_selected_right_9, this.main.GraphicsDevice); Texture2D textFieldWrong = ConversionManager.BitmapToTexture(Resource1.textfield_selected_wrong_9, this.main.GraphicsDevice); Texture2D windowSelected = ConversionManager.BitmapToTexture(Resource1.window_selected_9, this.main.GraphicsDevice); Texture2D windowUnselected = ConversionManager.BitmapToTexture(Resource1.window_unselected_9, this.main.GraphicsDevice); Texture2D panelSelected = ConversionManager.BitmapToTexture(Resource1.panel_selected_9, this.main.GraphicsDevice); Texture2D panelUnselected = ConversionManager.BitmapToTexture(Resource1.panel_unselected_9, this.main.GraphicsDevice); Texture2D dropdown = ConversionManager.BitmapToTexture(Resource1.dropdown, this.main.GraphicsDevice); Texture2D btnDefault = ConversionManager.BitmapToTexture(Resource1.btn_default_9, this.main.GraphicsDevice); Texture2D btnClicked = ConversionManager.BitmapToTexture(Resource1.btn_clicked_9, this.main.GraphicsDevice); Texture2D btnHover = ConversionManager.BitmapToTexture(Resource1.btn_hover_9, this.main.GraphicsDevice); Texture2D sliderRange = ConversionManager.BitmapToTexture(Resource1.sliderRange_9, this.main.GraphicsDevice); TextureSliderDefault = ConversionManager.BitmapToTexture(Resource1.slider, this.main.GraphicsDevice); TextureSliderSelected = ConversionManager.BitmapToTexture(Resource1.sliderSelected, this.main.GraphicsDevice); NinePatchSliderRange.LoadFromTexture(sliderRange); TextureCheckBoxDefault = ConversionManager.BitmapToTexture(Resource1.checkbox_default, this.main.GraphicsDevice); TextureCheckBoxSelected = ConversionManager.BitmapToTexture(Resource1.checkbox_default_selected, this.main.GraphicsDevice); TextureCheckBoxDefaultChecked = ConversionManager.BitmapToTexture(Resource1.checkbox_checked, this.main.GraphicsDevice); TextureCheckBoxSelectedChecked = ConversionManager.BitmapToTexture(Resource1.checkbox_checked_selected, this.main.GraphicsDevice); NinePatchTextFieldDefault.LoadFromTexture(textFieldDefault); NinePatchTextFieldSelected.LoadFromTexture(textFieldSelected); NinePatchTextFieldRight.LoadFromTexture(textFieldRight); NinePatchTextFieldWrong.LoadFromTexture(textFieldWrong); NinePatchWindowSelected.LoadFromTexture(windowSelected); NinePatchWindowUnselected.LoadFromTexture(windowUnselected); NinePatchPanelUnselected.LoadFromTexture(panelUnselected); NinePatchPanelSelected.LoadFromTexture(panelSelected); NinePatchDropDown.LoadFromTexture(dropdown); NinePatchBtnDefault.LoadFromTexture(btnDefault); NinePatchBtnClicked.LoadFromTexture(btnClicked); NinePatchBtnHover.LoadFromTexture(btnHover); NinePatchTabDefault.LoadFromTexture(btnDefault); NinePatchTabSelected.LoadFromTexture(btnHover); foreach (View v in this.GetAllViews(this.RootView)) { v.LoadContent(reload); } White = new Texture2D(this.main.GraphicsDevice, 1, 1); White.SetData(new Color[] { Color.White }); }
/// <summary> /// Send GET request /// </summary> /// <typeparam name="T"></typeparam> /// <param name="source"></param> /// <param name="query"></param> /// <param name="headers"></param> /// <param name="cts"></param> /// <returns></returns> public async Task <T> Get <T>( string source, IDictionary <dynamic, dynamic> query = null, IDictionary <dynamic, dynamic> headers = null, CancellationTokenSource cts = null) { return(ConversionManager.Deserialize <T>(await Send(HttpMethod.Get, source, query, headers, null, cts).ConfigureAwait(false))); }
/// <summary> /// Default constructor. /// </summary> public GrammarAndSpellingErrorsFilterTest() { manager = ConversionManagerTestUtil.DummyConversionManager(); initialHTML = ""; cleanedHTML = ""; initialXmlDoc = new XmlDocument(); cleanedXmlDoc = new XmlDocument(); }
/// <summary> /// Default constructor. /// </summary> public WebToLocalStyleFilterTest() { manager = ConversionManagerTestUtil.DummyConversionManager(); initialHTML = ""; expectedHTML = ""; initialXmlDoc = new XmlDocument(); expectedXmlDoc = new XmlDocument(); }
/// <summary> /// Default constructor. /// </summary> public OfficeAttributesRemoverFilterTest() { manager = ConversionManagerTestUtil.DummyConversionManager(); initialHTML = ""; expectedHTML = ""; initialXmlDoc = new XmlDocument(); expectedXmlDoc = new XmlDocument(); }
/// <summary> /// Get account properties /// </summary> protected async Task GetAccountProps() { var inputAccount = (await GetResponse <InputAccountItemModel>($"/v3/accounts/{ Account.Id }")).Account; Account.Currency = inputAccount.Currency.ToUpper(); Account.Balance = ConversionManager.To <double>(inputAccount.Balance); Account.Leverage = inputAccount.MarginRate == 0 ? 1 : 1 / inputAccount.MarginRate; }
/// <summary> /// Calculate single value /// </summary> /// <param name="collection"></param> /// <returns></returns> public override RelativeStrengthIndicator Calculate(IIndexCollection <IPointModel> collection) { var currentPoint = collection.ElementAtOrDefault(collection.Count - 1); if (currentPoint == null) { return(this); } var positives = new List <double>(Interval); var negatives = new List <double>(Interval); for (var i = 1; i <= Interval; i++) { var nextPrice = collection.ElementAtOrDefault(collection.Count - i); var previousPrice = collection.ElementAtOrDefault(collection.Count - i - 1); if (nextPrice != null && previousPrice != null) { positives.Add(Math.Max(nextPrice.Bar.Close.Value - previousPrice.Bar.Close.Value, 0.0)); negatives.Add(Math.Max(previousPrice.Bar.Close.Value - nextPrice.Bar.Close.Value, 0.0)); } } var averagePositive = CalculationManager.SimpleAverage(positives, positives.Count - 1, Interval); var averageNegative = CalculationManager.SimpleAverage(negatives, negatives.Count - 1, Interval); var average = ConversionManager.Compare(averageNegative, 0) ? 1.0 : averagePositive / averageNegative; var nextValue = 100.0 - 100.0 / (1.0 + average); var nextIndicatorPoint = new PointModel { Time = currentPoint.Time, TimeFrame = currentPoint.TimeFrame, Last = nextValue, Bar = new PointBarModel { Close = nextValue } }; var previousIndicatorPoint = Values.ElementAtOrDefault(collection.Count - 1); if (previousIndicatorPoint == null) { Values.Add(nextIndicatorPoint); } Values[collection.Count - 1] = nextIndicatorPoint; currentPoint.Series[Name] = currentPoint.Series.TryGetValue(Name, out IPointModel seriesItem) ? seriesItem : new RelativeStrengthIndicator(); currentPoint.Series[Name].Bar.Close = currentPoint.Series[Name].Last = nextIndicatorPoint.Bar.Close; currentPoint.Series[Name].Time = currentPoint.Time; currentPoint.Series[Name].ChartData = ChartData; Last = Bar.Close = currentPoint.Series[Name].Bar.Close; return(this); }
/// <summary> /// Start streaming /// </summary> /// <returns></returns> public override async Task Subscribe() { await Unsubscribe(); // Orders var orderSubscription = OrderSenderStream.Subscribe(message => { switch (message.Action) { case ActionEnum.Create: CreateOrders(message.Next); break; case ActionEnum.Update: UpdateOrders(message.Next); break; case ActionEnum.Delete: DeleteOrders(message.Next); break; } }); _subscriptions.Add(orderSubscription); // Streaming var client = new WebsocketClient(new Uri(StreamSource + "/markets/events"), _streamOptions) { Name = Account.Name, ReconnectTimeout = TimeSpan.FromSeconds(30), ErrorReconnectTimeout = TimeSpan.FromSeconds(30) }; var connectionSubscription = client.ReconnectionHappened.Subscribe(message => { }); var disconnectionSubscription = client.DisconnectionHappened.Subscribe(message => { }); var messageSubscription = client.MessageReceived.Subscribe(message => { dynamic input = JObject.Parse(message.Text); var inputStream = $"{ input.type }"; switch (inputStream) { case "quote": break; } }); _subscriptions.Add(messageSubscription); _subscriptions.Add(connectionSubscription); _subscriptions.Add(disconnectionSubscription); await client.Start(); var query = new { linebreak = true, symbols = Account.Instruments.Values.Select(o => o.Name) }; client.Send(ConversionManager.Serialize(query)); }
/// <summary> /// Draws the ninepatch at the specified point /// </summary> /// <param name="sb">The spritebatch to use for drawing</param> /// <param name="position">The position to draw it at (top left)</param> /// <param name="contentWidth">The width of the content inside the Ninepatch</param> /// <param name="contentHeight">The height of the content inside the Ninepatch</param> /// <param name="angle">The angle in degrees to rotate the ninepatch.</param> public void Draw(SpriteBatch sb, Vector2 position, int contentWidth, int contentHeight, float angle = 0, float alpha = 1) { var topLeft = new Rectangle(1, 1, LeftMostPatch - 1, TopMostPatch - 1); var topMiddle = new Rectangle(LeftMostPatch, 1, (RightMostPatch - LeftMostPatch), TopMostPatch - 1); var topRight = new Rectangle(RightMostPatch + 1, 1, (Texture.Width - 1) - RightMostPatch, TopMostPatch - 1); var left = new Rectangle(1, TopMostPatch, LeftMostPatch - 1, (BottomMostPatch - TopMostPatch)); var middle = new Rectangle(LeftMostPatch, TopMostPatch, (RightMostPatch - LeftMostPatch), (BottomMostPatch - TopMostPatch)); var right = new Rectangle(RightMostPatch + 1, TopMostPatch, (Texture.Width - 1) - RightMostPatch, (BottomMostPatch - TopMostPatch)); var bottomLeft = new Rectangle(1, BottomMostPatch, LeftMostPatch - 1, (Texture.Height - 1) - BottomMostPatch); var bottomMiddle = new Rectangle(LeftMostPatch, BottomMostPatch, (RightMostPatch - LeftMostPatch), (Texture.Height - 1) - BottomMostPatch); var bottomRight = new Rectangle(RightMostPatch + 1, BottomMostPatch, (Texture.Width - 1) - RightMostPatch, (Texture.Height - 1) - BottomMostPatch); int topMiddleWidth = topMiddle.Width; int leftMiddleHeight = left.Height; float scaleMiddleByHorizontally = (contentWidth / (float)topMiddleWidth); float scaleMiddleByVertically = (contentHeight / (float)leftMiddleHeight); Vector2 drawTl = position; Vector2 drawT = drawTl + new Vector2(topLeft.Width, 0); Vector2 drawTr = drawT + new Vector2(topMiddle.Width * scaleMiddleByHorizontally, 0); Vector2 drawL = drawTl + new Vector2(0, topLeft.Height); Vector2 drawM = drawT + new Vector2(0, topMiddle.Height); Vector2 drawR = drawTr + new Vector2(0, topRight.Height); Vector2 drawBl = drawL + new Vector2(0, leftMiddleHeight * scaleMiddleByVertically); Vector2 drawBm = drawM + new Vector2(0, leftMiddleHeight * scaleMiddleByVertically); Vector2 drawBr = drawR + new Vector2(0, leftMiddleHeight * scaleMiddleByVertically); drawTl = RotateAroundOrigin(drawTl, position, angle); drawT = RotateAroundOrigin(drawT, position, angle); drawTr = RotateAroundOrigin(drawTr, position, angle); drawL = RotateAroundOrigin(drawL, position, angle); drawM = RotateAroundOrigin(drawM, position, angle); drawR = RotateAroundOrigin(drawR, position, angle); drawBl = RotateAroundOrigin(drawBl, position, angle); drawBm = RotateAroundOrigin(drawBm, position, angle); drawBr = RotateAroundOrigin(drawBr, position, angle); var angR = (float)ConversionManager.DegreeToRadians(angle); sb.Draw(Texture, drawTl, topLeft, Color.White * alpha, angR, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f); sb.Draw(Texture, drawT, topMiddle, Color.White * alpha, angR, Vector2.Zero, new Vector2(scaleMiddleByHorizontally, 1), SpriteEffects.None, 0f); sb.Draw(Texture, drawTr, topRight, Color.White * alpha, angR, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f); sb.Draw(Texture, drawL, left, Color.White * alpha, angR, Vector2.Zero, new Vector2(1, scaleMiddleByVertically), SpriteEffects.None, 0f); sb.Draw(Texture, drawM, middle, Color.White * alpha, angR, Vector2.Zero, new Vector2(scaleMiddleByHorizontally, scaleMiddleByVertically), SpriteEffects.None, 0f); sb.Draw(Texture, drawR, right, Color.White * alpha, angR, Vector2.Zero, new Vector2(1, scaleMiddleByVertically), SpriteEffects.None, 0f); sb.Draw(Texture, drawBl, bottomLeft, Color.White * alpha, angR, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f); sb.Draw(Texture, drawBm, bottomMiddle, Color.White * alpha, angR, Vector2.Zero, new Vector2(scaleMiddleByHorizontally, 1), SpriteEffects.None, 0f); sb.Draw(Texture, drawBr, bottomRight, Color.White * alpha, angR, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f); }
public void Moving(GameTime gameTime, Player player) { if (GameScreen.Reseau) { new Pathfinding(gameTime, player.Position, monster, map); } else { if (monster.Bounds.Intersects(player.Bounds)) { return; } if (ConversionManager.VectToId(map, monster.InitialPos) == ConversionManager.VectToId(map, monster.Position)) { OutRange = false; isPatrolling = true; } inVision = false; if (Math.Sqrt((Math.Pow(Math.Abs(monster.Position.X - player.Position.X), 2) + Math.Pow(Math.Abs(monster.Position.Y - player.Position.Y), 2))) < monster.VisionSight && !OutRange) { inVision = true; isPatrolling = false; } if (Math.Sqrt((Math.Pow(Math.Abs(monster.Position.X - monster.InitialPos.X), 2) + Math.Pow(Math.Abs(monster.Position.Y - monster.InitialPos.Y), 2))) > monster.MovingScope) { OutRange = true; inVision = false; } if (monster.Life < monster.LifeMax) { inVision = true; OutRange = false; isPatrolling = false; } if (inVision) { new Pathfinding(gameTime, player.Position, monster, map); } else if (!isPatrolling) { new Pathfinding(gameTime, monster.InitialPos, monster, map); } else { Patrol(gameTime); } } }
public void GetSafeNameTest() { string path = string.Empty; // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; actual = ConversionManager.GetSafeName(path); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void PToVTest() { Point p = new Point(); // TODO: Initialize to an appropriate value Vector2 expected = new Vector2(); // TODO: Initialize to an appropriate value Vector2 actual; actual = ConversionManager.PToV(p); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void ToSimUnitsTest2() { Vector2 displayUnits = new Vector2(); // TODO: Initialize to an appropriate value Vector2 expected = new Vector2(); // TODO: Initialize to an appropriate value Vector2 actual; actual = ConversionManager.ToSimUnits(displayUnits); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void ToSimUnitsTest8() { int displayUnits = 0; // TODO: Initialize to an appropriate value float expected = 0F; // TODO: Initialize to an appropriate value float actual; actual = ConversionManager.ToSimUnits(displayUnits); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void VToPTest() { Vector2 v = new Vector2(); // TODO: Initialize to an appropriate value Point expected = new Point(); // TODO: Initialize to an appropriate value Point actual; actual = ConversionManager.VToP(v); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void DegreeToRadiansTest() { double degree = 0F; // TODO: Initialize to an appropriate value double expected = 0F; // TODO: Initialize to an appropriate value double actual; actual = ConversionManager.DegreeToRadians(degree); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void FloatToTimeTest() { float minutes = 0F; // TODO: Initialize to an appropriate value TimeSpan expected = new TimeSpan(); // TODO: Initialize to an appropriate value TimeSpan actual; actual = ConversionManager.FloatToTime(minutes); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public override void Draw(SpriteBatch sb) { float XM = topLeft.X + (bottomRight.X - topLeft.X); Vector2 BBPC = ConversionManager.PToV(BoundBoxPart.Center); Vector2 BBC = ConversionManager.PToV(BoundBox.Center); DrawManager.Draw_Outline(BBPC, BoundBoxPart.Width, BoundBoxPart.Height, Color.Black, sb, 200); DrawManager.Draw_Line(new Vector2(XM, topLeft.Y), new Vector2(XM, bottomRight.Y), Color.White, sb, 150); DrawManager.Draw_Box(BBPC, BoundBoxPart.Width, BoundBoxPart.Height, Color.Black, sb, 0, 150); //base.Draw(); }
private void ensureComponents() { Debug.Log("Creating injector game object ..."); if (_gameObject == null) { _gameObject = new GameObject(); _gameObject.name = "CSLMusicMod_GO"; } if (_injector == null) { _injector = _gameObject.AddComponent<MusicInjector>(); } // Create settings if (_settings == null) { _settings = _gameObject.AddComponent<SettingsManager>(); } // Create the music list if (_music == null) _music = _gameObject.AddComponent<MusicManager>(); // Create the converter if (_conversion == null) _conversion = _gameObject.AddComponent<ConversionManager>(); //Create music player if (_musicplayer == null) _musicplayer = _gameObject.AddComponent<BackgroundMusicPlayer>(); // Create folders _gameObject.GetComponent<MusicManager>().CreateMusicFolder(); // Load the settings _gameObject.GetComponent<SettingsManager>().LoadModSettings(); //Add audio watcher to player _musicplayer.AudioWatcher = _injector.AudioWatcher; }