mirror of
https://github.com/Tribufu/ServerManagers
synced 2026-08-08 04:01:05 +00:00
source code checkin
This commit is contained in:
parent
5f8fb2c825
commit
7e57b72e35
675 changed files with 168433 additions and 0 deletions
|
|
@ -0,0 +1,87 @@
|
|||
// See license at end of the file
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using WPFSharp.Globalizer.Converters;
|
||||
|
||||
namespace WPFSharp.Globalizer.Controls
|
||||
{
|
||||
public class LanguageSelectionComboBox : ComboBox
|
||||
{
|
||||
public LanguageSelectionComboBox()
|
||||
{
|
||||
var itemSourceBinding = new Binding
|
||||
{
|
||||
Source = AvailableLanguages.Instance,
|
||||
BindsDirectlyToSource = true
|
||||
};
|
||||
SetBinding(ItemsSourceProperty, itemSourceBinding);
|
||||
|
||||
ItemTemplate = new DataTemplate();
|
||||
var binding = new Binding { Converter = new LanguageNameConverter() };
|
||||
var textElement = new FrameworkElementFactory(typeof(TextBlock));
|
||||
textElement.SetBinding(TextBlock.TextProperty, binding);
|
||||
ItemTemplate.VisualTree = textElement;
|
||||
|
||||
SelectionChanged += LanguageSelectionComboBox_SelectionChanged;
|
||||
|
||||
var selectedItemBinding = new Binding("SelectedLanguage")
|
||||
{
|
||||
Source = AvailableLanguages.Instance,
|
||||
Mode = BindingMode.OneWay
|
||||
};
|
||||
SetBinding(SelectedItemProperty, selectedItemBinding);
|
||||
}
|
||||
|
||||
void LanguageSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var lang = e.AddedItems[0] as string;
|
||||
if (!string.IsNullOrWhiteSpace(lang))
|
||||
GlobalizedApplication.Instance.GlobalizationManager.SwitchLanguage(lang);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region License
|
||||
/*
|
||||
WPFSharp.Globalizer - A project deisgned to make localization and styling
|
||||
easier by decoupling both process from the build.
|
||||
|
||||
Copyright (c) 2015, Jared Barneck (Rhyous)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Use of the source code or binaries that in any way competes with WPFSharp.Globalizer
|
||||
or competes with distribution, whether open source or commercial, is
|
||||
prohibited unless permission is specifically granted under a separate
|
||||
license by Jared Barneck (Rhyous).
|
||||
4. Forking for personal or internal, or non-competing commercial use is allowed.
|
||||
Distributing compiled releases as part of your non-competing project is
|
||||
allowed.
|
||||
5. Public copies, or forks, of source is allowed, but from such, public
|
||||
distribution of compiled releases is forbidden.
|
||||
6. Source code enhancements or additions are the property of the author until
|
||||
the source code is contributed to this project. By contributing the source
|
||||
code to this project, the author immediately grants all rights to the
|
||||
contributed source code to Jared Barneck (Rhyous).
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#endregion
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
// See license at end of the file
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using WPFSharp.Globalizer.Converters;
|
||||
|
||||
namespace WPFSharp.Globalizer.Controls
|
||||
{
|
||||
public class LanguageSelectionMenuItemList : MenuItem
|
||||
{
|
||||
public LanguageSelectionMenuItemList()
|
||||
{
|
||||
ItemsSource = AvailableLanguages.Instance;
|
||||
|
||||
var checkableMenuItemStyle = new Style { TargetType = typeof(MenuItem) };
|
||||
|
||||
var headerBinding = new Binding { Converter = new LanguageNameConverter() };
|
||||
var headerSetter = new Setter(HeaderProperty, headerBinding);
|
||||
checkableMenuItemStyle.Setters.Add(headerSetter);
|
||||
|
||||
var isCheckableSetter = new Setter(IsCheckableProperty, true);
|
||||
checkableMenuItemStyle.Setters.Add(isCheckableSetter);
|
||||
|
||||
ICommand command = new RelayCommand(SelectLanguage);
|
||||
var commandSetter = new Setter(CommandProperty, command);
|
||||
checkableMenuItemStyle.Setters.Add(commandSetter);
|
||||
|
||||
var commandParamBinding = new Binding();
|
||||
var commandParamSetter = new Setter(CommandParameterProperty, commandParamBinding);
|
||||
checkableMenuItemStyle.Setters.Add(commandParamSetter);
|
||||
|
||||
var isCheckedMultiBinding = new MultiBinding { Converter = new MultiValueStringsMatchConverter(), Mode = BindingMode.OneWay };
|
||||
isCheckedMultiBinding.Bindings.Add(new Binding { Mode = BindingMode.OneWay });
|
||||
isCheckedMultiBinding.Bindings.Add(new Binding("SelectedLanguage") { Source = AvailableLanguages.Instance, Mode = BindingMode.OneWay });
|
||||
var isCheckedSetter = new Setter(IsCheckedProperty, isCheckedMultiBinding);
|
||||
checkableMenuItemStyle.Setters.Add(isCheckedSetter);
|
||||
|
||||
Resources.Add(typeof(MenuItem), checkableMenuItemStyle);
|
||||
}
|
||||
|
||||
public void SelectLanguage(object inLanguage)
|
||||
{
|
||||
var lang = inLanguage as string;
|
||||
if (!string.IsNullOrWhiteSpace(lang))
|
||||
GlobalizedApplication.Instance.GlobalizationManager.SwitchLanguage(lang);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region License
|
||||
/*
|
||||
WPFSharp.Globalizer - A project deisgned to make localization and styling
|
||||
easier by decoupling both process from the build.
|
||||
|
||||
Copyright (c) 2015, Jared Barneck (Rhyous)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Use of the source code or binaries that in any way competes with WPFSharp.Globalizer
|
||||
or competes with distribution, whether open source or commercial, is
|
||||
prohibited unless permission is specifically granted under a separate
|
||||
license by Jared Barneck (Rhyous).
|
||||
4. Forking for personal or internal, or non-competing commercial use is allowed.
|
||||
Distributing compiled releases as part of your non-competing project is
|
||||
allowed.
|
||||
5. Public copies, or forks, of source is allowed, but from such, public
|
||||
distribution of compiled releases is forbidden.
|
||||
6. Source code enhancements or additions are the property of the author until
|
||||
the source code is contributed to this project. By contributing the source
|
||||
code to this project, the author immediately grants all rights to the
|
||||
contributed source code to Jared Barneck (Rhyous).
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#endregion
|
||||
119
src/WPFSharp.Globalizer/Controls/RelayCommand.cs
Normal file
119
src/WPFSharp.Globalizer/Controls/RelayCommand.cs
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
// See license at end of the file
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace WPFSharp.Globalizer.Controls
|
||||
{
|
||||
internal class RelayCommand : ICommand
|
||||
{
|
||||
#region Member variables
|
||||
readonly Action<object> _Execute;
|
||||
readonly Predicate<object> _CanExecute;
|
||||
#endregion Member variables
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Constructor for RelayCommand that only takes a method to run.
|
||||
/// No CanExecute method is passed, so CanExecute will always be true.
|
||||
/// </summary>
|
||||
/// <param name="inMethodToExecute">The method to execute. Could be a lambda.</param>
|
||||
public RelayCommand(Action<object> inMethodToExecute)
|
||||
: this(inMethodToExecute, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for RelayCommand that takes both a method to run
|
||||
/// and a bool method to determine if it CanExecute.
|
||||
/// </summary>
|
||||
/// <param name="inMethodToExecute">The execution logic.</param>
|
||||
/// <param name="inCanExecute">The execution status logic.</param>
|
||||
public RelayCommand(Action<object> inMethodToExecute, Predicate<object> inCanExecute)
|
||||
{
|
||||
if (inMethodToExecute == null)
|
||||
throw new ArgumentNullException("inMethodToExecute");
|
||||
|
||||
_Execute = inMethodToExecute;
|
||||
_CanExecute = inCanExecute;
|
||||
}
|
||||
#endregion Constructors
|
||||
|
||||
#region ICommand Members
|
||||
[DebuggerStepThrough]
|
||||
public bool CanExecute(object inParameter)
|
||||
{
|
||||
return _CanExecute == null || _CanExecute(inParameter);
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add { CommandManager.RequerySuggested += value; }
|
||||
remove { CommandManager.RequerySuggested -= value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run the method bound to the RelayCommand with the parameters
|
||||
/// passed in.
|
||||
/// </summary>
|
||||
/// <param name="inParameter"></param>
|
||||
public void Execute(object inParameter)
|
||||
{
|
||||
_Execute(inParameter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Re-evaluate CanExecute to enable or disable button.
|
||||
/// </summary>
|
||||
public void EvaluateCanExecute()
|
||||
{
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
|
||||
#endregion ICommand Members
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region License
|
||||
/*
|
||||
WPFSharp.Globalizer - A project deisgned to make localization and styling
|
||||
easier by decoupling both process from the build.
|
||||
|
||||
Copyright (c) 2015, Jared Barneck (Rhyous)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Use of the source code or binaries that in any way competes with WPFSharp.Globalizer
|
||||
or competes with distribution, whether open source or commercial, is
|
||||
prohibited unless permission is specifically granted under a separate
|
||||
license by Jared Barneck (Rhyous).
|
||||
4. Forking for personal or internal, or non-competing commercial use is allowed.
|
||||
Distributing compiled releases as part of your non-competing project is
|
||||
allowed.
|
||||
5. Public copies, or forks, of source is allowed, but from such, public
|
||||
distribution of compiled releases is forbidden.
|
||||
6. Source code enhancements or additions are the property of the author until
|
||||
the source code is contributed to this project. By contributing the source
|
||||
code to this project, the author immediately grants all rights to the
|
||||
contributed source code to Jared Barneck (Rhyous).
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#endregion
|
||||
34
src/WPFSharp.Globalizer/Controls/StyleSelectionComboBox.cs
Normal file
34
src/WPFSharp.Globalizer/Controls/StyleSelectionComboBox.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace WPFSharp.Globalizer.Controls
|
||||
{
|
||||
public partial class StyleSelectionComboBox : ComboBox
|
||||
{
|
||||
public StyleSelectionComboBox()
|
||||
{
|
||||
var itemSourceBinding = new Binding
|
||||
{
|
||||
Source = AvailableStyles.Instance,
|
||||
BindsDirectlyToSource = true,
|
||||
};
|
||||
SetBinding(ItemsSourceProperty, itemSourceBinding);
|
||||
|
||||
SelectionChanged += StyleSelectionComboBox_SelectionChanged;
|
||||
|
||||
var selectedItemBinding = new Binding("SelectedStyle")
|
||||
{
|
||||
Source = AvailableStyles.Instance,
|
||||
Mode = BindingMode.OneWay
|
||||
};
|
||||
SetBinding(SelectedItemProperty, selectedItemBinding);
|
||||
}
|
||||
|
||||
void StyleSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var style = e.AddedItems[0].ToString();
|
||||
if (!string.IsNullOrWhiteSpace(style))
|
||||
GlobalizedApplication.Instance.StyleManager.SwitchStyle(style);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
// See license at end of the file
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using WPFSharp.Globalizer.Converters;
|
||||
|
||||
namespace WPFSharp.Globalizer.Controls
|
||||
{
|
||||
public class StyleSelectionMenuItemList : MenuItem
|
||||
{
|
||||
public StyleSelectionMenuItemList()
|
||||
{
|
||||
ItemsSource = AvailableStyles.Instance;
|
||||
|
||||
var checkableMenuItemStyle = new Style { TargetType = typeof(MenuItem) };
|
||||
|
||||
var headerBinding = new Binding();
|
||||
var headerSetter = new Setter(HeaderProperty, headerBinding);
|
||||
checkableMenuItemStyle.Setters.Add(headerSetter);
|
||||
|
||||
var isCheckableSetter = new Setter(IsCheckableProperty, true);
|
||||
checkableMenuItemStyle.Setters.Add(isCheckableSetter);
|
||||
|
||||
ICommand command = new RelayCommand(SelectStyle);
|
||||
var commandSetter = new Setter(CommandProperty, command);
|
||||
checkableMenuItemStyle.Setters.Add(commandSetter);
|
||||
|
||||
var commandParamBinding = new Binding();
|
||||
var commandParamSetter = new Setter(CommandParameterProperty, commandParamBinding);
|
||||
checkableMenuItemStyle.Setters.Add(commandParamSetter);
|
||||
|
||||
var isCheckedMultiBinding = new MultiBinding { Converter = new MultiValueStringsMatchConverter(), Mode = BindingMode.OneWay };
|
||||
isCheckedMultiBinding.Bindings.Add(new Binding { Mode = BindingMode.OneWay });
|
||||
isCheckedMultiBinding.Bindings.Add(new Binding("SelectedStyle") { Source = AvailableStyles.Instance, Mode = BindingMode.OneWay });
|
||||
var isCheckedSetter = new Setter(IsCheckedProperty, isCheckedMultiBinding);
|
||||
checkableMenuItemStyle.Setters.Add(isCheckedSetter);
|
||||
|
||||
Resources.Add(typeof(MenuItem), checkableMenuItemStyle);
|
||||
}
|
||||
|
||||
public void SelectStyle(object inStyle)
|
||||
{
|
||||
var style = inStyle as string;
|
||||
if (!string.IsNullOrWhiteSpace(style))
|
||||
GlobalizedApplication.Instance.StyleManager.SwitchStyle(style);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region License
|
||||
/*
|
||||
WPFSharp.Globalizer - A project deisgned to make localization and styling
|
||||
easier by decoupling both process from the build.
|
||||
|
||||
Copyright (c) 2015, Jared Barneck (Rhyous)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Use of the source code or binaries that in any way competes with WPFSharp.Globalizer
|
||||
or competes with distribution, whether open source or commercial, is
|
||||
prohibited unless permission is specifically granted under a separate
|
||||
license by Jared Barneck (Rhyous).
|
||||
4. Forking for personal or internal, or non-competing commercial use is allowed.
|
||||
Distributing compiled releases as part of your non-competing project is
|
||||
allowed.
|
||||
5. Public copies, or forks, of source is allowed, but from such, public
|
||||
distribution of compiled releases is forbidden.
|
||||
6. Source code enhancements or additions are the property of the author until
|
||||
the source code is contributed to this project. By contributing the source
|
||||
code to this project, the author immediately grants all rights to the
|
||||
contributed source code to Jared Barneck (Rhyous).
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#endregion
|
||||
Loading…
Add table
Add a link
Reference in a new issue