Example #1
0
        static GeometryPoint GetGeometryPointFrom(SourcePoint srcPt, double val, Rect rect, double timeInPoint, TimeSpan leftTime, TimeSpan time)
        {
            Point         curPosPoint = new Point(rect.Location.X + ToolFunctions.GetDxByTime(time, timeInPoint, leftTime), val);
            GeometryPoint curPoint    = new GeometryPoint(curPosPoint, srcPt);

            return(curPoint);
        }
Example #2
0
        /// <summary>
        /// Рендеринг графиков
        /// </summary>
        /// <param name="dc">контекст рисования</param>
        protected void Render(DrawingContext dc)
        {
            Rect graphicRect = new Rect(this.Field.Location, new Size(this.Field.Width, HeightGraphic));

            for (int i = 0; i < CommonData.RenderedGraphics.Count; i++)
            {
                dc.PushOpacity(0.5);
                dc.DrawRoundedRectangle(
                    Macros.ChooseBrush(i,
                                       new LinearGradientBrush(
                                           new GradientStopCollection()
                {
                    new GradientStop(Colors.LightSteelBlue, 0.5), new GradientStop(Colors.LightSlateGray, 1)
                },
                                           new Point(0, 0), new Point(0, 1)),
                                       CommonData.IndexActiveGraphic,
                                       new LinearGradientBrush(
                                           new GradientStopCollection()
                {
                    new GradientStop(Colors.LightSlateGray, 0.5), new GradientStop(Colors.LightYellow, 1)
                },
                                           new Point(0, 0), new Point(0, 1))),
                    null,
                    new Rect(new Point(graphicRect.X, graphicRect.Y - 4), new Size(graphicRect.Width, graphicRect.Height + 8)), 5, 5);
                ToolFunctions.DrawAutoTxt(dc, CommonData.SourceGraphics[i].Name,
                                          new Rect(new Point(graphicRect.X - CommonData.Width_LeftBorder, graphicRect.Y), new Size(CommonData.Width_LeftBorder,
                                                                                                                                   (HeightGraphic < HeightBetweenGraphics) ? HeightBetweenGraphics : HeightGraphic)),
                                          Macros.ChooseBrush(i, Brushes.Black, CommonData.IndexActiveGraphic, Brushes.DarkBlue), TextAlignment.Center, 1.95, "Cambria");
                dc.Pop();
                DrawGraphic(dc, CommonData.RenderedGraphics[i], Macros.ChooseBrush(i, Brushes.Blue, CommonData.IndexActiveGraphic, Brushes.DarkBlue), graphicRect);
                graphicRect.Y += (HeightBetweenGraphics + HeightGraphic);
            }
        }
Example #3
0
 /*________________________________________*/
 /// <summary>
 /// Рендеринг меток, точек пересечений и значений в них
 /// </summary>
 /// <param name="dc">Контекст рисования</param>
 protected void Render(DrawingContext dc)
 {
     dc.PushOpacity(0.7);
     /*Отрисовка меток*/
     for (int i = Marks.Count - 1; i >= 0; i--)
     {
         if (Macros.CheckEntryTime(CommonData.LeftTime, Marks[i].Time, CommonData.RightTime))
         {
             Point MarkPoint = new Point(this.Field.X + ToolFunctions.GetDxByTime(Marks[i].Time, CommonData.TimeInPoint, CommonData.LeftTime), this.Field.Y);
             dc.DrawLine(new Pen(Macros.ChooseBrush(i, Brushes.DarkGreen, IndexTimeMark, Brushes.Orange), 1), MarkPoint, new Point(MarkPoint.X, this.Field.Bottom));
             Rect valueRect = new Rect(new Point(MarkPoint.X + 2, MarkPoint.Y + 2), new Size(6 * 5, 26));
             dc.DrawRoundedRectangle(
                 Macros.ChooseBrush(i, new LinearGradientBrush(Colors.DarkGreen, Colors.LightGreen, 0.5),
                                    IndexTimeMark, new LinearGradientBrush(Colors.Orange, Colors.OrangeRed, 0.5)),
                 new Pen(Macros.ChooseBrush(i, Brushes.DarkGreen, IndexTimeMark, Brushes.OrangeRed), 1),
                 valueRect, valueRect.Height / 5, valueRect.Height / 5);
             ToolFunctions.DrawAutoTxt(dc, Macros.TimeSpanToString(Marks[i].Time), valueRect, Brushes.White, TextAlignment.Justify, 1.95);
         }
     }
     /*Отрисовка значений в точке пересечения линии метки и графика*/
     for (int i = CrossPoints.Count - 1; i >= 0; i--)
     {
         dc.DrawGeometry(Brushes.Brown, new Pen(Brushes.Brown, 1), new EllipseGeometry(CrossPoints[i], 1, 1));
         Rect valueRect = new Rect(new Point(CrossPoints[i].X + 2, CrossPoints[i].Y + 2), new Size(Values[i].ToString().Length * 5 + 10, 13));
         dc.DrawRoundedRectangle(Brushes.WhiteSmoke, new Pen(Brushes.White, 1), valueRect, valueRect.Height / 5, valueRect.Height / 5);
         ToolFunctions.DrawAutoTxt(dc, "0x" + Values[i].ToString("X"), valueRect, Brushes.Brown, TextAlignment.Center, 1.95);
     }
     dc.Pop();
 }
Example #4
0
 /*----------------------------------------*/
 /// <summary>
 /// построение списка точек пересечения и списка значений в них
 /// </summary>
 protected void UpdateData()
 {
     CrossPoints.Clear();
     Values.Clear();
     for (int i = Marks.Count - 1; i >= 0; i--)
     {
         if (Macros.CheckEntryTime(CommonData.LeftTime, Marks[i].Time, CommonData.RightTime))
         {
             double X = this.Field.X + ToolFunctions.GetDxByTime(Marks[i].Time, CommonData.TimeInPoint, CommonData.LeftTime);
             foreach (GeometryGraphic geomGr in CommonData.RenderedGraphics)
             {
                 int cnt = geomGr.Points.Count;
                 for (int j = 0; j < cnt - 1; j++)
                 {
                     if ((X >= geomGr.Points[j].X) && (X < geomGr.Points[j + 1].X))
                     {
                         CrossPoints.Add(new Point(X, geomGr.Points[j].Y));
                         Values.Add(geomGr.Points[j].SourcePoint.Value);
                         break;
                     }
                 }
             }
         }
     }
 }
Example #5
0
        private void AddMark(object sender, ExecutedRoutedEventArgs e)
        {
            Point    locMark = (Point)e.Parameter;
            TimeMark mark    = new TimeMark(ToolFunctions.GetTimeByPoint(locMark,
                                                                         new Point(multiLayerGraphic_Canvas.CommonData.Width_LeftBorder, 0),
                                                                         multiLayerGraphic_Canvas.CommonData.TimeInPoint, multiLayerGraphic_Canvas.LeftTime), "Метка " + TimeMarks.Count);

            TimeMarks.Add(mark);
            multiLayerGraphic_Canvas.AddTimeMark(mark);
        }
Example #6
0
 private void multiLayerGraphic_Canvas_ApproximationChangedEvent(object sender, EventArgs <bool> e)
 {
     if (e.Value)
     {
         imageApproximation.Source = ToolFunctions.GetImage(Assembly.GetExecutingAssembly().FullName, "Resources/Other/Approximation.ico");
     }
     else
     {
         imageApproximation.Source = ToolFunctions.GetImage(Assembly.GetExecutingAssembly().FullName, "Resources/Other/NoApproximation.ico");
     }
 }
Example #7
0
 /// <summary>
 /// Рисование значения в точке
 /// </summary>
 /// <param name="dc">контекст рисования</param>
 /// <param name="renderedGraphic"></param>
 protected void DrawValuePoint(DrawingContext dc, GeometryGraphic renderedGraphic)
 {
     {
         dc.PushOpacity(0.5);
         Rect valueRect = new Rect(new Point(renderedGraphic.Points[0].Position.X + 2, renderedGraphic.Points[0].Position.Y + 2),
                                   new Size(renderedGraphic.Points[0].SourcePoint.Value.ToString().Length * 5 + 10, 13));
         dc.DrawRoundedRectangle(Brushes.WhiteSmoke, new Pen(Brushes.White, 1), valueRect, valueRect.Height / 5, valueRect.Height / 5);
         ToolFunctions.DrawAutoTxt(dc, "0x" + renderedGraphic.Points[0].SourcePoint.Value.ToString("X"), valueRect, Brushes.Brown, TextAlignment.Center, 1.95);
         //
         valueRect = new Rect(new Point(renderedGraphic.Points.Last().Position.X + 2, renderedGraphic.Points.Last().Position.Y + 2),
                              new Size(renderedGraphic.Points.Last().SourcePoint.Value.ToString().Length * 5 + 10, 13));
         dc.DrawRoundedRectangle(Brushes.WhiteSmoke, new Pen(Brushes.White, 1), valueRect, valueRect.Height / 5, valueRect.Height / 5);
         ToolFunctions.DrawAutoTxt(dc, "0x" + renderedGraphic.Points.Last().SourcePoint.Value.ToString("X"), valueRect, Brushes.Brown, TextAlignment.Center, 1.95);
         dc.Pop();
     }
 }
Example #8
0
 /// <summary>
 /// Пересчёт размеров компонентов типа BaseVisualComponent
 /// </summary>
 void MultiLayerGraphic_RecalculationSizesEvent(object sender, EventArgs e)
 {
     if ((RenderSize.Width == 0) || (RenderSize.Height == 0))
     {
         return;
     }
     //вычисление коэффициента при каждом измененнии размера компонента
     CommonData.TimeInPoint = ToolFunctions.GetTimeInPt(CommonData.Width_LeftBorder, RenderSize.Width - CommonData.Width_RightBorder,
                                                        CommonData.LeftTime, CommonData.RightTime);
     // пересчёт размеров на основе формул
     timeScale.Field.Size         = new Size(RenderSize.Width - CommonData.Width_LeftBorder - CommonData.Width_RightBorder, RenderSize.Height); //формула размера "Временной шкалы"
     graphicVisualizer.Field.Size = new Size(RenderSize.Width - CommonData.Width_LeftBorder - CommonData.Width_RightBorder,
                                             RenderSize.Height - CommonData.Width_UpBorder - CommonData.Width_DownBorder);                      //формула размера области "Двумерных графиков"
     timeMarksScale.Field.Size = new Size(RenderSize.Width - CommonData.Width_LeftBorder - CommonData.Width_RightBorder,
                                          RenderSize.Height);                                                                                   //формула размера области "Временных меток"
     this.InvalidateVisual();                                                                                                                   //вызов рендеринга
 }
Example #9
0
        /// <summary>
        /// Рисование значения в точке
        /// </summary>
        /// <param name="dc">контекст рисования</param>
        /// <param name="renderedGraphic"></param>
        protected void DrawValuePoint(DrawingContext dc, GeometryGraphic renderedGraphic)
        {
            int  countPoints          = renderedGraphic.Points.Count;
            bool IsTextUnderPrevPoint = true;

            for (int i = 0; i < countPoints - 1; i++)
            {
                Size cellSize = new Size(renderedGraphic.Points[i].SourcePoint.Value.ToString().Length * 5 + 10, 13);
                IsTextUnderPrevPoint = ToolFunctions.DrawTxtValue(dc, renderedGraphic.Points[i].Position, renderedGraphic.Points[i + 1].Position,
                                                                  renderedGraphic.Points[i].SourcePoint.Value, IsTextUnderPrevPoint, cellSize);
            }
            //Last point
            if (renderedGraphic.Points[countPoints - 1].SourcePoint.Time.CompareTo(CommonData.RightTime) > 0)
            {
                return;
            }
            Size cellSizeLast = new Size(renderedGraphic.Points[countPoints - 1].SourcePoint.Value.ToString().Length * 5 + 10, 13);

            IsTextUnderPrevPoint = ToolFunctions.DrawTxtValue(dc, renderedGraphic.Points[countPoints - 1].Position, renderedGraphic.Points[countPoints - 1].Position,
                                                              renderedGraphic.Points[countPoints - 1].SourcePoint.Value, IsTextUnderPrevPoint, cellSizeLast);
        }
Example #10
0
 /// <summary>
 /// Передвижение прямоугольника видимого интервала времени
 /// </summary>
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (ScrollingFlag)
     {
         Point    position    = e.GetPosition(this);
         TimeSpan newLeftTime = ToolFunctions.GetTimeByPoint(position, new Point(btScrollLeft.Width, 0), TimeInPoint, LeftTimeBorder);
         if (newLeftTime.CompareTo(LeftTimeBorder) < 0)
         {
             return;
         }
         if (newLeftTime.CompareTo(RightTimeBorder.Subtract(VisibilityTimeInterval)) > 0)
         {
             VisibilityLeftTimeBorder = RightTimeBorder.Subtract(VisibilityTimeInterval);
         }
         else
         {
             VisibilityLeftTimeBorder = newLeftTime;
         }
         RaiseScrolledEvent(this.scrollBarData);
     }
 }
Example #11
0
        /// <summary>
        /// Рендеринг временной шкалы и прямоугольника выбранного интервала
        /// </summary>
        /// <param name="drawingContext">контекст рисования</param>
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);
            Size szCellTxt = new Size(6 * (fontSize / 2), RenderSize.Height);
            Rect rect      = new Rect(new Point(btScrollLeft.Width, 0), new Size(RenderSize.Width - btScrollLeft.Width - btScrollRight.Width, RenderSize.Height));

            drawingContext.DrawRoundedRectangle(new LinearGradientBrush(new GradientStopCollection()
            {
                new GradientStop(Colors.LightGray, 0), new GradientStop(Colors.WhiteSmoke, 0.5), new GradientStop(Colors.LightGray, 1)
            },
                                                                        new Point(0, 0), new Point(0, 1)), new Pen(Brushes.DarkGray, 1), new Rect(new Point(0, 0), RenderSize), 5, 5);
            drawingContext.PushClip(new RectangleGeometry(rect));
            /*Левая временная полоса*/
            ToolFunctions.DrawVTimeLine(drawingContext, rect.Location, szCellTxt,
                                        ToolFunctions.TimeSpanToString(ToolFunctions.GetTimeByPoint(rect.Location, rect.Location, TimeInPoint, LeftTimeBorder)), rect.Height, true, fontSize);
            /*Правая временная полоса*/
            ToolFunctions.DrawVTimeLine(drawingContext, new Point(rect.X + rect.Width, rect.Y), szCellTxt,
                                        ToolFunctions.TimeSpanToString(ToolFunctions.GetTimeByPoint(rect.Location, rect.Location, TimeInPoint, RightTimeBorder)), rect.Height, false, fontSize);
            /*количество временных линий*/
            double cnt            = (int)(rect.Width / dxTimeLine);
            double wSmallInterval = rect.Width / cnt;
            Point  linePt         = new Point(rect.X + wSmallInterval, rect.Y);

            /*отрисовка временных линий*/
            for (int i = 0; i < (int)cnt - 1; i++)
            {
                ToolFunctions.DrawVTimeLine(drawingContext, linePt, szCellTxt,
                                            ToolFunctions.TimeSpanToString(ToolFunctions.GetTimeByPoint(linePt, rect.Location, TimeInPoint, LeftTimeBorder)), rect.Height, true, fontSize);
                linePt.X += wSmallInterval;
            }
            drawingContext.PushOpacity(0.5);
            Rect visibleIntervalRect = new Rect(
                new Point(rect.X + ToolFunctions.GetDxByTime(VisibilityLeftTimeBorder, TimeInPoint, LeftTimeBorder), 0),
                new Size(ToolFunctions.GetDxByTime(VisibilityRightTimeBorder, TimeInPoint, LeftTimeBorder) - ToolFunctions.GetDxByTime(VisibilityLeftTimeBorder, TimeInPoint, LeftTimeBorder),
                         rect.Height));

            drawingContext.DrawRoundedRectangle(Brushes.LightCoral, new Pen(Brushes.DarkRed, 1), visibleIntervalRect, 5, 5);
        }
Example #12
0
        /// <summary>
        /// Рендеринг шкалы времени
        /// </summary>
        /// <param name="dc">контекст рисования</param>
        protected void Render(DrawingContext dc)
        {
            dc.PushOpacity(0.6);
            /*Левая временная полоса*/
            ToolFunctions.DrawVTimeLine(dc, this.Field.Location, SizeCellTimeValue,
                                        ToolFunctions.TimeSpanToString(ToolFunctions.GetTimeByPoint(this.Field.Location, this.Field.Location, CommonData.TimeInPoint, CommonData.LeftTime)), this.Field.Height);
            /*Правая временная полоса*/
            ToolFunctions.DrawVTimeLine(dc, new Point(this.Field.X + this.Field.Width, this.Field.Y), SizeCellTimeValue,
                                        ToolFunctions.TimeSpanToString(ToolFunctions.GetTimeByPoint(this.Field.Location, this.Field.Location, CommonData.TimeInPoint, CommonData.RightTime)), this.Field.Height, false);
            /*количество временных линий*/
            double cnt            = (int)(this.Field.Width / dX_TimeLine);
            double wSmallInterval = this.Field.Width / cnt;
            Point  linePt         = new Point(this.Field.X + wSmallInterval, this.Field.Y);

            /*отрисовка временных линий*/
            for (int i = 0; i < (int)cnt - 1; i++)
            {
                ToolFunctions.DrawVTimeLine(dc, linePt, SizeCellTimeValue,
                                            ToolFunctions.TimeSpanToString(ToolFunctions.GetTimeByPoint(linePt, this.Field.Location, CommonData.TimeInPoint, CommonData.LeftTime)), this.Field.Height);
                linePt.X += wSmallInterval;
            }
            dc.Pop();
        }
Example #13
0
        /*-------------------------------------------------------------------------------------------------------------*/
        /// <summary>
        /// Построить двумерный график
        /// </summary>
        /// <param name="srcGraphic">Исходные данные</param>
        /// <param name="rect">область отображения на экране</param>
        /// <param name="timeInPoint">коэффициент</param>
        /// <param name="leftTime">левая временная граница</param>
        /// <param name="rightTime">правая временная граница</param>
        /// <returns>двумерный график</returns>
        public static GeometryGraphic Construct(SourceGraphic srcGraphic, Rect rect, double timeInPoint, TimeSpan leftTime, TimeSpan rightTime)
        {
            GeometryGraphic geometryGraphic = new GeometryGraphic();

            if (srcGraphic.Points.Count == 0)
            {
                return(geometryGraphic);
            }
            double minV        = rect.Location.Y + rect.Height; // -30;
            double maxV        = rect.Location.Y;               // +10;
            double valInPx     = (minV - maxV) / srcGraphic.MaxValue;
            int    countPoints = srcGraphic.Points.Count;

            for (int i = 0; i < countPoints; i++)
            {
                if ((i < (countPoints - 1)) && (srcGraphic.Points[i].Time.CompareTo(leftTime) <= 0) && (srcGraphic.Points[i + 1].Time.CompareTo(leftTime) >= 0))
                {
                    Point         curPosPoint = new Point(rect.Location.X + ToolFunctions.GetDxByTime(leftTime, timeInPoint, leftTime), (minV - srcGraphic.Points[i].Value * valInPx));
                    GeometryPoint curPoint    = new GeometryPoint(curPosPoint, srcGraphic.Points[i]);
                    geometryGraphic.Points.Add(curPoint);
                }
                else if ((srcGraphic.Points[i].Time.CompareTo(leftTime) > 0) && (srcGraphic.Points[i].Time.CompareTo(rightTime) < 0))
                {
                    Point         curPosPoint = new Point(rect.Location.X + ToolFunctions.GetDxByTime(srcGraphic.Points[i].Time, timeInPoint, leftTime), (minV - srcGraphic.Points[i].Value * valInPx));
                    GeometryPoint curPoint    = new GeometryPoint(curPosPoint, srcGraphic.Points[i]);
                    geometryGraphic.Points.Add(curPoint);
                }
                else if (srcGraphic.Points[i].Time.CompareTo(rightTime) >= 0)
                {
                    Point         curPosPoint = new Point(rect.Location.X + +ToolFunctions.GetDxByTime(rightTime, timeInPoint, leftTime), (minV - srcGraphic.Points[i].Value * valInPx));
                    GeometryPoint curPoint    = new GeometryPoint(curPosPoint, srcGraphic.Points[i]);
                    geometryGraphic.Points.Add(curPoint);
                    return(geometryGraphic);
                }
            }
            return(geometryGraphic);
        }
    private static void BulidScriptDllBytes(BuildTarget bt)
    {
        if (bt == BuildTarget.iOS)
        {
            return;
        }

        string Scriptdllcsproj = PEditor.Properties.Resources.Scriptdllcsproj;

        XmlDocument xmldoc = new XmlDocument();

        xmldoc.LoadXml(Scriptdllcsproj);
        XmlDocument xmldocGameTrunk = new XmlDocument();

        xmldocGameTrunk.Load(getCSProjectName());

        string debugmacro = xmldocGameTrunk.GetElementsByTagName("DefineConstants").Item(0).InnerText;

        debugmacro = debugmacro.Replace("UNITY_EDITOR;", "");
        debugmacro = debugmacro.Replace("UNITY_EDITOR_64;", "");
        debugmacro = debugmacro.Replace("UNITY_EDITOR_WIN;", "");
        string releasemacro = xmldocGameTrunk.GetElementsByTagName("DefineConstants").Item(1).InnerText;

        releasemacro = releasemacro.Replace("DEBUG;", "");
        releasemacro = releasemacro.Replace("UNITY_EDITOR;", "");
        releasemacro = releasemacro.Replace("UNITY_EDITOR_64;", "");
        releasemacro = releasemacro.Replace("UNITY_EDITOR_WIN;", "");
        XmlNode includenode = xmldoc.GetElementsByTagName("ItemGroup").Item(1);

        includenode.RemoveAll();

        string[] allassetpaths = AssetDatabase.GetAllAssetPaths();

        var scriptpaths =
            from path in allassetpaths
            where path.Contains("Assets/Scripts/") && !Directory.Exists(path) && Path.GetExtension(path) == ".cs"
            select path.Replace('/', '\\');

        foreach (string scriptpath in scriptpaths)
        {
            XmlElement compile = xmldoc.CreateElement("Compile", xmldoc.GetElementsByTagName("Project").Item(0).NamespaceURI);
            compile.SetAttribute("Include", scriptpath);
            includenode.AppendChild(compile);
        }

        #region 计算MD5
        List <byte>   listMacroAndScriptBytes = new List <byte>();
        DirectoryInfo ScriptsFolder           = new DirectoryInfo(Application.dataPath + "/Scripts");
        foreach (FileInfo item in ScriptsFolder.GetFiles("*.cs", SearchOption.AllDirectories))
        {
            listMacroAndScriptBytes.AddRange(File.ReadAllBytes(item.FullName));
        }
        listMacroAndScriptBytes.AddRange(System.Text.Encoding.UTF8.GetBytes(releasemacro));
        byte[] hashbyte = listMacroAndScriptBytes.ToArray();

        System.Security.Cryptography.MD5CryptoServiceProvider md5CSP = new System.Security.Cryptography.MD5CryptoServiceProvider();

        byte[] scriptMD5Bytes = md5CSP.ComputeHash(hashbyte);

        string scriptMD5 = System.BitConverter.ToString(scriptMD5Bytes);

        if (File.Exists(Application.dataPath + "/Resources/assetsbundles/scriptdll/scriptdllmd5.bytes"))
        {
            string oldsMD5 = File.ReadAllText(Application.dataPath + "/Resources/assetsbundles/scriptdll/scriptdllmd5.bytes");
            if (oldsMD5 == scriptMD5)
            {
                Debug.Log("代码没变化!不会生成代码dll");
                return;
            }
        }


        #endregion

        XmlNode referencenode = xmldoc.GetElementsByTagName("ItemGroup").Item(0);
        referencenode.RemoveAll();
        XmlNode trunkreferencenode = xmldocGameTrunk.GetElementsByTagName("ItemGroup").Item(0);

        foreach (var node in trunkreferencenode.ChildNodes)
        {
            XmlNode xmlnode = (node as XmlNode).Clone();

            XmlElement reference = xmldoc.CreateElement("Reference", xmldoc.GetElementsByTagName("Project").Item(0).NamespaceURI);
            if (!xmlnode.Attributes["Include"].InnerText.Contains("UnityEditor"))
            {
                reference.SetAttribute("Include", xmlnode.Attributes["Include"].InnerText);

                if (xmlnode.ChildNodes.Count > 0)
                {
                    XmlNode pathnode = xmldoc.CreateNode(XmlNodeType.Element, "HintPath", xmldoc.GetElementsByTagName("Project").Item(0).NamespaceURI);
                    pathnode.InnerText = xmlnode.FirstChild.InnerText;
                    reference.AppendChild(pathnode);
                }
                referencenode.AppendChild(reference);
            }

            //XmlNode node = xmldoc.CreateNode(XmlNodeType.Element, "HintPath", xmldoc.GetElementsByTagName("Project").Item(0).NamespaceURI);
            //node.InnerText = refrencedllpath;
            //reference.AppendChild(node);
        }
        //XmlElement assetmblereference = xmldoc.CreateElement("Reference", xmldoc.GetElementsByTagName("Project").Item(0).NamespaceURI);
        //assetmblereference.SetAttribute("Include", "Assembly-CSharp");
        //XmlNode assetmpathnode = xmldoc.CreateNode(XmlNodeType.Element, "HintPath", xmldoc.GetElementsByTagName("Project").Item(0).NamespaceURI);
        //assetmpathnode.InnerText = "Temp/UnityVS_bin/Release/Assembly-CSharp.dll".Replace('/','\\');
        //assetmblereference.AppendChild(assetmpathnode);
        //referencenode.AppendChild(assetmblereference);
        //var refrencedllpaths =
        //    from path in allassetpaths
        //    where path.Contains("Assets/Plugins") && !Directory.Exists(path) && Path.GetExtension(path).Contains("dll")
        //    select path.Replace('/', '\\');

        //foreach (string refrencedllpath in refrencedllpaths)
        //{
        //    XmlElement reference = xmldoc.CreateElement("Reference", xmldoc.GetElementsByTagName("Project").Item(0).NamespaceURI);
        //    reference.SetAttribute("Include", Path.GetFileNameWithoutExtension(refrencedllpath));
        //    XmlNode node = xmldoc.CreateNode(XmlNodeType.Element,"HintPath", xmldoc.GetElementsByTagName("Project").Item(0).NamespaceURI);
        //    node.InnerText = refrencedllpath;
        //    reference.AppendChild(node);
        //    referencenode.AppendChild(reference);
        //}

        XmlNode UnityBuildTarget = xmldoc.GetElementsByTagName("UnityBuildTarget").Item(0);
        UnityBuildTarget.InnerText = xmldocGameTrunk.GetElementsByTagName("UnityBuildTarget").Item(0).InnerText;

        XmlNode TargetFrameworkVersion = xmldoc.GetElementsByTagName("TargetFrameworkVersion").Item(0);
        TargetFrameworkVersion.InnerText = xmldocGameTrunk.GetElementsByTagName("TargetFrameworkVersion").Item(0).InnerText;

        XmlNode TargetFrameworkProfile = xmldoc.GetElementsByTagName("TargetFrameworkProfile").Item(0);
        TargetFrameworkProfile.InnerText = xmldocGameTrunk.GetElementsByTagName("TargetFrameworkProfile").Item(0).InnerText;

        XmlNode UnityProjectType = xmldoc.GetElementsByTagName("UnityProjectType").Item(0);
        UnityProjectType.InnerText = xmldocGameTrunk.GetElementsByTagName("UnityProjectType").Item(0).InnerText;


        XmlNode UnityVersion = xmldoc.GetElementsByTagName("UnityVersion").Item(0);
        UnityVersion.InnerText = Application.unityVersion;


        XmlNode DefineConstantsdebug = xmldoc.GetElementsByTagName("DefineConstants").Item(0);
        DefineConstantsdebug.InnerText = debugmacro;

        DefineConstantsdebug           = xmldoc.GetElementsByTagName("DefineConstants").Item(1);
        DefineConstantsdebug.InnerText = releasemacro;


        string Scriptdllprojpath = System.Environment.CurrentDirectory + "/Scriptdll.csproj";
        xmldoc.Save(Scriptdllprojpath);



        //System.Diagnostics.Process process = System.Diagnostics.Process.Start("C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\MSBuild", "/p:Configuration=Release " + Scriptdllprojpath);

        System.Diagnostics.Process process = new System.Diagnostics.Process();
        //process.StartInfo.FileName = "C:\\Program Files\\Unity\\MonoDevelop\\bin\\MSBuild\\dotnet.4.0\\MonoDevelop.Projects.Formats.MSBuild.exe";
        process.StartInfo.FileName              = "C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\MSBuild.exe";
        process.StartInfo.Arguments             = "/p:Configuration=Release " + Scriptdllprojpath;
        process.StartInfo.RedirectStandardInput = true;
        process.StartInfo.UseShellExecute       = false;
        process.StartInfo.CreateNoWindow        = true;
        process.Start();

        process.WaitForExit();



        string srcdll  = Environment.CurrentDirectory + "/Temp/ScriptDll_bin/Release/scriptdll.dll";
        string destdll = Application.dataPath + "/Resources/assetsbundles/scriptdll/scriptdll.bytes";
        string md5file = Application.dataPath + "/Resources/assetsbundles/scriptdll/scriptdllmd5.bytes";
        ToolFunctions.CreateNewFolder(Application.dataPath + "/Resources/assetsbundles/scriptdll");
        try
        {
            File.Copy(srcdll, destdll);
        }
        catch (Exception e)
        {
            Debug.LogError(e);
            return;
        }
        //PSupport.Encryption ecp = new PSupport.Encryption();
        byte[] bytes = File.ReadAllBytes(destdll);
        //bytes = ecp.Encrypt(bytes);
        File.WriteAllBytes(destdll, bytes);
        File.WriteAllText(md5file, scriptMD5);
        AssetDatabase.Refresh();
        AssetDatabase.SaveAssets();

        ToolFunctions.DeleteFolder(Environment.CurrentDirectory + "/Temp/ScriptDll_bin");
        ToolFunctions.DeleteFolder(Environment.CurrentDirectory + "/Temp/ScriptDll_obj");


        File.Delete(Scriptdllprojpath);
        AssetDatabase.Refresh();
        AssetDatabase.SaveAssets();



        Debug.Log("生成:Assets/Resources/assetsbundles/scriptdll/Scriptdll.bytes----成功!!!");
    }
Example #15
0
 /// <summary>
 /// Расчёт коэффициента TimeInPoint
 /// </summary>
 void HorizontalTimeScrollBar_ChangeTimeInPointEvent(object sender, EventArgs e)
 {
     TimeInPoint = ToolFunctions.GetTimeInPt(btScrollLeft.Width, RenderSize.Width - btScrollLeft.Width - btScrollRight.Width, scrollBarData.LeftTimeBorder, scrollBarData.RightTimeBorder);
 }
 public override string ToString()
 => string.Format(
     CultureInfo.InvariantCulture,
     "v = {0}m/s | ω = {1}°/s",
     ToolFunctions.Format("0.##", v),
     ToolFunctions.Format("0.#", w.ToDegree()));
Example #17
0
        public static GeometryGraphic ConstructWithApproximation(SourceGraphic srcGraphic, Rect rect, double timeInPoint, TimeSpan leftTime, TimeSpan rightTime, double accuracyApproximationPx, out bool isAppearApproximation)
        {
            GeometryGraphic geometryGraphic = new GeometryGraphic();

            isAppearApproximation = false;
            if (srcGraphic.Points.Count == 0)
            {
                return(geometryGraphic);
            }
            double minV    = rect.Location.Y + rect.Height; // -30;
            double maxV    = rect.Location.Y;               // +10;
            double valInPx = (minV - maxV) / srcGraphic.MaxValue;

            int countPoints = srcGraphic.Points.Count;

            if (srcGraphic.Points.Count < 5)
            {
                for (int i = 0; i < countPoints; i++)
                {
                    geometryGraphic.Points.Add(GetGeometryPointFrom(srcGraphic.Points[i], (minV - srcGraphic.Points[i].Value * valInPx), rect, timeInPoint, leftTime, srcGraphic.Points[i].Time));
                }
                return(geometryGraphic);
            }

            GeometryPoint prevPt = new GeometryPoint();

            for (int i = 0; i < countPoints; i++)
            {
                if ((i < (countPoints - 1)) && (srcGraphic.Points[i].Time.CompareTo(leftTime) <= 0) && (srcGraphic.Points[i + 1].Time.CompareTo(leftTime) >= 0))
                {
                    Point         curPosPoint = new Point(rect.Location.X + ToolFunctions.GetDxByTime(leftTime, timeInPoint, leftTime), (minV - srcGraphic.Points[i].Value * valInPx));
                    GeometryPoint curPoint    = new GeometryPoint(curPosPoint, srcGraphic.Points[i]);
                    geometryGraphic.Points.Add(curPoint);
                    prevPt = curPoint;
                }
                else if ((srcGraphic.Points[i].Time.CompareTo(leftTime) > 0) && (srcGraphic.Points[i].Time.CompareTo(rightTime) < 0))
                {
                    Point         curPosPoint = new Point(rect.Location.X + ToolFunctions.GetDxByTime(srcGraphic.Points[i].Time, timeInPoint, leftTime), (minV - srcGraphic.Points[i].Value * valInPx));
                    GeometryPoint curPoint    = new GeometryPoint(curPosPoint, srcGraphic.Points[i]);

                    if (i == 1)
                    {
                        geometryGraphic.Points.Add(curPoint);
                        prevPt = curPoint;
                        continue;
                    }
                    if (i == (countPoints - 1 - 1))
                    {
                        geometryGraphic.Points.Add(curPoint);
                        prevPt = curPoint;
                        continue;
                    }

                    if ((curPoint.X - prevPt.X) < accuracyApproximationPx)
                    {
                        isAppearApproximation = true;
                        continue;
                    }
                    else
                    {
                        geometryGraphic.Points.Add(curPoint);
                        prevPt = curPoint;
                    }
                }
                else if (srcGraphic.Points[i].Time.CompareTo(rightTime) >= 0)
                {
                    Point         curPosPoint = new Point(rect.Location.X + +ToolFunctions.GetDxByTime(rightTime, timeInPoint, leftTime), (minV - srcGraphic.Points[i].Value * valInPx));
                    GeometryPoint curPoint    = new GeometryPoint(curPosPoint, srcGraphic.Points[i]);
                    geometryGraphic.Points.Add(curPoint);
                    return(geometryGraphic);
                }
            }

            return(geometryGraphic);
        }
    private static void BulidNativeScriptToDll()
    {
        string      NativeScriptdllcsproj = PEditor.Properties.Resources.NativeScriptdllcsproj;
        XmlDocument xmldoc = new XmlDocument();

        xmldoc.LoadXml(NativeScriptdllcsproj);
        XmlDocument xmldocGameTrunk = new XmlDocument();

        xmldocGameTrunk.Load(getCSProjectName());
        XmlNode includenode = xmldoc.GetElementsByTagName("ItemGroup").Item(1);

        includenode.RemoveAll();

        DirectoryInfo dirinfo = new DirectoryInfo(System.Environment.CurrentDirectory + "\\NativeScriptForDll\\");

        FileInfo[] fileinfos = dirinfo.GetFiles();

        //string[] allassetpaths = AssetDatabase.GetAllAssetPaths();

        //var scriptpaths =
        //    from path in allassetpaths
        //    where path.Contains("Editor/NativeScriptForDll") && !Directory.Exists(path)
        //    select path.Replace('/', '\\');

        foreach (FileInfo scriptpathinfo in fileinfos)
        {
            string scriptpath = scriptpathinfo.FullName;
            if (Path.GetExtension(scriptpath) == ".cs")
            {
                XmlElement compile = xmldoc.CreateElement("Compile", xmldoc.GetElementsByTagName("Project").Item(0).NamespaceURI);
                compile.SetAttribute("Include", scriptpath);
                includenode.AppendChild(compile);
            }
        }
        XmlNode referencenode = xmldoc.GetElementsByTagName("ItemGroup").Item(0);

        referencenode.RemoveAll();
        XmlNode trunkreferencenode = xmldocGameTrunk.GetElementsByTagName("ItemGroup").Item(0);

        foreach (var node in trunkreferencenode.ChildNodes)
        {
            XmlNode xmlnode = (node as XmlNode).Clone();
            if (xmlnode.InnerText.Contains("NativeScript"))
            {
                continue;
            }
            XmlElement reference = xmldoc.CreateElement("Reference", xmldoc.GetElementsByTagName("Project").Item(0).NamespaceURI);
            if (!xmlnode.Attributes["Include"].InnerText.Contains("UnityEditor"))
            {
                reference.SetAttribute("Include", xmlnode.Attributes["Include"].InnerText);

                if (xmlnode.ChildNodes.Count > 0)
                {
                    XmlNode pathnode = xmldoc.CreateNode(XmlNodeType.Element, "HintPath", xmldoc.GetElementsByTagName("Project").Item(0).NamespaceURI);
                    pathnode.InnerText = xmlnode.FirstChild.InnerText;
                    reference.AppendChild(pathnode);
                }
                referencenode.AppendChild(reference);
            }

            //XmlNode node = xmldoc.CreateNode(XmlNodeType.Element, "HintPath", xmldoc.GetElementsByTagName("Project").Item(0).NamespaceURI);
            //node.InnerText = refrencedllpath;
            //reference.AppendChild(node);
        }

        string Scriptdllprojpath = System.Environment.CurrentDirectory + "/NativeScriptDll.csproj";

        xmldoc.Save(Scriptdllprojpath);



        //System.Diagnostics.Process process = System.Diagnostics.Process.Start("C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\MSBuild", "/p:Configuration=Release " + Scriptdllprojpath);

        System.Diagnostics.Process process = new System.Diagnostics.Process();
        //process.StartInfo.FileName = "C:\\Program Files\\Unity\\MonoDevelop\\bin\\MSBuild\\dotnet.12.0\\MonoDevelop.Projects.Formats.MSBuild.exe";
        process.StartInfo.FileName              = "C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\MSBuild.exe";
        process.StartInfo.Arguments             = "/p:Configuration=Release " + Scriptdllprojpath;
        process.StartInfo.RedirectStandardInput = true;
        process.StartInfo.UseShellExecute       = false;
        process.StartInfo.CreateNoWindow        = true;
        process.Start();

        process.WaitForExit();



        string srcdll  = Environment.CurrentDirectory + "/Temp/NativeStriptDll_bin/Release/NativeScript.dll";
        string destdll = Application.dataPath + "/Plugins/NativeScript.dll";

        try
        {
            File.Copy(srcdll, destdll, true);
        }
        catch (Exception e)
        {
            Debug.LogError(e);
            return;
        }

        File.Copy(srcdll, destdll, true);
        ToolFunctions.DeleteFolder(Environment.CurrentDirectory + "/Temp/NativeStriptDll_bin");
        ToolFunctions.DeleteFolder(Environment.CurrentDirectory + "/Temp/NativeStriptDll_obj");

        AssetDatabase.Refresh();
        AssetDatabase.SaveAssets();

        AssetDatabase.ImportAsset("Assets/Plugins/", ImportAssetOptions.ForceSynchronousImport);

        File.Delete(Scriptdllprojpath);


        Debug.Log(Application.dataPath + "/Plugins/NativeScript.dll ----成功!!!");
    }
 public override string ToString()
 => string.Format(
     CultureInfo.InvariantCulture,
     "调整后轮:{0}°",
     ToolFunctions.Format("0.#", value.ToDegree()));