コード例 #1
0
ファイル: D2DImage.cs プロジェクト: rootacite/Shinengine
        public void DrawStartup(System.Windows.Controls.Image contorl)
        {
            if (FirstDraw != null)
            {
                try
                {
                    FirstDraw(m_d2d_info, null, Width, Height);
                    contorl.Dispatcher.Invoke(new Action(() => { Commit(); }));
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
            }

            m_Dipter = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(1)
            };
            m_Dipter.Tick += (e, v) =>
            {
                Dpis = Times;
                Debug.WriteLine("Speed:" + Dpis.ToString());

                Times = 0;
            };
            m_Dipter2 = new Thread(() =>
            {//绘图代码
                while (isRunning)
                {
                    DrawProcResult?UpData = null;
                    Stopwatch sw          = new Stopwatch();
                    sw.Start();

                    UpData = DrawProc?.Invoke(m_d2d_info, Loadedsouce, Width, Height);
                    if (!(UpData == DrawProcResult.Ignore || UpData == null))
                    {
                        contorl.Dispatcher.Invoke(new Action(() => { Commit(); }));
                    }

                    sw.Stop();

                    decimal time      = sw.ElapsedTicks / (decimal)Stopwatch.Frequency * 1000;
                    decimal wait_time = 1000.0M / (decimal)TargetDpi - time;

                    if (wait_time < 0)
                    {
                        wait_time = 0;
                    }

                    if (UpData == DrawProcResult.Normal || UpData == null)
                    {
                        Thread.Sleep((int)wait_time);
                        Times++;
                        continue;
                    }
                    if (UpData == DrawProcResult.Ignore)
                    {
                        continue;
                    }
                    if (UpData == DrawProcResult.Death)
                    {
                        this.Dispose();
                        break;
                    }
                }

                Disposing?.Invoke(Loadedsouce, this);

                buffer = null;

                //////
                D2dRelease(m_d2d_info);
                Disposed?.Invoke();
            })
            {
                IsBackground = true
            };

            contorl.Source = buffer;

            m_Dipter.Start();
            m_Dipter2.Start();
        }
コード例 #2
0
        public void Update()
        {
            XmlDocument doc     = new XmlDocument();
            var         xmlPath = Path.Combine(Environment.CurrentDirectory, "platforms", "Tizen", tizenManifestFile);

            try
            {
                doc.Load(xmlPath);
            }
            catch
            {
                Logger.Log($"Failed to load tizen-manifest.xml");
                return;
            }

            var nsmgr = new XmlNamespaceManager(doc.NameTable);

            nsmgr.AddNamespace("manifest", namespaceURI);
            var uiApplicationNode = doc.SelectSingleNode("//manifest:ui-application", nsmgr);

            if (uiApplicationNode == null)
            {
                Logger.Log($"Failed to find <ui-application>");
                return;
            }

            var iconNodes = doc.SelectNodes("//manifest:icon", nsmgr);

            foreach (XmlElement node in iconNodes)
            {
                if (node.HasAttribute("dpi") == false)
                {
                    uiApplicationNode.RemoveChild(node);
                }
                else
                {
                    foreach (var dpi in Dpis)
                    {
                        var dpiType = dpi.Path.Replace(resourcePath, "");
                        if (node.Attributes["dpi"].Value == dpiType)
                        {
                            uiApplicationNode.RemoveChild(node);
                        }
                    }
                }
            }

            foreach (var dpi in Dpis)
            {
                var dpiType  = dpi.Path.Replace(resourcePath, "");
                var iconNode = doc.CreateElement("icon", namespaceURI);
                iconNode.SetAttribute("dpi", dpiType);
                iconNode.InnerText = dpiType + "/" + AppIconName + dpi.FileSuffix + ".png";
                uiApplicationNode.PrependChild(iconNode);
            }
            var defaultIconNode = doc.CreateElement("icon", namespaceURI);
            var defaultDpi      = Dpis.Where(n => n.Path.EndsWith(defaultDpiType)).FirstOrDefault();

            defaultIconNode.InnerText = defaultDpiType + "/" + AppIconName + defaultDpi.FileSuffix + ".png";
            uiApplicationNode.PrependChild(defaultIconNode);

            doc.Save(xmlPath);
        }