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

Commit

Permalink
Merge pull request #10 from Microsoft/users/markAtMicrosoft/Variables…
Browse files Browse the repository at this point in the history
…NotUsed

Remove some compiler warnings, update Installation instructions and e…
  • Loading branch information
markAtMicrosoft committed May 25, 2018
2 parents c244ca2 + 86a9d63 commit 4a5e4db
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 53 deletions.
3 changes: 3 additions & 0 deletions Installation.md
Expand Up @@ -43,6 +43,9 @@ Use the following steps to create your LUIS App and retrieve an App ID
- Copy the **Application ID** shown and paste into the LUIS App Id field in Settings for Snip Insights-

You can now paste each key in the settings panel of the application.
Remember to Click the **Save** button after entering all the keys.

> **NOTE** For each key entered there is a corresponding Service Endpoint. There are some default endpoints included (You can use as an example) but when you copy each key, also check and replace the Service Endpoint for each service you are using. You will find the service endpoint for each Cognitive Service on the Overview Page. Remember to Click the **Save** button after updating all the Service Endpoints.
Congratulations! You should now have a fully working application to get started. Have fun testing the project and thank you for your contribution!

Expand Down
6 changes: 3 additions & 3 deletions SnipInsight/AIServices/AILogic/TranslationHandler.cs
Expand Up @@ -83,7 +83,7 @@ public async Task<string> GetResult(string textToTranslate, string fromLanguage,

try
{
WebResponse response = webRequest.GetResponse();
WebResponse response = await webRequest.GetResponseAsync();

using (StreamReader translatedStream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")))
{
Expand Down Expand Up @@ -113,7 +113,7 @@ private async Task GetLanguagesForTranslate()
WebRequest request = WebRequest.Create(URI);
request.Headers.Add("Ocp-Apim-Subscription-Key", this.Key);

WebResponse response = request.GetResponse();
WebResponse response = await request.GetResponseAsync();

using (Stream stream = response.GetResponseStream())
{
Expand Down Expand Up @@ -143,7 +143,7 @@ private async Task GetLanguageNames()
}

// Read and parse the XML response
var response = request.GetResponse();
var response = await request.GetResponseAsync();

string[] languageNames;
using (Stream stream = response.GetResponseStream())
Expand Down
6 changes: 3 additions & 3 deletions SnipInsight/AIServices/AIViewModels/ImageAnalysisViewModel.cs
Expand Up @@ -123,7 +123,7 @@ private void NavigateToCelebrityUrlCommandExecute()
{
Process.Start(Celebrity.URL);
}
catch (Win32Exception e)
catch (Win32Exception)
{
MessageBox.Show(Resources.No_Browser);
}
Expand All @@ -138,7 +138,7 @@ private void NavigateToLandmarkUrlCommandExecute()
{
Process.Start(Landmarks[0].URL);
}
catch (Win32Exception e)
catch (Win32Exception)
{
MessageBox.Show(Resources.No_Browser);
}
Expand All @@ -153,7 +153,7 @@ private void NavigateToNewsUrlCommandExecute(NewsModel newsModel)
{
Process.Start(newsModel.URL);
}
catch (Win32Exception e)
catch (Win32Exception)
{
MessageBox.Show(Resources.No_Browser);
}
Expand Down
Expand Up @@ -74,7 +74,7 @@ private void GoToUrl(string url)
{
Process.Start(url);
}
catch (Win32Exception CaughtExeception)
catch (Win32Exception)
{
MessageBox.Show(Resources.No_Browser);
}
Expand Down
4 changes: 2 additions & 2 deletions SnipInsight/AIServices/AIViewModels/OCRViewModel.cs
Expand Up @@ -334,7 +334,7 @@ private void CompareResult(HandWrittenModel writtenModel, PrintedModel printedMo
result.Append(line.Text + "\n");
}
}
catch (Exception e)
catch (Exception)
{ }

string writtenResult = result.ToString() ?? string.Empty;
Expand All @@ -356,7 +356,7 @@ private void CompareResult(HandWrittenModel writtenModel, PrintedModel printedMo
}
}
}
catch (Exception e)
catch (Exception)
{ }

printedResult = result.ToString() ?? string.Empty;
Expand Down
18 changes: 9 additions & 9 deletions SnipInsight/AppManager.cs
Expand Up @@ -151,7 +151,7 @@ internal FirstRunWindow FirstRunWindow
{ ActionNames.ShareSendToOneNoteWithImage, WrapException(OnShareSendToOneNoteWithImage)},
{ ActionNames.CopyWithImage, WrapException(OnCopyWithImage)},
{ ActionNames.ClearOldImageData, WrapException(ClearOldImageData)},
{ ActionNames.Delete, WrapAsyncException(OnDelete)},
{ ActionNames.Delete, WrapException(OnDelete)},
{ ActionNames.DeleteLibraryItems, WrapAsyncException(OnDeleteLibraryItems)},
{ ActionNames.CleanFiles, WrapException(OnCleanFiles)},
{ ActionNames.ShowImageCapturedToastMessage, WrapException(ShowImageCapturedToastMessage)},
Expand Down Expand Up @@ -853,9 +853,9 @@ internal void OnExit()
}
}

private async Task OnDelete()
private void OnDelete()
{
await Delete(ViewModel.SavedSnipInsightFile, ViewModel.SavedCaptureImage, ViewModel.SavedInkedImage, true);
Delete(ViewModel.SavedSnipInsightFile, ViewModel.SavedCaptureImage, ViewModel.SavedInkedImage, true);
}

private async Task OnDeleteLibraryItems()
Expand All @@ -868,7 +868,7 @@ public Task DeleteLibraryItemsAsync()
return DeleteAsync(ViewModel.SelectedLibraryItems, true, false);
}

async public Task Delete(string SnipInsightFile, string savedCaptureImage, string savedInkedImage, bool raiseOutcomeTrigger)
public void Delete(string SnipInsightFile, string savedCaptureImage, string savedInkedImage, bool raiseOutcomeTrigger)
{
try
{
Expand All @@ -887,7 +887,7 @@ async public Task Delete(string SnipInsightFile, string savedCaptureImage, strin
return;
}

var success = await DeleteCore(SnipInsightFile, savedCaptureImage, savedInkedImage);
var success = DeleteCore(SnipInsightFile, savedCaptureImage, savedInkedImage);

if (success)
{
Expand Down Expand Up @@ -982,7 +982,7 @@ public async Task DeleteAsync(IEnumerable<SnipInsightLink> items, bool showConfi
{
var deletedIndex = GetCurrentContentIndexInLibrary(item);

var success = await DeleteCore(item);
var success = DeleteCore(item);

processedCount++;

Expand Down Expand Up @@ -1355,7 +1355,7 @@ void OnCleanFiles()
}


public Task<bool> DeleteCore(SnipInsightLink SnipInsight)
public bool DeleteCore(SnipInsightLink SnipInsight)
{
bool isPackage = Path.GetExtension(SnipInsight.Url) == ".mixp";

Expand All @@ -1375,7 +1375,7 @@ public Task<bool> DeleteCore(SnipInsightLink SnipInsight)
/// Delete files core.
/// </summary>
/// <returns></returns>
public async Task<bool> DeleteCore(string SnipInsightFile, string savedCaptureImage, string savedInkedImage)
public bool DeleteCore(string SnipInsightFile, string savedCaptureImage, string savedInkedImage)
{
// delete the captured image.
if (!string.IsNullOrWhiteSpace(savedCaptureImage))
Expand Down Expand Up @@ -2052,7 +2052,7 @@ public class OperationResult
}

#region Share
async Task Publish(Action<OperationResult> continueWith, string failureMessageForToast, bool embedCodeNeeded = false)
void Publish(Action<OperationResult> continueWith, string failureMessageForToast, bool embedCodeNeeded = false)
{
if (continueWith == null)
{
Expand Down
2 changes: 1 addition & 1 deletion SnipInsight/ResourceDictionaries/SnipStyles.xaml
Expand Up @@ -1106,7 +1106,7 @@
<Setter Property="BorderThickness" Value="2" />
<Setter Property="BorderBrush" Value="LightGray" />
<Setter Property="Height" Value="Auto" />
<Setter Property="MaxLength" Value="50" />
<Setter Property="MaxLength" Value="255" />
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
<Setter Property="TextWrapping" Value="NoWrap" />
Expand Down
1 change: 1 addition & 0 deletions SnipInsight/SnipInsight.csproj
Expand Up @@ -13,6 +13,7 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkProfile />
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
Expand Down
2 changes: 0 additions & 2 deletions SnipInsight/Util/AppUsageLogger.cs
Expand Up @@ -33,7 +33,6 @@ internal AppUsageLogger(string langName, string appName, string appVersion, stri
_os = string.Format("{0} ({1})", envOS, osBitness);
_process = processBitness;
_itInstall = itInstall;
_entryId = 0;

const int UploadDelay = 29567;
const int IdleThreshold = 5107;
Expand Down Expand Up @@ -183,7 +182,6 @@ private void UploadSuccessCallback()
private string _langName;
private string _uploadLogFile;
private string _sessionId;
private int _entryId;
private object _lock;
private DateTime _lastLogged;
private LogUploader _logUploader;
Expand Down
2 changes: 0 additions & 2 deletions SnipInsight/Views/EditorSideNavigation.xaml.cs
Expand Up @@ -22,8 +22,6 @@ public partial class EditorSideNavigation : UserControl
/// <summary>
/// Defines if the pen was already checked
/// </summary>
private bool isPenChecked = false;

public EditorSideNavigation()
{
InitializeComponent();
Expand Down
69 changes: 41 additions & 28 deletions SnipInsight/Views/SettingsPanel.xaml
Expand Up @@ -97,8 +97,19 @@
Visibility="{Binding InsightsVisible, Converter={StaticResource BooleanToVisibility}}"
AutomationProperties.Name="Api Keys">
<Separator Margin="15"/>
<TextBlock Style="{DynamicResource SettingsTitleStyle}"
Text="Insight Service Keys" AutomationProperties.Name="InsightServiceKeysSubPanel"/>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{DynamicResource SettingsTitleStyle}"
Text="Insight Service Keys" AutomationProperties.Name="InsightServiceKeysSubPanel"/>
<Button Style="{DynamicResource SettingsPanelButton}"
x:Name="UpdateButtonKeys"
VerticalAlignment="Center"
AutomationProperties.Name="SettingsPanelButton"
ToolTip="{x:Static properties:Resources.UpdateKeys}"
Margin="24,8,0,8"
Click="UpdateAllKeys">
Save
</Button>
</StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
Expand All @@ -125,7 +136,7 @@
</TextBlock>
<TextBox Grid.Row="0" Grid.Column="1" Name="EntitySearch"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="EntitySearchKeyTextbox">
AutomationProperties.Name="EntitySearchKeyTextbox" TextChanged="Key_OnTextChanged">
</TextBox>
<TextBlock Grid.Row="1" Grid.Column="0">
<Hyperlink RequestNavigate="Open_HyperLink"
Expand All @@ -138,7 +149,7 @@
</TextBlock>
<TextBox Grid.Row="1" Grid.Column="1" Name="ImageAnalysis"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="ImageAnalysisKeyTextbox">
AutomationProperties.Name="ImageAnalysisKeyTextbox" TextChanged="Key_OnTextChanged">
</TextBox>
<TextBlock Grid.Row="2"
Grid.Column="0">
Expand All @@ -154,7 +165,7 @@
Grid.Column="1"
Name="ImageSearch"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="ImageSearchKeyTextbox">
AutomationProperties.Name="ImageSearchKeyTextbox" TextChanged="Key_OnTextChanged">
</TextBox>
<TextBlock Grid.Row="3"
Grid.Column="0">
Expand All @@ -168,7 +179,7 @@
</TextBlock>
<TextBox Grid.Row="3" Grid.Column="1" Name="TextRecognition"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="TextRecognitionKeyTextbox">
AutomationProperties.Name="TextRecognitionKeyTextbox" TextChanged="Key_OnTextChanged">
</TextBox>
<TextBlock Grid.Row="4"
Grid.Column="0">
Expand All @@ -184,7 +195,7 @@
Grid.Column="1"
Name="Translator"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="TranslatorKeyTextbox">
AutomationProperties.Name="TranslatorKeyTextbox" TextChanged="Key_OnTextChanged">
</TextBox>
<TextBlock Grid.Row="5"
Grid.Column="0">
Expand All @@ -200,7 +211,7 @@
Grid.Column="1"
Name="ContentModerator"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="ContentModeratorKeyTextbox">
AutomationProperties.Name="ContentModeratorKeyTextbox" TextChanged="Key_OnTextChanged">
</TextBox>
<TextBlock Grid.Row="6" Grid.Column="0">
<Hyperlink RequestNavigate="Open_HyperLink"
Expand All @@ -215,7 +226,7 @@
Grid.Column="1"
Name="LUISKey"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="LUIS Key Textbox">
AutomationProperties.Name="LUIS Key Textbox" TextChanged="Key_OnTextChanged">
</TextBox>
<TextBlock Grid.Row="7"
Grid.Column="0">
Expand All @@ -229,11 +240,22 @@
</TextBlock>
<TextBox Grid.Row="7" Grid.Column="1" Name="LUISAppId"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="LUISAppIdTextbox">
AutomationProperties.Name="LUISAppIdTextbox" TextChanged="Key_OnTextChanged">
</TextBox>
</Grid>
<TextBlock Style="{DynamicResource SettingsTitleStyle}"
Text="Insight Service Endpoints" AutomationProperties.Name="InsightServiceEndpointsSubPanel"/>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{DynamicResource SettingsTitleStyle}" VerticalAlignment="Center"
Text="Insight Service Endpoints" AutomationProperties.Name="InsightServiceEndpointsSubPanel"/>
<Button Style="{DynamicResource SettingsPanelButton}"
x:Name="UpdateButton"
VerticalAlignment="Center"
AutomationProperties.Name="SettingsPanelButton"
ToolTip="{x:Static properties:Resources.UpdateKeys}"
Margin="24,8,0,8"
Click="UpdateAllKeys">
Save
</Button>
</StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
Expand All @@ -260,7 +282,7 @@
</TextBlock>
<TextBox Grid.Row="0" Grid.Column="1" Name="EntitySearchEndpoint"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="EntitySearchKeyTextbox">
AutomationProperties.Name="EntitySearchKeyTextbox" TextChanged="Key_OnTextChanged">
</TextBox>
<TextBlock Grid.Row="1" Grid.Column="0">
<Hyperlink RequestNavigate="Open_HyperLink"
Expand All @@ -273,7 +295,7 @@
</TextBlock>
<TextBox Grid.Row="1" Grid.Column="1" Name="ImageAnalysisEndpoint"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="ImageAnalysisKeyTextbox">
AutomationProperties.Name="ImageAnalysisKeyTextbox" TextChanged="Key_OnTextChanged">
</TextBox>
<TextBlock Grid.Row="2"
Grid.Column="0">
Expand All @@ -289,7 +311,7 @@
Grid.Column="1"
Name="ImageSearchEndpoint"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="ImageSearchKeyTextbox">
AutomationProperties.Name="ImageSearchKeyTextbox" TextChanged="Key_OnTextChanged">
</TextBox>
<TextBlock Grid.Row="3"
Grid.Column="0">
Expand All @@ -303,7 +325,7 @@
</TextBlock>
<TextBox Grid.Row="3" Grid.Column="1" Name="TextRecognitionEndpoint"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="TextRecognitionKeyTextbox">
AutomationProperties.Name="TextRecognitionKeyTextbox" TextChanged="Key_OnTextChanged">
</TextBox>
<TextBlock Grid.Row="4"
Grid.Column="0">
Expand All @@ -319,7 +341,7 @@
Grid.Column="1"
Name="TranslatorEndpoint"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="TranslatorKeyTextbox">
AutomationProperties.Name="TranslatorKeyTextbox" TextChanged="Key_OnTextChanged">
</TextBox>
<TextBlock Grid.Row="5"
Grid.Column="0">
Expand All @@ -335,7 +357,7 @@
Grid.Column="1"
Name="ContentModeratorEndpoint"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="ContentModeratorKeyTextbox">
AutomationProperties.Name="ContentModeratorKeyTextbox" TextChanged="Key_OnTextChanged">
</TextBox>
<TextBlock Grid.Row="6" Grid.Column="0">
<Hyperlink RequestNavigate="Open_HyperLink"
Expand All @@ -350,7 +372,7 @@
Grid.Column="1"
Name="LUISKeyEndpoint"
Style="{DynamicResource SettingsTextBoxStyle}"
AutomationProperties.Name="LUIS Key Textbox">
AutomationProperties.Name="LUIS Key Textbox" TextChanged="Key_OnTextChanged">
</TextBox>
<!--<TextBlock Grid.Row="7"
Grid.Column="0">
Expand All @@ -368,15 +390,6 @@
</TextBox>-->
</Grid>

<Button Style="{DynamicResource SettingsPanelButton}"
Grid.Row="1"
Grid.Column="1"
AutomationProperties.Name="SettingsPanelButton"
ToolTip="{x:Static properties:Resources.UpdateKeys}"
Margin="0,10,0,0"
Click="UpdateAllKeys">
Update
</Button>
</StackPanel>

<Separator Margin="15"/>
Expand Down

0 comments on commit 4a5e4db

Please sign in to comment.