public Profile(string name) { Name = name; SlotPage firstPage = new SlotPage(""); SlotPages = new List <SlotPage>(); SlotPages.Add(firstPage); }
public static Slot GetSlotById(int id) { SlotPage page = CurProfile.SlotPages.Find(p => p.Path == CurPathString()); if (page != null) { Slot slot = page.Slots.Find(s => s.Id == id); return(slot); } return(null); }
public SlotPage GetPageByPath(string path) { SlotPage page = SlotPages.Find(sp => sp.Path == path); if (page != null) { return(page); } page = new SlotPage(path); SlotPages.Add(page); return(page); }
public static void SetSetting(int id, string settingName, string value) { SlotPage page = CurProfile.SlotPages.Find(p => p.Path == CurPathString()); if (page != null) { Slot slot = page.Slots.Find(s => s.Id == id); if (slot != null) { slot.Settings[settingName] = value; SaveData(); } } }
public void DeleteSlot(string path, int id) { SlotPage page = GetPageByPath(path); if (page != null) { Slot slot = page.Slots.Find(s => s.Id == id); if (slot != null) { //Delete slot images try { if (File.Exists(slot.Image_0)) { File.Delete(slot.Image_0); } if (File.Exists(slot.Image_1)) { File.Delete(slot.Image_1); } } catch (Exception err) { Console.WriteLine(err); } if (slot.Type == SlotType.Folder) { string deletePath = path; if (path != "") { deletePath += "."; } DeletePage(deletePath + id.ToString()); page.Slots.Remove(slot); } else { page.Slots.Remove(slot); } } } }
public void AddNewSlot(string path, int id, SlotType type) { SlotPage page = GetPageByPath(path); if (page != null) { Slot slot = page.Slots.Find(s => s.Id == id); if (slot == null) { slot = new Slot(id, type); page.Slots.Add(slot); } else { //Here ask for change slot slot.Type = type; //TODO: Manage slot settings } } }
public static void SetImage(int id, string path, bool state = false) { SlotPage page = CurProfile.SlotPages.Find(p => p.Path == CurPathString()); if (page != null) { Slot slot = page.Slots.Find(s => s.Id == id); if (slot != null) { if (!state) { slot.Image_0 = path; } else { slot.Image_1 = path; } SaveData(); } } }
public static string GetSetting(int id, string settingName) { try { SlotPage page = CurProfile.SlotPages.Find(p => p.Path == CurPathString()); if (page != null) { Slot slot = page.Slots.Find(s => s.Id == id); if (slot != null) { if (slot.Settings[settingName] != null) { return(slot.Settings[settingName]); } } } } catch (Exception err) { Console.WriteLine(err); } return(null); }
private void ShowSlotSettings(ActionSlot actionSlot) { SlotPage page = Storage.GetSlotPage(); Slot slot = null; int id = 1; if (page != null) { id = GetSlotId(actionSlot); slot = page.Slots.Find(s => s.Id == id); } if (slot == null) return; switch (slot.Type) { case SlotType.None: break; case SlotType.Folder: break; case SlotType.FolderBack: break; case SlotType.OpenApp: break; case SlotType.Website: break; case SlotType.Hotkey: break; } curSlot.BackgroundImage = actionSlot.BackgroundImage; title.Text = Storage.GetSetting(id, "Title"); bottomPanel.Visible = true; isVisible = true; }
public static SlotPage GetSlotPage() { SlotPage page = CurProfile.SlotPages.Find(p => p.Path == CurPathString()); return(page); }
// Syncronize slots with current storage state private void SyncSlots() { SlotPage page = Storage.CurProfile.GetPageByPath(Storage.CurPathString()); foreach (ActionSlot slot in Slots) { int id = Int32.Parse(Regex.Match(slot.Name, @"\d+").Value); SlotLabel label = slot.Controls.OfType <SlotLabel>().First(); Slot found = Storage.GetSlotById(id); if (found != null) { slot.Type = found.Type; label.Text = Storage.GetSetting(id, "Title"); ((Control)slot).AllowDrop = true; //TODO: Manage image changing if (!File.Exists(found.Image_0)) { switch (found.Type) { case SlotType.None: slot.BackgroundImage = null; break; case SlotType.Folder: slot.BackgroundImage = Properties.Resources.slot_folder; break; case SlotType.FolderBack: slot.BackgroundImage = Properties.Resources.slot_folder_back; break; case SlotType.OpenApp: slot.BackgroundImage = Properties.Resources.slot_launch; break; case SlotType.Website: slot.BackgroundImage = Properties.Resources.slot_website; break; case SlotType.Hotkey: break; } } else { Image img = Bitmap.FromFile(found.Image_0); Bitmap bgImg = new Bitmap(img); img.Dispose(); slot.BackgroundImage = bgImg; } } else if (Storage.CurPathString() != "" && slot == Slots[0]) { slot.Type = SlotType.FolderBack; slot.BackgroundImage = Properties.Resources.slot_folder_back; label.Text = ""; ((Control)slot).AllowDrop = false; } else { slot.Type = SlotType.None; label.Text = ""; slot.BackgroundImage = null; } } }