Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions FloatFolder/System/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@

namespace FloatFolder
{
public class App
{
List<Shortcut> shortcuts;

public App()
{
shortcuts = new List<Shortcut>();
}
public class App
{
List<Shortcut> shortcuts;

public App()
{
shortcuts = new List<Shortcut>();
}

static string EscapeLiteral(string value)
{
if (value == null)
{
return string.Empty;
}

return value.Replace("\\", "\\\\").Replace("\"", "\\\"");
}

public void AddShortcut(string name, string url)
{
Expand Down Expand Up @@ -50,11 +60,11 @@ public string GenerateApp()
code.AppendLine("namespace SavanDev {");
code.AppendLine(Template.AppProgram).AppendLine();

StringBuilder codeShortcut = new StringBuilder();
foreach (var item in shortcuts) {
codeShortcut.AppendLine("Nombre.Add(\"" + item.name + "\");");
codeShortcut.AppendLine("Url.Add(\"" + item.url.Replace("\\", "\\\\") + "\");");
}
StringBuilder codeShortcut = new StringBuilder();
foreach (var item in shortcuts) {
codeShortcut.AppendLine("Nombre.Add(\"" + EscapeLiteral(item.name) + "\");");
codeShortcut.AppendLine("Url.Add(\"" + EscapeLiteral(item.url) + "\");");
}

string size;
switch (shortcuts.Count)
Expand Down
188 changes: 120 additions & 68 deletions FloatFolder/System/Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ namespace FloatFolder
{
static class Template
{
public static readonly string AppNamespace = @"using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Reflection;
using System.Runtime.InteropServices;";
public static readonly string AppNamespace = @"using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Windows.Forms;
using System.Reflection;
using System.Runtime.InteropServices;";

public static readonly string AppProgram = @"static class Program
{
Expand All @@ -30,8 +31,9 @@ public static string AppMain(string shortcuts, string size)
return @"public class App : Form
{
System.ComponentModel.IContainer components;
ListView listView1;
ImageList imageList1;
ListView listView1;
ImageList imageList1;
Label titleLabel;

protected override void Dispose(bool disposing)
{
Expand All @@ -46,51 +48,76 @@ void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.listView1 = new ListView();
this.imageList1 = new ImageList(this.components);
this.SuspendLayout();
//
// listView1
//
this.listView1.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
this.listView1.BackColor = SystemColors.Control;
this.listView1.BorderStyle = BorderStyle.None;
this.listView1.LargeImageList = this.imageList1;
this.listView1.Location = new Point(12, 12);
this.listView1.Size = new Size(" + size + @");
this.listView1.TileSize = new Size(143, 32);
this.listView1.SelectedIndexChanged += this.listView1_SelectedIndexChanged;
//
// imageList1
//
this.imageList1.ColorDepth = ColorDepth.Depth32Bit;
this.imageList1.ImageSize = new Size(32, 32);
this.imageList1.TransparentColor = Color.Transparent;
//
// Form1
//
this.AutoScaleDimensions = new SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new Size(this.listView1.Width + 12, this.listView1.Height + 12);
this.ControlBox = false;
this.Controls.Add(this.listView1);
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = FormStartPosition.Manual;
this.Deactivate += this.Form1_Deactivate;
this.Load += this.Form1_Load;
this.ResumeLayout(false);

}
this.imageList1 = new ImageList(this.components);
this.titleLabel = new Label();
this.SuspendLayout();
//
// listView1
//
this.listView1.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
this.listView1.BackColor = Color.FromArgb(250, 250, 250);
this.listView1.BorderStyle = BorderStyle.None;
this.listView1.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point);
this.listView1.ForeColor = Color.FromArgb(33, 33, 33);
this.listView1.FullRowSelect = true;
this.listView1.HideSelection = false;
this.listView1.LargeImageList = this.imageList1;
this.listView1.Location = new Point(24, 72);
this.listView1.Size = new Size(" + size + @");
this.listView1.TileSize = new Size(Math.Max(48, this.listView1.Width - 24), 64);
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = View.Tile;
this.listView1.SelectedIndexChanged += this.listView1_SelectedIndexChanged;
//
// imageList1
//
this.imageList1.ColorDepth = ColorDepth.Depth32Bit;
this.imageList1.ImageSize = new Size(48, 48);
this.imageList1.TransparentColor = Color.Transparent;
//
// titleLabel
//
this.titleLabel.AutoSize = false;
this.titleLabel.Font = new Font("Segoe UI", 12F, FontStyle.Bold, GraphicsUnit.Point);
this.titleLabel.ForeColor = Color.White;
this.titleLabel.Location = new Point(24, 24);
this.titleLabel.Size = new Size(this.listView1.Width, 32);
this.titleLabel.Text = "Accesos directos";
this.titleLabel.TextAlign = ContentAlignment.MiddleLeft;
//
// Form1
//
this.AutoScaleDimensions = new SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = Color.FromArgb(33, 33, 33);
this.ClientSize = new Size(this.listView1.Width + 48, this.listView1.Height + 96);
this.ControlBox = false;
this.Controls.Add(this.titleLabel);
this.Controls.Add(this.listView1);
this.DoubleBuffered = true;
this.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
this.FormBorderStyle = FormBorderStyle.None;
this.Opacity = 0.92D;
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = FormStartPosition.Manual;
this.Text = string.Empty;
this.TopMost = true;
this.Deactivate += this.Form1_Deactivate;
this.Load += this.Form1_Load;
this.ResumeLayout(false);

}

// Normal code
List<string> Url = new List<string>();
List<string> Nombre = new List<string>();

public App()
{
InitializeComponent();
//Establecer posición del formulario
public App()
{
InitializeComponent();

//Establecer posición del formulario
if(Cursor.Position.X + Size.Width > Screen.PrimaryScreen.WorkingArea.Width || Cursor.Position.Y + Size.Height > Screen.PrimaryScreen.WorkingArea.Height)
Location = Cursor.Position - Size;
else
Expand All @@ -114,25 +141,50 @@ public static Bitmap getApplicationIcon(string source)
return Icon.ExtractAssociatedIcon(source).ToBitmap();
}

void Form1_Load(object sender, EventArgs e)
{
foreach (var item in Url)
{
imageList1.Images.Add(getApplicationIcon(item));
}

for (int i = 0; i < Nombre.Count; i++)
{
listView1.Items.Add(Nombre[i]);
listView1.Items[i].ImageIndex = i;
}
}

void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(Url[listView1.SelectedIndices[0]]);
Application.Exit();
}
void Form1_Load(object sender, EventArgs e)
{
listView1.TileSize = new Size(Math.Max(48, listView1.ClientSize.Width - 24), 64);

foreach (var item in Url)
{
imageList1.Images.Add(getApplicationIcon(item));
}

for (int i = 0; i < Nombre.Count; i++)
{
listView1.Items.Add(Nombre[i]);
listView1.Items[i].ImageIndex = i;
}
}

protected override void OnCreateControl()
{
base.OnCreateControl();

int radius = 18;

using (GraphicsPath path = new GraphicsPath())
{
path.StartFigure();
path.AddArc(0, 0, radius, radius, 180, 90);
path.AddArc(Width - radius, 0, radius, radius, 270, 90);
path.AddArc(Width - radius, Height - radius, radius, radius, 0, 90);
path.AddArc(0, Height - radius, radius, radius, 90, 90);
path.CloseFigure();
Region = new Region(path);
}
}

void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listView1.SelectedIndices.Count == 0)
{
return;
}

System.Diagnostics.Process.Start(Url[listView1.SelectedIndices[0]]);
Application.Exit();
}
}";
}
}
Expand Down