Skip to content
This repository has been archived by the owner on Dec 10, 2023. It is now read-only.

Commit

Permalink
v1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
NotroDev committed Feb 6, 2023
1 parent f7ddde1 commit 37f2c91
Show file tree
Hide file tree
Showing 15 changed files with 441 additions and 100 deletions.
Binary file modified SkEditor+ Installer/Release/setup.exe
Binary file not shown.
74 changes: 31 additions & 43 deletions SkEditorPlus/Data/CompletionData.cs
@@ -1,55 +1,43 @@
using AvalonEditB.CodeCompletion;
using AvalonEditB.Document;
using AvalonEditB.Editing;
using SkEditorPlus.Windows.Generators;
using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace SkEditorPlus.Data
{
public class CompletionData : ICompletionData
public class CompletionData
{
public CompletionData(string text, string description = "Brak opisu")
{
Text = text;
Description = description;
}

public System.Windows.Media.ImageSource Image
public static List<CompletionDataElement> completionList = new()
{
get { return null; }
}

public string Text { get; private set; }

public object Content
{
get { return this.Text; }
}

public object Description
{ get; private set; }

double ICompletionData.Priority => 1;

public void Complete(TextArea textArea, ISegment completionSegment,
EventArgs insertionRequestEventArgs)
{
var caretOffset = textArea.Caret.Offset;
var line = textArea.Document.GetLineByOffset(caretOffset);
textArea.Document.Replace(line.Offset, caretOffset - line.Offset, "");

CommandGenerator commandGenerator = new(GetMainWindow().skEditor);
commandGenerator.ShowDialog();
}
public static MainWindow GetMainWindow()
new CompletionDataElement("command", "command /{c}:\n\t"),
new CompletionDataElement("commandgen"),
new CompletionDataElement("options", "options:\n\t"),
new CompletionDataElement("variables", "variables:\n\t"),
new CompletionDataElement("trigger", "trigger:\n\t"),
new CompletionDataElement("if", "if {c}:"),
new CompletionDataElement("ifelse", "if {c}:\n\t\nelse:\n\t"),
new CompletionDataElement("else"),
new CompletionDataElement("send", "send \"{c}\""),
new CompletionDataElement("sendallp", "send \"{c}\" to all players"),
};

public static ListBoxItem[] GetCompletionData(string word)
{
List<Window> windowList = new();
foreach (Window window in System.Windows.Application.Current.Windows)
windowList.Add(window);
return (MainWindow)windowList.Find(window => window.GetType() == typeof(MainWindow));
List<ListBoxItem> completions = new();
foreach (var item in completionList)
{
if (item.Name.StartsWith(word))
{
//if (item.Name.Equals(word)) continue;
completions.Add(new ListBoxItem { Content = item.Name });
}
}
return completions.ToArray();
}

}
}
}
33 changes: 33 additions & 0 deletions SkEditorPlus/Data/CompletionDataElement.cs
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SkEditorPlus.Data
{
public class CompletionDataElement
{
public string Name { get; set; }
public string Description { get; set; }

public string Word { get; set; }

public CompletionDataElement(string name, string word = "none", string description = "none")
{
Name = name;

if (!description.Equals("none"))
{
Description = description;
}

if (!word.Equals("none"))
{
Word = word;
return;
}
Word = word;
}
}
}
2 changes: 1 addition & 1 deletion SkEditorPlus/MainWindow.xaml
Expand Up @@ -15,7 +15,7 @@
WindowStartupLocation="CenterScreen"
WindowState="Maximized"
mc:Ignorable="d"
MaxHeight="{x:Static SystemParameters.MaximizedPrimaryScreenHeight}" Closing="OnClosing">
MaxHeight="{x:Static SystemParameters.MaximizedPrimaryScreenHeight}" Closing="OnClosing" SizeChanged="OnSizeChanged" StateChanged="Window_StateChanged">
<hc:Window.NonClientAreaContent>
<Grid x:Name="TitleBar">
<Grid.ColumnDefinitions>
Expand Down
46 changes: 44 additions & 2 deletions SkEditorPlus/MainWindow.xaml.cs
Expand Up @@ -9,8 +9,11 @@
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using Window = HandyControl.Controls.Window;

Expand All @@ -29,11 +32,23 @@ public Menu GetMenu()
return MenuBar;
}


[DllImport("user32.dll")]
static extern IntPtr GetWindow(IntPtr hWnd, uint wCmd);
const uint GW_HWNDNEXT = 2;

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool IsWindowVisible(IntPtr hWnd);


public event LoadFinishedEvent LoadFinished;


private static readonly string version = "1.4.0";
private static readonly string version = "1.4.1";

public static string Version { get => version; }

Expand Down Expand Up @@ -243,5 +258,32 @@ public void HandleNamedPipe_OpenRequest(string filesToOpen)
}
catch { }
}

private void OnSizeChanged(object sender, SizeChangedEventArgs e)
{
FixCut();
}

private void FixCut()
{
if (WindowState == WindowState.Maximized)
{
IntPtr hWnd = new WindowInteropHelper(Application.Current.MainWindow).Handle;

IntPtr hNext = hWnd;
do
hNext = GetWindow(hNext, GW_HWNDNEXT);
while (!IsWindowVisible(hNext));

SetForegroundWindow(hNext);

Activate();
}
}

private void Window_StateChanged(object sender, EventArgs e)
{
FixCut();
}
}
}

0 comments on commit 37f2c91

Please sign in to comment.