private void LocationAddButton_Click(object sender, RoutedEventArgs e) { var path = LocationFolderBrowserDialog.SelectedPath; if (string.IsNullOrEmpty(path)) { path = (string)GameScanLocationsListBox.SelectedValue; } if (string.IsNullOrEmpty(path)) { path = System.IO.Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)); } LocationFolderBrowserDialog.SelectedPath = path; LocationFolderBrowserDialog.Description = "Browse for Scan Location"; var result = LocationFolderBrowserDialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { // Don't allow to add windows folder. var winFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Windows); if (LocationFolderBrowserDialog.SelectedPath.StartsWith(winFolder, StringComparison.OrdinalIgnoreCase)) { MessageBoxWindow.Show("Windows folders are not allowed.", "Windows Folder", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information); } else { if (!Contains(LocationFolderBrowserDialog.SelectedPath)) { SettingsManager.Options.GameScanLocations.Add(LocationFolderBrowserDialog.SelectedPath); // Change selected index for change event to fire. GameScanLocationsListBox.SelectedItem = LocationFolderBrowserDialog.SelectedPath; } } } }
/// <summary> /// 保存按键 /// </summary> private bool SaveKey() { try { string errMsg = string.Empty; oldKeyNum = KeyNum; var keyChar = Convert.ToChar(KeyNum); var key = (System.Windows.Forms.Keys)keyChar; if (GlobalVariable.systemSetting == null) { GlobalVariable.systemSetting = new SystemSetting(); } GlobalVariable.systemSetting.KeyShortcuts = ((int)key).ToString(); if ( DataConverter.EntityToXml <SystemSetting>( System.Environment.CurrentDirectory + "/SysSettingCache.xml", GlobalVariable.systemSetting, ref errMsg)) { MessageBoxWindow.Show("提示", "截图快捷键设置成功!", MessageBoxButton.OK, GlobalVariable.WarnOrSuccess.Success); KeyButtonIsEnable = false; return(true); } else { MessageBoxWindow.Show("提示", "快捷键设置出错!" + errMsg, MessageBoxButton.OK, GlobalVariable.WarnOrSuccess.Warn); LogHelper.WriteError("快捷键设置出错:" + errMsg); return(false); } } catch (Exception ex) { LogHelper.WriteError("快捷键设置出错:" + ex.Message); return(false); } }
void CheckDevices() { DeviceInfo[] offline; DeviceInfo[] problem; DeviceInfo[] unknown; GetDevices(out offline, out problem, out unknown); var list = new List <string>(); list.Add(string.Format("{0,4} offline devices", offline.Length)); list.Add(string.Format("{0,4} problem devices", problem.Length)); list.Add(string.Format("{0,4} unknown devices", unknown.Length)); if (!IsHandleCreated) { return; } ControlsHelper.BeginInvoke(() => { LogTextBox.Text = ""; var result = MessageBoxWindow.Show("Do you want to remove:\r\n\r\n" + string.Join("\r\n", list), "Remove Devices", MessageBoxButton.YesNo); if (result != MessageBoxResult.Yes) { return; } var ts = new ThreadStart(CleanupDevices); var t = new Thread(ts); t.IsBackground = false; t.Start(); }); }
/// <summary> /// 退出讨论组 /// </summary> public static bool ExitGroup(string groupId, string groupName, List <AntSdkGroupMember> Members) { ExitGroupInput input = new ExitGroupInput(); input.groupId = groupId; input.token = AntSdkService.AntSdkLoginOutput.token; input.userId = AntSdkService.AntSdkLoginOutput.userId; input.version = GlobalVariable.Version; BaseOutput output = new BaseOutput(); var errCode = 0; string errMsg = string.Empty; //TODO:AntSdk_Modify //DONE:AntSdk_Modify var isResult = AntSdkService.GroupExitor(AntSdkService.AntSdkLoginOutput.userId, groupId, ref errCode, ref errMsg); if (isResult) { string[] ThreadParams = new string[3]; ThreadParams[0] = groupId; ThreadParams[1] = ImageHandle.GetGroupPicture(Members.Where(c => c.userId != AntSdkService.AntSdkLoginOutput.userId).Select(c => c.picture).ToList()); ThreadParams[2] = string.IsNullOrEmpty(groupName) ? "" : groupName; Thread UpdateGroupPictureThread = new Thread(UpdateGroupPicture); UpdateGroupPictureThread.Start(ThreadParams); //OnDropOutGroupEvent(this); } else { MessageBoxWindow.Show(errMsg, GlobalVariable.WarnOrSuccess.Warn); } return(isResult); }
private static void QuickMessageBox(string message) { PriorityQueue.AddUiWorkItem(() => { MessageBoxWindow.Show(message, "Foursquare communication problem", System.Windows.MessageBoxButton.OK); }); }
protected virtual void OnLoginSuccess() { //NotifyIconControl.Instance.notifyIcon.ContextMenu.MenuItems["ExitApp"].Click -= ItemExitClick; //NotifyIconControl.Instance.notifyIcon.MouseClick -= OnNotifyIconMouseClick; //NotifyIconControl.Instance.notifyIcon.Visible = false; //this.LoginSuccessEvent?.Invoke(); System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); System.Windows.Application.Current.Dispatcher.Invoke(() => { MainWindowViewModel model = new MainWindowViewModel(); var result = model.GetGroupList(); if (!result) { loginCount++; //如果尝试3获取数据失败,返回登录页面 if (loginCount >= 3) { MessageBoxWindow.Show("尝试多次获取群数据失败,请联系管理员。", GlobalVariable.WarnOrSuccess.Warn); if (IsLoginSuccess) { var errorCode = 0; var errorMsg = string.Empty; //发送状态 AntSdkService.AntSdkUpdateCurrentUserState((int)GlobalVariable.OnLineStatus.OffLine, ref errorCode, ref errorMsg); //停止SDK SDK.AntSdk.AntSdkService.StopAntSdk(ref errorCode, ref errorMsg); AudioChat.ExitClearApi(); } System.Windows.Application.Current.Shutdown(); CommonMethods.StartApplication(System.Windows.Forms.Application.StartupPath + "/AntennaChat.exe"); return; } OnLoginSuccess(); return; } //model.DownloadUserHeadImage(); MainWindowView mainWindow = new MainWindowView { DataContext = model }; //model.InitMainVM(); if (this.LoginWindow != null) { var loginWindow = LoginWindow as LoginWindowView; loginWindow?.taskbarIcon.Dispose(); } loginCount = 0; mainWindow.Show(); GlobalVariable.LastLoginDatetime = DateTime.Now; this.LoginWindow?.Close(); }); stopWatch.Stop(); Antenna.Framework.LogHelper.WriteDebug($"[Model_LoginSuccessEvent({stopWatch.Elapsed.TotalMilliseconds}毫秒)]"); }
static bool IsElevated() { var isElevated = JocysCom.ClassLibrary.Security.PermissionHelper.IsElevated; if (!isElevated) { MessageBoxWindow.Show("You must run this program as administrator for this feature to work."); } return(isElevated); }
private void LoadGm1File(string listboxItemBefore) { if (Logger.Loggeractiv) { Logger.Log("LoadGm1File"); } Cursor = new Avalonia.Input.Cursor(Avalonia.Input.StandardCursorType.Wait); try { vm.TgxButtonExportEnabled = false; vm.TgxButtonImportEnabled = false; vm.ReplaceWithSaveFileTgx = false; if (vm.DecodeData(listboxItemBefore, this)) { Utility.datatype = (GM1FileHeader.DataType)vm.File.FileHeader.IDataType; vm.Filetype = Utility.GetText("Datatype") + ((GM1FileHeader.DataType)vm.File.FileHeader.IDataType); if (vm.File.Palette == null) { vm.ImportButtonEnabled = true; vm.ColorButtonsEnabled = false; vm.OrginalStrongholdAnimationButtonEnabled = false; vm.ActuellColorTable = null; } else { vm.OrginalStrongholdAnimationButtonEnabled = true; vm.ColorButtonsEnabled = true; vm.ImportButtonEnabled = true; } vm.ButtonsEnabled = true; var filewithoutgm1ending = listboxItemBefore.Replace(".gm1", ""); if (!File.Exists(vm.UserConfig.WorkFolderPath + "\\" + filewithoutgm1ending + "\\" + filewithoutgm1ending + "Save.gm1")) { vm.ReplaceWithSaveFile = false; } else { vm.ReplaceWithSaveFile = true; } } } catch (Exception e) { if (Logger.Loggeractiv) { Logger.Log("Exception:\n" + e.Message); } MessageBoxWindow messageBox = new MessageBoxWindow(MessageBoxWindow.MessageTyp.Info, "Something went wrong: pls add a issue on the Github Page\n\nError:\n" + e.Message); messageBox.Show(); } Cursor = new Avalonia.Input.Cursor(Avalonia.Input.StandardCursorType.Arrow); }
public void AddNewGame() { var fullPath = ""; var row = GamesDataGridView.SelectedRows.Cast <DataGridViewRow>().FirstOrDefault(); if (row != null) { var item = (x360ce.Engine.Data.UserGame)row.DataBoundItem; fullPath = item.FullPath; } var path = ""; AddGameOpenFileDialog.DefaultExt = ".exe"; if (!string.IsNullOrEmpty(fullPath)) { var fi = new System.IO.FileInfo(fullPath); if (string.IsNullOrEmpty(path)) { path = fi.Directory.FullName; } AddGameOpenFileDialog.FileName = fi.Name; } AddGameOpenFileDialog.Filter = EngineHelper.GetFileDescription(".exe") + " (*.exe)|*.exe|All files (*.*)|*.*"; AddGameOpenFileDialog.FilterIndex = 1; AddGameOpenFileDialog.RestoreDirectory = true; if (string.IsNullOrEmpty(path)) { path = System.IO.Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)); } AddGameOpenFileDialog.InitialDirectory = path; AddGameOpenFileDialog.Title = "Browse for Executable"; var result = AddGameOpenFileDialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { // Don't allow to add windows folder. var winFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Windows); if (AddGameOpenFileDialog.FileName.StartsWith(winFolder, StringComparison.OrdinalIgnoreCase)) { MessageBoxWindow.Show("Windows folders are not allowed.", "Windows Folder", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information); } else { ScanStarted = DateTime.Now; var success = System.Threading.ThreadPool.QueueUserWorkItem(ScanGames, AddGameOpenFileDialog.FileName); if (!success) { ScanProgressLevel0Label.Text = "Scan failed!"; ScanProgressLevel1Label.Text = ""; } } } }
/// <summary> /// Load the IMG as Color 2byte list /// </summary> /// <param name="filename">The Filepath/Filenamee to load</param> /// <param name="width">The width from the IMG</param> /// <param name="height">The Height from the IMG</param> /// <param name="animatedColor">Needed if alpha is 0 or 1</param> /// <param name="pixelsize">Pixelsize of a pixel needed for Colortable</param> /// <returns></returns> internal static List <UInt16> LoadImage(String filename, ref int width, ref int height, int animatedColor = 1, int pixelsize = 1, uint type = 0, int offsetx = 0, int offsety = 0) { if (Logger.Loggeractiv) { Logger.Log("LoadImage"); } List <UInt16> colors = new List <UInt16>(); try { var image = Image.Load(filename); if (width == 0) { width = image.Width; } if (height == 0) { height = image.Height; } for (int y = offsety; y < height + offsety; y += pixelsize) { for (int x = offsetx; x < width + offsetx; x += pixelsize) //Bgra8888 { var pixel = image[x, y]; byte a = (animatedColor >= 1 || ((GM1FileHeader.DataType)type) == GM1FileHeader.DataType.TilesObject || ((GM1FileHeader.DataType)type) == GM1FileHeader.DataType.Animations || ((GM1FileHeader.DataType)type) == GM1FileHeader.DataType.TGXConstSize || ((GM1FileHeader.DataType)type) == GM1FileHeader.DataType.NOCompression || ((GM1FileHeader.DataType)type) == GM1FileHeader.DataType.NOCompression1) ? byte.MaxValue : byte.MinValue; if (pixel.A == 0) { colors.Add((ushort)32767); } else { colors.Add(EncodeColorTo2Byte((uint)(pixel.B | pixel.G << 8 | pixel.R << 16 | a << 24))); } } } } catch (Exception e) { if (Logger.Loggeractiv) { Logger.Log("Exception:\n" + e.Message); } MessageBoxWindow messageBox = new MessageBoxWindow(MessageBoxWindow.MessageTyp.Info, "Something went wrong: pls add a issue on the Github Page\n\nError:\n" + e.Message); messageBox.Show(); } return(colors); }
private void LoginButton_Click(object sender, EventArgs e) { // Secure login over insecure web services. if (LoginButton.Text == "Log In") { var o = SettingsManager.Options; var saveOptions = false; if (o.CheckAndFixUserRsaKeys()) { SettingsManager.OptionsData.Save(); } var ws = new WebServiceClient(); var url = InternetDatabaseUrlComboBox.Text; ws.Url = url; CloudMessage results; // If cloud RSA keys are missing then... if (string.IsNullOrEmpty(o.CloudRsaPublicKey)) { // Step 1: Get Server's Public RSA key for encryption. var msg = new CloudMessage(CloudAction.GetPublicRsaKey); CloudHelper.ApplySecurity(msg); msg.Values.Add(CloudKey.RsaPublicKey, o.UserRsaPublicKey); // Retrieve public RSA key. results = ws.Execute(msg); if (results.ErrorCode == 0) { o.CloudRsaPublicKey = results.Values.GetValue <string>(CloudKey.RsaPublicKey); saveOptions = true; } } if (saveOptions) { SettingsManager.OptionsData.Save(); } var cmd2 = new CloudMessage(CloudAction.LogIn); CloudHelper.ApplySecurity(cmd2, o.UserRsaPublicKey, o.CloudRsaPublicKey, UsernameTextBox.Text, PasswordTextBox.Text); cmd2.Values.Add(CloudKey.ComputerId, o.ComputerId, true); cmd2.Values.Add(CloudKey.ProfileId, o.ProfileId, true); results = ws.Execute(cmd2); if (results.ErrorCode != 0) { MessageBoxWindow.Show(results.ErrorMessage, string.Format("{0} Result", CloudAction.LogIn), System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information); } else { MessageBoxWindow.Show(string.Format("Authorized: {0}", results.ErrorMessage), string.Format("{0} Result", CloudAction.LogIn), System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information); } } else { } }
private void SaveNewPassword(object obj) { if (ChangePassword()) { ErrMsg = string.Empty; //MessageBoxWindow.Show("提示", "密码修改成功,请重新登录!", MessageBoxButton.OK, GlobalVariable.WarnOrSuccess.Success); //ChangePasswordSuccessEvent?.Invoke(this, EventArgs.Empty); } else { MessageBoxWindow.Show("提示", ErrMsg, MessageBoxButton.OK, GlobalVariable.WarnOrSuccess.Warn); } }
/// <summary> /// 拒绝 /// </summary> public void RefuseAudio() { if (!AntSdkService.AntSdkIsConnected) { MessageBoxWindow.Show("提示", "网络连接已断开,无法进行语音电话!", MessageBoxButton.OK, GlobalVariable.WarnOrSuccess.Warn); AudioChat._currentChannelId = 0; CloseWin(); return; } AudioChat.AudioResult(ModelId, false); AudioChat._currentChannelId = 0; CloseWin(); }
internal unsafe static WriteableBitmap LoadImageAsBitmap(String filename, ref int width, ref int height, int offsetx = 0, int offsety = 0) { if (Logger.Loggeractiv) { Logger.Log("LoadImage"); } var image = Image.Load(filename); if (width == 0) { width = image.Width; } if (height == 0) { height = image.Height; } WriteableBitmap bitmap = new WriteableBitmap(new PixelSize(width, height), new Vector(300, 300), Avalonia.Platform.PixelFormat.Rgba8888); using (var bit = bitmap.Lock()) { try { int xBit = 0, yBit = 0; for (int y = offsety; y < height + offsety; y++) { for (int x = offsetx; x < width + offsetx; x++) //Bgra8888 { var pixel = image[x, y]; var ptr = (uint *)bit.Address; ptr += (uint)((bitmap.PixelSize.Width * yBit) + xBit); *ptr = pixel.PackedValue; xBit++; } xBit = 0; yBit++; } } catch (Exception e) { if (Logger.Loggeractiv) { Logger.Log("Exception:\n" + e.Message); } MessageBoxWindow messageBox = new MessageBoxWindow(MessageBoxWindow.MessageTyp.Info, "Something went wrong: pls add a issue on the Github Page\n\nError:\n" + e.Message); messageBox.Show(); } } return(bitmap); }
private void LoadTgxFile(string listboxItemBefore) { if (Logger.Loggeractiv) { Logger.Log("LoadGfxFile"); } Cursor = new Avalonia.Input.Cursor(Avalonia.Input.StandardCursorType.Wait); try { vm.ColorButtonsEnabled = false; vm.OrginalStrongholdAnimationButtonEnabled = false; vm.ActuellColorTable = null; vm.ReplaceWithSaveFile = false; vm.ButtonsEnabled = false; vm.ImportButtonEnabled = false; vm.TgxButtonExportEnabled = true; vm.ReplaceWithSaveFileTgx = false; vm.DecodeTgxData(listboxItemBefore, this); var filewithouttgxending = listboxItemBefore.Replace(".tgx", ""); if (File.Exists(vm.UserConfig.WorkFolderPath + "\\" + filewithouttgxending + "\\" + filewithouttgxending + ".png")) { vm.TgxButtonImportEnabled = true; } if (!File.Exists(vm.UserConfig.WorkFolderPath + "\\" + filewithouttgxending + "\\" + filewithouttgxending + "Save.tgx")) { vm.ReplaceWithSaveFileTgx = false; } else { vm.ReplaceWithSaveFileTgx = true; } } catch (Exception e) { if (Logger.Loggeractiv) { Logger.Log("Exception:\n" + e.Message); } MessageBoxWindow messageBox = new MessageBoxWindow(MessageBoxWindow.MessageTyp.Info, "Something went wrong: pls add a issue on the Github Page\n\nError:\n" + e.Message); messageBox.Show(); } Cursor = new Avalonia.Input.Cursor(Avalonia.Input.StandardCursorType.Arrow); }
/// <summary> /// 获取当前用户的所有群组,并请求群组离线消息 /// </summary> public void GetGroupList() { var temperrorCode = 0; var temperrorMsg = string.Empty; var groups = AntSdkService.GetGroupList(AntSdkService.AntSdkLoginOutput.userId, ref temperrorCode, ref temperrorMsg); if (!string.IsNullOrEmpty(temperrorMsg)) { Application.Current.Dispatcher.Invoke(new Action(() => MessageBoxWindow.Show(temperrorMsg, GlobalVariable.WarnOrSuccess.Warn))); } if (groups == null || groups.Length == 0) { return; } GroupInfos = new List <AntSdkGroupInfo>(groups); }
internal void AddStructureToProject() { OpenFileDialog dialog = new OpenFileDialog { Filter = "Structure/Schematic Files(*.nbt,*.schematic, *.schem)|*.nbt;*.schematic;*.schem", InitialDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".minecraft\\saves") }; var dialogResult = dialog.ShowDialog(); _window.SwitchTabs(1); Mouse.OverrideCursor = Cursors.Wait; if (dialogResult == true) { var filePath = dialog.FileName; StructureProcessor processor; try { processor = StructureProcessorFactory.Build(dialog.FileName); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } try { Project = processor.AddStructureToProject(Project, filePath, dialog.SafeFileName); } catch { MessageBoxWindow window = new MessageBoxWindow() { Title = "File Format Not Supported", MessageText = $"The schematic file that was loaded was either corrupt or not a supported schematic type. {Environment.NewLine}" + $"Redstone Sidekick currently supports Minecraft structure files and Sponge Specification .schem files (Like the ones used by the newest version of WorldEdit).", WindowStartupLocation = WindowStartupLocation.CenterScreen, ShowActivated = true }; window.Show(); } } Mouse.OverrideCursor = null; }
internal void CreateProjectCode() { var projectCode = ProjectStringEncoder.Encode(Project, ProjectStringEncoder.CraftingTreeOptions.Light); Clipboard.Clear(); Clipboard.SetText(projectCode); MessageBoxWindow window = new MessageBoxWindow() { Title = "Created Project Code", MessageText = "Redstone Sidekick Project Code copied to clipboard!", WindowStartupLocation = WindowStartupLocation.CenterScreen, ShowActivated = true }; window.Show(); }
/// <summary> /// 设置消息提醒方式 /// </summary> public void SetMsgRemind(GlobalVariable.MsgRemind?remind = null) { AntSdkUpdateGroupConfigInput input = new AntSdkUpdateGroupConfigInput(); input.userId = AntSdkService.AntSdkLoginOutput.userId; input.groupId = this.GroupInfo.groupId; BaseOutput output = new BaseOutput(); var errCode = 0; string errMsg = string.Empty; if (remind == null) { input.state = MessageNoticeIsChecked ? ((int)GlobalVariable.MsgRemind.Remind).ToString() : ((int)GlobalVariable.MsgRemind.NoRemind).ToString(); } else { input.state = ((int)remind.Value).ToString(); } var isResult = AntSdkService.UpdateGroupConfig(input, ref errCode, ref errMsg); if (isResult) { GroupInfo.state = int.Parse(input.state); if (GroupInfo.state == (int)GlobalVariable.MsgRemind.NoRemind) { MessageNoticeIsChecked = false; MessageHideIsChecked = true; ImageNoRemindVisibility = Visibility.Visible; } else { MessageNoticeIsChecked = true; MessageHideIsChecked = false; ImageNoRemindVisibility = Visibility.Collapsed; } } else { MessageBoxWindow.Show(errMsg, GlobalVariable.WarnOrSuccess.Warn); } }
private void DataGridCell_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var cell = (DataGridCell)sender; var item = MainDataGrid.SelectedItems.Cast <CloudItem>().FirstOrDefault(); if (item == null) { return; } var error = item.Error; if (error == null) { return; } var message = JocysCom.ClassLibrary.Runtime.LogHelper.ExceptionToText(error); MessageBoxWindow.Show(message, error.Message, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); }
private bool Login() { LoginInput input = new LoginInput(); input.os = (int)GlobalVariable.OSType.PC; input.osStr = ""; input.version = GlobalVariable.Version; input.loginName = cmb_id.Text; input.password = txt_pwd.PasswordStr; input.manufacture = ""; output = new LoginOutput(); string errMsg = string.Empty; if (!HttpService.Instance.Login(input, ref output, ref errMsg)) { MessageBoxWindow.Show("登录失败:" + errMsg, this); return(false); } return(true); }
private void TasksDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0 || e.ColumnIndex < 0) { return; } var item = TasksDataGridView.SelectedRows.Cast <DataGridViewRow>().Select(x => (CloudItem)x.DataBoundItem).FirstOrDefault(); if (item == null) { return; } var error = item.Error; if (error == null) { return; } var message = JocysCom.ClassLibrary.Runtime.LogHelper.ExceptionToText(error); MessageBoxWindow.Show(message, error.Message, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); }
/// <summary> /// 解散讨论组 /// </summary> public static void DismissGroup(string groupId) { ExitGroupInput input = new ExitGroupInput(); input.groupId = groupId; input.token = AntSdkService.AntSdkLoginOutput.token; input.userId = AntSdkService.AntSdkLoginOutput.userId; input.version = GlobalVariable.Version; BaseOutput output = new BaseOutput(); var errCode = 0; var errMsg = string.Empty; var isResult = AntSdkService.DissolveGroup(AntSdkService.AntSdkLoginOutput.userId, groupId, ref errCode, ref errMsg); if (isResult) { //OnDropOutGroupEvent(this); } else { MessageBoxWindow.Show(errMsg, GlobalVariable.WarnOrSuccess.Warn); } }
internal void LoadProject() { RedstoneSidekickProject project; OpenFileDialog dialog = new OpenFileDialog { Filter = "Redstone Sidekick Projects (*.rsp)|*.rsp", InitialDirectory = $"{GlobalDataVars.AppDirectory}" }; var success = dialog.ShowDialog(); if (success == true) { _window.SwitchTabs(1); string filePath = dialog.FileName; string fileName = dialog.SafeFileName; project = RSPFileProcessor.LoadProjectFromFile(filePath, fileName); if (project != null) { Project = project; } } else { //TODO: Log Error. MessageBoxWindow window = new MessageBoxWindow() { Title = "File Invalid", MessageText = "File was not a valid .rsp file. Please try again.", WindowStartupLocation = WindowStartupLocation.CenterScreen, ShowActivated = true }; window.Show(); } }
private void InitMqttService(LoginOutput output) { string errMsg = string.Empty; if (!MqttService.Instance.Connect(output.user.token, ref errMsg)) { MessageBoxWindow.Show(errMsg); return; } List <string> topics = new List <string>(); topics.Add("C10086"); //用户信息相关,组织架构更新(暂时写死用10086) topics.Add(output.user.userId); ////讨论组新增 //订阅讨论组ID(讨论组删除,讨论组成员更新,讨论组基本信息更新) topics.Add("message_ack"); //消息回执格式 topics.Add(output.user.token); //踢出用户登录 if (!MqttService.Instance.Subscribe(topics, ref errMsg)) { MessageBoxWindow.Show(errMsg); return; } MqttService.Instance.MessageReceived += MqttMessageReceived; }
private void CreateGroup() { // 讨论组名不能为空 //if (string.IsNullOrWhiteSpace(GroupName)) //{ // GroupNameBorderBrush = new SolidColorBrush(Colors.Red); // //GroupNameBorderThickness = new Thickness(1, 1, 1, 1); // return; //} //else //{ // GroupNameBorderBrush = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#e0e0e0")); // //GroupNameBorderThickness = new Thickness(0); //} // 讨论组成员不能少于3 if (GroupMemberList == null || GroupMemberList.Count < 3) { MessageBoxWindow.Show("讨论组至少需要包括三个成员", GlobalVariable.WarnOrSuccess.Warn); return; } if (string.IsNullOrWhiteSpace(GroupName.Trim(' ')))//自定义群名为空 取默认值 { GroupName = GetNewGroupName(); } GroupName = GroupName.TrimStart(' '); #region 旧代码 CreateGroupInput input = new CreateGroupInput(); input.token = AntSdkService.AntSdkLoginOutput.token; input.version = GlobalVariable.Version; input.userId = AntSdkService.AntSdkLoginOutput.userId; input.groupName = GroupName; //获取讨论组成员头像 //List<string> picList = new List<string>(); //foreach (ContactInfoViewModel m in GroupMemberList) //{ // picList.Add(m.Photo); //} //input.groupPicture = ImageHandle.GetGroupPicture(picList); //input.groupPicture =; input.userIds = string.Join(",", GroupMemberList.Select(c => c.User.userId).ToArray()); //CreateGroupOutput output = new CreateGroupOutput(); var errCode = 0; var errMsg = string.Empty; //if (!(new HttpService()).CreateGroup(input, ref output, ref errMsg)) //{ // if (output.errorCode != "1004") // { // MessageBoxWindow.Show(errMsg,GlobalVariable.WarnOrSuccess.Warn); // } // return; //} //output.group.groupPicture = ImageHandle.GetGroupPicture(GroupMemberList.Select(c => c.Photo).ToList()); //ThreadPool.QueueUserWorkItem(m => //{ //}); #endregion AntSdkCreateGroupInput newGroupInput = new AntSdkCreateGroupInput(); newGroupInput.userId = AntSdkService.AntSdkLoginOutput.userId; newGroupInput.groupName = GroupName; newGroupInput.userIds = GroupMemberList.Select(c => c.User.userId).ToArray(); //newGroupInput.groupPicture = ImageHandle.GetGroupPicture(GroupMemberList.Select(c => c.Photo).ToList()); //TODO:AntSdk_Modify //DONE:AntSdk_Modify AntSdkCreateGroupOutput createGroupOutput = AntSdkService.CreateGroup(newGroupInput, ref errCode, ref errMsg); if (createGroupOutput == null) { if (!AntSdkService.AntSdkIsConnected) { errMsg = "网络已断开,请检查网络"; } if (!string.IsNullOrEmpty(errMsg)) { MessageBoxWindow.Show(errMsg, GlobalVariable.WarnOrSuccess.Warn); } return; } createGroupOutput.groupPicture = ImageHandle.GetGroupPicture(GroupMemberList.Select(c => c.Photo).ToList()); //异步更新讨论组头像,这里需要用前台线程,因此不能用线程池 string[] ThreadParams = new string[3]; ThreadParams[0] = createGroupOutput.groupId; ThreadParams[1] = createGroupOutput.groupPicture; ThreadParams[2] = string.IsNullOrEmpty(createGroupOutput.groupName) ? "" : createGroupOutput.groupName; Thread UpdateGroupPictureThread = new Thread(GroupPublicFunction.UpdateGroupPicture); UpdateGroupPictureThread.Start(ThreadParams); this.CreateGroupOutput = createGroupOutput; App.Current.Dispatcher.BeginInvoke((Action)(() => { this.close.Invoke(); })); }
public static JObject ProcessMetaAndNotificationsReturnJson(string json, string venueId = null) { // JSON-P needs to be parsed. We just use the callback of 'j'. int function = json.IndexOf('('); // If Foursquare is rather broken, the JSON-P will never be // used. I've received this once on 1/26/2011. Debug.Assert(function >= 0); if (function < 0) { //"{\"meta\":{\"code\":500,\"errorType\":\"server_error\",\"errorDetail\":\"Foursquare servers are experiencing problems. Please retry and check status.foursquare.com for updates.\"},\"response\":{}}\n" if (json.Contains("500") && json.Contains("error")) { // TODO: OneTimeMessageBox if (!_oneTimeMessageBoxShown) { _oneTimeMessageBoxShown = true; PriorityQueue.AddUiWorkItem(() => { MessageBoxWindow.Show("The Foursquare servers are experiencing problems. Please check status.foursquare.com for updates.", "Foursquare is down", System.Windows.MessageBoxButton.OK); }); } return(null); } } JObject response = null; try { string updated = json.Substring(function + 1, json.Length - function - 3); JObject jo = JObject.Parse(updated); var meta = jo["meta"]; if (meta != null) { string errorCode = Json.TryGetJsonProperty(meta, "errorType"); if (errorCode != null) { switch (errorCode) { case "invalid_auth": var so = Application.Current as ISignOutAndClear; if (so != null) { so.SignOutAndClear(); // FourSquareApp.Instance.SignOutAndClear(); } throw new UserIntendedException( "Invalid OAuth credentials, please sign in again.", new InvalidOperationException("Invalid OAUTH")); // OAuth token was not provided or was invalid. case "param_error": throw new InvalidOperationException("param error"); // A required parameter was missing or a parameter was malformed. This is also used if the resource ID in the path is incorrect. case "endpoint_error": throw new InvalidOperationException("The endpoint doesn't exist."); // The requested path does not exist. case "not_authorized": // Although authentication succeeded, the acting user is not allowed to see this information due to privacy restrictions. throw new InvalidOperationException("Not authorized."); case "rate_limit_exceeded": // Rate limit for this hour exceeded. throw new UserIntendedException( "You've been using foursquare a lot this hour and are now rate limited!", new InvalidOperationException("Rate limit exceeded.")); case "deprecated": // Something about this request is using deprecated functionality, or the response format may be about to change. //QuietWatson.ReportException( // new InvalidOperationException("The foursquare API was deprecated.", // new InvalidOperationException(meta.ToString()))); break; case "server_error": throw new UserIntendedException( "Foursquare's servers are having difficulty. Please check status.foursquare.com for updates.", new InvalidOperationException("Server error")); // Server is currently experiencing issues. Check status.foursquare.com for updates. case "other": break; // No longer failing out here... // throw new InvalidOperationException("other error"); // Some other type of error occurred. } } string httpStatusCode = Json.TryGetJsonProperty(meta, "code"); int code; if (int.TryParse(httpStatusCode, out code)) { switch (code) { // TODO: BEFORE INGESTION: FIGURE OUT THIS ERROR HANDLING! case 400: // Bad Request /* * Any case where a parameter is invalid, or a required parameter is missing. This includes the case where no OAuth token is provided and the case where a resource ID is specified incorrectly in a path. */ break; case 401: // Unauthorized /* * The OAuth token was provided but was invalid. * */ // Should probably... // 1. Sign out // (inc. clear iso-store) // 2. Inform the user and have them sign in again break; case 403: // Forbidden /* * The requested information cannot be viewed by the acting user, for example, because they are not friends with the user whose data they are trying to read. * */ break; case 404: // Not found /* * Endpoint does not exist. * */ break; case 405: // Method not allowed /* * Attempting to use POST with a GET-only endpoint, or vice-versa. * */ break; case 409: // Conflict! // Duplicate venue being added. // For NOW, not doing anything here... break; } } Debug.Assert(httpStatusCode == "200" || httpStatusCode == "409"); } response = (JObject)jo["response"]; if (response != null) { // JObject response = (JObject)jo["response"]; var notifications = jo["notifications"]; if (notifications != null) { if (FourSquare.IgnoreNextNotification) { FourSquare.IgnoreNextNotification = false; } else { var app = Application.Current as IProcessNotifications; var optionalCheckinRequest = FourSquare.Instance.MostRecentCheckinRequest; FourSquare.Instance.MostRecentCheckinRequest = null; ((IProcessNotifications)app).ProcessNotifications(notifications, venueId, optionalCheckinRequest); // FourSquareApp.Instance.ProcessNotifications(notifications, venueId); } } } } catch (NullReferenceException) { // Sometimes happening parsing JSON. } catch (UserIntendedException ex) { QuickMessageBox(ex.Message); } catch (InvalidOperationException ex) { // These in theory are less user-friendly. QuickMessageBox(ex.Message); } #if DEBUG if (response == null) { // Let's assume a message was already shown. //throw new InvalidOperationException("No response provided."); } #endif return(response ?? new JObject()); // new for 8/12/2011: hope this doesn't mess up too much parsing. }
/// <summary> /// Decode the actual GM1 File to Imgs and the typical headers /// </summary> /// <param name="array">The GM1 File as Array</param> /// <param name="name">Name of the File</param> /// <returns></returns> public bool DecodeGm1File(byte[] array, String name) { if (Logger.Loggeractiv) { Logger.Log("DecodeGm1File:\nFile:" + name); } fileArray = array; if (this.fileHeader == null) { this.fileHeader = new GM1FileHeader(array); this.fileHeader.Name = name; if (fileHeader.IDataType == (UInt32)GM1FileHeader.DataType.Animations) { this.palette = new Palette(array); } if (Logger.Loggeractiv) { Logger.Log("Datatype" + ((GM1FileHeader.DataType)fileHeader.IDataType)); } } actualPositionInByteArray = (GM1FileHeader.fileHeaderSize + Palette.paletteSize); this._TGXImage = new List <TGXImage>(); this.tilesImage = new List <TilesImage>(); //Supported Types try { switch ((GM1FileHeader.DataType)fileHeader.IDataType) { case GM1FileHeader.DataType.Animations: case GM1FileHeader.DataType.Interface: case GM1FileHeader.DataType.TGXConstSize: case GM1FileHeader.DataType.Font: CreateImages(array); return(true); case GM1FileHeader.DataType.NOCompression: case GM1FileHeader.DataType.NOCompression1: CreateNoCompressionImages(array, ((GM1FileHeader.DataType)fileHeader.IDataType == GM1FileHeader.DataType.NOCompression1) ? 0 : 7); return(true); case GM1FileHeader.DataType.TilesObject: CreateTileImage(array); return(true); default: break; } } catch (Exception e) { if (Logger.Loggeractiv) { Logger.Log("Exception:\n" + e.Message); } MessageBoxWindow messageBox = new MessageBoxWindow(MessageBoxWindow.MessageTyp.Info, "Something went wrong: pls add a issue on the Github Page\n\nError:\n" + e.Message); messageBox.Show(); return(false); } return(false); }
/// <summary> /// 发送消息 /// </summary> /// <param name="o"></param> private void SendMassMsg(object o) { if (ContactUsers == null || ContactUsers.Count == 0) { MessageBoxWindow.Show("请先选择消息接收人!", GlobalVariable.WarnOrSuccess.Warn); return; } else if (string.IsNullOrWhiteSpace(MsgContent)) { MessageBoxWindow.Show("消息内容不能为空!", GlobalVariable.WarnOrSuccess.Warn); return; } else if (MsgContent.Length > 500) { MessageBoxWindow.Show("消息内容不能超过500个字符!", GlobalVariable.WarnOrSuccess.Warn); return; } MassMsg msg = new MassMsg(); msg.mtp = (int)GlobalVariable.MsgType.MassMsg; //TODO:AntSdk_Modify AntSdkMassMsgCtt ctt = new AntSdkMassMsgCtt(); //ctt.messageId = PublicTalkMothed.timeStampAndRandom(); ctt.sendUserId = AntSdkService.AntSdkCurrentUserInfo.userId; if (ContactUsers != null && ContactUsers.Count > 0) { ctt.targetId = string.Join(",", ContactUsers.Where(m => m.userId != AntSdkService.AntSdkCurrentUserInfo.userId).Select(c => c.userId).ToArray()); } ctt.companyCode = GlobalVariable.CompanyCode; ctt.content = MsgContent; ctt.os = (int)GlobalVariable.OSType.PC; ctt.sessionId = DataConverter.GetSessionID(AntSdkService.AntSdkCurrentUserInfo.userId, GlobalVariable.MassAssistantId); ctt.chatIndex = null; ctt.sendTime = null; string errMsg = ""; //DONE:AntSdk_Modify AntSdkChatMsg.MultiSend massMsg = new AntSdkChatMsg.MultiSend(); massMsg.sendUserId = AntSdkService.AntSdkCurrentUserInfo.userId; if (ContactUsers != null && ContactUsers.Count > 0) { massMsg.targetId = string.Join(",", ContactUsers.Where(m => m.userId != AntSdkService.AntSdkCurrentUserInfo.userId).Select(c => c.userId).ToArray()); } massMsg.content = MsgContent; massMsg.chatType = (int)AntSdkchatType.Point; massMsg.messageId = PublicTalkMothed.timeStampAndRandom(); massMsg.sessionId = DataConverter.GetSessionID(AntSdkService.AntSdkCurrentUserInfo.userId, GlobalVariable.MassAssistantId); var isResult = AntSdkService.SdkPublishChatMsg(massMsg, ref errMsg); // AntSdkMassMsgCtt if (isResult) { ctt.messageId = massMsg.messageId; LogHelper.WriteWarn("---------------------------消息助手群发消息已发送---------------------"); SendMassMsgEvent?.Invoke(ctt); (o as System.Windows.Window)?.Close(); } else { MessageBoxWindow.Show("消息发送失败!" + errMsg, GlobalVariable.WarnOrSuccess.Warn); } }
/// <summary> /// Display a message-box to the user, based upon the given options. /// This particular method is the one that all of the other Notify methods invoke to do the actual work. /// </summary> /// <param name="options">a MessageBoxConfiguration object that fully specifies everything about the message-box</param> /// <returns>a MessageResult indicating which action the user took, or TimedOut if the user took no action before the timeout expired</returns> public MessageResult NotifyUser(IMessageBoxConfiguration options) { MessageBoxConfiguration configuration = options as MessageBoxConfiguration; var messageBoxWindow = new MessageBoxWindow(this, configuration); // If the developer who is calling this has provided a custom visual element // to show within the message-box, set that now. //CBL //if (_customElement != null) //{ // messageBoxWindow.SetCustomElement(_customElement); //} // If we are doing testing, and have specified that a specific button is to be emulated as having been selected by the user, // then verify that that button is indeed present.. if (IsTesting) { if (TestFacility.ButtonResultToSelect.HasValue) { string complaint; if (!GetWhetherButtonIsIncluded(configuration.ButtonFlags, out complaint)) { // Announce the error throw new ArgumentOutOfRangeException(complaint); } } } //TODO: The following should not be needed for Silverlight.. // Try to give it a parent-window to position itself relative to. #if !SILVERLIGHT FrameworkElement parentElement = configuration.ParentElement; Window parentWindow = null; if (parentElement == null) { // When running unit-tests, Application.Current might be null. if (Application.Current != null) { parentWindow = Application.Current.MainWindow; // If the parent-window has not actually been shown yet, this would cause an exception. if (parentWindow != null && parentWindow.IsLoaded) { messageBoxWindow.Owner = parentWindow; } } } else if (parentElement.IsLoaded) { parentWindow = parentElement as Window; if (parentWindow != null) { messageBoxWindow.Owner = parentWindow; } } #endif // Finally, show the message-box. //TODO: for Silverlight, need to prepare to receive the result asynchronously!!! #if SILVERLIGHT messageBox.Show(); #else _messageBoxWindow = messageBoxWindow; if (configuration.IsAsynchronous) { messageBoxWindow.Show(); } else { messageBoxWindow.ShowDialog(); } #endif return messageBoxWindow.Result; }
//public string NewGroupPicture; /// <summary> /// 更新讨论组 /// </summary> private void UpdateGroup() { if (GroupInfo == null) { return; } AntSdkUpdateGroupInput input = new AntSdkUpdateGroupInput(); input.userId = AntSdkService.AntSdkLoginOutput.userId; input.groupId = this.GroupInfo.groupId; NewGroupMemberList = new List <AntSdkContact_User>(); foreach (ContactInfoViewModel vm in GroupMemberList) { if (!OriginalMemberIds.Contains(vm.User.userId)) { if (input.userIds == null) { input.userIds = new List <string>(); } input.userIds.Add(vm.User.userId); if (input.userNames == null) { input.userNames = new List <string>(); } input.userNames.Add(vm.User.userName); NewGroupMemberList.Add(vm.User); } } if (NewGroupMemberList.Count != 0) { BaseOutput output = new BaseOutput(); var errCode = 0; string errMsg = string.Empty; //TODO:AntSdk_Modify //DONE:AntSdk_Modify var isResult = AntSdkService.UpdateGroup(input, ref errCode, ref errMsg); if (!isResult) { NewGroupMemberList = null; MessageBoxWindow.Show(errMsg, GlobalVariable.WarnOrSuccess.Warn); return; } //if (!(new HttpService()).UpdateGroup(input, ref output, ref errMsg)) //{ // NewGroupMemberList = null; // if (output.errorCode != "1004") // { // MessageBoxWindow.Show(errMsg,GlobalVariable.WarnOrSuccess.Warn); // } // return; // //OnUpdateGroupEvent(input.groupId, input.userIds); //} string[] ThreadParams = new string[3]; ThreadParams[0] = this.GroupInfo.groupId; ThreadParams[1] = ImageHandle.GetGroupPicture(GroupMemberList.Select(c => c.Photo).ToList()); ThreadParams[2] = string.IsNullOrEmpty(this.GroupInfo.groupName) ? "" : this.GroupInfo.groupName; Thread UpdateGroupPictureThread = new Thread(GroupPublicFunction.UpdateGroupPicture); UpdateGroupPictureThread.Start(ThreadParams); //this.NewGroupPicture = input.groupPicture; } App.Current.Dispatcher.BeginInvoke((Action)(() => { this.close.Invoke(); })); }