Esempio n. 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var settings = _settings.Settings;

            if (_aspectCalc.Version != null)
            {
                label8.Text = Resources.AspectDescriptionFileVersion + _aspectCalc.Version;
            }

            _astip = new frmAstip(settings.TryGetValue("enablewallpaper", out var enableWallpaper) && enableWallpaper == "true");

            if (settings.TryGetValue("basicfirst", out var basicFirst))
            {
                _basicFirst = basicFirst == "true";
            }

            var fileList = new List <string>();

            GetAllFileByDir(@"pictures\color\", fileList);
            foreach (var filename in fileList)
            {
                var parsedFilename = Path.GetFileNameWithoutExtension(filename);
                _aspectCalc.FindAspect(parsedFilename)?.Let(aspect =>
                {
                    imageList1.Images.Add(aspect.Name, Image.FromFile(filename));
                    listView1.Items.Add(new ListViewItem(aspect.FullName, aspect.Name));
                });
            }

            if (_basicFirst)
            {
                var basicAspects = new List <ListViewItem>();

                foreach (var item in from ListViewItem item in listView1.Items
                         where _aspectCalc.FindAspect(item.ImageKey).IsBasicAspect
                         select item)
                {
                    basicAspects.Add(item);
                    listView1.Items.Remove(item);
                }

                if (basicAspects.Count > 0)
                {
                    for (var index = 0; index < basicAspects.Count; ++index)
                    {
                        listView1.Items.Insert(index, basicAspects[index]);
                    }
                }

                // Bug Fix
                var items = (from ListViewItem item in listView1.Items select(ListViewItem) item.Clone()).ToArray();
                listView1.Clear();
                listView1.Items.AddRange(items);
            }

            listView2.Items.AddRange((from ListViewItem item in listView1.Items select(ListViewItem) item.Clone())
                                     .ToArray());
            listView3.Items.AddRange((from ListViewItem item in listView1.Items select(ListViewItem) item.Clone())
                                     .ToArray());
        }
Esempio n. 2
0
        private Point _pointView = new Point(0, 0);        //定义外部存储变量
        private void listView1_MouseMove(object sender, MouseEventArgs e)
        {
            var lv = listView1.GetItemAt(e.X, e.Y);

            if (lv != null)
            {
                var aspect = _aspectCalc.FindAspect(lv.ImageKey);
                aspect.Recipe?.Let(recipe =>
                {
                    if (_pointView.X != e.X || _pointView.Y != e.Y)                     //防止tooltip不停闪烁问题
                    {
                        var aspects = new[]
                        { aspect, _aspectCalc.FindAspect(recipe.Item1), _aspectCalc.FindAspect(recipe.Item2) };
                        var aspectsName = aspects.Select(a => a.FullName);
                        var tmpImage    = aspects.Select(a => imageList1.Images[imageList1.Images.Keys.IndexOf(a.Name)]);

                        _astip.UpdateAstip(tmpImage, aspectsName);
                        if (ActiveForm != null)
                        {
                            _astip.Location = new Point(e.X + listView1.Left + ActiveForm.Left + 10,
                                                        e.Y + listView1.Top + ActiveForm.Top - 70);
                        }

                        _astip.Visible = true;
                        Focus();
                    }
                });
            }
            else
            {
                _astip.Visible = false;                 //没有取到item自动隐藏
            }

            _pointView = new Point(e.X, e.Y);
        }