-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMyPrefsWindowController.m
232 lines (163 loc) · 5.82 KB
/
MyPrefsWindowController.m
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
//
// MyPrefsWindowController.m
// MyCoolProgram
//
#import "MyPrefsWindowController.h"
#import "device_setup_controller.h"
#import "Device.h"
@implementation MyPrefsWindowController
- (void)setupToolbar
{
[self addView:generalPrefsView label:@"General"];
[self addView:advancedPrefsView label:@"Advanced"];
}
- (IBAction) closeAddIntWindow:(id)sender {
NSRect currentViewFrame = NSZeroRect;
NSRect frame;
currentViewFrame = [self frameForView:generalPrefsView];
NSPoint point = NSMakePoint(currentViewFrame.origin.x,currentViewFrame.origin.y);
// NSArray *arr1 = [self childWindows];
// if ([arr1 count] == 1)
[self.window removeChildWindow:window2];
NSRect newWindowFrame = NSMakeRect(currentViewFrame.origin.x,currentViewFrame.origin.y + 459.0,480.0,000.0);
NSDictionary *windowResize;
windowResize = [NSDictionary dictionaryWithObjectsAndKeys:
window2, NSViewAnimationTargetKey,
[NSValue valueWithRect: newWindowFrame],
NSViewAnimationEndFrameKey,
nil];
NSDictionary *oldFadeOut = nil;
/* if (_extview != nil) {
oldFadeOut = [NSDictionary dictionaryWithObjectsAndKeys:
_extview, NSViewAnimationTargetKey,
NSViewAnimationFadeOutEffect,
NSViewAnimationEffectKey, nil];
}
NSDictionary *newFadeIn;
newFadeIn = [NSDictionary dictionaryWithObjectsAndKeys:
_extview, NSViewAnimationTargetKey,
NSViewAnimationFadeInEffect,
NSViewAnimationEffectKey, nil];
NSArray *animations;
animations = [NSArray arrayWithObjects:
windowResize, newFadeIn, oldFadeOut, nil];*/
NSArray *animations;
animations = [NSArray arrayWithObjects:
windowResize, nil];
NSViewAnimation *animation;
animation = [[NSViewAnimation alloc]
initWithViewAnimations: animations];
[animation setAnimationBlockingMode: NSAnimationBlocking];
[animation setDuration: 0.5]; // or however long you want it for
[animation startAnimation]; // because it's blocking, once it returns, we're done
[animation release];
[window2 close];
// [self update];
}
- (IBAction) AddDevice:(id)sender
{
// device_setup_controller *contr = [[device_setup_controller alloc] init];
// [contr addDevice:[idField stringValue] ip:[NSNumber numberWithInt:([ipAddr intValue])] type:[setType objectValueOfSelectedItem]];
if([[idField stringValue] isEqualToString:@""])
{
}
else if([setType objectValueOfSelectedItem] == nil)
{
}
else if([[ipAddr stringValue] isEqualToString:@""])
{
}
else
{
Device *dev = [NSEntityDescription insertNewObjectForEntityForName:@"Device" inManagedObjectContext:_moc];
dev.id = [idField stringValue];
dev.type = [setType objectValueOfSelectedItem];
NSManagedObject *manageip = [NSEntityDescription insertNewObjectForEntityForName:@"IP" inManagedObjectContext:_moc];
[manageip setValue:[NSNumber numberWithInt:[ipAddr intValue]] forKey:@"address"];
dev.manageip = manageip;
dev.login = [login stringValue];
dev.password = [password stringValue];
/*if ([dev.type isEqualToString:@"Neo"])
{
Neo_controller *neo = [[Neo_controller alloc] initWithIp:dev.manageip];
[neo pingDevice];
sleep(1);
if([neo checkAvaliability])
{
// dev.links = [NSNumber numberWithInt:[neo checkIntNumber]] ;
}
}*/
// check int number
[_moc processPendingChanges];
[dev_table reloadData];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReloadData" object:nil];
// [DevStatus setStringValue:@"Connected"];
[self closeAddIntWindow:(id)nil];
[idField setStringValue:@""];
[setType setStringValue:@""];
[ipAddr setStringValue:@""];
}
}
- (IBAction) openAddIntWindow:(id)sender {
NSRect currentViewFrame = NSZeroRect;
currentViewFrame = [self frameForView:generalPrefsView];
[window2 setStyleMask:NSBorderlessWindowMask];
[window2 setFrameOrigin:NSMakePoint(currentViewFrame.origin.x,currentViewFrame.origin.y + 459.0)];
[window2 setParentWindow:self.window];
// [self addChildWindow:window2 ordered:1];
[window2 makeKeyAndOrderFront:self];
[self.window addChildWindow:window2 ordered:1];
[window2 makeKeyWindow];
// [window2 setAlphaValue:0.4];
// [window display];
NSRect newWindowFrame = NSMakeRect(currentViewFrame.origin.x,currentViewFrame.origin.y + 159.0,480.0,300.0);
NSDictionary *windowResize;
windowResize = [NSDictionary dictionaryWithObjectsAndKeys:
window2, NSViewAnimationTargetKey,
[NSValue valueWithRect: newWindowFrame],
NSViewAnimationEndFrameKey,
nil];
NSDictionary *oldFadeOut = nil;
/* if (_extview != nil) {
oldFadeOut = [NSDictionary dictionaryWithObjectsAndKeys:
_extview, NSViewAnimationTargetKey,
NSViewAnimationFadeOutEffect,
NSViewAnimationEffectKey, nil];
}
NSDictionary *newFadeIn;
newFadeIn = [NSDictionary dictionaryWithObjectsAndKeys:
_extview, NSViewAnimationTargetKey,
NSViewAnimationFadeInEffect,
NSViewAnimationEffectKey, nil];*/
NSArray *animations;
animations = [NSArray arrayWithObjects:
windowResize, nil];
NSViewAnimation *animation;
animation = [[NSViewAnimation alloc]
initWithViewAnimations: animations];
[animation setAnimationBlockingMode: NSAnimationBlocking];
[animation setDuration: 0.5]; // or however long you want it for
[animation startAnimation]; // because it's blocking, once it returns, we're done
[animation release];
//[self.window update];
// [window2 makeKeyAndOrderFront:self];
// }
// [window2 display];
}
-processFinished:(id)sender;
{
if([[sender objectAtIndex:0] isEqualToString:@"renew"])
{
[self RenewObjWithdata:[sender objectAtIndex:1]];
}
}
- (NSManagedObjectContext *)managedObjectContext
{
if (_moc == nil)
{
_moc = [[NSManagedObjectContext alloc] init];
_moc = [[NSApp delegate] managedObjectContext];
}
return _moc;
}
@end