blob: c10f7c2f06e56274bc6732075d2b945ec9db6442 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
// **********************************************************************
//
// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.IO;
using System.Windows.Forms;
using EnvDTE;
namespace Ice.VisualStudio
{
public partial class OutputDirView : UserControl
{
public OutputDirView()
{
InitializeComponent();
toolTip.SetToolTip(txtOutputDir, "Output directory for Slice compiler generated files.");
toolTip.SetToolTip(btnSelectOutputDir, "Output directory for Slice compiler generated files.");
}
public void init(IceConfigurationDialog dialog, Project project)
{
this._dialog = dialog;
this._project = project;
}
public void load()
{
txtOutputDir.Text = Util.getProjectOutputDirRaw(_project);
}
public void setEnabled(bool enabled)
{
txtOutputDir.Enabled = enabled;
btnSelectOutputDir.Enabled = enabled;
}
public bool apply(ref bool changed)
{
changed = false;
if(hasUnsavedChanges())
{
if(!Util.updateOutputDir(_project, txtOutputDir.Text))
{
return false;
}
changed = true;
}
return true;
}
public bool hasUnsavedChanges()
{
if(!txtOutputDir.Text.Trim().Equals(Util.getProjectOutputDirRaw(_project)))
{
return true;
}
return false;
}
private void btnSelectOutputDir_Click(object sender, EventArgs e)
{
if(_dialog.editingIncludeDir())
{
_dialog.endEditIncludeDir(true);
}
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.SelectedPath = Util.getProjectAbsoluteOutputDir(_project);
dialog.Description = "Select Base Directory For Slice Generated Files";
DialogResult result = dialog.ShowDialog();
if(result == DialogResult.OK)
{
txtOutputDir.Text = Util.relativePath(_project, dialog.SelectedPath);
_dialog.needSave();
}
}
private void txtOutputDir_KeyPress(object sender, KeyPressEventArgs e)
{
_editing = true;
if(e.KeyChar == (char)Keys.Return)
{
checkOutputDir();
e.Handled = true;
}
}
private void txtOutputDir_KeyUp(object sender, KeyEventArgs e)
{
_editing = true;
if(e.KeyCode != Keys.Return)
{
_dialog.needSave();
}
}
private void txtOutputDir_Focus(object sender, EventArgs e)
{
if(_dialog.editingIncludeDir())
{
_dialog.endEditIncludeDir(true);
}
_editing = true;
}
private void txtOutputDir_LostFocus(object sender, EventArgs e)
{
if(_editing)
{
checkOutputDir();
}
}
private bool checkOutputDir()
{
//
// Set to false so the loss of focus does not cause another call
//
_editing = false;
if(hasUnsavedChanges())
{
_dialog.needSave();
}
return true;
}
private IceConfigurationDialog _dialog;
private Project _project;
private bool _editing = false;
}
}
|