mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	Completed rename from RainmeterEditor to RainmeterStudio
This commit is contained in:
		
							
								
								
									
										12
									
								
								RainmeterStudio/Documents/Ini/IniDocument.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								RainmeterStudio/Documents/Ini/IniDocument.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using RainmeterStudio.Model;
 | 
			
		||||
 | 
			
		||||
namespace RainmeterStudio.Documents.Ini
 | 
			
		||||
{
 | 
			
		||||
    /*public class IniDocument : IDocument
 | 
			
		||||
    {
 | 
			
		||||
    }*/
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										31
									
								
								RainmeterStudio/Documents/Ini/IniSkinDesigner.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								RainmeterStudio/Documents/Ini/IniSkinDesigner.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using RainmeterStudio.Model;
 | 
			
		||||
 | 
			
		||||
namespace RainmeterStudio.Documents.Ini
 | 
			
		||||
{
 | 
			
		||||
    /*public class IniSkinDesigner : IDocumentEditor
 | 
			
		||||
    {
 | 
			
		||||
        public override IDocument Document
 | 
			
		||||
        {
 | 
			
		||||
            get { throw new NotImplementedException(); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override string Title
 | 
			
		||||
        {
 | 
			
		||||
            get { throw new NotImplementedException(); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override System.Windows.UIElement EditorUI
 | 
			
		||||
        {
 | 
			
		||||
            get { throw new NotImplementedException(); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override EventHandler SelectionChanged
 | 
			
		||||
        {
 | 
			
		||||
            get { throw new NotImplementedException(); }
 | 
			
		||||
        }
 | 
			
		||||
    }*/
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								RainmeterStudio/Documents/Ini/IniSkinDesignerControl.xaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								RainmeterStudio/Documents/Ini/IniSkinDesignerControl.xaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
<UserControl x:Class="RainmeterStudio.Documents.Ini.IniSkinDesignerControl"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             mc:Ignorable="d" 
 | 
			
		||||
             d:DesignHeight="300" d:DesignWidth="300">
 | 
			
		||||
    <Grid>
 | 
			
		||||
            
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
							
								
								
									
										27
									
								
								RainmeterStudio/Documents/Ini/IniSkinDesignerControl.xaml.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								RainmeterStudio/Documents/Ini/IniSkinDesignerControl.xaml.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Controls;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
using System.Windows.Documents;
 | 
			
		||||
using System.Windows.Input;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using System.Windows.Media.Imaging;
 | 
			
		||||
using System.Windows.Navigation;
 | 
			
		||||
using System.Windows.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace RainmeterStudio.Documents.Ini
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Interaction logic for IniSkinDesignerControl.xaml
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class IniSkinDesignerControl : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        public IniSkinDesignerControl()
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								RainmeterStudio/Documents/Ini/IniSkinDesignerFactory.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								RainmeterStudio/Documents/Ini/IniSkinDesignerFactory.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using RainmeterStudio.Model;
 | 
			
		||||
 | 
			
		||||
namespace RainmeterStudio.Documents.Ini
 | 
			
		||||
{
 | 
			
		||||
    /*public class IniSkinDesignerFactory : IDocumentEditorFactory
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    }*/
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										35
									
								
								RainmeterStudio/Documents/Text/TextDocument.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								RainmeterStudio/Documents/Text/TextDocument.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using RainmeterStudio.Model;
 | 
			
		||||
 | 
			
		||||
namespace RainmeterStudio.Documents.Text
 | 
			
		||||
{
 | 
			
		||||
    public class TextDocument : IDocument
 | 
			
		||||
    {
 | 
			
		||||
        public string Name
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return Path.GetFileName(FilePath);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public string FilePath
 | 
			
		||||
        {
 | 
			
		||||
            get; set;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public string Text
 | 
			
		||||
        {
 | 
			
		||||
            get; set;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public TextDocument()
 | 
			
		||||
        {
 | 
			
		||||
            Text = String.Empty;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										27
									
								
								RainmeterStudio/Documents/Text/TextEditor.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								RainmeterStudio/Documents/Text/TextEditor.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using RainmeterStudio.Model;
 | 
			
		||||
 | 
			
		||||
namespace RainmeterStudio.Documents.Text
 | 
			
		||||
{
 | 
			
		||||
    public class TextEditor : IDocumentEditor
 | 
			
		||||
    {
 | 
			
		||||
        private TextDocument _document;
 | 
			
		||||
        private TextEditorControl _control;
 | 
			
		||||
 | 
			
		||||
        public TextEditor(TextDocument document)
 | 
			
		||||
        {
 | 
			
		||||
            _document = document;
 | 
			
		||||
            _control = new TextEditorControl(document);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override IDocument Document { get { return _document; } }
 | 
			
		||||
 | 
			
		||||
        public override string Title { get { return _document.Name; } }
 | 
			
		||||
 | 
			
		||||
        public override System.Windows.UIElement EditorUI { get { return _control; } }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								RainmeterStudio/Documents/Text/TextEditorControl.xaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								RainmeterStudio/Documents/Text/TextEditorControl.xaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
<UserControl x:Class="RainmeterStudio.Documents.Text.TextEditorControl"
 | 
			
		||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
			
		||||
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
			
		||||
             mc:Ignorable="d" 
 | 
			
		||||
             d:DesignHeight="300" d:DesignWidth="300">
 | 
			
		||||
    <Grid>
 | 
			
		||||
        <TextBox Name="text" AcceptsReturn="True" />
 | 
			
		||||
    </Grid>
 | 
			
		||||
</UserControl>
 | 
			
		||||
							
								
								
									
										32
									
								
								RainmeterStudio/Documents/Text/TextEditorControl.xaml.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								RainmeterStudio/Documents/Text/TextEditorControl.xaml.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Controls;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
using System.Windows.Documents;
 | 
			
		||||
using System.Windows.Input;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using System.Windows.Media.Imaging;
 | 
			
		||||
using System.Windows.Navigation;
 | 
			
		||||
using System.Windows.Shapes;
 | 
			
		||||
 | 
			
		||||
namespace RainmeterStudio.Documents.Text
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Interaction logic for TextEditorControl.xaml
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class TextEditorControl : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        private TextDocument _document;
 | 
			
		||||
 | 
			
		||||
        public TextEditorControl(TextDocument document)
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
 | 
			
		||||
            _document = document;
 | 
			
		||||
            text.Text = document.Text;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										59
									
								
								RainmeterStudio/Documents/Text/TextEditorFactory.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								RainmeterStudio/Documents/Text/TextEditorFactory.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,59 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using RainmeterStudio.Business;
 | 
			
		||||
using RainmeterStudio.Model;
 | 
			
		||||
 | 
			
		||||
namespace RainmeterStudio.Documents.Text
 | 
			
		||||
{
 | 
			
		||||
    public class TextEditorFactory : IDocumentEditorFactory
 | 
			
		||||
    {
 | 
			
		||||
        private TextStorage _storage = new TextStorage();
 | 
			
		||||
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        public string EditorName
 | 
			
		||||
        {
 | 
			
		||||
            get { return Resources.Strings.DocumentEditor_Text_Name; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        public IEnumerable<DocumentFormat> CreateDocumentFormats
 | 
			
		||||
        {
 | 
			
		||||
            get 
 | 
			
		||||
            {
 | 
			
		||||
                yield return new DocumentFormat()
 | 
			
		||||
                {
 | 
			
		||||
                    Name = Resources.Strings.DocumentFormat_TextFile_Name,
 | 
			
		||||
                    Category = Resources.Strings.Category_Utility,
 | 
			
		||||
                    DefaultExtension = ".txt",
 | 
			
		||||
                    Description = Resources.Strings.DocumentFormat_TextFile_Description,
 | 
			
		||||
                    Icon = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Resources/Icons/text_file_32.png", UriKind.RelativeOrAbsolute)),
 | 
			
		||||
                    Factory = this
 | 
			
		||||
                };
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public IDocumentEditor CreateEditor(IDocument document)
 | 
			
		||||
        {
 | 
			
		||||
            TextDocument textDocument = document as TextDocument;
 | 
			
		||||
 | 
			
		||||
            if (textDocument == null)
 | 
			
		||||
                throw new ArgumentException("Cannot edit provided document.");
 | 
			
		||||
 | 
			
		||||
            return new TextEditor(textDocument);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public IDocumentStorage Storage { get { return _storage; } }
 | 
			
		||||
 | 
			
		||||
        public IDocument CreateDocument(DocumentFormat format, string path)
 | 
			
		||||
        {
 | 
			
		||||
            var document = new TextDocument();
 | 
			
		||||
            document.FilePath = path;
 | 
			
		||||
 | 
			
		||||
            return document;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										64
									
								
								RainmeterStudio/Documents/Text/TextStorage.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								RainmeterStudio/Documents/Text/TextStorage.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,64 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using RainmeterStudio.Model;
 | 
			
		||||
 | 
			
		||||
namespace RainmeterStudio.Documents.Text
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Storage for text files
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class TextStorage : IDocumentStorage
 | 
			
		||||
    {
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        IDocument IDocumentStorage.Read(string path)
 | 
			
		||||
        {
 | 
			
		||||
            TextDocument document = new TextDocument();
 | 
			
		||||
            document.FilePath = path;
 | 
			
		||||
            document.Text = File.ReadAllText(path);
 | 
			
		||||
 | 
			
		||||
            return document;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        public void Write(string path, IDocument document)
 | 
			
		||||
        {
 | 
			
		||||
            TextDocument textDocument = document as TextDocument;
 | 
			
		||||
 | 
			
		||||
            if (textDocument == null)
 | 
			
		||||
                throw new ArgumentException("Provided document is not supported by this storage.");
 | 
			
		||||
 | 
			
		||||
            File.WriteAllText(path, textDocument.Text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        public bool CanRead(string path)
 | 
			
		||||
        {
 | 
			
		||||
            // Open the file
 | 
			
		||||
            FileStream file = File.OpenRead(path);
 | 
			
		||||
 | 
			
		||||
            // Read a small chunk (1kb should be enough)
 | 
			
		||||
            byte[] buffer = new byte[1024];
 | 
			
		||||
            int read = file.Read(buffer, 0, buffer.Length);
 | 
			
		||||
 | 
			
		||||
            // Close file
 | 
			
		||||
            file.Close();
 | 
			
		||||
 | 
			
		||||
            // Find 4 consecutive zero bytes
 | 
			
		||||
            int cnt = 0;
 | 
			
		||||
            for (int i = 0; i < read; i++)
 | 
			
		||||
            {
 | 
			
		||||
                // Count zero bytes
 | 
			
		||||
                if (buffer[i] == 0)
 | 
			
		||||
                    ++cnt;
 | 
			
		||||
                else cnt = 0;
 | 
			
		||||
 | 
			
		||||
                // Found > 4? Most likely binary file
 | 
			
		||||
                if (cnt >= 4)
 | 
			
		||||
                    return false;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Not found, probably text file
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user