private void lstInformers_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Console.WriteLine(lstInformants.SelectedIndex);
            if (lstInformers.SelectedIndex != -1)
            {
                Informer inf = (Informer)lstInformers.SelectedItem;

                // id
                txtInformerId.Text = inf.Id.ToString();
                // name
                txtInformerName.Text = inf.Name;
                // nationality
                txtInformerNationality.Text = inf.Nationality;
                // cpr
                txtInformerCPR.Text = inf.CPR;
                // currency
                txtInformerCurrency.Text = inf.Currency;
                // paymenttype
                txtInformerPaymentType.Text = inf.PaymentType;
                // tags
                txtInformerTags.Text = inf.Tags;

                // Check for existence of appearance, and insert if it exists
                Appearance infapp = InfoWrapper.GetAppearance(inf.Id);
                if (infapp.Id != -1)
                {
                    txtInformerHeight.Text    = infapp.Height.ToString();
                    txtInformerEyecolor.Text  = infapp.Eyecolor;
                    txtInformerHaircolor.Text = infapp.Haircolor;
                }

                Address infadd = InfoWrapper.GetAddress(inf.Id);
                // Check for existence of address, and insert if it exists
                if (infadd.Id != -1)
                {
                    txtInformerStreet.Text   = infadd.Street;
                    txtInformerAreacode.Text = infadd.AreaCode.ToString();
                }

                Database.Entities.Image infimg = InfoWrapper.GetImage(inf.Id);
                // Check for existence of image, and insert if it exists
                if (infimg.Id != -1)
                {
                    try {
                        MemoryStream ms = new MemoryStream(infimg.Data);

                        BitmapImage bimg = new BitmapImage();
                        bimg.BeginInit();
                        bimg.StreamSource = ms;
                        bimg.EndInit();

                        imgInformer.Source = bimg;
                    } catch (Exception ex) {
                        MessageBox.Show($"Billedformatet er ikke understøttet.\n\n{ex.Message}");
                    }
                }
            }
        }
        private void lstObserved_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lstObserved.SelectedIndex != -1)
            {
                Observed obs = (Observed)lstObserved.SelectedItem;

                // id
                txtObservedId.Text = obs.Id.ToString();
                // name
                txtObservedName.Text = obs.Name;
                // nationality
                txtObservedNationality.Text = obs.Nationality;
                // cpr
                txtObservedCPR.Text = obs.CPR;
                // tags
                txtObservedTags.Text = obs.Tags;

                // Check for existence of appearance, and insert if it exists
                Appearance obsapp = InfoWrapper.GetAppearance(obs.Id);
                if (obsapp.Id != -1)
                {
                    txtObservedHeight.Text    = obsapp.Height.ToString();
                    txtObservedEyecolor.Text  = obsapp.Eyecolor;
                    txtObservedHaircolor.Text = obsapp.Haircolor;
                }

                Address obsadd = InfoWrapper.GetAddress(obs.Id);
                // Check for existence of address, and insert if it exists
                if (obsadd.Id != -1)
                {
                    txtObservedStreet.Text   = obsadd.Street;
                    txtObservedAreacode.Text = obsadd.AreaCode.ToString();
                }

                Database.Entities.Image obsimg = InfoWrapper.GetImage(obs.Id);
                // Check for existence of image, and insert if it exists
                if (obsimg.Id != -1)
                {
                    try {
                        MemoryStream ms = new MemoryStream(obsimg.Data);

                        BitmapImage bimg = new BitmapImage();
                        bimg.BeginInit();
                        bimg.StreamSource = ms;
                        bimg.EndInit();

                        imgObserved.Source = bimg;
                    } catch (Exception ex) {
                        MessageBox.Show($"Billedformatet er ikke understøttet.\n\n{ex.Message}");
                    }
                }
            }
        }
        private void lstAgents_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lstAgents.SelectedIndex != -1)
            {
                Agent agent = (Agent)lstAgents.SelectedItem;

                // id
                txtAgentId.Text = agent.Id.ToString();
                // name
                txtAgentName.Text = agent.Name;
                // nationality
                txtAgentNationality.Text = agent.Nationality;
                // cpr
                txtAgentCPR.Text = agent.CPR;

                // Check for existence of appearance, and populate if it exists
                Appearance agentapp = InfoWrapper.GetAppearance(agent.Id);
                if (agentapp.Id != -1)
                {
                    txtAgentHeight.Text    = agentapp.Height.ToString();
                    txtAgentEyecolor.Text  = agentapp.Eyecolor;
                    txtAgentHaircolor.Text = agentapp.Haircolor;
                }

                Address agentadd = InfoWrapper.GetAddress(agent.Id);
                // Check for existence of address, and populate if it exists
                if (agentadd.Id != -1)
                {
                    txtAgentStreet.Text   = agentadd.Street;
                    txtAgentAreacode.Text = agentadd.AreaCode.ToString();
                }

                Database.Entities.Image agentimg = InfoWrapper.GetImage(agent.Id);
                // Check for existence of image, and populate if it exists
                if (agentimg.Id != -1)
                {
                    try {
                        MemoryStream ms = new MemoryStream(agentimg.Data);

                        BitmapImage bimg = new BitmapImage();
                        bimg.BeginInit();
                        bimg.StreamSource = ms;
                        bimg.EndInit();

                        imgAgent.Source = bimg;
                    } catch (Exception ex) {
                        MessageBox.Show($"Billedformatet er ikke understøttet.\n\n{ex.Message}");
                    }
                }
            }
        }
示例#4
0
        private void AddMetadataToPanel(int i, string id)
        {
            string thumbnail = HitomiCore.GetThumbnailAddress(id);

            string    temp = Path.GetTempFileName();
            WebClient wc   = new WebClient();

            wc.Headers["Accept-Encoding"] = "application/x-gzip";
            wc.Encoding = Encoding.UTF8;
            wc.DownloadFile(new Uri(HitomiDef.HitomiThumbnail + thumbnail), temp);

            Image img;

            using (FileStream fs = new FileStream(temp, FileMode.Open, FileAccess.Read, FileShare.None, 4096, FileOptions.DeleteOnClose))
            {
                img = Image.FromStream(fs);
            }
            if (closed)
            {
                img.Dispose();
                LogEssential.Instance.PushLog(() => $"Unexpected Disposed! {HitomiDef.HitomiThumbnail + thumbnail} {temp} {i} {id}");
                return;
            }
            info[i] = new InfoWrapper(img.Clone() as Image);

            PictureBox[] pbs = { pb1, pb2, pb3, pb4 };
            RemoveEvent(pbs[i], "EventMouseEnter");
            RemoveEvent(pbs[i], "EventMouseMove");
            RemoveEvent(pbs[i], "EventMouseLeave");
            pbs[i].MouseEnter += info[i].Picture_MouseEnter;
            pbs[i].MouseMove  += info[i].Picture_MouseMove;
            pbs[i].MouseLeave += info[i].Picture_MouseLeave;

            if (pbs[i].InvokeRequired)
            {
                pbs[i].Invoke(new Action(() => { pbs[i].Image = img; }));
            }
            else
            {
                pbs[i].Image = img;
            }

            LogEssential.Instance.PushLog(() => $"Load successful! {HitomiDef.HitomiThumbnail + thumbnail} {temp} {i} {id}");
        }
示例#5
0
        private async void listView1_MouseDoubleClickAsync(object sender, MouseEventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                foreach (var iw in info.Where(iw => iw != null))
                {
                    iw.Dispose();
                }
                info = null;
                info = new InfoWrapper[4];
                LogEssential.Instance.PushLog(() => $"Successful disposed! [RecommendControl] {artist}");
                artist    = listView1.SelectedItems[0].SubItems[0].Text.Replace('_', ' ');
                pb1.Image = null;
                pb2.Image = null;
                pb3.Image = null;
                pb4.Image = null;
                await LoadThumbnailAsync();
            }

            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
        }
示例#6
0
        private void FilterInfos()
        {
            // 回收引用
            ReferencePool.Release(_cacheInfos);

            // 清空列表
            _cacheInfos.Clear();

            // 绘制显示列表
            var fileLoaders = AssetSystem.GetAllLoaders();

            _loaderTotalCount = fileLoaders.Count;
            foreach (var loader in fileLoaders)
            {
                // 只搜索关键字
                if (string.IsNullOrEmpty(_filterKey) == false)
                {
                    if (loader.LoadPath.Contains(_filterKey) == false)
                    {
                        continue;
                    }
                }

                string info = Substring(loader.LoadPath, "/assets/");
                info = info.Replace(".unity3d", string.Empty);
                info = $"{info} = {loader.RefCount}";

                InfoWrapper element = ReferencePool.Spawn <InfoWrapper>();
                element.Info                = info;
                element.LoadState           = loader.States;
                element.ProviderFailedCount = loader.GetFailedProviderCount();

                // 添加到显示列表
                _cacheInfos.Add(element);
            }

            // 重新排序
            _cacheInfos.Sort();
        }
        private void FilterInfos()
        {
            // 回收引用
            ReferencePool.Release(_cacheInfos);

            // 清空列表
            _cacheInfos.Clear();

            // 绘制显示列表
            var fileLoaders = AssetSystem.GetAllLoaders();

            _loaderTotalCount = fileLoaders.Count;
            foreach (var loader in fileLoaders)
            {
                // 只搜索关键字
                if (string.IsNullOrEmpty(_filterKey) == false)
                {
                    if (loader.BundleInfo.ManifestPath.Contains(_filterKey) == false)
                    {
                        continue;
                    }
                }

                string      info    = $"资源名称:{loader.BundleInfo.ManifestPath}  资源版本:{loader.BundleInfo.Version}  引用计数:{loader.RefCount}";
                InfoWrapper element = ReferencePool.Spawn <InfoWrapper>();
                element.Info                = info;
                element.LoadState           = loader.States;
                element.ProviderFailedCount = loader.GetFailedProviderCount();

                // 添加到显示列表
                _cacheInfos.Add(element);
            }

            // 重新排序
            _cacheInfos.Sort();
        }
        private void btnSaveAgent_Click(object sender, RoutedEventArgs e)
        {
            try {
                Agent agent = new Agent();

                agent.Id          = int.Parse(txtAgentId.Text);
                agent.Name        = txtAgentName.Text;
                agent.Nationality = txtAgentNationality.Text;
                agent.CPR         = txtAgentCPR.Text;

                AgentWrapper.SaveAgent(agent);

                // Try to save appearance
                if (txtAgentHeight.Text != "" || txtAgentEyecolor.Text != "" || txtAgentHaircolor.Text != "")
                {
                    Appearance appearance;
                    if (agent.Id == -1)
                    {
                        appearance = new Appearance(int.Parse(txtAgentHeight.Text), txtAgentEyecolor.Text, txtAgentHaircolor.Text, InfoWrapper.GetLastPersonId());
                    }
                    else
                    {
                        appearance = new Appearance(int.Parse(txtAgentHeight.Text), txtAgentEyecolor.Text, txtAgentHaircolor.Text, agent.Id);
                    }

                    InfoWrapper.SaveAppearence(appearance);
                }

                // Try to save address
                if (txtAgentStreet.Text != "" || txtAgentAreacode.Text != "")
                {
                    Address address;
                    // Check if it's a new agent
                    if (agent.Id == -1)
                    {
                        address = new Address(txtAgentStreet.Text, int.Parse(txtAgentAreacode.Text), InfoWrapper.GetLastPersonId());
                    }
                    else
                    {
                        address = new Address(txtAgentStreet.Text, int.Parse(txtAgentAreacode.Text), agent.Id);
                    }

                    InfoWrapper.SaveAddress(address);
                }

                // Try to save image
                if (txtAgentImagePath.Text != "")
                {
                    if (File.Exists(txtAgentImagePath.Text))
                    {
                        FileStream   fs = new FileStream(txtAgentImagePath.Text, FileMode.Open, FileAccess.Read);
                        BinaryReader br = new BinaryReader(fs);

                        Database.Entities.Image img;

                        // if new agent
                        if (agent.Id == -1)
                        {
                            img = new Database.Entities.Image(br.ReadBytes(Convert.ToInt32(fs.Length)), InfoWrapper.GetLastPersonId());
                        }
                        else
                        {
                            img = new Database.Entities.Image(br.ReadBytes(Convert.ToInt32(fs.Length)), agent.Id);
                        }

                        InfoWrapper.SaveImage(img);
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show($"Der er sket en fejl. Er alle felterne korrekt udfyldt?\n\n{ex.Message}");
            }
        }
        private void btnSaveInformer_Click(object sender, RoutedEventArgs e)
        {
            try {
                Informer informer = new Informer();

                informer.Id          = int.Parse(txtInformerId.Text);
                informer.Name        = txtInformerName.Text;
                informer.Nationality = txtInformerNationality.Text;
                informer.CPR         = txtInformerCPR.Text;
                informer.Currency    = txtInformerCurrency.Text;
                informer.PaymentType = txtInformerPaymentType.Text;
                informer.Tags        = txtInformerTags.Text;

                InformerWrapper.SaveInformer(informer);

                // Try to save appearance
                if (txtInformerHeight.Text != "" || txtInformerEyecolor.Text != "" || txtInformerHaircolor.Text != "")
                {
                    Appearance appearance;
                    if (informer.Id == -1)
                    {
                        appearance = new Appearance(int.Parse(txtInformerHeight.Text), txtInformerEyecolor.Text, txtInformerHaircolor.Text, InfoWrapper.GetLastPersonId());
                    }
                    else
                    {
                        appearance = new Appearance(int.Parse(txtInformerHeight.Text), txtInformerEyecolor.Text, txtInformerHaircolor.Text, informer.Id);
                    }

                    InfoWrapper.SaveAppearence(appearance);
                }

                // Try to save address
                if (txtInformerStreet.Text != "" || txtInformerAreacode.Text != "")
                {
                    Address address;
                    // If it's a new informer
                    if (informer.Id == -1)
                    {
                        address = new Address(txtInformerStreet.Text, int.Parse(txtInformerAreacode.Text), InfoWrapper.GetLastPersonId());
                    }
                    else
                    {
                        address = new Address(txtInformerStreet.Text, int.Parse(txtInformerAreacode.Text), informer.Id);
                    }

                    InfoWrapper.SaveAddress(address);
                }

                // Try to save image
                if (txtInformerImagePath.Text != "")
                {
                    if (File.Exists(txtInformerImagePath.Text))
                    {
                        FileStream   fs = new FileStream(txtInformerImagePath.Text, FileMode.Open, FileAccess.Read);
                        BinaryReader br = new BinaryReader(fs);

                        Database.Entities.Image img;

                        // if new informer
                        if (informer.Id == -1)
                        {
                            img = new Database.Entities.Image(br.ReadBytes(Convert.ToInt32(fs.Length)), InfoWrapper.GetLastPersonId());
                        }
                        else
                        {
                            img = new Database.Entities.Image(br.ReadBytes(Convert.ToInt32(fs.Length)), informer.Id);
                        }

                        InfoWrapper.SaveImage(img);
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show($"Der er sket en fejl. Er alle felterne korrekt udfyldt?\n\n{ex.Message}");
            }
        }