예제 #1
0
        private void ClickCalcHeatmap(object sender, RoutedEventArgs e)
        {
            Models.Memory     mem  = (sender as Button).DataContext as Models.Memory;
            Models.AppVersion ver  = VersionList.SelectedItem as Models.AppVersion;
            byte[]            data = AutoHelper.GetMemorySize(ver, mem);

            int height = Convert.ToInt32(Math.Ceiling(data.Length / 16.0));

            Debug.WriteLine("Höhe: " + height);

            WriteableBitmap map = new WriteableBitmap(16, height, 1, 1, PixelFormats.Indexed8, BitmapPalettes.WebPalette);

            int stride = (map.PixelWidth * map.Format.BitsPerPixel + 7) / 8;

            byte[] pixelByteArray = new byte[map.PixelHeight * stride];

            map.CopyPixels(pixelByteArray, stride, 0);

            for (int i = 0; i < pixelByteArray.Length; i++)
            {
                int val = (i >= data.Length) ? 0 : data[i];
                switch (val)
                {
                case 0:
                    pixelByteArray[i] = 18;
                    break;

                case 1:
                case 2:
                case 3:
                case 4:
                    pixelByteArray[i] = 205;
                    break;

                case 5:
                case 6:
                case 7:
                    pixelByteArray[i] = 193;
                    break;

                case 8:
                    pixelByteArray[i] = 180;
                    break;

                default:
                    pixelByteArray[i] = 0;
                    break;
                }
            }

            map.WritePixels(new Int32Rect(0, 0, map.PixelWidth, map.PixelHeight), pixelByteArray, stride, 0);
            OutHeatmap.Source = map;
        }
예제 #2
0
        private void ClickOpen(object sender, RoutedEventArgs e)
        {
            OpenFileDialog diag = new OpenFileDialog();

            diag.Title  = "Projekt öffnen";
            diag.Filter = "Kaenx Hersteller Projekt (*.ae-manu)|*.ae-manu";
            if (diag.ShowDialog() == true)
            {
                string general = System.IO.File.ReadAllText(diag.FileName);
                General = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.ModelGeneral>(general, new Newtonsoft.Json.JsonSerializerSettings()
                {
                    TypeNameHandling = Newtonsoft.Json.TypeNameHandling.Auto
                });
                filePath = diag.FileName;

                foreach (Models.Application app in General.Applications)
                {
                    foreach (Models.AppVersion ver in app.Versions)
                    {
                        foreach (Models.Parameter para in ver.Parameters)
                        {
                            if (!string.IsNullOrEmpty(para._memory))
                            {
                                Models.Memory mem = ver.Memories.Single(m => m.Name == para._memory);
                                para.MemoryObject = mem;
                            }
                            if (!string.IsNullOrEmpty(para._parameterType))
                            {
                                Models.ParameterType pt = ver.ParameterTypes.Single(p => p.Name == para._parameterType);
                                para.ParameterTypeObject = pt;
                            }
                        }

                        foreach (Models.ParameterRef pref in ver.ParameterRefs)
                        {
                            if (!string.IsNullOrEmpty(pref._parameter))
                            {
                                Models.Parameter para = ver.Parameters.Single(p => p.Name == pref._parameter);
                                pref.ParameterObject = para;
                            }
                        }

                        foreach (Models.ComObjectRef cref in ver.ComObjectRefs)
                        {
                            if (!string.IsNullOrEmpty(cref._comObject))
                            {
                                Models.ComObject com = ver.ComObjects.Single(c => c.Name == cref._comObject);
                                cref.ComObjectObject = com;
                            }
                        }

                        LoadSubDyn(ver.Dynamics[0], ver.ParameterRefs.ToList(), ver.ComObjectRefs.ToList());
                    }


                    string mid = app._maskId;
                    if (string.IsNullOrEmpty(mid))
                    {
                        continue;
                    }

                    Models.MaskVersion mask = BCUs.Single(bcu => bcu.Id == mid);
                    app.Mask = mask;
                }


                foreach (Models.Hardware hard in General.Hardware)
                {
                    if (string.IsNullOrEmpty(hard._appsString))
                    {
                        continue;
                    }

                    foreach (string name in hard._appsString.Split(','))
                    {
                        try{
                            hard.Apps.Add(General.Applications.Single(app => app.Name == name));
                        } catch {}
                    }
                }

                SetSubCatalogItems(General.Catalog[0]);

                SetButtons(true);
            }
        }