forked from mdeykun/DynamicsCrmUpdater
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0691bc
commit d11f306
Showing
181 changed files
with
17,758 additions
and
2,567 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
CrmConnectionProjects/McTools.Xrm.Connection.WinForms/AddConnectionFileDialog.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Windows.Forms; | ||
|
||
namespace McTools.Xrm.Connection.WinForms | ||
{ | ||
public partial class AddConnectionFileDialog : Form | ||
{ | ||
public AddConnectionFileDialog() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public ConnectionFile OpenedFile { get; private set; } | ||
public string OpenedFilePath { get; private set; } | ||
|
||
private void btnBrowse_Click(object sender, EventArgs e) | ||
{ | ||
var ofd = new OpenFileDialog | ||
{ | ||
Filter = "XML file|*.xml|CONFIG file|*.config", | ||
}; | ||
|
||
if (ofd.ShowDialog(this) == DialogResult.OK) | ||
{ | ||
txtFilePath.Text = ofd.FileName; | ||
} | ||
} | ||
|
||
private void btnCancel_Click(object sender, EventArgs e) | ||
{ | ||
DialogResult = DialogResult.Cancel; | ||
Close(); | ||
} | ||
|
||
private void btnOk_Click(object sender, EventArgs e) | ||
{ | ||
try | ||
{ | ||
var newCc = CrmConnections.LoadFromFile(txtFilePath.Text); | ||
OpenedFile = new ConnectionFile(newCc) | ||
{ | ||
Path = txtFilePath.Text, | ||
Name = newCc.Name, | ||
LastUsed = DateTime.Now | ||
}; | ||
|
||
if (ConnectionsList.Instance.Files.Any(f => f.Name == OpenedFile.Name)) | ||
{ | ||
int cloneId = 1; | ||
string newName = OpenedFile.Name ?? "New File"; | ||
|
||
while (ConnectionsList.Instance.Files.FirstOrDefault(f => f.Name == newName) != null) | ||
{ | ||
var rule = new System.Text.RegularExpressions.Regex(".* \\(" + cloneId + "\\)$"); | ||
if (rule.IsMatch(newName)) | ||
{ | ||
cloneId++; | ||
newName = $"{OpenedFile.Name.Replace($" ({cloneId - 1})", "")} ({cloneId})"; | ||
} | ||
else | ||
{ | ||
newName = $"{newName} ({cloneId})"; | ||
} | ||
} | ||
|
||
OpenedFile.Name = newName; | ||
|
||
MessageBox.Show(this, $"A connection file with this name already exists!\n\nIt has been renamed to '{newName}'", "Warning", | ||
MessageBoxButtons.OK, MessageBoxIcon.Warning); | ||
} | ||
|
||
ConnectionManager.ConfigurationFile = txtFilePath.Text; | ||
ConnectionsList.Instance.Files.First(f => f.Path == txtFilePath.Text).Name = OpenedFile.Name; | ||
ConnectionManager.Instance.LoadConnectionsList(); | ||
ConnectionsList.Instance.Save(); | ||
|
||
OpenedFilePath = txtFilePath.Text; | ||
|
||
DialogResult = DialogResult.OK; | ||
Close(); | ||
} | ||
catch (Exception error) | ||
{ | ||
MessageBox.Show(this, "It seems something went wrong when loading your file: " + error, | ||
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); | ||
} | ||
} | ||
} | ||
} |
158 changes: 158 additions & 0 deletions
158
CrmConnectionProjects/McTools.Xrm.Connection.WinForms/AddConnectionFileDialog.designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
24 changes: 24 additions & 0 deletions
24
CrmConnectionProjects/McTools.Xrm.Connection.WinForms/CRMLoginForm1.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Window x:Class="McTools.Xrm.Connection.WinForms.CRMLoginForm1" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:CrmLoginCtrl="clr-namespace:Microsoft.Xrm.Tooling.CrmConnectControl;assembly=Microsoft.Xrm.Tooling.CrmConnectControl" | ||
Title="CRM Login" Width="465" Height="471" | ||
ResizeMode="NoResize" | ||
SizeToContent="Height" | ||
WindowStartupLocation="CenterScreen" | ||
WindowStyle="None" | ||
AllowsTransparency="True" | ||
BorderThickness="1" | ||
BorderBrush="#173561" | ||
Loaded="Window_Loaded"> | ||
<Window.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="pack://application:,,,/Microsoft.Xrm.Tooling.Ui.Styles;component/Resources/Button/Styles.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Window.Resources> | ||
<Grid> | ||
<CrmLoginCtrl:CrmServerLoginControl Name="CrmLoginCtrl" Grid.Row="1" ShowTitle="False" Margin="10,5" VerticalAlignment="Bottom" /> | ||
</Grid> | ||
</Window> |
Oops, something went wrong.