public File(string _path, string _localto = null) { string p = System.IO.Path.GetFullPath(_path); this.Path = p; this.Name = System.IO.Path.GetFileNameWithoutExtension(p); string ext = System.IO.Path.GetExtension(p); this.Extension = (ext == "") ? "" : ext.Substring(1); this.Directories = new Bunch <string>(); if (_localto != null && p.Contains(_localto)) { p = p.Substring(_localto.Length + ((_localto.Last() == '\\') ? 0 : 1)); } string[] ds = p.Split('\\'); for (int i = 0; i < ds.Length - 1; i++) { this.Directories.Add(ds[i]); } while (Directories.Any(item => item[0] == '#')) { Directories.Remove(Directories.First(item => item[0] == '#')); } //if (_localto != null) //{ // this.Directories = new Bunch<string>(); // if (p.Contains(_localto)) // { // p = p.Substring(_localto.Length); // string[] ds = p.Split('\\'); // for (int i = 0; i < ds.Length - 1; i++) // this.Directories.Add(ds[i]); // } //} //string assembly = Assembly.GetCallingAssembly().Location.Substring(0, Assembly.GetCallingAssembly().Location.Length - System.IO.Path.GetFileName(Assembly.GetCallingAssembly().Location).Length); }
public override void Update() { double y = this.Spacing; Bunch <double> pos = new Bunch <double>(); Bunch <double> threshes = new Bunch <double>(); Bunch <double> middles = new Bunch <double>(); foreach (T item in this.Items) { pos.Add(y); threshes.Add(y + item.GetHeight() + this.Spacing / 2); middles.Add(y + item.GetHeight() / 2); y += item.GetHeight() + this.Spacing; } double lheight = 0; if (this.Items.Count > 0) { middles.Add(y + this.Items.Last.GetHeight() / 2); T d = this.Items.First(item => item._BeingDragged); if (d != null) { int index = d._ListIndex; double p = d.Y + d.GetHeight() / 2; if (p < threshes[0]) { index = 0; } else if (p > threshes.Last) { index = threshes.Count - 1; } else { for (int i = 0; i < threshes.Count; i++) { if (p < threshes[i]) { index = i; break; } } } T[] items = this.Items.ToArray(); int dif = index - d._ListIndex; if (dif > 0) { for (int i = d._ListIndex + 1; i <= index; i++) { items[i]._ListIndex--; } } else if (dif < 0) { for (int i = index; i < d._ListIndex; i++) { items[i]._ListIndex++; } } d._ListIndex = index; if (dif != 0) { this.OnOrderChange(); } } foreach (T item in this.Items) { if (!item._BeingDragged) { item.Y += (pos[item._ListIndex] - item.Y) / 2; if (Meth.Abs(item.Y - pos[item._ListIndex]) < 1) { item.Y = pos[item._ListIndex]; item._NeedsUpdate = false; } } else { item.Y += item.LocalMousePosition.Y - item._DragStart.Y; } item.Y = Meth.Limit(0, item.Y, this.Height - item.GetHeight()); item.Z = item._BeingDragged ? 1 : 0; } lheight = this.Items.Last.GetHeight(); } else { pos.Add(0); middles.Add(double.MaxValue); } if (this.LocalMousePosition.X >= 0 && this.LocalMousePosition.X < this.Width && this.LocalMousePosition.Y >= 0 && this.LocalMousePosition.Y < pos.Last + lheight + this.Spacing && !this.Items.Any(item => item._BeingDragged)) { this._MousePos = threshes.IndexOf((this.Spacing / 2 + threshes).Last(t => t < middles.First(m => m > this.LocalMousePosition.Y))) + 1; Vector v = new Vector(this.Width / 2, (this.Spacing / 2 + threshes)[this._MousePos]); if (this.Plus.Position != v) { this.Plus.Position = v; this.PlusArea.Shape = new Rectangle(this.Plus.Position - this.Spacing / 2, this.Spacing); } this.Plus.Visible = true; } else { this.Plus.Visible = false; } this.Plus.Color = this.PlusArea.IsHovered ? Color.White * 0.5 : Color.Black; }