public void SetFrom(DisplaySettings displaySettings) { this.GenerateDisplayCode = displaySettings.GenerateDisplayCode; this.Is2D = displaySettings.Is2D; this.ResolutionWidth = displaySettings.ResolutionWidth; this.ResolutionHeight = displaySettings.ResolutionHeight; this.FixedAspectRatio = displaySettings.FixedAspectRatio; this.AspectRatioWidth = displaySettings.AspectRatioWidth; this.AspectRatioHeight = displaySettings.AspectRatioHeight; this.SupportLandscape = displaySettings.SupportLandscape; this.SupportPortrait = displaySettings.SupportPortrait; this.RunInFullScreen = displaySettings.RunInFullScreen; this.AllowWindowResizing = displaySettings.AllowWindowResizing; this.Scale = displaySettings.Scale; this.ResizeBehavior = displaySettings.ResizeBehavior; }
/// <summary> /// Gets all available display settings. /// </summary> /// <returns>Array of possible screen resolutions.</returns> public static List <DisplaySettings> GetDisplaySettings() { var result = new Dictionary <string, DisplaySettings>(); var devMode = new NativeMethods.DEVMODE(); var modeNumber = 0; while (NativeMethods.EnumDisplaySettings(null, modeNumber++, ref devMode)) { var ds = new DisplaySettings() { BitsPerPixel = devMode.dmBitsPerPel, Flags = devMode.dmDisplayFlags, Frequency = devMode.dmDisplayFrequency, Height = devMode.dmPelsHeight, Width = devMode.dmPelsWidth }; if (!result.ContainsKey(ds.ToString())) { result.Add(ds.ToString(), ds); } } return(result.Values.ToList()); }
private void OnConsoleVideoMode(string arguments) { if (!string.IsNullOrEmpty(arguments)) { try { Vec2I mode = Vec2I.Parse(arguments); if (EngineApp.Instance.FullScreen && !DisplaySettings.VideoModeExists(mode)) { string text = string.Format("Cannot change screen resolution to \"{0}x{1}\". " + "This resolution is not supported by the system.", mode.X, mode.Y); Log.Warning(text); return; } EngineApp.Instance.VideoMode = mode; } catch (Exception ex) { Log.Warning(ex.Message); } } else { Print(string.Format("Value: \"{0}\"", EngineApp.Instance.VideoMode)); } }
public DisplaySettings ToDisplaySettings() { DisplaySettings toReturn = new DisplaySettings(); toReturn.GenerateDisplayCode = this.GenerateDisplayCode; toReturn.Is2D = this.Is2D; toReturn.ResolutionWidth = this.ResolutionWidth; toReturn.ResolutionHeight = this.ResolutionHeight; toReturn.FixedAspectRatio = this.FixedAspectRatio; toReturn.AspectRatioWidth = this.AspectRatioWidth; toReturn.AspectRatioHeight = this.AspectRatioHeight; toReturn.SupportLandscape = this.SupportLandscape; toReturn.SupportPortrait = this.SupportPortrait; toReturn.RunInFullScreen = this.RunInFullScreen; toReturn.AllowWindowResizing = this.AllowWindowResizing; toReturn.Scale = this.Scale; toReturn.ResizeBehavior = this.ResizeBehavior; return(toReturn); }
public static void CreateGlueProjectSettingsFor(GlueProjectSave project) { DisplaySettings settings = new DisplaySettings(); settings.AllowWindowResizing = false; settings.AspectRatioHeight = 9; settings.AspectRatioWidth = 16; settings.Is2D = project.In2D; settings.ResizeBehavior = ResizeBehavior.StretchVisibleArea; settings.ResizeBehaviorGum = ResizeBehavior.StretchVisibleArea; settings.ResolutionWidth = project.ResolutionWidth; settings.ResolutionHeight = project.ResolutionHeight; settings.RunInFullScreen = false; settings.Scale = 100; settings.ScaleGum = 100; settings.SupportLandscape = true; settings.SupportPortrait = false; project.DisplaySettings = settings; }
public static void drawTicks(Bitmap bmp, FftSettings fftSettings, DisplaySettings displaySettings) { Graphics gfx = Graphics.FromImage(bmp); double tickSpacingSec = displaySettings.tickSpacingSec; double tickSpacingHz = displaySettings.tickSpacingHz; double horizontalTickSpacing = tickSpacingSec * fftSettings.sampleRate / fftSettings.step; double firstFreqTick = fftSettings.FrequencyFromIndex(displaySettings.pixelLower) + tickSpacingHz; double lastFreqTick = fftSettings.FrequencyFromIndex(displaySettings.pixelUpper) - tickSpacingHz; for (double frequency = 0; frequency < fftSettings.maxFreq; frequency += tickSpacingHz) { if ((frequency < firstFreqTick) || (frequency > lastFreqTick)) { continue; } int yPosition = bmp.Height - (fftSettings.IndexFromFrequency(frequency) - displaySettings.pixelLower); Point p1 = new Point(bmp.Width - displaySettings.tickSize, yPosition); Point p2 = new Point(bmp.Width, yPosition); DrawLineWithShadow(gfx, p1, p2); DrawTextWithShadow(gfx, Math.Round(frequency).ToString(), p1, displaySettings.tickFont, displaySettings.sfTicksRight); } for (double xPx = 0; xPx < bmp.Width; xPx += horizontalTickSpacing) { Point p1 = new Point((int)xPx, bmp.Height); Point p2 = new Point((int)xPx, bmp.Height - displaySettings.tickSize); DrawLineWithShadow(gfx, p1, p2); } }
/// <summary> /// Find out which marker to use for the village /// </summary> public Marker GetMarker(DisplaySettings settings, Village village) { if (!village.HasPlayer) { if (settings.HideAbandoned) { return(null); } return(AbandonedMarker); } else { Marker marker; Player ply = village.Player; if (_markPlayer.TryGetValue(ply.Id, out marker) && marker.Settings.Enabled) { return(marker); } if (ply.HasTribe && _markTribe.TryGetValue(ply.Tribe.Id, out marker) && marker.Settings.Enabled) { return(marker); } if (settings.MarkedOnly) { return(null); } return(EnemyMarker); } }
private static bool HasDisplaySetting(IEnumerable <DisplaySettings> availableDisplaySettings, DisplaySettings check) { return(availableDisplaySettings.Any(item => item.Width == check.Width && item.BitDepth == check.BitDepth && item.Height == check.Height && item.RefreshRate == check.RefreshRate)); }
private List <CategoryItem> CreateCategories() { var categories = new List <CategoryItem>(); #pragma warning disable IDE0008 // Use explicit type foreach (var t in Enum.GetValues(typeof(DeviceType))) { #pragma warning restore IDE0008 string name = t.ToString(); CategoryItem category = new CategoryItem() { Category = "Devices", Name = name, }; switch (name) { case nameof(DeviceType.Display): var dui = new DisplaySettings(); dui.ItemChanged += SettingsItemChanged; category.UIElement = dui; break; case nameof(DeviceType.InputSwitch): var iui = new InputSwitchSettings(); iui.ItemChanged += SettingsItemChanged; category.UIElement = iui; break; case nameof(DeviceType.MediaInfo): var mui = new MediaInfoSettings(); mui.ItemChanged += SettingsItemChanged; category.UIElement = mui; break; case nameof(DeviceType.Processor): var pui = new ProcessorSettings(); pui.ItemChanged += SettingsItemChanged; category.UIElement = pui; break; case nameof(DeviceType.Serial): var sui = new SerialSettings(); sui.ItemChanged += SettingsItemChanged; category.UIElement = sui; break; case nameof(DeviceType.Source): var srui = new SourceSettings(); srui.ItemChanged += SettingsItemChanged; category.UIElement = srui; break; } categories.Add(category); } return(categories); }
public static void Read() { HttpRequest request = HttpContext.Current.Request; string str = request.Cookies["Key1"].GetString(); int num = request.Cookies["Key2"].ToInt(0); DisplaySettings setting = request.Cookies["Key3"].FromJson <DisplaySettings>(); DateTime dt = request.Cookies["Key4"].ConverTo <DateTime>(); }
public void DisplaySettingsTargetResolutionTest() { var Settings = new DisplaySettings(new Point(640, 400), new Point(1280, 800), new Point(640, 400)); Assert.AreEqual(320, Settings.Viewport.X); Assert.AreEqual(200, Settings.Viewport.Y); Assert.AreEqual(640, Settings.Viewport.Width); Assert.AreEqual(400, Settings.Viewport.Height); }
public static void SaveDisplaySettings() { var settings = new DisplaySettings(); settings.Capture(); string json = JsonUtility.ToJson(settings); PlayerPrefs.SetString("GBDisplaySettings", json); PlayerPrefs.Save(); }
protected virtual DisplaySettings CreateDisplaySettings() { DisplaySettings settings = new DisplaySettings(); settings.setDepthBuffer(true); settings.setNumMultiSamples((uint)numSamples); settings.setMinimumNumStencilBits(8); settings.setMinimumNumAlphaBits(8); return(settings); }
private string GetIndentationString(DisplaySettings displaySettings) { if (displaySettings.IndentationUseTabs) { int numberOfTabs = displaySettings.IndentationSize / displaySettings.IndentationTabSize; int numberOfSpaces = displaySettings.IndentationSize % displaySettings.IndentationTabSize; return(new string('\t', numberOfTabs) + new string(' ', numberOfSpaces)); } return(new string(' ', displaySettings.IndentationSize)); }
public ContinentLinesPainter(Graphics g, DisplaySettings settings, VillageDimensions dimensions, Rectangle gameRectangle, Rectangle mapSize) { _settings = settings; _g = g; _visibleGameRectangle = gameRectangle; _toPaint = mapSize; _villageWidthSpacing = dimensions.SizeWithSpacing.Width; _villageHeightSpacing = dimensions.SizeWithSpacing.Height; }
/// <summary> /// Lädt aus einem XML-Element DisplaySettings /// </summary> /// <param name="root"></param> /// <returns></returns> private DisplaySettings LoadSettings(XElement root) { DisplaySettings settings = new DisplaySettings(); settings.CenterX = double.Parse(root.Element("CenterX").Value, CultureInfo.InvariantCulture); settings.CenterY = double.Parse(root.Element("CenterY").Value, CultureInfo.InvariantCulture); settings.Rotation = double.Parse(root.Element("Rotation").Value, CultureInfo.InvariantCulture); settings.Scale = double.Parse(root.Element("Scale").Value, CultureInfo.InvariantCulture); return(settings); }
public void InitializeMiniMapDisplay(DisplaySettings settings) { Debug.Assert(_isMiniMap); _displaysettings = settings; Location = new Location(DisplayTypes.Shape, 500, 500, MiniMapDrawerFactory.MaxZoomLevel); var loc = Location; Display = new Display(settings, true, this, ref loc); }
/// <summary> /// Computes possible minimum requires sizes to fit the button text /// </summary> /// <returns>Possible sizes</returns> protected List <Size> GetPossibleTextSizes() { Graphics g = Graphics.FromHwnd(Handle); List <Size> possibleSizes = DisplaySettings.GetPossibleTextSizes(g, Text, Font, FormatFlags); g.Dispose(); return(possibleSizes); }
/// <summary> /// Unity awake function. Initialize values for the DIRE system, /// </summary> void Awake() { /// See if the DIRE instance has been set. Only one may be registered. if (DIRE.Instance != null) { Debug.Log("Multiple instances of DIRE script"); } else { /// register the DIRE instance. Set so that it will remain when scenes are loaded. DIRE.Instance = this; //DontDestroyOnLoad(this); string programDir = "/DIRE"; string settingsDir = "/Settings"; List <string> searchPaths = new List <string>(); //searchPaths.Add(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + programDir + settingsDir); // searchPaths.Add(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + programDir + settingsDir); // searchPaths.Add(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + programDir + settingsDir); // searchPaths.Add(Directory.GetCurrentDirectory() + "/.." + settingsDir); searchPaths.Add(Application.dataPath + "/.." + settingsDir); searchPaths.Add(Application.dataPath + "/FullPackage/Settings"); searchPaths.Add(@"C:\DIRE\"); SetupSearch = new FileSearch(); foreach (string path in searchPaths) { SetupSearch.Add(Path.GetFullPath(path)); } Debug.Log("Unified Search Path: " + Environment.NewLine + SetupSearch); /// Load display settings from definition file DisplaySettings settings = LoadDisplayDefinition(); /// Initialize DIRE display system. InitializeDisplay(settings); if (!(settings == null || settings.screens.Count <= 0)) { calculateGeometricCenter(settings); if (defaultCam != null) { defaultCam.SetActive(false); } } //InitializeInputs(); GetComponent <ARTtrack>().InitializeTracking(); GetComponent <ARTtrack>().SetTracking(GetComponent <ARTtrack>().CheckTracking()); } }
private float SetCameraFromDisplaySettings(float yResolution, DisplaySettings displaySettings) { SpriteManager.Camera.Orthogonal = displaySettings.Is2D; if (displaySettings.GenerateDisplayCode) { SetResolution(displaySettings.ResolutionWidth, displaySettings.ResolutionHeight); yResolution = displaySettings.ResolutionHeight; } SpriteManager.Camera.OrthogonalWidth = displaySettings.ResolutionWidth; SpriteManager.Camera.OrthogonalHeight = displaySettings.ResolutionHeight; return(yResolution); }
public static void Write() { string str = "中国"; int aa = 25; DisplaySettings setting = new DisplaySettings { Style = 3, Size = 50 }; DateTime dt = new DateTime(2012, 1, 1, 12, 0, 0); str.WriteCookie("Key1", DateTime.Now.AddDays(1d)); aa.WriteCookie("Key2", null); setting.ToJson().WriteCookie("Key3", null); dt.WriteCookie("Key4", null); }
private void ResetTracker() { TrackingSettings trackingSettings = new TrackingSettings() { Type = TrackingType.Full, }; this.configuration.Tracking = trackingSettings; DisplaySettings displaySettings = this.DisplaySettings; displaySettings.Tracking = trackingSettings; this.DisplaySettings = displaySettings; this.configuration.Tracking = trackingSettings; }
private DisplayInfo getCurrentDisplayInfo(DisplayInfo displayInfo) { DisplayInfo res = DisplaySettings.GetDisplayDevices(); foreach (var device in res.devices) { var device2 = displayInfo.devices.FirstOrDefault(_device => _device.DeviceID == device.DeviceID && _device.Enabled == true); if (device2 != null) { device.Enabled = true; device.Scaling = device2.Scaling; } } return res; }
public bool TrySaveDisplaySettings(DisplaySettings displaySettings, string filePath) { try { File.WriteAllText(filePath, JsonConvert.SerializeObject(displaySettings, Formatting.Indented)); } catch (Exception ex) { LogManager.GetCurrentClassLogger().Error(ex, "Error while saving display settingsView."); return(false); } return(true); }
/// <summary> /// Requests that the shape process the shape command. /// </summary> /// <param name="command">Command requested by the shape.</param> /// <param name="context">Execution context: these are the arguments specified in the event. Please /// note that the command is one of the arguments.</param> /// <param name="settings">Display settings.</param> /// <returns>New display settings.</returns> public DisplaySettings Execute(string command, NameValueCollection context, DisplaySettings settings, bool forceChange) { bool dropEvent = (string.IsNullOrEmpty(VisioUtils.GetProperty(_shape, "Prop", "ShapeXML"))); if (command == "drop" && !dropEvent) { return(settings); } /* * If the command was a "drop" (shape dragged from stencil into page) * then execute it right now. This must be done before the following * statement. */ if (command == "drop") { OnPageDrop(); } /* * */ string shapeXml = null; if (forceChange && VisioUtils.ShapeCustomProps != null) { shapeXml = VisioUtils.ShapeCustomProps; VisioUtils.SetProperty(VisioShape, "Prop", "ShapeXML", shapeXml); } else { shapeXml = VisioUtils.GetProperty(VisioShape, "Prop", "ShapeXML"); } Form.SetShapeXml(shapeXml); /* * Command router. */ switch (command) { case "drop": case "edit": return(OnShapeEdit(command, context, settings, forceChange)); default: return(OnExecuteCustom(command, context, settings)); } }
public static string GetResultsText(DisplaySettings displaySettings, TransitionGroupDocNode nodeGroup) { float? libraryProduct = nodeGroup.GetLibraryDotProduct(displaySettings.ResultsIndex); float? isotopeProduct = nodeGroup.GetIsotopeDotProduct(displaySettings.ResultsIndex); RatioValue ratio = null; if (displaySettings.NormalizationMethod is NormalizationMethod.RatioToLabel ratioToLabel) { ratio = displaySettings.NormalizedValueCalculator.GetTransitionGroupRatioValue(ratioToLabel, displaySettings.NodePep, nodeGroup, nodeGroup.GetChromInfoEntry(displaySettings.ResultsIndex)); } if (null == ratio && !isotopeProduct.HasValue && !libraryProduct.HasValue) { return(string.Empty); } StringBuilder sb = new StringBuilder(@" ("); int len = sb.Length; if (isotopeProduct.HasValue) { sb.Append(string.Format(@"idotp {0}", isotopeProduct.Value.ToString(DOTP_FORMAT))); } if (libraryProduct.HasValue) { if (sb.Length > len) { sb.Append(CS_SEPARATOR); } sb.Append(string.Format(@"dotp {0}", libraryProduct.Value.ToString(DOTP_FORMAT))); } if (ratio != null) { if (sb.Length > len) { sb.Append(CS_SEPARATOR); } if (!double.IsNaN(ratio.StdDev)) { sb.Append(string.Format(@"rdotp {0}", ratio.DotProduct.ToString(DOTP_FORMAT))); sb.Append(CS_SEPARATOR); } sb.Append(string.Format(Resources.TransitionGroupTreeNode_GetResultsText_total_ratio__0__, MathEx.RoundAboveZero(ratio.Ratio, 2, 4))); } sb.Append(@")"); return(sb.ToString()); }
public StilettoMakerGUI(Stiletto plugin) { displaySettings = StilettoContext._displaySettingsProvider.Value; if (StudioAPI.InsideStudio) { RegisterStudioControls(); } else { MakerAPI.RegisterCustomSubCategories += (_, e) => RegisterMakerControls(plugin, e); } StilettoContext.OnHeelInfoUpdate += OnHeelInfoUpdate; }
private void ChangeTracker(TrackingSettings trackerSettings) { // Check recording state RecordingState state = this.recorder.State; // Debug.Assert(state == RecordingState.Idle); if (state != RecordingState.Idle) { return; } DisplaySettings displaySettings = this.DisplaySettings; displaySettings.Tracking = trackerSettings; this.DisplaySettings = displaySettings; this.configuration.Tracking = trackerSettings; }
public void DisplaySettingsNoTargetResolutionTest() { var Settings = new DisplaySettings(new Point(640, 400), new Point(1280, 800), null); Assert.AreEqual(1280, Settings.Viewport.Width); Assert.AreEqual(800, Settings.Viewport.Height); Assert.AreEqual(2, Settings.ScaleMatrix.M11); Assert.AreEqual(2, Settings.ScaleMatrix.M22); Settings.OnClientSizeChanged(640, 500); Assert.AreEqual(0, Settings.Viewport.X); Assert.AreEqual(50, Settings.Viewport.Y); Assert.AreEqual(640, Settings.Viewport.Width); Assert.AreEqual(400, Settings.Viewport.Height); }
public ActionResult Edit(DisplaySettings settings) { if (!ValidateRequest) { return(View(settings)); } var response = this._displaySettingsService.SaveDisplaySettings(settings); if (response.Success) { return(RedirectToAction("SlideDetails", "Slide", new { id = settings.SlideId })); } return(View(settings)); }
public PlatformTestsConsole() { InitializeComponent(); MessagingCenter.Subscribe <ITestResult>(this, "AssemblyFinished", AssemblyFinished); MessagingCenter.Subscribe <ITest>(this, "TestStarted", TestStarted); MessagingCenter.Subscribe <ITestResult>(this, "TestFinished", TestFinished); MessagingCenter.Subscribe <Exception>(this, "TestRunnerError", OutputTestRunnerError); Rerun.Clicked += RerunClicked; togglePassed.Clicked += ToggledPassedClicked; _displaySettings = new DisplaySettings(); BindingContext = _displaySettings; }
public static void CompressExe(IList contents, bool dbPro, DisplaySettings settings, string oldExe, string newExe, string compressDll) { FileStream fs = null; BinaryReader br = null; int exeSection = 0, extraData = 0; string tempExe = Path.GetTempFileName(); //save exe SaveExe(contents, tempExe, oldExe, dbPro, settings); try { fs = new FileStream(tempExe, FileMode.Open); br = new BinaryReader(fs); SkipExeSection(fs, br); exeSection = (int)fs.Position; //get size of extra data ListViewFileItem lvi = (ListViewFileItem) contents[contents.Count - 1]; if (lvi.SubItems[(int)ListViewOrder.Name].Text == ListViewStrings.ExtraData) { lvi = (ListViewFileItem)contents[contents.Count - 1]; extraData = lvi.Size; } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (br != null) br.Close(); if (fs != null) fs.Close(); } try { CompressDll(oldExe, exeSection, extraData, newExe, compressDll); } catch(Exception ex) { MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (File.Exists(tempExe)) File.Delete(tempExe); }
/// <summary> /// Gets all available display settings. /// </summary> /// <returns>Array of possible screen resolutions.</returns> public static List<DisplaySettings> GetDisplaySettings() { var result = new Dictionary<string, DisplaySettings>(); var devMode = new NativeMethods.DEVMODE(); var modeNumber = 0; while (NativeMethods.EnumDisplaySettings(null, modeNumber++, ref devMode)) { var ds = new DisplaySettings() { BitsPerPixel = devMode.dmBitsPerPel, Flags = devMode.dmDisplayFlags, Frequency = devMode.dmDisplayFrequency, Height = devMode.dmPelsHeight, Width = devMode.dmPelsWidth }; if (!result.ContainsKey(ds.ToString())) result.Add(ds.ToString(), ds); } return result.Values.ToList(); }
public Display(DisplaySettings settings, bool isMiniMap, Map map, ref Location location) : this(settings, map) { // Validate zoom or we have a potential divide by zero etc if (isMiniMap) { ZoomInfo zoom = DrawerFactoryBase.CreateMiniMapZoom(location.Zoom); location = zoom.Validate(location); _drawerFactoryStrategy = DrawerFactoryBase.CreateMiniMap(location.Zoom); } else { ZoomInfo zoom = DrawerFactoryBase.CreateZoom(location.Display, location.Zoom); location = ValidateZoom(zoom, location); _drawerFactoryStrategy = DrawerFactoryBase.Create(location.Display, location.Zoom, settings.Scenery); } // TODO: make this lazy. Setting here = crash // Is fixed by calling UpdateLocation after Map.Location is set //_visibleRectangle = GetGameRectangle(); }
public static string DisplayText(TransitionGroupDocNode nodeGroup, DisplaySettings settings) { return GetLabel(nodeGroup.TransitionGroup, nodeGroup.PrecursorMz, GetResultsText(nodeGroup, settings.NodePep, settings.Index, settings.RatioIndex)); }
public void SetDisplaySettings(DisplaySettings settings) { Debug.Assert(!_isMiniMap); _displaysettings = settings; }
public AppSettings() { DisplaySettings = new DisplaySettings(); GeneralSettings = new GeneralSettings(); }
/// <summary>Initializes the instance with the specified values. These values will override any configured values.</summary> /// <param name="domain">The domain to be used, or null to use the configured value.</param> /// <param name="privateKey">The private key to be used, or null to use the configured value.</param> /// <param name="publicKey">The public key to be used, or null to use the configured value.</param> /// <param name="logOnDisplay">The display settings for the log on script.</param> /// <param name="linkDisplay">The display settings for the link/connect script.</param> /// <param name="authProviders">The provider names which will be supported for authentication.</param> /// <param name="shareProviders">The providers which will be supported for sharing.</param> internal void InitializeValues(Uri domain, string privateKey, string publicKey, DisplaySettings logOnDisplay, DisplaySettings linkDisplay, IEnumerable<string> authProviders, IEnumerable<Provider> shareProviders) { if (domain != null && domain.IsAbsoluteUri && !domain.Scheme.Equals(Uri.UriSchemeHttps)) throw new ArgumentException("The specified OneAll API domain does not use an HTTPS scheme. A correct OneAll API domain must use the HTTPS scheme.", "domain"); _domain = domain; _privateKey = privateKey; _publicKey = publicKey; _loginDisplay = logOnDisplay; _linkDisplay = linkDisplay; _providerNames = authProviders; _providers = shareProviders; SetCredential(); }
public static void SaveExe(ICollection contents, string fileName, string oldName, bool dbPro, DisplaySettings settings) { FileStream fsExe = null; //old dbpro exe BinaryReader brExe = null; FileStream fsOut = null; //new dbpro exe BinaryWriter bwOut = null; FileStream fsFile; //current file being written BinaryReader brFile; string name; bool overWrite = false; //has oldName been overwritten int exeSection = -1; //size of exeSection try { if (fileName == oldName) { //Trying to overwrite file so move old name to %temp% before opening File.Move(oldName, Path.GetTempPath() + Path.GetFileName(oldName)); oldName = Path.GetTempPath() + Path.GetFileName(oldName); overWrite = true; } if (oldName != "") { //if there is an old dbpro exe load it fsExe = new FileStream(oldName, FileMode.Open); brExe = new BinaryReader(fsExe); } //open new exe fsOut = new FileStream(fileName, FileMode.Create); bwOut = new BinaryWriter(fsOut); foreach (ListViewFileItem lvi in contents) { if (lvi.SubItems[(int)ListViewOrder.Location].Text == ListViewStrings.LocationExe) { //internal file fsFile = fsExe; brFile = brExe; } else { //external file fsFile = new FileStream(lvi.SubItems[(int)ListViewOrder.Location].Text, FileMode.Open); brFile = new BinaryReader(fsFile); } //seek to data start fsFile.Seek(lvi.Offset, SeekOrigin.Begin); //name if (lvi.SubItems[(int)ListViewOrder.FileType].Text == ListViewStrings.Yes) { //is a normal file so write name and filedata length name = DbcRemoveNull(lvi.Text); if (dbPro == false) name = DbcAddNull(name); bwOut.Write(name.Length); bwOut.Write(Encoding.ASCII.GetBytes(name)); } //check for _virtual.dat if (lvi.Text == ListViewStrings.VirtualDat) { //size bwOut.Write(lvi.Size); //write display settings bwOut.Write((int) settings.Mode); bwOut.Write(settings.Width); bwOut.Write(settings.Height); bwOut.Write(settings.Depth); //write data fsFile.Seek(16, SeekOrigin.Current); bwOut.Write(brFile.ReadBytes(lvi.Size - 16)); } else { //not _virtual.dat if (lvi.SubItems[(int)ListViewOrder.FileType].Text == ListViewStrings.No && lvi.SubItems[(int)ListViewOrder.Name].Text == ListViewStrings.ExtraData) { //extra data so write exeSection size at end of extra data bwOut.Write(brFile.ReadBytes(lvi.Size - 4)); bwOut.Write(exeSection); } else { //not _virtual.dat or extra data int written = WriteData(fsFile, brFile, lvi, bwOut); if (lvi.SubItems[(int)ListViewOrder.Name].Text == ListViewStrings.ExeSection) { //set exeSection size if it was written exeSection = written; } } } if (lvi.SubItems[(int)ListViewOrder.Location].Text != ListViewStrings.LocationExe) { //close external file brFile.Close(); fsFile.Close(); } } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (brExe != null) brExe.Close(); if (fsExe != null) fsExe.Close(); if (bwOut != null) bwOut.Close(); if (fsOut != null) fsOut.Close(); //delete oldName in temp dir if required if (overWrite == true) { File.Delete(oldName); } } }
public window() { Text = "dark_explorer"; Size = new Size(600,600); contents = new ListView(); contents.Parent = this; contents.Location = new Point(10,30); contents.Size = new Size(570,535); contents.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom; contents.View = View.Details; contents.Columns.Add("Name",210,HorizontalAlignment.Left); contents.Columns.Add("Attached File",75,HorizontalAlignment.Left); contents.Columns.Add("Upx",45,HorizontalAlignment.Left); contents.Columns.Add("Null Str table",75,HorizontalAlignment.Left); contents.Columns.Add("File size",70,HorizontalAlignment.Right); contents.Columns.Add("Location",90,HorizontalAlignment.Left); contents.AllowColumnReorder = true; exeType = new ComboBox(); exeType.Parent = this; exeType.Location = new Point(10, 5); exeType.DropDownStyle = ComboBoxStyle.DropDownList; exeType.Items.Add("DbPro"); exeType.Items.Add("Dbc"); exeType.SelectedIndex = 0; exeType.Width = 60; exeName = new Label(); exeName.Location = new Point(exeType.Left + exeType.Width + 10, 5); exeName.Parent = this; exeName.AutoSize = true; exeName.Text = ""; //context menu EventHandler mDisplay = new EventHandler(mDisplayOnClick); EventHandler mLoad = new EventHandler(mLoadOnClick); EventHandler mSave = new EventHandler(mSaveOnClick); EventHandler mInsert = new EventHandler(mInsertOnClick); EventHandler mInsertWild = new EventHandler(mInsertWildOnClick); EventHandler mRemove = new EventHandler(mRemoveOnClick); EventHandler mReplace = new EventHandler(mReplaceOnClick); EventHandler mExtract = new EventHandler(mExtractOnClick); EventHandler mEdit = new EventHandler(mEditOnClick); EventHandler mEditWild = new EventHandler(mEditWildOnClick); EventHandler mView = new EventHandler(mViewOnClick); EventHandler mDecompress = new EventHandler(mDecompressOnClick); EventHandler mCompress = new EventHandler(mCompressOnClick); EventHandler mExternalise = new EventHandler(mExternaliseOnClick); EventHandler mAbout = new EventHandler(mAboutOnClick); EventHandler mExit = new EventHandler(mExitOnClick); MenuItem[] amiTools = {new MenuItem("Decompress Exe/Pck", mDecompress), new MenuItem("Compress Exe/Pck", mCompress), new MenuItem("Externalise Dlls", mExternalise)}; MenuItem[] ami = { new MenuItem("No display settings", mDisplay), new MenuItem("&Load", mLoad), new MenuItem("&Save", mSave), new MenuItem("-"), new MenuItem("&Insert", mInsert), new MenuItem("Insert *", mInsertWild), new MenuItem("&Remove", mRemove), new MenuItem("Rep&lace", mReplace), new MenuItem("&Extract", mExtract), new MenuItem("E&dit", mEdit), new MenuItem("Edit *", mEditWild), new MenuItem("&View", mView), new MenuItem("-"), new MenuItem("&Tools", amiTools), new MenuItem("-"), new MenuItem("&About", mAbout), new MenuItem("E&xit", mExit) }; contents.ContextMenu = new ContextMenu(ami); contents.ContextMenu.MenuItems[MENU_DISPLAY].Enabled = false; contents.ContextMenu.MenuItems[MENU_SAVE].Enabled = false; contents.ContextMenu.MenuItems[MENU_REMOVE].Enabled = false; contents.ContextMenu.MenuItems[MENU_REPLACE].Enabled = false; contents.ContextMenu.MenuItems[MENU_EXTRACT].Enabled = false; contents.ContextMenu.MenuItems[MENU_EDIT].Enabled = false; contents.ContextMenu.MenuItems[MENU_EDITWILD].Enabled = false; contents.ContextMenu.MenuItems[MENU_VIEW].Enabled = false; contents.ContextMenu.MenuItems[MENU_TOOLS].MenuItems[MENU_DECOMPRESS].Enabled = false; contents.ContextMenu.MenuItems[MENU_TOOLS].MenuItems[MENU_COMPRESS].Enabled = false; contents.ContextMenu.MenuItems[MENU_TOOLS].MenuItems[MENU_EXTERNALISE].Enabled = false; this.ContextMenu = contents.ContextMenu; displaySettings = new DisplaySettings(); //double click item action contents.ItemActivate += mView; contents.SelectedIndexChanged += new EventHandler(contents_SelectedIndexChanged); AllowDrop = true; DragOver += new DragEventHandler(window_DragOver); DragDrop += new DragEventHandler(window_DragDrop); }
public FindPredicate(FindOptions findOptions, DisplaySettings displaySettings) { FindOptions = findOptions; DisplaySettings = displaySettings; NormalizedFindText = findOptions.CaseSensitive ? findOptions.Text : findOptions.Text.ToLower(); }
/// <summary> /// Executes a custom shape command, if implemented in a derived class. /// </summary> /// <param name="command">Name of the command to execute.</param> /// <param name="context">The full shape command context.</param> /// <param name="settings">Display settings, in case visual interaction is required.</param> /// <returns>Change the current display settings.</returns> protected virtual DisplaySettings OnExecuteCustom( string command, NameValueCollection context, DisplaySettings settings ) { throw new NotSupportedException( "Unsupported command: " + command ); }
/// <summary> /// Find out which marker to use for the village /// </summary> public Marker GetMarker(DisplaySettings settings, Village village) { if (!village.HasPlayer) { if (settings.HideAbandoned) { return null; } return AbandonedMarker; } else { Marker marker; Player ply = village.Player; if (_markPlayer.TryGetValue(ply.Id, out marker) && marker.Settings.Enabled) { return marker; } if (ply.HasTribe && _markTribe.TryGetValue(ply.Tribe.Id, out marker) && marker.Settings.Enabled) { return marker; } if (settings.MarkedOnly) { return null; } return EnemyMarker; } }
private Display(DisplaySettings settings, Map map) { _settings = settings; _map = map; _markers = map.MarkerManager; }
public static string DisplayText(PeptideDocNode node, DisplaySettings settings) { return GetLabel(node, string.Empty); }
public static string getDisplayString(DisplaySettings settings) { string displaystring = settings.Width.ToString() + "x" + settings.Height.ToString() + "x" + settings.Depth.ToString(); switch ((int) settings.Mode) { case 0: displaystring += " hidden"; break; case 1: displaystring += " windowed"; break; case 2: displaystring += " windowed desktop"; break; case 3: displaystring += " full exclusive"; break; case 4: displaystring += " windowed fullscreen"; break; } return displaystring; }
public static string DisplayText(TransitionDocNode nodeTran, DisplaySettings settings) { return GetLabel(nodeTran, GetResultsText(nodeTran, settings.Index, settings.RatioIndex)); }
private void LoadExe(string filename) { Cursor.Current = Cursors.WaitCursor; displaySettings.Depth = -1; displaySettings.Width = -1; displaySettings.Height = -1; displaySettings.Mode = DisplayMode.Hidden; contents.BeginUpdate(); contents.Items.Clear(); contents.ContextMenu.MenuItems[MENU_DISPLAY].Text = "No display settings"; contents.ContextMenu.MenuItems[MENU_DISPLAY].Enabled = false; displaySettings = proExe.LoadExe(contents, filename, this); exeName.Text = filename; contents.ContextMenu.MenuItems[MENU_SAVE].Enabled = true; contents.ContextMenu.MenuItems[MENU_TOOLS].MenuItems[MENU_DECOMPRESS].Enabled = true; contents.ContextMenu.MenuItems[MENU_TOOLS].MenuItems[MENU_COMPRESS].Enabled = true; contents.ContextMenu.MenuItems[MENU_TOOLS].MenuItems[MENU_EXTERNALISE].Enabled = true; updateAlternatingColours(); contents.EndUpdate(); //work out exeType foreach (ListViewFileItem lvi in contents.Items) { if (lvi.SubItems[(int)ListViewOrder.FileType].Text == ListViewStrings.Yes) { //attached file if (lvi.Text.EndsWith("\0")) { //filename is null terminated so is dbc exe exeType.SelectedIndex = exeType.Items.IndexOf("Dbc"); } else { exeType.SelectedIndex = exeType.Items.IndexOf("DbPro"); } break; } } Cursor.Current = Cursors.Default; }
public static DisplaySettings LoadDisplaySettings(ILSpySettings settings) { XElement e = settings["DisplaySettings"]; DisplaySettings s = new DisplaySettings(); s.SelectedFont = new FontFamily((string)e.Attribute("Font") ?? "Consolas"); s.SelectedFontSize = (double?)e.Attribute("FontSize") ?? 10.0 * 4 / 3; s.ShowLineNumbers = (bool?)e.Attribute("ShowLineNumbers") ?? false; return s; }
public static DisplaySettings LoadExe(ListView contents, string fileName, window win) { //debugLog.StartSection("LoadExe"); DisplaySettings settings = new DisplaySettings(); int exeSectionSize = 0, extraDataSize = 0; FileStream fs = null; BinaryReader br = null; try { fs = new FileStream(fileName, FileMode.Open); br = new BinaryReader(fs); ListViewFileItem lvi; //debugLog.Log("Loading " + Path.GetFileName(fileName)); //check exe signiture if (Encoding.ASCII.GetString(br.ReadBytes(2)) == "MZ") { //debugLog.Log("Found exe signiture"); SkipExeSection(fs, br); //add exe to listview lvi = new ListViewFileItem(); lvi.SubItems[(int)ListViewOrder.Name].Text = ListViewStrings.ExeSection; lvi.Offset = 0; lvi.Size = (int)fs.Position; exeSectionSize = lvi.Size; lvi.SubItems[(int)ListViewOrder.FileType].Text = ListViewStrings.No; lvi.SubItems[(int)ListViewOrder.Upx].Text = ListViewStrings.No; lvi.SubItems[(int)ListViewOrder.NullString].Text = ListViewStrings.No; lvi.SubItems[(int)ListViewOrder.FileSize].Text = lvi.Size.ToString("n0"); lvi.SubItems[(int)ListViewOrder.Location].Text = ListViewStrings.LocationExe; contents.Items.Add(lvi); //debugLog.Log("Exe section size = " + lvi.Size.ToString("n0")); //Check for exe with no attached data if (lvi.Size == (int)fs.Length) { //debugLog.Log("Exe has no appended data"); return settings; } } else { //it's a pck file so files start at begining of file //debugLog.Log("Exe signiture not found, assuming .pck"); fs.Seek(0, SeekOrigin.Begin); } //add attached files int nameLength = 1; while (nameLength > 0 && nameLength < 500 && fs.Position < fs.Length) { lvi = new ListViewFileItem(); nameLength = br.ReadInt32(); //MessageBox.Show(nameLength.ToString()); if (nameLength > 0 && nameLength < 500) { //file lvi.SubItems[(int)ListViewOrder.Name].Text = Encoding.ASCII.GetString(br.ReadBytes(nameLength)); lvi.Size = br.ReadInt32(); lvi.Offset = (int)fs.Position; //debugLog.Log(DbcRemoveNull(lvi.Text).PadRight(26, ' ') + " Size :" + lvi.Size.ToString("n0").PadRight(10, ' ') + // " Offset :" + lvi.Offset.ToString("n0")); //check for _virtual.dat if (lvi.SubItems[(int)ListViewOrder.Name].Text == ListViewStrings.VirtualDat) { //get display settings settings.Mode = (DisplayMode) br.ReadInt32(); settings.Width = br.ReadInt32(); settings.Height = br.ReadInt32(); settings.Depth = br.ReadInt32(); contents.ContextMenu.MenuItems[window.MENU_DISPLAY].Text = proExe.getDisplayString(settings); contents.ContextMenu.MenuItems[window.MENU_DISPLAY].Enabled = true; fs.Seek(-16, SeekOrigin.Current); } fs.Seek(lvi.Size, SeekOrigin.Current); lvi.SubItems[(int)ListViewOrder.FileType].Text = ListViewStrings.Yes; lvi.SubItems[(int)ListViewOrder.Upx].Text = ListViewStrings.No; lvi.SubItems[(int)ListViewOrder.NullString].Text = ListViewStrings.No; lvi.SubItems[(int)ListViewOrder.FileSize].Text = lvi.Size.ToString("n0"); lvi.SubItems[(int)ListViewOrder.Location].Text = ListViewStrings.LocationExe; } else { //compressed or extra data lvi.SubItems[(int)ListViewOrder.Name].Text = ListViewStrings.ExtraData; lvi.Offset = (int)fs.Position - 4; lvi.Size = (int)(fs.Length - (fs.Position - 4)); lvi.SubItems[(int)ListViewOrder.FileType].Text = ListViewStrings.No; lvi.SubItems[(int)ListViewOrder.Upx].Text = ListViewStrings.No; lvi.SubItems[(int)ListViewOrder.NullString].Text = ListViewStrings.No; lvi.SubItems[(int)ListViewOrder.FileSize].Text = lvi.Size.ToString("n0"); lvi.SubItems[(int)ListViewOrder.Location].Text = ListViewStrings.LocationExe; fs.Seek(-4, SeekOrigin.End); extraDataSize = br.ReadInt32(); //debugLog.Log("Extra data size :" + lvi.Size.ToString("n0") + " reported exe section size :" + // extraDataSize.ToString("n0")); //if (extraDataSize != exeSectionSize) // debugLog.Log("Warning exe section size reported in extra data does not match actual exe section size"); } contents.Items.Add(lvi); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (br != null) br.Close(); if (fs != null) fs.Close(); } return settings; }
public override string GetDisplayText(DisplaySettings settings) { return PeptideGroupTreeNode.ProteinModalDisplayText(this); }
public static void DecompressExe(ICollection contents, bool dbPro, DisplaySettings settings, string oldExe, string newExe) { FileStream fs = null; BinaryReader br = null; FileStream fsDll = null; BinaryWriter bwDll = null; int dataLength, exeSection = 0, dataOffset = 0; string compressDll = Path.GetTempFileName(); string tempExe = Path.GetTempFileName(); //save exe SaveExe(contents, tempExe, oldExe, dbPro, settings); try { fs = new FileStream(tempExe, FileMode.Open); br = new BinaryReader(fs); SkipExeSection(fs, br); exeSection = (int)fs.Position; //skip compress.dll name dataLength = br.ReadInt32(); fs.Seek(dataLength, SeekOrigin.Current); dataLength = br.ReadInt32(); //write compress.dll fsDll = new FileStream(compressDll, FileMode.Create); bwDll = new BinaryWriter(fsDll); bwDll.Write(br.ReadBytes(dataLength)); dataOffset = (int)fs.Position; //start of compressed data } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (br != null) br.Close(); if (fs != null) fs.Close(); if (bwDll != null) bwDll.Close(); if (fsDll != null) fsDll.Close(); } try { DecompressDll(oldExe, exeSection, dataOffset, newExe, compressDll); } catch(Exception ex) { MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (File.Exists(compressDll)) File.Delete(compressDll); if (File.Exists(tempExe)) File.Delete(tempExe); }
public override string GetDisplayText(DisplaySettings settings) { return PeptideTreeNode.DisplayText(this, settings); }
private static int CountOccurrances(SrmDocument doc, string searchText, DisplaySettings displaySettings, bool reverse, bool caseSensitive) { IdentityPath pathFound = doc.SearchDocumentForString(IdentityPath.ROOT, searchText, displaySettings, reverse, caseSensitive); if (pathFound == null) return 0; IdentityPath pathFoundNext = pathFound; int i = 0; do { pathFoundNext = doc.SearchDocumentForString(pathFoundNext, searchText, displaySettings, reverse, caseSensitive); i++; } while (!Equals(pathFound, pathFoundNext)); return i; }
/// <summary> /// Builds the classes from a sets file /// </summary> public static DisplaySettings ReadSettings(FileInfo file, Map map, Monitor monitor) { Debug.Assert(file.Exists); var newReader = XDocument.Load(file.FullName); var sets = new XmlReaderSettings(); sets.IgnoreWhitespace = true; sets.CloseInput = true; using (XmlReader r = XmlReader.Create(File.Open(file.FullName, FileMode.Open, FileAccess.Read), sets)) { r.ReadStartElement(); //DateTime date = XmlConvert.ToDateTime(r.GetAttribute("Date")); // You string youString = r.GetAttribute("Name"); r.ReadStartElement(); Player ply = World.Default.GetPlayer(youString); if (ply != null) { World.Default.You = ply; } else { World.Default.You = new Player(); } map.MarkerManager.ReadDefaultMarkers(r); r.ReadEndElement(); // Monitor monitor.ReadXml(r); // MainMap r.ReadStartElement(); // MainMap: Location Point? location = World.Default.GetCoordinates(r.GetAttribute("XY")); int x = 500; int y = 500; if (location.HasValue) { x = location.Value.X; y = location.Value.Y; } int z = Convert.ToInt32(r.GetAttribute("Zoom")); var displayType = (DisplayTypes)Enum.Parse(typeof(DisplayTypes), r.GetAttribute("Display"), true); map.HomeLocation = new Location(displayType, x, y, z); // MainMap: Display r.ReadStartElement(); Color backgroundColor = XmlHelper.GetColor(r.GetAttribute("BackgroundColor")); r.ReadStartElement(); bool continentLines = Convert.ToBoolean(r.ReadElementString("LinesContinent")); bool provinceLines = Convert.ToBoolean(r.ReadElementString("LinesProvince")); bool hideAbandoned = Convert.ToBoolean(r.ReadElementString("HideAbandoned")); bool markedOnly = Convert.ToBoolean(r.ReadElementString("MarkedOnly")); r.Skip(); r.ReadEndElement(); var displaySettings = new DisplaySettings(backgroundColor, continentLines, provinceLines, hideAbandoned, markedOnly); // Views World.Default.Views = ReadViews(newReader); // MainMap: Markers r.ReadStartElement(); map.MarkerManager.ReadUserDefinedMarkers(r); // MainMap: Manipulators Dictionary<ManipulatorManagerTypes, ManipulatorManagerBase> dict = map.Manipulators.Manipulators; map.Manipulators.CleanUp(); r.ReadToFollowing("Manipulator"); while (r.IsStartElement("Manipulator")) { var manipulatorType = (ManipulatorManagerTypes)Enum.Parse(typeof(ManipulatorManagerTypes), r.GetAttribute("Type")); if (dict.ContainsKey(manipulatorType)) { if (dict[manipulatorType].UseLegacyXmlWriter) { dict[manipulatorType].ReadXml(r); } else { r.Skip(); dict[manipulatorType].ReadXml(newReader); } } else { r.Skip(); } } r.ReadEndElement(); if (r.IsStartElement("RoamingManipulators")) { r.Skip(); map.Manipulators.ReadRoamingXml(newReader); } // End Main Map r.ReadEndElement(); return displaySettings; } }
/// <summary> /// Requests that the shape process the shape command. /// </summary> /// <param name="command">Command requested by the shape.</param> /// <param name="context">Execution context: these are the arguments specified in the event. Please /// note that the command is one of the arguments.</param> /// <param name="settings">Display settings.</param> /// <returns>New display settings.</returns> public DisplaySettings Execute( string command, NameValueCollection context, DisplaySettings settings, bool forceChange ) { bool dropEvent = (string.IsNullOrEmpty(VisioUtils.GetProperty(_shape, "Prop", "ShapeXML"))); if (command == "drop" && !dropEvent) return settings; /* * If the command was a "drop" (shape dragged from stencil into page) * then execute it right now. This must be done before the following * statement. */ if ( command == "drop" ) OnPageDrop(); /* * */ string shapeXml = null; if (forceChange && VisioUtils.ShapeCustomProps != null) { shapeXml = VisioUtils.ShapeCustomProps; VisioUtils.SetProperty(VisioShape, "Prop", "ShapeXML", shapeXml); } else shapeXml = VisioUtils.GetProperty(VisioShape, "Prop", "ShapeXML"); Form.SetShapeXml(shapeXml); /* * Command router. */ switch ( command ) { case "drop": case "edit": return OnShapeEdit(command, context, settings, forceChange); default: return OnExecuteCustom( command, context, settings ); } }
private static int CountOccurrances(SrmDocument doc, FindOptions findOptions, DisplaySettings displaySettings) { var results = doc.SearchDocument(new Bookmark(IdentityPath.ROOT), findOptions, displaySettings); if (results == null) return 0; FindResult resultsNext = results; int i = 0; do { resultsNext = doc.SearchDocument(resultsNext.Bookmark, findOptions, displaySettings); i++; } while (!Equals(resultsNext.Bookmark, results.Bookmark)); return i; }
/// <summary> /// Edits the properties of the designated shape. /// </summary> /// <param name="command">Command requested by the shape.</param> /// <param name="context">Execution context: these are the arguments specified in the event. Please /// note that the command is one of the arguments.</param> /// <param name="settings">Display settings.</param> /// <returns>New display settings.</returns> protected DisplaySettings OnShapeEdit(string command, NameValueCollection context, DisplaySettings settings, bool forceChange) { if ( settings == null ) throw new ArgumentNullException( "settings" ); if ( Form.PropertyCount == 0 ) return settings; DisplaySettings ns = (DisplaySettings) settings.Clone(); Form.Left = settings.Left; Form.Top = settings.Top; Form.SelectedTabName = settings.TabName; if (!forceChange) Form.ShowDialog(); if (Form.DialogResult == DialogResult.OK || forceChange) { XmlDocument xml = Form.GetShapeXml(); string shapeText = GetShapeText( xml ); #region Channel Text StringBuilder channelText = new StringBuilder(); foreach (XmlElement xe in xml.SelectNodes("properties/channels/channel")) { if (channelText.Length == 0) channelText.Append("["); else channelText.Append(", "); channelText.Append(xe.InnerText); } if (channelText.Length > 0) channelText.Append(']'); #endregion SetShapeText( shapeText, channelText.ToString()); VisioUtils.SetProperty(_shape, "Prop", "ShapeXML", xml.OuterXml); ns.TabName = Form.SelectedTabName; } else { if (command == "drop") { try { VisioShape.Delete(); } catch (Exception) { } } } ns.Left = Form.Left; ns.Top = Form.Top; return ns; }
public void RunTestFindNode(RefinementSettings.ConvertToSmallMoleculesMode asSmallMolecules) { if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.none) TestDirectoryName = asSmallMolecules.ToString(); TestSmallMolecules = false; // Don't need the magic test node, we have an explicit test SrmDocument doc = CreateStudy7Doc(); doc = (new RefinementSettings()).ConvertToSmallMolecules(doc, asSmallMolecules); var displaySettings = new DisplaySettings(null, false, 0, 0); //, ProteinDisplayMode.ByName); // Find every other transition, searching down. List<TransitionDocNode> listTransitions = doc.MoleculeTransitions.ToList(); var pathFound = doc.GetPathTo(0, 0); int i; for (i = 0; i < doc.MoleculeTransitionCount; i += 2) { pathFound = doc.SearchDocumentForString(pathFound, String.Format("{0:F04}", listTransitions[i].Mz), displaySettings, false, false); Assert.AreEqual(doc.GetPathTo((int)SrmDocument.Level.Transitions, i), pathFound); } // Test wrapping in search down. pathFound = doc.SearchDocumentForString(pathFound, String.Format("{0:F04}", listTransitions[0].Mz), displaySettings, false, false); Assert.AreEqual(doc.GetPathTo((int)SrmDocument.Level.Transitions, 0), pathFound); // Find every other peptide searching up while for each finding one of its children searching down. pathFound = doc.LastNodePath; List<PeptideDocNode> listPeptides = new List<PeptideDocNode>(); listPeptides.AddRange(doc.Molecules); List<TransitionGroupDocNode> listTransitionGroups = new List<TransitionGroupDocNode>(); listTransitionGroups.AddRange(doc.MoleculeTransitionGroups); for (int x = doc.MoleculeCount; x > 0; x -= 2) { // Test case insensitivity. pathFound = doc.SearchDocumentForString(pathFound, listPeptides[x-1].ToString().ToLower(), displaySettings, true, false); Assert.AreEqual(doc.GetPathTo((int)SrmDocument.Level.Molecules, x-1), pathFound); // Test parents can find children. pathFound = doc.SearchDocumentForString(pathFound, String.Format("{0:F04}", listTransitionGroups[x * 2 - 1].PrecursorMz), displaySettings, false, true); Assert.AreEqual(doc.GetPathTo((int)SrmDocument.Level.TransitionGroups, x * 2 - 1), pathFound); // Test Children can find parents. pathFound = doc.SearchDocumentForString(pathFound, listPeptides[x - 1].ToString().ToLower(), displaySettings, true, false); Assert.AreEqual(doc.GetPathTo((int)SrmDocument.Level.Molecules, x - 1), pathFound); } // Test wrapping in search up. pathFound = doc.SearchDocumentForString(pathFound, String.Format("{0:F04}", listTransitionGroups[listTransitionGroups.Count - 1].PrecursorMz), displaySettings, false, true); Assert.AreEqual(doc.GetPathTo((int)SrmDocument.Level.TransitionGroups, listTransitionGroups.Count - 1), pathFound); // Test children can find other parents. pathFound = doc.SearchDocumentForString(pathFound, listPeptides[0].ToString().ToLowerInvariant(), displaySettings, true, false); Assert.AreEqual(doc.GetPathTo((int)SrmDocument.Level.Molecules, 0), pathFound); // Test forward and backward searching in succession const string heavyText = "heavy"; int countHeavyForward = CountOccurrances(doc, heavyText, displaySettings, false, true); Assert.IsTrue(countHeavyForward > 0); Assert.AreEqual(countHeavyForward, CountOccurrances(doc, heavyText, displaySettings, true, true)); // More tests of case insensitive searching Assert.AreEqual(0, CountOccurrances(doc, heavyText.ToUpperInvariant(), displaySettings, false, true)); Assert.AreEqual(countHeavyForward, CountOccurrances(doc, heavyText.ToUpperInvariant(), displaySettings, false, false)); if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.masses_only) Assert.AreEqual(1, CountOccurrances(doc, "hgflpr", displaySettings, true, false)); // Test mismatched transitions finder var missmatchFinder = new FindOptions().ChangeCustomFinders(new[] {new MismatchedIsotopeTransitionsFinder()}); Assert.AreEqual(4, CountOccurrances(doc, missmatchFinder, displaySettings)); var docRemoved = (SrmDocument) doc.RemoveChild(doc.Children[1]).RemoveChild(doc.Children[2]); Assert.AreEqual(0, CountOccurrances(docRemoved, missmatchFinder, displaySettings)); var refineRemoveHeavy = new RefinementSettings {RefineLabelType = IsotopeLabelType.heavy}; var docLight = refineRemoveHeavy.Refine(doc); Assert.AreEqual(0, CountOccurrances(docLight, missmatchFinder, displaySettings)); var refineRemoveLight = new RefinementSettings {RefineLabelType = IsotopeLabelType.light}; var docHeavy = refineRemoveLight.Refine(doc); Assert.AreEqual(0, CountOccurrances(docHeavy, missmatchFinder, displaySettings)); var docMulti = ResultsUtil.DeserializeDocument("MultiLabel.sky", typeof(MultiLabelRatioTest)); docMulti = (new RefinementSettings()).ConvertToSmallMolecules(docMulti, asSmallMolecules); Assert.AreEqual(0, CountOccurrances(docMulti, missmatchFinder, displaySettings)); var pathTranMultiRemove = docMulti.GetPathTo((int) SrmDocument.Level.Transitions, 7); var tranMultiRemove = docMulti.FindNode(pathTranMultiRemove); var docMultiRemoved = (SrmDocument) docMulti.RemoveChild(pathTranMultiRemove.Parent, tranMultiRemove); Assert.AreEqual(2, CountOccurrances(docMultiRemoved, missmatchFinder, displaySettings)); var tranGroupMultiRemove = docMulti.FindNode(pathTranMultiRemove.Parent); var docMultiGroupRemoved = (SrmDocument) docMulti.RemoveChild(pathTranMultiRemove.Parent.Parent, tranGroupMultiRemove); Assert.AreEqual(0, CountOccurrances(docMultiGroupRemoved, missmatchFinder, displaySettings)); }