1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-10 08:34:06 +02:00

Refactor some code and replace the only RichTextLabel use with Label

This commit is contained in:
chylex 2016-07-04 03:53:44 +02:00
parent 88e5681155
commit 780908f777
8 changed files with 15 additions and 134 deletions

View File

@ -1,41 +0,0 @@
namespace TweetDck.Core.Controls {
partial class RichTextLabel {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.SuspendLayout();
//
// RichTextLabel
//
this.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.ReadOnly = true;
this.TabStop = false;
this.MouseEnter += new System.EventHandler(this.RichTextLabel_MouseEnter);
this.ResumeLayout(false);
}
#endregion
}
}

View File

@ -1,59 +0,0 @@
using System;
using System.Windows.Forms;
using TweetDck.Core.Utils;
namespace TweetDck.Core.Controls{
public partial class RichTextLabel : RichTextBox{
/// <summary>
/// Wraps the body of a RTF formatted string with default tags and formatting.
/// </summary>
public static string Wrap(string str){
string rtf = @"{\rtf1\ansi\ansicpg1250\deff0\deflang1029{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}";
rtf += @"{\*\generator Msftedit 4.20.69.1337;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang1036\f0\fs16 ";
rtf += str;
return rtf;
}
/// <summary>
/// Wraps URL tags around a link.
/// </summary>
public static string AddLink(string url){
return @"{\field{\*\fldinst{HYPERLINK """+url+@"""}}{\fldrslt{\ul\cf1 "+url+@"}}}";
}
/// <summary>
/// Uses v5 of RichTextBox, which fixes URLs and other crap.
/// </summary>
protected override CreateParams CreateParams{
get{
CreateParams createParams = base.CreateParams;
if (NativeMethods.LoadLibrary("msftedit.dll") != IntPtr.Zero){
createParams.ClassName = "RICHEDIT50W";
}
return createParams;
}
}
public RichTextLabel(){
InitializeComponent();
SetStyle(ControlStyles.Selectable,false);
SetStyle(ControlStyles.UserMouse,true);
SetStyle(ControlStyles.SupportsTransparentBackColor,true);
}
private void RichTextLabel_MouseEnter(object sender, EventArgs e){
Cursor = Cursors.Default;
}
protected override void WndProc(ref Message m){
if (m.Msg == 0x204 || m.Msg == 0x205){ // WM_RBUTTONDOWN, WM_RBUTTONUP
return;
}
base.WndProc(ref m);
}
}
}

View File

@ -9,12 +9,6 @@
namespace TweetDck.Core.Other{
sealed partial class FormSettings : Form{
private static UserConfig Config{
get{
return Program.UserConfig;
}
}
private readonly Dictionary<Type,BaseTabSettings> tabs = new Dictionary<Type,BaseTabSettings>(4);
public FormSettings(FormBrowser browserForm, UpdateHandler updates){
@ -48,7 +42,7 @@ private void SelectTab<T>(Func<T> constructor) where T : BaseTabSettings{
}
private void FormSettings_FormClosing(object sender, FormClosingEventArgs e){
Config.Save();
Program.UserConfig.Save();
}
private void btnExport_Click(object sender, EventArgs e){
@ -71,7 +65,7 @@ private void btnExport_Click(object sender, EventArgs e){
}
if (file != null){
Config.Save();
Program.UserConfig.Save();
ExportManager manager = new ExportManager(file);

View File

@ -20,9 +20,6 @@ public enum MouseButton{
Left, Right
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr LoadLibrary(string name);
[DllImport("Shell32.dll")]
public static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);

View File

@ -30,7 +30,7 @@ private void InitializeComponent() {
this.btnAskLater = new System.Windows.Forms.Button();
this.btnMigrate = new System.Windows.Forms.Button();
this.btnMigrateUninstall = new System.Windows.Forms.Button();
this.labelQuestion = new TweetDck.Core.Controls.RichTextLabel();
this.labelQuestion = new System.Windows.Forms.Label();
this.panelButtons.SuspendLayout();
this.SuspendLayout();
//
@ -38,7 +38,7 @@ private void InitializeComponent() {
//
this.btnIgnore.AutoSize = true;
this.btnIgnore.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnIgnore.Location = new System.Drawing.Point(353, 0);
this.btnIgnore.Location = new System.Drawing.Point(391, 0);
this.btnIgnore.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
this.btnIgnore.Name = "btnIgnore";
this.btnIgnore.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
@ -57,16 +57,16 @@ private void InitializeComponent() {
this.panelButtons.Controls.Add(this.btnMigrate);
this.panelButtons.Controls.Add(this.btnMigrateUninstall);
this.panelButtons.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
this.panelButtons.Location = new System.Drawing.Point(12, 75);
this.panelButtons.Location = new System.Drawing.Point(12, 67);
this.panelButtons.Name = "panelButtons";
this.panelButtons.Size = new System.Drawing.Size(480, 23);
this.panelButtons.Size = new System.Drawing.Size(518, 23);
this.panelButtons.TabIndex = 0;
//
// btnAskLater
//
this.btnAskLater.AutoSize = true;
this.btnAskLater.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnAskLater.Location = new System.Drawing.Point(412, 0);
this.btnAskLater.Location = new System.Drawing.Point(450, 0);
this.btnAskLater.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.btnAskLater.Name = "btnAskLater";
this.btnAskLater.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
@ -80,7 +80,7 @@ private void InitializeComponent() {
//
this.btnMigrate.AutoSize = true;
this.btnMigrate.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnMigrate.Location = new System.Drawing.Point(289, 0);
this.btnMigrate.Location = new System.Drawing.Point(327, 0);
this.btnMigrate.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
this.btnMigrate.Name = "btnMigrate";
this.btnMigrate.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
@ -94,7 +94,7 @@ private void InitializeComponent() {
//
this.btnMigrateUninstall.AutoSize = true;
this.btnMigrateUninstall.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnMigrateUninstall.Location = new System.Drawing.Point(185, 0);
this.btnMigrateUninstall.Location = new System.Drawing.Point(223, 0);
this.btnMigrateUninstall.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.btnMigrateUninstall.Name = "btnMigrateUninstall";
this.btnMigrateUninstall.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
@ -109,22 +109,18 @@ private void InitializeComponent() {
this.labelQuestion.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.labelQuestion.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.labelQuestion.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.labelQuestion.Location = new System.Drawing.Point(49, 9);
this.labelQuestion.Margin = new System.Windows.Forms.Padding(40, 3, 3, 3);
this.labelQuestion.Name = "labelQuestion";
this.labelQuestion.ReadOnly = true;
this.labelQuestion.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
this.labelQuestion.Size = new System.Drawing.Size(443, 60);
this.labelQuestion.Size = new System.Drawing.Size(481, 52);
this.labelQuestion.TabIndex = 2;
this.labelQuestion.TabStop = false;
this.labelQuestion.Text = "";
//
// FormMigrationQuestion
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(504, 110);
this.ClientSize = new System.Drawing.Size(542, 102);
this.Controls.Add(this.labelQuestion);
this.Controls.Add(this.panelButtons);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
@ -145,7 +141,7 @@ private void InitializeComponent() {
private System.Windows.Forms.Button btnIgnore;
private System.Windows.Forms.FlowLayoutPanel panelButtons;
private System.Windows.Forms.Button btnMigrate;
private RichTextLabel labelQuestion;
private System.Windows.Forms.Label labelQuestion;
private System.Windows.Forms.Button btnAskLater;
private System.Windows.Forms.Button btnMigrateUninstall;
}

View File

@ -1,7 +1,6 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using TweetDck.Core.Controls;
namespace TweetDck.Migration{
partial class FormMigrationQuestion : Form{
@ -10,7 +9,7 @@ partial class FormMigrationQuestion : Form{
public FormMigrationQuestion(){
InitializeComponent();
labelQuestion.Rtf = RichTextLabel.Wrap(@"Hey there, I found some TweetDeck data! Do you want to \b Migrate\b0 it and delete the old data folder, \b Ignore\b0 the request forever, or just try "+Program.BrandName+@" first?\par You may also \b Migrate & Purge\b0 which uninstalls TweetDeck too!");
labelQuestion.Text = "Hey there, I found some TweetDeck data! Do you want to »Migrate« it and delete the old data folder, »Ignore« the request forever, or try "+Program.BrandName+" out first?\r\nYou may also »Migrate && Purge« which uninstalls TweetDeck too!";
}
protected override void OnPaint(PaintEventArgs e){

View File

@ -97,6 +97,7 @@ private static void Main(){
if (File.Exists(ExportManager.CookiesPath)){
File.Delete(ExportManager.CookiesPath);
}
File.Move(ExportManager.TempCookiesPath,ExportManager.CookiesPath);
}catch(Exception e){
HandleException("Could not import the cookie file to restore login session.",e);

View File

@ -114,12 +114,6 @@
<Compile Include="Core\Handling\DialogHandlerBrowser.cs" />
<Compile Include="Core\Handling\LifeSpanHandler.cs" />
<Compile Include="Core\Handling\TweetNotification.cs" />
<Compile Include="Core\Controls\RichTextLabel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Core\Controls\RichTextLabel.Designer.cs">
<DependentUpon>RichTextLabel.cs</DependentUpon>
</Compile>
<Compile Include="Core\Other\FormAbout.cs">
<SubType>Form</SubType>
</Compile>