private void LoadMapButton_Click(object sender, RoutedEventArgs e) { if (MetadataUpdates.Count > 0) { SuperMessageBoxService.ShowWarning("Confirmation", "Do you want to apply your changes? \r\n\r\n" + "Press YES to apply\r\n" + "Press No to discard the changes you have made\r\n", "Yes", "No", "Cancel", () => { ApplyChanges(); if (LoadMapClicked != null) { LoadMapClicked(sender, e); } }, () => { if (LoadMapClicked != null) { LoadMapClicked(sender, e); } }); } else { if (LoadMapClicked != null) { LoadMapClicked(sender, e); } } }
private void MultiNodesContextMenuOnChangeNodeTypeClicked(object sender, ChangeNodeTypeEventArgs e) { if (NodeControls.Any()) { if (NodeControls.Any(q => q.ViewModelNode.IsMapNode)) { SuperMessageBoxService.ShowWarning("Change Node Type", "You are changing a map node, you might lose any content within the map. Are you sure you wish to continue? \r\n\r\n" + "Press YES to change node type anyway\r\n" + "Press NO to Cancel", "Yes", "No", () => { foreach (var selectableNode in NodeControls) { IoC.GetInstance <ISuperGraphNodeFactory>().UpdateNode(selectableNode.ViewModelNode, e.ChangedTo); } }); } else { foreach (var selectableNode in NodeControls) { IoC.GetInstance <ISuperGraphNodeFactory>().UpdateNode(selectableNode.ViewModelNode, e.ChangedTo); } } } }
private void Ok_Click(object sender, RoutedEventArgs e) { Uri uri; if (Uri.TryCreate(UrlTextBox.Text, UriKind.Absolute, out uri)) { if (HeightTextBox.Value != null && WidthTextBox.Value != null && InsertClicked != null) { var args = new InsertImageEventArgs { Url = ImageInline.UriSource, Height = (int)ImageInline.Height, Width = (int)ImageInline.Width }; InsertClicked(sender, args); } else { SuperMessageBoxService.ShowError("Error", "Please specify width and height for the image."); } } else { SuperMessageBoxService.ShowError("Error", "Invalid URL entered"); } Close(); }
private void GetUsersPermissionLevelNameCompleted(object sender, GetUsersPermissionLevelNameCompletedEventArgs e) { if (!e.Result.HasError) { var permission = PermissionLevel.Convert(e.Result.Result); App.PermissionLevel = permission; if (permission != PermissionLevel.None) { SuperGraph.ExplorerOnly = permission < PermissionLevel.Author; DebugLogger.Instance.LogMsg("User Permission Loaded: " + permission); if (IsLoadMapByGuid) { DebugLogger.Instance.LogMsg(string.Format("Loading map through URL: NodeId[{0}],MapId[{1}],DomainId[{2}]", NodeId, MapId, DomainId)); PreLoader.ReadyToInitialiseControllers += OnReadyToInitialiseControllers; PreLoader.Load(DomainId, NodeId, MapId); } else { Loader.Visibility = Visibility.Collapsed; HomeScreen(); } } else { SuperMessageBoxService.Show("Access Denied", "It seems that you don't have permission to access Glyma, please contact your system administrator for assistance.", MessageBoxType.ErrorWithNoInput); } } else { SuperMessageBoxService.ShowError("Error Occurred", "There was a problem reading Glyma permissions, please try again later"); } }
private void ClientOnGetSecurityAssociationsCompleted(object sender, GetSecurityAssociationsCompletedEventArgs e) { if (e.Result != null) { if (!e.Result.HasError) { var securityObject = sender as ManagementConsoleObject; if (securityObject != null) { securityObject.Load(e.Result.Result, e.Result.Result.IsInherited); var selectedItem = XTreeView.SelectedItem; if (selectedItem != null) { PermissionDetails.DataContext = null; var binding = new Binding { Source = XTreeView, Path = new PropertyPath("SelectedItem"), Mode = BindingMode.TwoWay, }; PermissionDetails.SetBinding(DataContextProperty, binding); PermissionDetails.Visibility = Visibility.Visible; XTreeView.SelectedItem = selectedItem; } } } else { SuperMessageBoxService.ShowError("Error Occurred", "An error occurred while retrieving the Glyma permissions."); } } }
private void ClientOnGetHighestPermissionNameCompleted(object sender, GetPermissionNameForObjectCompletedEventArgs e) { var item = DataContext as IManagementConsoleObject; if (!e.Result.HasError && item != null) { var id = sender as Guid?; if (id != null && id == item.Id) { item.CurrentUserPermissionLevel = PermissionLevel.Convert(e.Result.Result); //todo: if the user is security manager, needs to be returned as well if (item.CurrentUserPermissionLevel >= PermissionLevel.Author || App.PermissionLevel == PermissionLevel.SecurityManager) { NewMapButton.IsEnabled = true; if (item.CurrentUserPermissionLevel >= PermissionLevel.MapManager || App.PermissionLevel == PermissionLevel.SecurityManager) { DeleteButton.IsEnabled = true; } } if (App.PermissionLevel != PermissionLevel.SecurityManager) { item.IsLoaded = true; } } } else { SuperMessageBoxService.ShowError("Error Occurred", "There was a problem reading Glyma permissions, please try again later"); } }
private void ExportButton_Click(object sender, RoutedEventArgs e) { if (!IsBusy) { IsBusy = true; if (ExportTypeBox.SelectedIndex >= 0 && RootMap != null) { //TODO: in the future when exporting different MapType's we may have different options var type = EnumHelper.GetEnum <ExportType>(ExportTypeBox.SelectedValue.ToString()); if (type == ExportType.PDF || type == ExportType.Word) { var exportOptionDialog = new ExportOptionDialog(type, MapType.IBIS); //TODO: In the future other MapType's will be handled exportOptionDialog.ExportOptionSelected += ExportOptionDialogOnExportOptionSelected; exportOptionDialog.Closed += ExportOptionDialogOnClosed; exportOptionDialog.Show(); } else { ExportOptionDialogOnExportOptionSelected(sender, new ExportOptionSelectedEventArgs { ExportOption = new ExportOption(type, MapType.IBIS) }); //TODO: In the future other MapType's will be handled } } } else { SuperMessageBoxService.ShowInformation("Busy", "Sorry we are currently busy, please try again later"); } }
private void ClientOnGetAllSecurityGroupsCompleted(object sender, GetAllSecurityGroupsCompletedEventArgs e) { if (!e.Result.HasError) { foreach (var pair in e.Result.Result) { SecurityGroups.Add(PermissionLevel.Convert(pair.Key), pair.Value); } foreach (var valuePair in SecurityGroups) { foreach (var item in valuePair.Value) { if (AllSecurityGroups.All(q => q.GroupId != item.GroupId)) { AllSecurityGroups.Add(item); } } } MapManager.QueryDomainsCompleted.RegisterEvent(OnAcquireDomainsCompleted); MapManager.QueryDomainsAsync(); } else { SuperMessageBoxService.ShowError("Error Occurred", "An error occurred while retrieving the groups with Glyma permissions.", Close); } }
protected void LoadFailed() { SuperMessageBoxService.ShowError("Load Map", "Oops, we are unable to find the map.", () => { if (MapLoadFailed != null) { MapLoadFailed(this, null); } }); }
private void UpdateCompleted(object sender, UpdateSecurityAssociationsCompletedEventArgs e) { if (!e.Result.HasError) { UpdateSuccessful(); } else { SuperMessageBoxService.ShowError("Error Occurred", "An error occurred while applying the Glyma permissions."); } }
private void IsExportingAvailableCompleted(object sender, UtilityProxy.ResultEventArgs <bool> e) { if (!e.HasError) { App.IsExportEnabled = e.Result; } else { SuperMessageBoxService.ShowError("Error Occurred", "Failed to access export service"); } _mapManager.InitialiseMapManagerAsync(); }
private void PermissionDetails_OnRestoreInheritanceButtonClicked(object sender, RoutedEventArgs e) { SuperMessageBoxService.ShowConfirmation("Restore Inheritance Warning", "You are about to inherit permissions from the project. Any custom permissions will be lost.", () => { var rootMap = sender as RootMap; if (rootMap != null) { _securityManager.RestoreRootMapInheritanceAsync(rootMap, RestoreRootMapInheritanceCompleted, rootMap.ParentId, rootMap.Id); } }); }
private void PermissionDetails_OnBreakInheritanceButtonClicked(object sender, RoutedEventArgs e) { SuperMessageBoxService.ShowConfirmation("Break Inheritance Warning", "You are about to create unique permissions for this map. Changes made to the project permissions will no longer affect this map.", () => { var rootMap = sender as RootMap; if (rootMap != null) { _securityManager.BreakRootMapInheritanceAsync(rootMap, BreakRootMapInheritanceCompleted, rootMap.ParentId, rootMap.Id); } }); }
private void XTreeView_OnLoadOnDemand(object sender, RadRoutedEventArgs e) { var clickedItem = e.OriginalSource as RadTreeViewItem; if (clickedItem != null) { var securityObject = clickedItem.DataContext as IManagementConsoleObject; if (securityObject != null) { if (_selectedProjectItemToExpand == null) { if (securityObject is Project) { _selectedProjectItemToExpand = clickedItem; if (App.PermissionLevel == PermissionLevel.SecurityManager) { _securityManager.GetSecurityAssociationsAsync(securityObject, ClientOnGetSecurityAssociationsCompleted, AllSecurityGroups, new GlymaSecurableObject { SecurableParentUid = Guid.Empty, SecurableObjectUid = securityObject.Id }); } MapManager.QueryMapByDomainCompleted.RegisterEvent(securityObject.Node.DomainId, OnAcquireNodeByDomainCompleted); MapManager.QueryMapByDomainAsync(securityObject.Node.DomainId); } else if (securityObject is RootMap) { clickedItem.IsLoadOnDemandEnabled = false; clickedItem.IsLoadingOnDemand = false; } } else { SuperMessageBoxService.ShowWarning("Busy", "We are currently working on retreiving data from the server, please try again later", "OK", null); clickedItem.IsLoadOnDemandEnabled = true; clickedItem.IsLoadingOnDemand = false; //allow it to be loaded later } } } }
private void ClientOnGetPermissionNameForObjectCompleted(object sender, GetPermissionNameForObjectCompletedEventArgs e) { var permissionLevel = PermissionLevel.None; if (!e.Result.HasError && Context == sender) { var permission = PermissionLevel.Convert(e.Result.Result); if (permission >= PermissionLevel.Author || App.PermissionLevel == PermissionLevel.OldAuthor || App.PermissionLevel == PermissionLevel.SecurityManager) { permissionLevel = PermissionLevel.Author; } else if (permission >= PermissionLevel.Reader || App.PermissionLevel == PermissionLevel.OldReader) { permissionLevel = PermissionLevel.Reader; } else if (permission == PermissionLevel.None) { SuperMessageBoxService.Show("Access Denied", "It seems that you don't have permission to access this map, please contact your system administrator for assistance.", MessageBoxType.ErrorWithNoInput); return; } } else { SuperMessageBoxService.ShowError("Error Occurred", "There was a problem reading Glyma permissions, please try again later"); return; } if (PermissionLoaded != null) { PermissionLoaded(this, new UserPermissionEventArgs { Permission = permissionLevel }); } ActiveModel = new Map(); var nodeType = MapManager.NodeTypes[Context.MapObjectType]; if (nodeType == MapManager.NodeTypes["CompendiumMapNode"]) { MapManager.QueryMapByNodeCompleted.RegisterEvent(Context.Proxy, LoadNodesCompleted, Context.Proxy); MapManager.QueryMapByNodeAsync(Context.Proxy, 1); } VideoController.Clear(); }
private void OnInitialiseMapManagerCompleted(object sender, Proxy.InitialiseMapManagerEventArgs e) { if (!e.IsInitialised) { SuperMessageBoxService.Show("Incorrect Glyma Version", e.ErrorMessage, MessageBoxType.ErrorWithNoInput); } else { if (RelatedContentPanelUtil.Instance.IsJavascriptLibraryLoaded()) { SecurityManager.GetUsersPermissionLevelNameAsync("Initialisation", GetUsersPermissionLevelNameCompleted); } else { SuperMessageBoxService.Show("Missing Dependencies", "Please contact your administrator as dependency files are missing from the system", MessageBoxType.ErrorWithNoInput); } } }
/// <summary> /// This method is provided for when populating the HtmlEditor in Advanced (Raw) mode, it doesn't insert the GlymaNodeDescription DIV around the content /// </summary> /// <returns></returns> public string GetRawTextForAdvancedMode() { var description = HtmlFormatProvider.Export(RadRichTextBox.Document); if (description.Length > 8000) { SuperMessageBoxService.ShowError("Save Description Failed", "Sorry, your description is too long."); description = NodeProperties.Description; } if (string.IsNullOrWhiteSpace(description)) { //no content, return empty return(string.Empty); } else { return(description); } }
private void CbRichTextAdvanceMode_Unchecked(object sender, RoutedEventArgs e) { SuperMessageBoxService.ShowWarning("Advanced Text", "Some content might be automatically removed.\r\n" + "Are you sure you want to continue?", "Yes", "No", () => { IframePanel.Visibility = Visibility.Collapsed; RawPanel.Visibility = Visibility.Collapsed; DesignerPanel.Visibility = Visibility.Visible; DescriptionType = NodeDescriptionType.Html; RichTextEditor.LoadHtml(HtmlEditor.Text); }, () => { CbRichTextAdvanceMode.Checked -= CbRichTextAdvanceMode_Checked; CbRichTextAdvanceMode.IsChecked = true; CbRichTextAdvanceMode.Checked += CbRichTextAdvanceMode_Checked; }); }
private void BtnDelete_Click(object sender, RoutedEventArgs e) { if (NodeMetadataDataGrid.SelectedItem != null) { var metadata = NodeMetadataDataGrid.SelectedItem as UIMetadata; if (metadata != null) { if ((!metadata.IsInserted && string.IsNullOrEmpty(metadata.Name)) || (metadata.IsInserted && (string.IsNullOrWhiteSpace(metadata.OriginalName) || string.IsNullOrEmpty(metadata.OriginalName)))) { SuperMessageBoxService.Show("Delete Property Failed", "The selected property did not exist", MessageBoxType.Error); } else { SuperMessageBoxService.ShowConfirmation("Delete Property", string.Format("Are you sure to delete the property '{0}'?", metadata.Name), () => DeleteMetadata(metadata)); } } } }
private void AuthorContextMenuOnChangeNodeTypeClicked(object sender, ChangeNodeTypeEventArgs e) { if (_parentNodeControl != null) { if (_parentNodeControl.ViewModelNode.IsMapNode && e.ChangedTo != ChangeNodeTypeEnum.Map) { SuperMessageBoxService.ShowWarning("Change Node Type", "You are changing a map node, you might lose any content within the map. Are you sure you wish to continue? \r\n\r\n" + "Press YES to change node type anyway\r\n" + "Press NO to Cancel", "Yes", "No", () => _parentNodeControl.ChangeNodeType(e)); } else { _parentNodeControl.ChangeNodeType(e); } } }
private void DeleteAllNodes() { if (NodeControls.Any(q => q.ViewModelNode.IsMapNode)) { SuperMessageBoxService.ShowWarning("Delete Node(s)", "You have selected map node(s) to be deleted. All content within the map node(s) will be deleted." + "Press YES to delete", "Yes", "Cancel", () => { var deleteNodeCollection = GetSelectedNodesCollection(); IoC.GetInstance <ISuperGraphRelationshipFactory>().DeleteNodes(deleteNodeCollection.Nodes.ToList(), SelectorControl.Context, true); }); } else { var deleteNodeCollection = GetSelectedNodesCollection(); IoC.GetInstance <ISuperGraphRelationshipFactory>().DeleteNodes(deleteNodeCollection.Nodes.ToList(), SelectorControl.Context, true); } }
private void OutDatedDownload_OnClick(object sender, RoutedEventArgs e) { SuperMessageBoxService.Show("Confirmation", "The export file you've chosen is outdated, are you still want to download the file?", "Yes", "No", MessageBoxType.Confirmation, () => { var button = sender as RadButton; if (button != null) { var exportJob = button.DataContext as IExportJob; if (exportJob != null && exportJob.Link != null) { Uri uri; if (Uri.TryCreate(exportJob.Link, UriKind.Absolute, out uri)) { System.Windows.Browser.HtmlPage.Window.Navigate(uri, "_blank"); } } } }); }
private void OnGetExportJobsCompleted(object sender, ResultEventArgs <ExportJobCollection> e) { if (!e.HasError) { if (e.Context is Guid && (Guid)e.Context == RootMap.Id) { if (RootMap != null) { RootMap.ExportJobs = new ObservableCollection <IExportJob>(); foreach (var pair in e.Result.OrderByDescending(q => q.Value.Created)) { RootMap.ExportJobs.Add(pair.Value); } RefreshFilter(); } } } else { SuperMessageBoxService.ShowError("Error Occurred", "There was a failure reading the exports that exist for the selected map."); } }
private void Cancel_OnClick(object sender, RoutedEventArgs e) { var button = sender as RadButton; if (button != null) { var exportJob = button.DataContext as IExportJob; if (exportJob != null) { SuperMessageBoxService.ShowConfirmation("Cancel Export Confirmation", "Are you sure to cancel the export?", () => { if (!IsBusy) { IsBusy = true; ExportServiceManager.DeleteExportJobCompleted.RegisterEvent(exportJob.Id, OnDeleteExportJobCompleted); ExportServiceManager.DeleteExportJobAsync(exportJob); } }); } } }
private void OnUnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { if (e.ExceptionObject is NodeNotFoundException) { ((MainPage)RootVisual).Loader.Visibility = Visibility.Collapsed; SuperMessageBoxService.Show( "Load Map Failed", "Sorry, unfortunately we can’t find the map you’re looking for", "Select a new map", "Cancel", MessageBoxType.Error, () => ((MainPage)RootVisual).HomeScreen() ); } else if (e.ExceptionObject.InnerException != null) { if (e.ExceptionObject.InnerException is TimeoutException) { ((MainPage)RootVisual).Loader.Visibility = Visibility.Collapsed; SuperMessageBoxService.Show( "Communication Failed", "Unfortunately it seems your internet connection is not working", "Refresh", "Cancel", MessageBoxType.Error, () => HtmlPage.Document.Submit() ); } } else { var unhandledExceptionDialog = new UnhandledExceptionDialog(); unhandledExceptionDialog.UnhandledException = e.ExceptionObject; unhandledExceptionDialog.Show(); } }
private void OnSaveClicked(object sender, RoutedEventArgs e) { if (NodeProperties != null) { var description = string.Empty; var iframeUrl = string.Empty; switch (DescriptionType) { case NodeDescriptionType.Iframe: iframeUrl = UrlTextBox.Text; NodeProperties.RemoveMetadata("Description.Content"); break; case NodeDescriptionType.Html: description = RichTextEditor.GetRawText(); NodeProperties.RemoveMetadata("Description.Url"); break; case NodeDescriptionType.RawInput: description = HtmlEditor.Text; NodeProperties.RemoveMetadata("Description.Url"); break; case NodeDescriptionType.None: description = string.Empty; NodeProperties.RemoveMetadata("Description.Url"); NodeProperties.RemoveMetadata("Description.Width"); NodeProperties.RemoveMetadata("Description.Height"); NodeProperties.RemoveMetadata("Description.Content"); NodeProperties.RemoveMetadata("Description.Type"); break; } if (DescriptionType != NodeDescriptionType.None) { //If no content was entered in the HTML or RawInput assume the Description.Type is none and all should be removed if (DescriptionType == NodeDescriptionType.Html || DescriptionType == NodeDescriptionType.RawInput) { if (description.Length > 8000) { SuperMessageBoxService.ShowError("Save Description Failed", "Sorry, your description is too long.", () => { RadTabControl.SelectedIndex = 1; }); } else { if (NodeProperties is MultipleNodesProperties) { NodeProperties.DescriptionType = DescriptionType; if (!string.IsNullOrEmpty(description)) { Description = description; } } else { Description = description; //if setting an empty string it will remove the Description.Content metadata if (!string.IsNullOrEmpty(description)) { NodeProperties.DescriptionType = DescriptionType; } else { NodeProperties.RemoveMetadata("Description.Type"); //if setting an empty string it will remove the Description.Type when it was HTML or RawInput NodeProperties.DescriptionType = NodeDescriptionType.None; //trigger the PropertyChanged event - though not stored } } } } else if (DescriptionType == NodeDescriptionType.Iframe) { if (NodeProperties is MultipleNodesProperties) { // If the DataContext is the MultipleNodesProperties and the URLs didn't all match the field will be an empty string. NodeProperties.DescriptionType = DescriptionType; } else { if (!string.IsNullOrEmpty(iframeUrl)) { NodeProperties.DescriptionType = DescriptionType; } else { NodeProperties.RemoveMetadata("Description.Type"); //if no url is entered then clear the Description.Type metadata NodeProperties.DescriptionType = NodeDescriptionType.None; //trigger the PropertyChanged event - though not stored } } } else { NodeProperties.DescriptionType = DescriptionType; //for future description types like GPS, though they may have their own validation } } NodeProperties.EndEdit(); Close(); } }
private void RadComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { switch (DescriptionTypeSelector.SelectedIndex) { case 0: //Selected Text (Rich Text or Raw HTML) //check if the previous selection was Embed Web Page and if the URL had been specified if (_previousSelection == 1 && !string.IsNullOrWhiteSpace(NodeProperties.DescriptionUrl)) { SuperMessageBoxService.ShowWarning("Change Description Type", "The embedded web page will be removed and replaced with text.\r\n" + "Are you sure you want to continue?", "Yes", "No", () => { DescriptionNotice.Visibility = Visibility.Collapsed; CbRichTextAdvanceMode.Visibility = Visibility.Visible; IframePanel.Visibility = Visibility.Collapsed; WidthHeightPanels.Visibility = Visibility.Visible; //Clear the IFrame Details. NodeProperties.DescriptionUrl = ""; if (CbRichTextAdvanceMode.IsChecked == true) { RawPanel.Visibility = Visibility.Visible; DesignerPanel.Visibility = Visibility.Collapsed; DescriptionType = NodeDescriptionType.RawInput; } else { RawPanel.Visibility = Visibility.Collapsed; DesignerPanel.Visibility = Visibility.Visible; DescriptionType = NodeDescriptionType.Html; } }, () => { _previousSelection = -1; //this will prevent a double warning message DescriptionTypeSelector.SelectedIndex = 1; }); } else { DescriptionNotice.Visibility = Visibility.Collapsed; CbRichTextAdvanceMode.Visibility = Visibility.Visible; IframePanel.Visibility = Visibility.Collapsed; WidthHeightPanels.Visibility = Visibility.Visible; if (CbRichTextAdvanceMode.IsChecked == true) { RawPanel.Visibility = Visibility.Visible; DesignerPanel.Visibility = Visibility.Collapsed; DescriptionType = NodeDescriptionType.RawInput; } else { RawPanel.Visibility = Visibility.Collapsed; DesignerPanel.Visibility = Visibility.Visible; DescriptionType = NodeDescriptionType.Html; } } break; case 1: //Selected Embed Web Page //check if previous selection was Text and if there was any content entered if (_previousSelection == 0 && ((DescriptionType == NodeDescriptionType.Html && !string.IsNullOrWhiteSpace(RichTextEditor.GetRawText())) || (DescriptionType == NodeDescriptionType.RawInput && !string.IsNullOrWhiteSpace(HtmlEditor.Text)))) { SuperMessageBoxService.ShowWarning("Change Description Type", "The text will be removed and replaced with embedded web page.\r\n" + "Are you sure you want to continue?", "Yes", "No", () => { DescriptionNotice.Visibility = Visibility.Collapsed; IframePanel.Visibility = Visibility.Visible; RawPanel.Visibility = Visibility.Collapsed; DesignerPanel.Visibility = Visibility.Collapsed; DescriptionType = NodeDescriptionType.Iframe; CbRichTextAdvanceMode.Visibility = Visibility.Collapsed; WidthHeightPanels.Visibility = Visibility.Visible; //Clear the HTML editors RichTextEditor.LoadHtml(""); HtmlEditor.Text = ""; }, () => { _previousSelection = -1; //this will prevent a double warning message DescriptionTypeSelector.SelectedIndex = 0; }); } else { DescriptionNotice.Visibility = Visibility.Collapsed; IframePanel.Visibility = Visibility.Visible; RawPanel.Visibility = Visibility.Collapsed; DesignerPanel.Visibility = Visibility.Collapsed; DescriptionType = NodeDescriptionType.Iframe; CbRichTextAdvanceMode.Visibility = Visibility.Collapsed; WidthHeightPanels.Visibility = Visibility.Visible; } break; case -1: DescriptionNotice.Visibility = Visibility.Visible; IframePanel.Visibility = Visibility.Collapsed; WidthHeightPanels.Visibility = Visibility.Collapsed; RawPanel.Visibility = Visibility.Collapsed; DesignerPanel.Visibility = Visibility.Collapsed; DescriptionType = NodeDescriptionType.None; CbRichTextAdvanceMode.Visibility = Visibility.Collapsed; break; } _previousSelection = DescriptionTypeSelector.SelectedIndex; }
public void SaveToImage(SuperGraphControl mapCanvas) { var saveDlg = new SaveFileDialog { Filter = "JPEG Files (*.jpg)|*.jpg", DefaultExt = ".jpg" }; var showDialog = saveDlg.ShowDialog(); if (showDialog != null && (bool)showDialog) { WriteableBitmap bitmap; try { double left, right, top, bottom; mapCanvas.GetMapBounds(out left, out right, out top, out bottom); left -= 70; right += 70; top -= 170; bottom += 170; double mapHeight = bottom - top; double mapWidth = right - left; var transform = new TransformGroup(); ScaleTransform st; TranslateTransform tt; var moved = mapCanvas.MoveGraphTransform; double xMove, yMove; const ScreenCaptureType type = ScreenCaptureType.ZoomedFullScale; Canvas canvas; switch (type) { case ScreenCaptureType.FullScale: xMove = moved.X + left; yMove = moved.Y + top; st = new ScaleTransform { ScaleX = 1 / mapCanvas.Zoom, ScaleY = 1 / mapCanvas.Zoom, CenterX = 0, CenterY = 0 }; transform.Children.Add(st); tt = new TranslateTransform { X = -xMove, Y = -yMove, }; transform.Children.Add(tt); canvas = new Canvas { Background = new SolidColorBrush(Colors.White), Width = (int)mapWidth, Height = (int)mapHeight }; bitmap = new WriteableBitmap(canvas, null); break; case ScreenCaptureType.ZoomedFullScale: xMove = moved.X + left; yMove = moved.Y + top; tt = new TranslateTransform { X = -xMove * mapCanvas.Zoom, Y = -yMove * mapCanvas.Zoom, }; transform.Children.Add(tt); canvas = new Canvas { Background = new SolidColorBrush(Colors.White), Width = (int)(mapWidth * mapCanvas.Zoom), Height = (int)(mapHeight * mapCanvas.Zoom) }; bitmap = new WriteableBitmap(canvas, null); break; case ScreenCaptureType.CurrentScreenOnly: canvas = new Canvas { Background = new SolidColorBrush(Colors.White), Width = (int)mapCanvas.ActualWidth, Height = (int)mapCanvas.ActualHeight }; bitmap = new WriteableBitmap(canvas, null); break; default: canvas = new Canvas { Background = new SolidColorBrush(Colors.White), Width = (int)mapCanvas.ActualWidth, Height = (int)mapCanvas.ActualHeight }; bitmap = new WriteableBitmap(canvas, null); break; } bitmap.Render(mapCanvas, transform); bitmap.Invalidate(); using (var fs = saveDlg.OpenFile()) { var stream = GetImageStream(bitmap); //Get Bytes from memory stream and write into IO stream var binaryData = new Byte[stream.Length]; var bytesRead = stream.Read(binaryData, 0, (int)stream.Length); fs.Write(binaryData, 0, binaryData.Length); } } catch (Exception e) { SuperMessageBoxService.ShowError("Export Failed", "We are unable to export your map.\r\nPlease zoom out and try again."); } GC.Collect(); GC.WaitForPendingFinalizers(); } }
private void ContextMenuPaste_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { Visibility = Visibility.Collapsed; if (OperationDetails.Operation != NodeOperation.None && OperationDetails.Map != null && OperationDetails.Nodes != null) { if (IoC.GetInstance <ISuperGraphRelationshipFactory>().IsSameDomain) { var currentNodeControls = ContextMenuParent.GetNodeControls().ToList(); var operateNodes = OperationDetails.Nodes.ToList(); foreach (var nodeControl in currentNodeControls) { if (operateNodes.Any(q => q.Id == nodeControl.ViewModelNode.Id)) { operateNodes.RemoveAll(q => q.Id == nodeControl.ViewModelNode.Id); } } var currentRelationships = ContextMenuParent.GetRelationships().ToList(); var operateRelationships = OperationDetails.Relationships.ToList(); foreach (var relationship in currentRelationships) { if (operateRelationships.Any(q => q.From == relationship.From && q.To == relationship.To)) { operateRelationships.RemoveAll(q => q.From == relationship.From && q.To == relationship.To); } } switch (OperationDetails.Operation) { case NodeOperation.None: break; case NodeOperation.Cut: if (!OperationDetails.Map.Proxy.Id.Equals(ContextMenuParent.Context.Proxy.Id)) { IoC.GetInstance <ISuperGraphRelationshipFactory>().TranscludeNode(operateNodes, OperationDetails.Map, Location); IoC.GetInstance <ISuperGraphRelationshipFactory>().DeleteTranscludedNode(operateNodes, OperationDetails.Map, true); } break; case NodeOperation.Copy: IoC.GetInstance <ISuperGraphRelationshipFactory>().TranscludeNode(operateNodes, OperationDetails.Map, Location); break; case NodeOperation.Clone: break; case NodeOperation.CopyMultiNodes: IoC.GetInstance <ISuperGraphRelationshipFactory>().TranscludeNodes(operateNodes, OperationDetails.Map, Location, OperationDetails.OldLocation); IoC.GetInstance <ISuperGraphRelationshipFactory>().ConnectMultipleTranscludedNodes(operateRelationships, OperationDetails.Nodes.ToList(), OperationDetails.Map); break; case NodeOperation.CutMultiNodes: if (!OperationDetails.Map.Proxy.Id.Equals(ContextMenuParent.Context.Proxy.Id)) { IoC.GetInstance <ISuperGraphRelationshipFactory>().TranscludeNodes(operateNodes, OperationDetails.Map, Location, OperationDetails.OldLocation); IoC.GetInstance <ISuperGraphRelationshipFactory>().ConnectMultipleTranscludedNodes(operateRelationships, OperationDetails.Nodes.ToList(), OperationDetails.Map); IoC.GetInstance <ISuperGraphRelationshipFactory>().DeleteNodes(operateNodes, OperationDetails.Map, false); } break; } } else { SuperMessageBoxService.ShowWarning("Paste Node(s)", "You are attempting to copy/cut node(s) from another map/project. \r\n\r\n" + "Press YES to clone the node(s) into this map instead\r\n" + "Press NO to cancel", "Yes", "No", () => { var count = OperationDetails.Nodes.Count(); if (count > 1) { IoC.GetInstance <ISuperGraphNodeFactory>().CloneNodes(OperationDetails.Nodes, OperationDetails.Relationships); } else if (count == 1) { IoC.GetInstance <ISuperGraphNodeFactory>().CloneNode(OperationDetails.Nodes.First()); } }); } } }
private void PreLoaderOnMapLoadFailed(object sender, EventArgs eventArgs) { Loader.Visibility = Visibility.Collapsed; SuperMessageBoxService.ShowWarning("We cant find your map", "Please contact your system administrator for assistance", () => HomeScreen()); }