Skip to content

Commit 997cce0

Browse files
SPSP
authored andcommitted
Add project files.
1 parent 47a75d1 commit 997cce0

File tree

7 files changed

+330
-0
lines changed

7 files changed

+330
-0
lines changed

JSON File Explorer.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.13.35931.197 d17.13
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONFileExplorer", "JSON File Explorer\JSONFileExplorer.csproj", "{D2325AB6-AB55-4E73-B23E-FBC4D591BF6E}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{D2325AB6-AB55-4E73-B23E-FBC4D591BF6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{D2325AB6-AB55-4E73-B23E-FBC4D591BF6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{D2325AB6-AB55-4E73-B23E-FBC4D591BF6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{D2325AB6-AB55-4E73-B23E-FBC4D591BF6E}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {B2CB3DE9-15D2-4F4A-BB70-80A22B55F62E}
24+
EndGlobalSection
25+
EndGlobal

JSON File Explorer/App.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="JSON_File_Explorer.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:JSON_File_Explorer"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>

JSON File Explorer/App.xaml.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Configuration;
2+
using System.Data;
3+
using System.Windows;
4+
5+
namespace JSON_File_Explorer
6+
{
7+
/// <summary>
8+
/// Interaction logic for App.xaml
9+
/// </summary>
10+
public partial class App : Application
11+
{
12+
}
13+
14+
}

JSON File Explorer/AssemblyInfo.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net8.0-windows</TargetFramework>
6+
<RootNamespace>JSONFileExplorer</RootNamespace>
7+
<Nullable>enable</Nullable>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
<UseWPF>true</UseWPF>
10+
</PropertyGroup>
11+
12+
</Project>

JSON File Explorer/MainWindow.xaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<Window x:Class="JSONFileExplorer.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
Title="ID Database Manager" Height="600" Width="800"
5+
WindowStartupLocation="CenterScreen" Background="#1e1e1e">
6+
7+
<Grid Margin="10">
8+
<Grid.ColumnDefinitions>
9+
<ColumnDefinition Width="*"/>
10+
<ColumnDefinition Width="*"/>
11+
</Grid.ColumnDefinitions>
12+
<Grid.RowDefinitions>
13+
<RowDefinition Height="50"/>
14+
<RowDefinition Height="*"/>
15+
<RowDefinition Height="50"/>
16+
</Grid.RowDefinitions>
17+
18+
<Button Name="btnLoad" Grid.Row="0" Grid.ColumnSpan="2" Content="📂 DATABASE DOSYASINI YÜKLE (.json veya .txt)"
19+
Height="35" Margin="0,0,0,10" Background="#007acc" Foreground="White"
20+
FontWeight="Bold" Click="BtnLoad_Click"/>
21+
22+
<GroupBox Grid.Row="1" Grid.Column="0" Header="Mevcut İçerik" Foreground="#569cd6" Margin="0,0,5,0">
23+
24+
<ListBox Name="lstCurrentIds" Background="#252526" Foreground="#d4d4d4" FontFamily="Consolas"
25+
SelectionMode="Extended"
26+
KeyDown="LstCurrentIds_KeyDown">
27+
28+
<ListBox.ContextMenu>
29+
<ContextMenu>
30+
<MenuItem Header="❌ Seçilenleri Sil" Click="BtnDelete_Click"/>
31+
<Separator/>
32+
<MenuItem Header="📋 Seçilenleri Kopyala" Click="BtnCopy_Click"/>
33+
</ContextMenu>
34+
</ListBox.ContextMenu>
35+
36+
</ListBox>
37+
</GroupBox>
38+
39+
<GroupBox Grid.Row="1" Grid.Column="1" Header="Toplu Ekleme (Yapıştır Gitsin)" Foreground="#ce9178" Margin="5,0,0,0">
40+
<TextBox Name="txtBulkInput" AcceptsReturn="True" TextWrapping="Wrap"
41+
Background="#252526" Foreground="#dcdcaa" FontFamily="Consolas"
42+
VerticalScrollBarVisibility="Auto"
43+
ToolTip="Buraya alt alta veya karışık ID'leri yapıştır."/>
44+
</GroupBox>
45+
46+
<StackPanel Grid.Row="2" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0">
47+
<TextBlock Name="lblStatus" Text="Dosya bekleniyor..." VerticalAlignment="Center" Foreground="Gray" Margin="0,0,10,0" FontWeight="Bold"/>
48+
<Button Name="btnProcess" Content="💾 LİSTEYİ BİRLEŞTİR VE KAYDET" Width="200" Background="#4ec9b0" Foreground="Black" FontWeight="Bold" Click="BtnProcess_Click"/>
49+
</StackPanel>
50+
</Grid>
51+
</Window>
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text.Json;
6+
using System.Windows;
7+
using System.Windows.Controls; // ContextMenu ve ListBox için gerekli
8+
using Microsoft.Win32;
9+
10+
namespace JSONFileExplorer
11+
{
12+
public partial class MainWindow : Window
13+
{
14+
private HashSet<string> databaseIds = new HashSet<string>();
15+
private string currentFilePath = "";
16+
17+
public MainWindow()
18+
{
19+
InitializeComponent();
20+
}
21+
22+
// --- 1. DOSYA YÜKLEME ---
23+
private void BtnLoad_Click(object sender, RoutedEventArgs e)
24+
{
25+
OpenFileDialog openFileDialog = new OpenFileDialog();
26+
// Hem JSON hem TXT hem de uzantısız dosyaları görebilmek için filtre:
27+
openFileDialog.Filter = "Tüm Dosyalar (*.*)|*.*|JSON Dosyaları (*.json)|*.json|Metin Dosyaları (*.txt)|*.txt";
28+
29+
if (openFileDialog.ShowDialog() == true)
30+
{
31+
currentFilePath = openFileDialog.FileName;
32+
LoadData(currentFilePath);
33+
}
34+
}
35+
36+
private void LoadData(string path)
37+
{
38+
try
39+
{
40+
string content = File.ReadAllText(path);
41+
databaseIds.Clear();
42+
43+
try
44+
{
45+
// JSON formatı denemesi
46+
var tempDict = JsonSerializer.Deserialize<Dictionary<string, bool>>(content);
47+
if (tempDict != null)
48+
{
49+
foreach (var key in tempDict.Keys)
50+
{
51+
databaseIds.Add(key);
52+
}
53+
}
54+
}
55+
catch
56+
{
57+
// Düz yazı formatı denemesi
58+
string[] lines = content.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
59+
foreach (var line in lines)
60+
{
61+
string cleanId = line.Trim().Replace("\"", "").Replace(",", "");
62+
if (!string.IsNullOrWhiteSpace(cleanId))
63+
{
64+
databaseIds.Add(cleanId);
65+
}
66+
}
67+
}
68+
69+
UpdateUI();
70+
lblStatus.Text = $"✅ Yüklendi: {databaseIds.Count} adet kayıt.";
71+
}
72+
catch (Exception ex)
73+
{
74+
MessageBox.Show("Hata: " + ex.Message);
75+
}
76+
}
77+
78+
// --- 2. ARAYÜZ GÜNCELLEME ---
79+
private void UpdateUI()
80+
{
81+
lstCurrentIds.ItemsSource = null;
82+
// Tüm listeyi göster (Take(100) kaldırdık)
83+
lstCurrentIds.ItemsSource = databaseIds.ToList();
84+
((System.Windows.Controls.GroupBox)lstCurrentIds.Parent).Header = $"Mevcut İçerik (Toplam: {databaseIds.Count})";
85+
}
86+
87+
// --- 3. İŞLE VE KAYDET ---
88+
private void BtnProcess_Click(object sender, RoutedEventArgs e)
89+
{
90+
if (string.IsNullOrEmpty(currentFilePath))
91+
{
92+
MessageBox.Show("Lütfen önce bir dosya yükleyin!");
93+
return;
94+
}
95+
96+
string rawInput = txtBulkInput.Text;
97+
string[] newLines = rawInput.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
98+
99+
int addedCount = 0;
100+
int duplicateCount = 0;
101+
102+
foreach (var line in newLines)
103+
{
104+
string idToCheck = line.Trim().Replace("\"", "").Replace(",", "");
105+
106+
if (string.IsNullOrWhiteSpace(idToCheck)) continue;
107+
108+
if (databaseIds.Contains(idToCheck))
109+
{
110+
duplicateCount++;
111+
}
112+
else
113+
{
114+
databaseIds.Add(idToCheck);
115+
addedCount++;
116+
}
117+
}
118+
119+
SaveDatabase();
120+
121+
txtBulkInput.Clear();
122+
UpdateUI();
123+
124+
MessageBox.Show($"EKLENEN: {addedCount}\nZATEN VARDI: {duplicateCount}\nTOPLAM: {databaseIds.Count}", "İşlem Tamam");
125+
126+
lblStatus.Text = "Kayıt başarılı.";
127+
}
128+
129+
private void SaveDatabase()
130+
{
131+
// Dosyanın uzantısını kontrol et (.json mu?)
132+
string extension = Path.GetExtension(currentFilePath).ToLower();
133+
134+
// DURUM 1: Eğer dosya bir JSON ise, eski formatı koru (Roblox Table Formatı)
135+
if (extension == ".json")
136+
{
137+
var exportDict = new Dictionary<string, bool>();
138+
foreach (var id in databaseIds)
139+
{
140+
exportDict[id] = true;
141+
}
142+
143+
var options = new JsonSerializerOptions { WriteIndented = true };
144+
string jsonOutput = JsonSerializer.Serialize(exportDict, options);
145+
File.WriteAllText(currentFilePath, jsonOutput);
146+
}
147+
// DURUM 2: JSON değilse (txt veya uzantısız BLScriptsData gibi), DÜZ METİN kaydet
148+
else
149+
{
150+
// HashSet içindeki tüm ID'leri alt alta yaz
151+
File.WriteAllLines(currentFilePath, databaseIds);
152+
}
153+
}
154+
155+
// --- YENİ EKLENEN ÖZELLİKLER (SİLME & KOPYALAMA) ---
156+
157+
// Ortak Silme Fonksiyonu
158+
private void RemoveSelectedItems()
159+
{
160+
if (lstCurrentIds.SelectedItems.Count == 0) return;
161+
162+
// Seçilenleri listeye al
163+
var itemsToRemove = lstCurrentIds.SelectedItems.Cast<string>().ToList();
164+
165+
int deletedCount = 0;
166+
foreach (var id in itemsToRemove)
167+
{
168+
if (databaseIds.Contains(id))
169+
{
170+
databaseIds.Remove(id);
171+
deletedCount++;
172+
}
173+
}
174+
175+
UpdateUI();
176+
lblStatus.Text = $"🗑️ {deletedCount} adet kayıt silindi.";
177+
178+
// Değişikliği anında kaydetmek istersen burayı aç:
179+
// SaveDatabase();
180+
}
181+
182+
// Klavye Tuşuna Basınca (Delete Tuşu)
183+
private void LstCurrentIds_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
184+
{
185+
if (e.Key == System.Windows.Input.Key.Delete)
186+
{
187+
RemoveSelectedItems();
188+
}
189+
}
190+
191+
// Sağ Tık Menüsü: Sil
192+
private void BtnDelete_Click(object sender, RoutedEventArgs e)
193+
{
194+
RemoveSelectedItems();
195+
}
196+
197+
// Sağ Tık Menüsü: Kopyala
198+
private void BtnCopy_Click(object sender, RoutedEventArgs e)
199+
{
200+
if (lstCurrentIds.SelectedItems.Count == 0) return;
201+
202+
var selectedList = lstCurrentIds.SelectedItems.Cast<string>();
203+
string clipboardText = string.Join(Environment.NewLine, selectedList);
204+
205+
Clipboard.SetText(clipboardText);
206+
lblStatus.Text = "📋 Seçilenler kopyalandı.";
207+
}
208+
}
209+
}

0 commit comments

Comments
 (0)